From b859a4b26e4e4f9c87dd0f5089664d763e8318c8 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 20 Nov 2017 16:59:29 +0100 Subject: [PATCH] Clan Arena: prevent unwanted sudden rejoin as spectator and move of spectator camera when a player gets killed --- qcsrc/server/mutators/mutator/gamemode_ca.qc | 6 +++++- qcsrc/server/player.qc | 7 ++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 159df8a78..73d3825e5 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -266,7 +266,11 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies) ca_LastPlayerForTeam_Notify(frag_target); if (!allowed_to_spawn) - frag_target.respawn_flags = RESPAWN_SILENT; + { + frag_target.respawn_flags = RESPAWN_SILENT; + // prevent unwanted sudden rejoin as spectator and move of spectator camera + frag_target.respawn_time = time + 2; + } if (!warmup_stage) eliminatedPlayers.SendFlags |= 1; if(IS_BOT_CLIENT(frag_target)) diff --git a/qcsrc/server/player.qc b/qcsrc/server/player.qc index ac2dcb1ed..fc88b69bb 100644 --- a/qcsrc/server/player.qc +++ b/qcsrc/server/player.qc @@ -558,6 +558,7 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if(w != WEP_Null && accuracy_isgooddamage(attacker, this)) CS(attacker).accuracy.(accuracy_frags[w.m_id-1]) += 1; + this.respawn_time = 0; MUTATOR_CALLHOOK(PlayerDies, inflictor, attacker, this, deathtype, damage); damage = M_ARGV(4, float); excess = max(0, damage - take - save); @@ -586,6 +587,9 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, if(this.health >= 1 || !(IS_PLAYER(this) || this.classname == "body")) return; + if (!this.respawn_time) // can be set in the mutator hook PlayerDies + calculate_player_respawn_time(this); + // when we get here, player actually dies Unfreeze(this); // remove any icy remains @@ -621,9 +625,6 @@ void PlayerDamage(entity this, entity inflictor, entity attacker, float damage, STAT(MOVEVARS_SPECIALCOMMAND, this) = false; // sweet release - // when to allow respawn - calculate_player_respawn_time(this); - this.death_time = time; if (random() < 0.5) animdecide_setstate(this, this.anim_state | ANIMSTATE_DEAD1, true); -- 2.39.2