From 7513df962b61185b93a49e39b6bb054e20781a4b Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 1 Mar 2019 11:52:44 +0100 Subject: [PATCH] Reduce auto-revival time when frozen players are hit by enemies (time reduction depends on hit force). Optionally this behaviour can be enabled when frozen players are hit by teammates too --- gamemodes-server.cfg | 2 ++ .../gamemode/freezetag/sv_freezetag.qc | 30 +++++++++++++++++-- .../gamemode/freezetag/sv_freezetag.qh | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index 5442f4d7a..51d9d1938 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -368,6 +368,8 @@ set g_freezetag_revive_nade_health 40 "Amount of health player has if they reviv set g_freezetag_round_timelimit 180 "round time limit in seconds" set g_freezetag_revive_auto 1 "automatically revive frozen players after some time (g_freezetag_frozen_maxtime)" set g_freezetag_revive_auto_progress 1 "start the automatic reviving progress as soon as the player gets frozen" +set g_freezetag_revive_auto_reducible 1 "reduce auto-revival time when frozen players are hit by enemies; if cvar value is negative reduce time even when they are hit by teammates" +set g_freezetag_revive_auto_reducible_forcefactor 0.025 "hit force to time reduction conversion factor" set g_freezetag_frozen_maxtime 60 "frozen players will be automatically unfrozen after this time in seconds" seta g_freezetag_teams_override 0 set g_freezetag_team_spawns 0 "when 1, players spawn from the team spawnpoints of the map, if any" diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc index 5c73912aa..c300af673 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qc @@ -198,6 +198,7 @@ void freezetag_Freeze(entity targ, entity attacker) if(STAT(FROZEN, targ)) return; + targ.freezetag_frozen_time = time; if (autocvar_g_freezetag_revive_auto && autocvar_g_freezetag_frozen_maxtime > 0) targ.freezetag_frozen_timeout = time + autocvar_g_freezetag_frozen_maxtime; @@ -452,6 +453,30 @@ MUTATOR_HOOKFUNCTION(ft, Unfreeze) targ.freezetag_frozen_timeout = 0; } +MUTATOR_HOOKFUNCTION(ft, Damage_Calculate) +{ + entity frag_attacker = M_ARGV(1, entity); + entity frag_target = M_ARGV(2, entity); + //float frag_deathtype = M_ARGV(3, float); + //float frag_damage = M_ARGV(4, float); + vector frag_force = M_ARGV(6, vector); + + if (STAT(FROZEN, frag_target) == FROZEN_NORMAL && autocvar_g_freezetag_revive_auto_reducible + && autocvar_g_freezetag_frozen_maxtime > 0 && autocvar_g_freezetag_revive_auto) + { + float t = 0; + if ((autocvar_g_freezetag_revive_auto_reducible > 0 || DIFF_TEAM(frag_attacker, frag_target)) + && frag_target.freezetag_frozen_timeout > time) + { + if (fabs(autocvar_g_freezetag_revive_auto_reducible) == 1) + t = vlen(frag_force) * autocvar_g_freezetag_revive_auto_reducible_forcefactor; + frag_target.freezetag_frozen_timeout -= t; + if (frag_target.freezetag_frozen_timeout < time) + frag_target.freezetag_frozen_timeout = time; + } + } +} + #ifdef IS_REVIVING #undef IS_REVIVING #endif @@ -521,13 +546,14 @@ MUTATOR_HOOKFUNCTION(ft, PlayerPreThink, CBC_ORDER_FIRST) if(STAT(REVIVE_PROGRESS, player) >= 1) { + float frozen_time = time - player.freezetag_frozen_time; Unfreeze(player, false); freezetag_count_alive_players(); if(n == -1) { - Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, autocvar_g_freezetag_frozen_maxtime); - Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, autocvar_g_freezetag_frozen_maxtime); + Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_FREEZETAG_AUTO_REVIVED, frozen_time); + Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_FREEZETAG_AUTO_REVIVED, player.netname, frozen_time); return true; } diff --git a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh index 07a59272a..7fdf8d5c4 100644 --- a/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh +++ b/qcsrc/common/gamemodes/gamemode/freezetag/sv_freezetag.qh @@ -29,6 +29,8 @@ float freezetag_teams; bool autocvar_g_freezetag_revive_auto; int autocvar_g_freezetag_revive_auto_progress; +int autocvar_g_freezetag_revive_auto_reducible; +float autocvar_g_freezetag_revive_auto_reducible_forcefactor; float autocvar_g_freezetag_revive_extra_size; float autocvar_g_freezetag_revive_speed; bool autocvar_g_freezetag_revive_nade; -- 2.39.2