]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/weapons/weaponsystem.qc
Merge branch 'master' into Mario/vaporizer_damage
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / weapons / weaponsystem.qc
index accf5b2f0fab1681c4eacdd456e5edc075e2079e..f53e3c53d09119c21b6c5542d640197dc9cf0b37 100644 (file)
@@ -9,10 +9,10 @@
 #include "../t_items.qh"
 #include "../../common/animdecide.qh"
 #include "../../common/constants.qh"
-#include "../../common/monsters/monsters.qh"
+#include "../../common/monsters/all.qh"
 #include "../../common/notifications.qh"
 #include "../../common/util.qh"
-#include "../../common/weapons/weapons.qh"
+#include "../../common/weapons/all.qh"
 #include "../../csqcmodellib/sv_model.qh"
 
 /*
 
 float W_WeaponRateFactor()
 {
-       float t;
-       t = 1.0 / g_weaponratefactor;
+       float t = 1.0 / g_weaponratefactor;
 
-       weapon_rate = t;
-       MUTATOR_CALLHOOK(WeaponRateFactor);
+       MUTATOR_CALLHOOK(WeaponRateFactor, t);
        t = weapon_rate;
 
        return t;
 }
 
+float W_WeaponSpeedFactor()
+{
+       float t = 1.0 * g_weaponspeedfactor;
+
+       MUTATOR_CALLHOOK(WeaponSpeedFactor, t);
+       t = ret_float;
+
+       return t;
+}
+
 
 void(float fr, float t, void() func) weapon_thinkf;
 
@@ -109,12 +117,12 @@ void CL_WeaponEntity_SetModel(string name)
                // if there is a child entity, hide it until we're sure we use it
                if (self.weaponentity)
                        self.weaponentity.model = "";
-               setmodel(self, strcat("models/weapons/v_", name, ".md3")); // precision set below
+               setmodel(self, W_Model(strcat("v_", name, ".md3")));
                v_shot_idx = gettagindex(self, "shot"); // used later
                if(!v_shot_idx)
                        v_shot_idx = gettagindex(self, "tag_shot");
 
-               setmodel(self, strcat("models/weapons/h_", name, ".iqm")); // precision set below
+               setmodel(self, W_Model(strcat("h_", name, ".iqm")));
                // preset some defaults that work great for renamed zym files (which don't need an animinfo)
                self.anim_fire1  = animfixfps(self, '0 1 0.01', '0 0 0');
                self.anim_fire2  = animfixfps(self, '1 1 0.01', '0 0 0');
@@ -127,14 +135,14 @@ void CL_WeaponEntity_SetModel(string name)
                {
                        if (!self.weaponentity)
                                self.weaponentity = spawn();
-                       setmodel(self.weaponentity, strcat("models/weapons/v_", name, ".md3")); // precision does not matter
+                       setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
                        setattachment(self.weaponentity, self, "weapon");
                }
                else if(gettagindex(self, "tag_weapon"))
                {
                        if (!self.weaponentity)
                                self.weaponentity = spawn();
-                       setmodel(self.weaponentity, strcat("models/weapons/v_", name, ".md3")); // precision does not matter
+                       setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
                        setattachment(self.weaponentity, self, "tag_weapon");
                }
                else
@@ -164,7 +172,7 @@ void CL_WeaponEntity_SetModel(string name)
                                self.movedir = gettaginfo(self, idx);
                        else
                        {
-                               print("WARNING: weapon model ", self.model, " does not support the 'shot' tag, will display shots TOTALLY wrong\n");
+                               LOG_INFO("WARNING: weapon model ", self.model, " does not support the 'shot' tag, will display shots TOTALLY wrong\n");
                                self.movedir = '0 0 0';
                        }
                }
@@ -188,7 +196,7 @@ void CL_WeaponEntity_SetModel(string name)
                                self.spawnorigin = gettaginfo(self, idx);
                        else
                        {
-                               print("WARNING: weapon model ", self.model, " does not support the 'shell' tag, will display casings wrong\n");
+                               LOG_INFO("WARNING: weapon model ", self.model, " does not support the 'shell' tag, will display casings wrong\n");
                                self.spawnorigin = self.movedir;
                        }
                }
@@ -217,7 +225,7 @@ void CL_WeaponEntity_SetModel(string name)
                        }
                        else
                        {
-                               print("WARNING: weapon model ", self.model, " does not support the 'handle' tag and neither does the v_ model support the 'shot' tag, will display muzzle flashes TOTALLY wrong\n");
+                               LOG_INFO("WARNING: weapon model ", self.model, " does not support the 'handle' tag and neither does the v_ model support the 'shot' tag, will display muzzle flashes TOTALLY wrong\n");
                                self.oldorigin = '0 0 0'; // there is no way to recover from this
                        }
                }
@@ -371,7 +379,7 @@ void CL_ExteriorWeaponentity_Think()
                self.dmg = self.owner.modelindex;
                self.deadflag = self.owner.deadflag;
                if (self.owner.weaponname != "")
-                       setmodel(self, strcat("models/weapons/v_", self.owner.weaponname, ".md3")); // precision set below
+                       setmodel(self, W_Model(strcat("v_", self.owner.weaponname, ".md3")));
                else
                        self.model = "";
 
@@ -464,17 +472,17 @@ float weapon_prepareattack_checkammo(float secondary)
        {
                // always keep the Mine Layer if we placed mines, so that we can detonate them
                entity mine;
-               if(self.weapon == WEP_MINE_LAYER)
+               if(self.weapon == WEP_MINE_LAYER.m_id)
                for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
                        return false;
 
-               if(self.weapon == WEP_SHOTGUN)
+               if(self.weapon == WEP_SHOTGUN.m_id)
                if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
                        return false; // no clicking, just allow
 
                if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons
                {
-                       sound (self, CH_WEAPON_A, "weapons/dryfire.wav", VOL_BASE, ATTEN_NORM);
+                       sound (self, CH_WEAPON_A, W_Sound("dryfire"), VOL_BASE, ATTEN_NORM);
                        self.prevdryfire = time;
                }
 
@@ -629,7 +637,7 @@ void weapon_thinkf(float fr, float t, void() func)
 
        if((fr == WFRAME_FIRE1 || fr == WFRAME_FIRE2) && t)
        {
-               if((self.weapon == WEP_SHOCKWAVE || self.weapon == WEP_SHOTGUN) && fr == WFRAME_FIRE2)
+               if((self.weapon == WEP_SHOCKWAVE.m_id || self.weapon == WEP_SHOTGUN.m_id) && fr == WFRAME_FIRE2)
                        animdecide_setaction(self, ANIMACTION_MELEE, restartanim);
                else
                        animdecide_setaction(self, ANIMACTION_SHOOT, restartanim);
@@ -641,17 +649,17 @@ void weapon_thinkf(float fr, float t, void() func)
        }
 }
 
-float forbidWeaponUse()
+float forbidWeaponUse(entity player)
 {
        if(time < game_starttime && !autocvar_sv_ready_restart_after_countdown)
                return 1;
        if(round_handler_IsActive() && !round_handler_IsRoundStarted())
                return 1;
-       if(self.player_blocked)
+       if(player.player_blocked)
                return 1;
-       if(self.frozen)
+       if(player.frozen)
                return 1;
-       if(self.weapon_blocked)
+       if(player.weapon_blocked)
                return 1;
        return 0;
 }
@@ -666,7 +674,7 @@ void W_WeaponFrame()
        if (!self.weaponentity || self.health < 1)
                return; // Dead player can't use weapons and injure impulse commands
 
-       if(forbidWeaponUse())
+       if(forbidWeaponUse(self))
        if(self.weaponentity.state != WS_CLEAR)
        {
                w_ready();
@@ -732,7 +740,7 @@ void W_WeaponFrame()
                        if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5)
                        {
                        #endif
-                               sound(self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM);
+                               sound(self, CH_WEAPON_SINGLE, W_Sound("weapon_switch"), VOL_BASE, ATTN_NORM);
                                self.weaponentity.state = WS_DROP;
                                weapon_thinkf(WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
                        #ifndef INDEPENDENT_ATTACK_FINISHED
@@ -908,7 +916,7 @@ void W_Reload(float sent_ammo_min, string sent_sound)
        // don't reload weapons that don't have the RELOADABLE flag
        if (!(e.spawnflags & WEP_FLAG_RELOADABLE))
        {
-               dprint("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
+               LOG_TRACE("Warning: Attempted to reload a weapon that does not have the WEP_FLAG_RELOADABLE flag. Fix your code!\n");
                return;
        }
 
@@ -927,7 +935,7 @@ void W_Reload(float sent_ammo_min, string sent_sound)
        {
                if(IS_REAL_CLIENT(self) && self.reload_complain < time)
                {
-                       play2(self, "weapons/unavailable.wav");
+                       play2(self, W_Sound("unavailable"));
                        sprint(self, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(self.weapon), "\n"));
                        self.reload_complain = time + 1;
                }