]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/cl_weapons.qc
Move footsteps to the mutator system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / cl_weapons.qc
index 7e9da5b212c90f9bc35e3daa25d49a18a159847d..34f17a613a7f438f566b6d47859463f50729ac4b 100644 (file)
@@ -158,16 +158,6 @@ float weapon_action(float wpn, float wrequest)
        return (get_weaponinfo(wpn)).weapon_func(wrequest);
 }
 
-string W_Name(float weaponid)
-{
-       return (get_weaponinfo(weaponid)).message;
-}
-
-float W_AmmoItemCode(float wpn)
-{
-       return (get_weaponinfo(wpn)).items & IT_AMMO;
-}
-
 .float savenextthink;
 void thrown_wep_think()
 {
@@ -311,8 +301,6 @@ float W_IsWeaponThrowable(float w)
                return 0;
        if (g_weaponarena)
                return 0;
-       if (g_lms)
-               return 0;
        if (g_cts)
                return 0;
        if (g_nexball && w == WEP_GRENADE_LAUNCHER)
@@ -357,15 +345,24 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce)
 
        W_SwitchWeapon_Force(self, w_getbestweapon(self));
        a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo);
-       if not(a)
-               return;
-       if(a == "")
-               sprint(self, strcat("You dropped the ^2", W_Name(w), "\n"));
-       else
-               sprint(self, strcat("You dropped the ^2", W_Name(w), " with ", a, "\n"));
+       
+       if not(a) return;
+       Send_Notification(NOTIF_ONE, self, MSG_MULTI, ITEM_WEAPON_DROP, a, w);
+}
+
+float forbidWeaponUse()
+{
+       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)
+               return 1;
+       if(self.freezetag_frozen)
+               return 1;
+       return 0;
 }
 
-// Bringed back weapon frame
 void W_WeaponFrame()
 {
        vector fo, ri, up;
@@ -376,22 +373,13 @@ void W_WeaponFrame()
        if (!self.weaponentity || self.health < 1)
                return; // Dead player can't use weapons and injure impulse commands
 
-       if(time < game_starttime && !autocvar_sv_ready_restart_after_countdown)
-               return;
-
-       if(round_handler_IsActive() && !round_handler_IsRoundStarted())
+       if(forbidWeaponUse())
        if(self.weaponentity.state != WS_CLEAR)
        {
                w_ready();
                return;
        }
 
-       if(self.player_blocked)
-               return;
-
-       if(self.freezetag_frozen == 1)
-               return;
-
        if(!self.switchweapon)
        {
                self.weapon = 0;
@@ -415,24 +403,25 @@ void W_WeaponFrame()
                        // end switching!
                        self.switchingweapon = self.switchweapon;
 
+                       entity newwep = get_weaponinfo(self.switchweapon);
+
                        //setanim(self, self.anim_draw, FALSE, TRUE, TRUE);
                        self.weaponentity.state = WS_RAISE;
                        weapon_action(self.switchweapon, WR_SETUP);
 
                        // set our clip load to the load of the weapon we switched to, if it's reloadable
-                       entity e;
-                       e = get_weaponinfo(self.switchweapon);
-                       if(e.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", e.netname, "_reload_ammo"))) // prevent accessing undefined cvars
+                       if(newwep.spawnflags & WEP_FLAG_RELOADABLE && cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"))) // prevent accessing undefined cvars
                        {
                                self.clip_load = self.(weapon_load[self.switchweapon]);
-                               self.clip_size = cvar(strcat("g_balance_", e.netname, "_reload_ammo"));
+                               self.clip_size = cvar(strcat("g_balance_", newwep.netname, "_reload_ammo"));
                        }
                        else
                                self.clip_load = self.clip_size = 0;
 
                        // VorteX: add player model weapon select frame here
                        // setcustomframe(PlayerWeaponRaise);
-                       weapon_thinkf(WFRAME_IDLE, autocvar_g_balance_weaponswitchdelay, w_ready);
+                       weapon_thinkf(WFRAME_IDLE, cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname)), w_ready);
+                       //print(sprintf("W_WeaponFrame(): cvar: %s, value: %f\n", sprintf("g_balance_%s_switchdelay_raise", newwep.netname), cvar(sprintf("g_balance_%s_switchdelay_raise", newwep.netname))));
                        weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, '0 0 0');
                }
                else if (self.weaponentity.state == WS_DROP)
@@ -445,6 +434,8 @@ void W_WeaponFrame()
                        // start switching!
                        self.switchingweapon = self.switchweapon;
 
+                       entity oldwep = get_weaponinfo(self.weapon);
+                       
 #ifndef INDEPENDENT_ATTACK_FINISHED
                        if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5)
                        {
@@ -452,7 +443,8 @@ void W_WeaponFrame()
                        sound (self, CH_WEAPON_SINGLE, "weapons/weapon_switch.wav", VOL_BASE, ATTN_NORM);
                        self.weaponentity.state = WS_DROP;
                        // set up weapon switch think in the future, and start drop anim
-                       weapon_thinkf(WFRAME_DONTCHANGE, autocvar_g_balance_weaponswitchdelay, w_clear);
+                       weapon_thinkf(WFRAME_DONTCHANGE, cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname)), w_clear);
+                       //print(sprintf("W_WeaponFrame(): cvar: %s, value: %f\n", sprintf("g_balance_%s_switchdelay_drop", oldwep.netname), cvar(sprintf("g_balance_%s_switchdelay_drop", oldwep.netname))));
                        weapon_boblayer1(PLAYER_WEAPONSELECTION_SPEED, PLAYER_WEAPONSELECTION_RANGE);
 #ifndef INDEPENDENT_ATTACK_FINISHED
                        }