]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Implement goal removal when bot returns the flag in a cleaner way
authorterencehill <piuntn@gmail.com>
Fri, 3 Nov 2017 14:41:02 +0000 (15:41 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 3 Nov 2017 14:41:02 +0000 (15:41 +0100)
qcsrc/server/bot/api.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qh

index cde97db885a3e962c7dc49d1363f29f796331095..12f05c75241909caa29cd6528ebc4028ced73714 100644 (file)
@@ -108,6 +108,3 @@ void waypoint_spawnforteleporter_wz(entity e, vector org, vector destination, fl
 void waypoint_spawn_fromeditor(entity pl);
 entity waypoint_spawn(vector m1, vector m2, float f);
 void waypoint_unreachable(entity pl);
-
-.entity goalcurrent;
-void navigation_clearroute(entity this);
index 739f672ca19f5dc253fc69b02916c96fdd473533..ae26c7e39965fce871779a23164db9ddfad39f15 100644 (file)
@@ -597,6 +597,8 @@ void ctf_Handle_Capture(entity flag, entity toucher, int capturetype)
                        { GameRules_scoring_add_team(enemy_flag.ctf_dropper, SCORE, ((enemy_flag.score_assist) ? enemy_flag.score_assist : autocvar_g_ctf_score_capture_assist)); }
        }
 
+       flag.enemy = toucher;
+
        // reset the flag
        player.next_take_time = time + autocvar_g_ctf_flag_collect_delay;
        ctf_RespawnFlag(enemy_flag);
@@ -639,6 +641,8 @@ void ctf_Handle_Return(entity flag, entity player)
        if(player.flagcarried == flag)
                WaypointSprite_Kill(player.wps_flagcarrier);
 
+       flag.enemy = player;
+
        // reset the flag
        ctf_RespawnFlag(flag);
 }
@@ -776,6 +780,7 @@ void ctf_CheckFlagReturn(entity flag, int returntype)
                        }
                        _sound(flag, CH_TRIGGER, flag.snd_flag_respawn, VOL_BASE, ATTEN_NONE);
                        ctf_EventLog("returned", flag.team, NULL);
+                       flag.enemy = NULL;
                        ctf_RespawnFlag(flag);
                }
        }
@@ -1179,8 +1184,9 @@ void ctf_RespawnFlag(entity flag)
 void ctf_Reset(entity this)
 {
        if(this.owner && IS_PLAYER(this.owner))
-        ctf_Handle_Throw(this.owner, NULL, DROP_RESET);
+               ctf_Handle_Throw(this.owner, NULL, DROP_RESET);
 
+       this.enemy = NULL;
        ctf_RespawnFlag(this);
 }
 
@@ -1863,11 +1869,8 @@ void havocbot_role_ctf_retriever(entity this)
        mf = havocbot_ctf_find_flag(this);
        if(mf.ctf_status==FLAG_BASE)
        {
-               if(this.goalcurrent == mf)
-               {
-                       navigation_clearroute(this);
+               if (mf.enemy == this) // did this bot return the flag?
                        navigation_goalrating_timeout_force(this);
-               }
                havocbot_ctf_reset_role(this);
                return;
        }
index 0b86a57f809936604fd51a5514b899108558dcac..33d64a074a290610fdb43a45dbfa7f08a996ede4 100644 (file)
@@ -133,6 +133,7 @@ float ctf_captimerecord; // record time for capturing the flag
 .float next_take_time;
 .bool ctf_flagdamaged_byworld;
 int ctf_teams;
+.entity enemy; // when flag is back in the base, it remembers last player who carried/touched the flag, useful to bots
 
 // passing/throwing properties
 .float pass_distance;