]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Hagar: fix the case of losing the weapon due to NIX
authorRudolf Polzer <divverent@xonotic.org>
Tue, 23 Aug 2011 06:19:50 +0000 (08:19 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Tue, 23 Aug 2011 06:19:50 +0000 (08:19 +0200)
qcsrc/common/constants.qh
qcsrc/server/cl_weapons.qc
qcsrc/server/w_hagar.qc

index 82b306506fe41387d843ab072babd34635a5e183..9180b668321a2e202eb80f702ef7059c267966a4 100644 (file)
@@ -669,6 +669,7 @@ float WR_RESETPLAYER    = 10; // (SVQC) does not need to do anything
 float WR_IMPACTEFFECT  = 11; // (CSQC) impact effect
 float WR_SWITCHABLE    = 12; // (CSQC) impact effect
 float WR_PLAYERDEATH    = 13; // (SVQC) does not need to do anything
+float WR_GONETHINK     = 14; // (SVQC) logic to run every frame, also if no longer having the weapon as long as the switch away has not been performed
 
 float HUD_PANEL_WEAPONS                = 0;
 float HUD_PANEL_AMMO           = 1;
index c46a736a06bbe5f0dae4c0bb8e064660875da1b4..658fe54d32901b2b689df87a6424ad47c05d9288 100644 (file)
@@ -403,13 +403,16 @@ void W_WeaponFrame()
                        W_SwitchWeapon_Force(self, w_getbestweapon(self));
                        wb = 0;
                }
+
+               v_forward = fo;
+               v_right = ri;
+               v_up = up;
+
                if(wb)
-               {
-                       v_forward = fo;
-                       v_right = ri;
-                       v_up = up;
                        weapon_action(self.weapon, WR_THINK);
-               }
+               else
+                       weapon_action(self.weapon, WR_GONETHINK);
+
                if (time + self.weapon_frametime * 0.5 >= self.weapon_nextthink)
                {
                        if(self.weapon_think)
index a27bdac8f06449b7347128b874a16c1a30306e18..0be80db124af3c7675ffc929ac1537d7eff9e81f 100644 (file)
@@ -201,6 +201,7 @@ void W_Hagar_Attack2_Load (void)
                        if(self.hagar_load)
                        {
                                // if we pressed primary fire while loading, unload all rockets and abort
+                               self.weaponentity.state = WS_READY;
                                W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
                                self.hagar_load = 0;
                                sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
@@ -220,6 +221,7 @@ void W_Hagar_Attack2_Load (void)
                                if(!self.hagar_loadblock && self.hagar_loadstep < time)
                                {
                                        W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
+                                       self.weaponentity.state = WS_INUSE;
                                        self.hagar_load += 1;
                                        sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM);
 
@@ -242,13 +244,14 @@ void W_Hagar_Attack2_Load (void)
 
        if(self.hagar_load)
        {
-               self.weaponentity.state = WS_INUSE; // prevents weapon switching
                if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && !autocvar_g_balance_hagar_secondary_load_hold))
+               {
+                       self.weaponentity.state = WS_READY;
                        W_Hagar_Attack2_Load_Release();
+               }
        }
        else
        {
-               self.weaponentity.state = WS_READY; // allows weapon switching
                self.hagar_loadbeep = FALSE;
        }
 
@@ -303,6 +306,15 @@ float w_hagar(float req)
                        }
                }
        }
+       else if (req == WR_GONETHINK)
+       {
+               // we lost the weapon and want to prepare switching away
+               if(self.hagar_load)
+               {
+                       self.weaponentity.state = WS_READY;
+                       W_Hagar_Attack2_Load_Release();
+               }
+       }
        else if (req == WR_PRECACHE)
        {
                precache_model ("models/weapons/g_hagar.md3");