From: Martin Taibr Date: Sat, 31 Dec 2016 21:00:59 +0000 (+0100) Subject: overkill: take into account last weapon held when switching while dead X-Git-Tag: xonotic-v0.8.2~331^2 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=d28ed6738f6436147cebda44376e55c65938f965 overkill: take into account last weapon held when switching while dead --- diff --git a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc index 56bc8d14cc..6e42899c19 100644 --- a/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/sv_overkill.qc @@ -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); } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index d4a3e9febf..c1cce0c0a6 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -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; diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 09e1cf70bd..36b1118345 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ /**/