From 9e1288f65383521366415f072e827ad5e305fef6 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 13 Sep 2021 23:43:41 +0200 Subject: [PATCH] Prepare LMS code for an cleaner merge (no actual change) --- qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc | 72 ++++++++++--------- 1 file changed, 40 insertions(+), 32 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc index 9185525e7..41673a7d7 100644 --- a/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc +++ b/qcsrc/common/gamemodes/gamemode/lms/sv_lms.qc @@ -172,39 +172,8 @@ MUTATOR_HOOKFUNCTION(lms, PutClientInServer) } } -MUTATOR_HOOKFUNCTION(lms, CalculateRespawnTime) +MUTATOR_HOOKFUNCTION(lms, PlayerSpawn) { - entity player = M_ARGV(0, entity); - player.respawn_flags |= RESPAWN_FORCE; - - int pl_lives = GameRules_scoring_add(player, LMS_LIVES, 0); - if (pl_lives <= 0) - { - player.respawn_flags = RESPAWN_SILENT; - // prevent unwanted sudden rejoin as spectator and movement of spectator camera - player.respawn_time = time + 2; - return true; - } - - if (autocvar_g_lms_dynamic_respawn_delay <= 0) - return false; - - int max_lives = 0; - int pl_cnt = 0; - FOREACH_CLIENT(it != player && IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME, { - int lives = GameRules_scoring_add(it, LMS_LIVES, 0); - if (lives > max_lives) - max_lives = lives; - pl_cnt++; - }); - - // min delay with only 2 players - if (pl_cnt == 1) // player wasn't counted - max_lives = 0; - - player.respawn_time = time + autocvar_g_lms_dynamic_respawn_delay_base + - autocvar_g_lms_dynamic_respawn_delay_increase * max(0, max_lives - pl_lives); - return true; } MUTATOR_HOOKFUNCTION(lms, ForbidSpawn) @@ -221,6 +190,10 @@ MUTATOR_HOOKFUNCTION(lms, ForbidSpawn) return false; } +MUTATOR_HOOKFUNCTION(lms, PlayerDies) +{ +} + void lms_RemovePlayer(entity player) { static int quitters = 0; @@ -437,6 +410,41 @@ MUTATOR_HOOKFUNCTION(lms, PlayerDied) lms_UpdateWaypoints(); } +MUTATOR_HOOKFUNCTION(lms, CalculateRespawnTime) +{ + entity player = M_ARGV(0, entity); + player.respawn_flags |= RESPAWN_FORCE; + + int pl_lives = GameRules_scoring_add(player, LMS_LIVES, 0); + if (pl_lives <= 0) + { + player.respawn_flags = RESPAWN_SILENT; + // prevent unwanted sudden rejoin as spectator and movement of spectator camera + player.respawn_time = time + 2; + return true; + } + + if (autocvar_g_lms_dynamic_respawn_delay <= 0) + return false; + + int max_lives = 0; + int pl_cnt = 0; + FOREACH_CLIENT(it != player && IS_PLAYER(it) && it.frags != FRAGS_PLAYER_OUT_OF_GAME, { + int lives = GameRules_scoring_add(it, LMS_LIVES, 0); + if (lives > max_lives) + max_lives = lives; + pl_cnt++; + }); + + // min delay with only 2 players + if (pl_cnt == 1) // player wasn't counted + max_lives = 0; + + player.respawn_time = time + autocvar_g_lms_dynamic_respawn_delay_base + + autocvar_g_lms_dynamic_respawn_delay_increase * max(0, max_lives - pl_lives); + return true; +} + MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill) { entity frag_target = M_ARGV(1, entity); -- 2.39.2