From 066a3655fee10f31e515946dac2b92394be245d1 Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 8 Aug 2024 00:29:32 +0200 Subject: [PATCH] CTF: Fix flag returning to base on first hit if g_ctf_flag_return_time is 0 and g_ctf_flag_return_damage is enabled Also default g_ctf_flag_return_time to 0 if negative --- gamemodes-server.cfg | 2 +- qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/gamemodes-server.cfg b/gamemodes-server.cfg index d3b253c6d..a32d1b2b9 100644 --- a/gamemodes-server.cfg +++ b/gamemodes-server.cfg @@ -281,7 +281,7 @@ set g_ctf_leaderboard 0 "show top capture times in the scoreboard" set g_ctf_flag_return 1 "auto return the flag to base when touched by a teammate" set g_ctf_flag_return_carrying 0 "(manual return mode) auto return the flag to base if touched by a flag carrier" set g_ctf_flag_return_carried_radius 100 "allow flags to be returned by carrier if base is within this radius" -set g_ctf_flag_return_time 30 "automatically return the flag to base after this amount of time" +set g_ctf_flag_return_time 30 "automatically return the flag to base after this amount of time; set it to 0 to disable this feature" set g_ctf_flag_return_dropped 100 "automatically return the flag to base if dropped within this distance from base (in qu)" set g_ctf_flag_return_damage 0 "allow the flag to be damaged when dropped, reducing time needed to automatically return to base; initial health is defined by g_ctf_flag_health" set g_ctf_flag_return_damage_delay 0 "how much time the flag takes to automatically return to base if it falls into lava/slime/trigger hurt" diff --git a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc index 7ae8db860..74b2d4d98 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc @@ -402,7 +402,7 @@ void ctf_Handle_Drop(entity flag, entity player, int droptype) wp.colormod = WPCOLOR_DROPPEDFLAG(flag.team); } - if(autocvar_g_ctf_flag_return_time || (autocvar_g_ctf_flag_return_damage && autocvar_g_ctf_flag_health)) + if(autocvar_g_ctf_flag_return_time > 0 || autocvar_g_ctf_flag_return_damage) { WaypointSprite_UpdateMaxHealth(flag.wps_flagdropped, flag.max_health); WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(flag, RES_HEALTH)); @@ -789,7 +789,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype) case PICKUP_DROPPED: { - pickup_dropped_score = (autocvar_g_ctf_flag_return_time ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_return_time) - time) / autocvar_g_ctf_flag_return_time, 1) : 1); + pickup_dropped_score = (autocvar_g_ctf_flag_return_time > 0 ? bound(0, ((flag.ctf_droptime + autocvar_g_ctf_flag_return_time) - time) / autocvar_g_ctf_flag_return_time, 1) : 1); pickup_dropped_score = floor((autocvar_g_ctf_score_pickup_dropped_late * (1 - pickup_dropped_score) + autocvar_g_ctf_score_pickup_dropped_early * pickup_dropped_score) + 0.5); LOG_TRACE("pickup_dropped_score is ", ftos(pickup_dropped_score)); GameRules_scoring_add_team(player, SCORE, pickup_dropped_score); @@ -827,12 +827,13 @@ void ctf_CheckFlagReturn(entity flag, int returntype) if((flag.ctf_status == FLAG_DROPPED) || (flag.ctf_status == FLAG_PASSING)) { if (flag.wps_flagdropped - && (autocvar_g_ctf_flag_return_time || autocvar_g_ctf_flag_return_damage)) + && (autocvar_g_ctf_flag_return_time > 0 || autocvar_g_ctf_flag_return_damage)) { WaypointSprite_UpdateHealth(flag.wps_flagdropped, GetResource(flag, RES_HEALTH)); } - if((GetResource(flag, RES_HEALTH) <= 0) || (time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time)) + if((GetResource(flag, RES_HEALTH) <= 0) + || (autocvar_g_ctf_flag_return_time > 0 && time >= flag.ctf_droptime + autocvar_g_ctf_flag_return_time)) { switch(returntype) { @@ -1039,7 +1040,7 @@ void ctf_FlagThink(entity this) ctf_CheckFlagReturn(this, RETURN_NEEDKILL); return; } - else if(autocvar_g_ctf_flag_return_time) + else if(autocvar_g_ctf_flag_return_time > 0) { TakeResource(this, RES_HEALTH, (this.max_health / autocvar_g_ctf_flag_return_time) * FLAG_THINKRATE); ctf_CheckFlagReturn(this, RETURN_TIMEOUT); -- 2.39.2