]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
CTF: Fix flag returning to base on first hit if g_ctf_flag_return_time is 0 and g_ctf...
authorterencehill <piuntn@gmail.com>
Wed, 7 Aug 2024 22:29:32 +0000 (00:29 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 7 Aug 2024 22:29:32 +0000 (00:29 +0200)
Also default g_ctf_flag_return_time to 0 if negative

gamemodes-server.cfg
qcsrc/common/gamemodes/gamemode/ctf/sv_ctf.qc

index d3b253c6d827b6dfb30554ebe0cabd3cc74aeaf3..a32d1b2b97e0b1c59bb715c253bdbe2a7253a179 100644 (file)
@@ -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"
index 7ae8db8600e43a225707165ce5f9e39bc41c0f8a..74b2d4d98012917c1a2811a8b0a5921d643e911c 100644 (file)
@@ -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);