]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
overkill: take into account last weapon held when switching while dead 400/head
authorMartin Taibr <taibr.martin@gmail.com>
Sat, 31 Dec 2016 21:00:59 +0000 (22:00 +0100)
committerMartin Taibr <taibr.martin@gmail.com>
Sat, 31 Dec 2016 21:00:59 +0000 (22:00 +0100)
qcsrc/common/mutators/mutator/overkill/sv_overkill.qc
qcsrc/server/client.qc
qcsrc/server/mutators/events.qh

index 56bc8d14cce8d4fad53d010fd57ecea83fa17e1d..6e42899c19fe426c275fad610def76defb222056 100644 (file)
@@ -172,17 +172,6 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink)
        if(IS_DEAD(player) || !IS_PLAYER(player) || STAT(FROZEN, player))
                return;
 
-       if(player.ok_lastwep)
-       {
-               Weapon newwep = Weapons_from(player.ok_lastwep);
-               if(player.ok_lastwep == WEP_HMG.m_id)
-                       newwep = WEP_MACHINEGUN;
-               if(player.ok_lastwep == WEP_RPC.m_id)
-                       newwep = WEP_VORTEX;
-               PS(player).m_switchweapon = newwep;
-               player.ok_lastwep = 0;
-       }
-
        ok_IncreaseCharge(player, PS(player).m_weapon.m_id);
 
        if(PHYS_INPUT_BUTTON_ATCK2(player))
@@ -249,10 +238,22 @@ MUTATOR_HOOKFUNCTION(ok, PlayerSpawn)
        }
        else
                player.ok_use_ammocharge = 0;
+}
 
-       // if player changed their weapon while dead, don't switch to their death weapon
-       if(player.impulse)
+MUTATOR_HOOKFUNCTION(ok, PlayerWeaponSelect)
+{
+       entity player = M_ARGV(0, entity);
+
+       if(player.ok_lastwep)
+       {
+               Weapon newwep = Weapons_from(player.ok_lastwep);
+               if(player.ok_lastwep == WEP_HMG.m_id)
+                       newwep = WEP_MACHINEGUN;
+               if(player.ok_lastwep == WEP_RPC.m_id)
+                       newwep = WEP_VORTEX;
+               PS(player).m_switchweapon = newwep;
                player.ok_lastwep = 0;
+       }
 }
 
 void self_spawnfunc_weapon_hmg(entity this) { spawnfunc_weapon_hmg(this); }
index d4a3e9febfa359aef00e37995c6b56961d0a8a25..c1cce0c0a6b310f5fe77a14e0d152fa9a5c3b7c0 100644 (file)
@@ -706,6 +706,8 @@ void PutClientInServer(entity this)
                this.weaponname = "";
                PS(this).m_switchingweapon = WEP_Null;
 
+               MUTATOR_CALLHOOK(PlayerWeaponSelect, this);
+
                if (!warmup_stage && !this.alivetime)
                        this.alivetime = time;
 
index 09e1cf70bd212497b69907be4ec13c31e97d33ca..36b1118345a23d6c7c2ae4ddcd28755c1a61f612 100644 (file)
@@ -31,6 +31,12 @@ MUTATOR_HOOKABLE(ForbidSpawn, EV_ForbidSpawn);
     /**/
 MUTATOR_HOOKABLE(PlayerSpawn, EV_PlayerSpawn);
 
+/** called after a player's weapon is chosen so it can be overriden here */
+#define EV_PlayerWeaponSelect(i, o) \
+       /** player spawning */ i(entity, MUTATOR_ARGV_0_entity) \
+    /**/
+MUTATOR_HOOKABLE(PlayerWeaponSelect, EV_PlayerWeaponSelect);
+
 /** called in reset_map */
 #define EV_reset_map_global(i, o) \
     /**/