]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: slightly increase timeout for finding a new goal when bot is chasing a player...
authorterencehill <piuntn@gmail.com>
Fri, 8 Sep 2017 15:00:30 +0000 (17:00 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 8 Sep 2017 15:00:30 +0000 (17:00 +0200)
17 files changed:
defaultServer.cfg
qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc
qcsrc/server/autocvars.qh
qcsrc/server/bot/api.qh
qcsrc/server/bot/default/bot.qc
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/roles.qc
qcsrc/server/bot/default/navigation.qc
qcsrc/server/bot/default/navigation.qh
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/mutators/mutator/gamemode_race.qc

index 596576a097fb93c6841a9e76ba1927a5909a1e13..a63ad8345dda9e0b1cf272fc3698fa7fe43aed41 100644 (file)
@@ -116,6 +116,7 @@ set bot_wander_enable 1 "Have bots wander around if they are unable to reach any
 // general bot AI cvars
 set bot_ai_thinkinterval 0.05
 set bot_ai_strategyinterval 5 "How often a new objective is chosen"
+set bot_ai_strategyinterval_movingtarget 3.5 "How often a new objective is chosen when current objective can move"
 set bot_ai_enemydetectioninterval 2 "How often bots pick a new target"
 set bot_ai_enemydetectionradius 10000 "How far bots can see enemies"
 set bot_ai_dodgeupdateinterval 0.2 "How often scan for items to dodge. Currently not in use."
index 0150de3925ee90072b040e2f5d132cd301a736ad..5a0e0975e528e7315c90e4ccf6e17199ac32e59e 100644 (file)
@@ -1488,7 +1488,7 @@ void havocbot_role_ons_offense(entity this)
        if(this.havocbot_attack_time>time)
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
@@ -1497,7 +1497,7 @@ void havocbot_role_ons_offense(entity this)
                havocbot_goalrating_ons_offenseitems(this, 10000, this.origin, 10000);
                navigation_goalrating_end(this);
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index 4303aa9764ea3d9164380fe49023c410824786bf..dea758e481e9e3f6adc19a08836517ab70a1adaa 100644 (file)
@@ -6,6 +6,7 @@ int autocvar__campaign_index;
 string autocvar__campaign_name;
 bool autocvar__sv_init;
 float autocvar_bot_ai_strategyinterval;
+float autocvar_bot_ai_strategyinterval_movingtarget;
 #define autocvar_bot_number cvar("bot_number")
 int autocvar_bot_vs_human;
 int autocvar_captureleadlimit_override;
index 27651bf8135c7d7eca91b7b948bc42586c9c9fc3..89e9a84a8c0902dc944f865d7ae3c11d02a36dd5 100644 (file)
@@ -30,7 +30,6 @@ float skill;
 .float bot_moveskill; // moving technique
 .float bot_pickup;
 .float(entity player, entity item) bot_pickupevalfunc;
-.float bot_strategytime;
 .string cleanname;
 .float havocbot_role_timeout;
 .float isbot; // true if this client is actually a bot
@@ -84,6 +83,9 @@ void navigation_dynamicgoal_unset(entity this);
 entity navigation_findnearestwaypoint(entity ent, float walkfromwp);
 void navigation_goalrating_end(entity this);
 void navigation_goalrating_start(entity this);
+void navigation_goalrating_timeout_set(entity this);
+void navigation_goalrating_timeout_force(entity this);
+bool navigation_goalrating_timeout(entity this);
 void navigation_markroutes(entity this, entity fixed_source_waypoint);
 void navigation_markroutes_inverted(entity fixed_source_waypoint);
 void navigation_routerating(entity this, entity e, float f, float rangebias);
index f599124db7bbb091e73b94bcbebc7cdfc4a0dbbc..0b591915d648b06654e57cdd53f387f7a9c4ccec 100644 (file)
@@ -133,7 +133,7 @@ void bot_think(entity this)
                if (this.deadflag == DEAD_DEAD)
                {
                        PHYS_INPUT_BUTTON_JUMP(this) = true; // press jump to respawn
-                       this.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(this);
                }
        }
        else if(this.aistatus & AI_STATUS_STUCK)
index 69549f8e356b6ece5b1fd5e145258887c34ed540..a03470e57c1307e024f1d1682dfb45cd50c39aeb 100644 (file)
@@ -584,7 +584,7 @@ void havocbot_movetogoal(entity this)
                                else if(havocbot_checkgoaldistance(this, gco))
                                {
                                        navigation_clearroute(this);
-                                       this.bot_strategytime = 0;
+                                       navigation_goalrating_timeout_force(this);
                                }
                                else
                                        return;
@@ -725,7 +725,7 @@ void havocbot_movetogoal(entity this)
        if(this.goalentity && wasfreed(this.goalentity))
        {
                navigation_clearroute(this);
-               this.bot_strategytime = 0;
+               navigation_goalrating_timeout_force(this);
                return;
        }
        else if(this.goalentity.bot_pickup)
@@ -740,7 +740,7 @@ void havocbot_movetogoal(entity this)
                                {
                                        this.goalentity.bot_pickup_respawning = false;
                                        navigation_clearroute(this);
-                                       this.bot_strategytime = 0;
+                                       navigation_goalrating_timeout_force(this);
                                        return;
                                }
                        }
@@ -752,7 +752,7 @@ void havocbot_movetogoal(entity this)
                        if(checkpvs(this.origin, this.goalentity))
                        {
                                navigation_clearroute(this);
-                               this.bot_strategytime = 0;
+                               navigation_goalrating_timeout_force(this);
                                return;
                        }
                }
@@ -760,13 +760,13 @@ void havocbot_movetogoal(entity this)
        if(!locked_goal)
        {
                if(navigation_poptouchedgoals(this) && this.bot_strategytime < time + 1)
-                       this.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(this);
        }
 
        // if ran out of goals try to use an alternative goal or get a new strategy asap
        if(this.goalcurrent == NULL)
        {
-               this.bot_strategytime = 0;
+               navigation_goalrating_timeout_force(this);
                return;
        }
 
@@ -853,7 +853,7 @@ void havocbot_movetogoal(entity this)
                        if(havocbot_checkgoaldistance(this, gco))
                        {
                                navigation_clearroute(this);
-                               this.bot_strategytime = 0;
+                               navigation_goalrating_timeout_force(this);
                                return;
                        }
 
@@ -914,7 +914,7 @@ void havocbot_movetogoal(entity this)
                        if(unreachable)
                        {
                                navigation_clearroute(this);
-                               this.bot_strategytime = 0;
+                               navigation_goalrating_timeout_force(this);
                        }
                }
 
index d33aadfac8ad3567b1a1543acfd6f6e4e0e11892..f20855d95e1bbf9f8f1979b040ea7cfa63583c6e 100644 (file)
@@ -202,17 +202,15 @@ void havocbot_role_generic(entity this)
        if(IS_DEAD(this))
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
 
-               if(IS_PLAYER(this.goalentity))
-                       this.bot_strategytime = time + min(2, autocvar_bot_ai_strategyinterval);
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -224,7 +222,7 @@ void havocbot_chooserole_generic(entity this)
 void havocbot_chooserole(entity this)
 {
        LOG_TRACE("choosing a role...");
-       this.bot_strategytime = 0;
+       navigation_goalrating_timeout_force(this);
        if(!MUTATOR_CALLHOOK(HavocBot_ChooseRole, this))
                havocbot_chooserole_generic(this);
 }
index bdd20e179d4b1a1040b089ecf2b29dd4cae75aed..d92d02f95a009135e2b7a3d9154d0abda8e3c939 100644 (file)
 
 .float speed;
 
+void navigation_goalrating_timeout_set(entity this)
+{
+       if((IS_PLAYER(this.goalentity) || IS_MONSTER(this.goalentity)) && !STAT(FROZEN, this.goalentity))
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval_movingtarget;
+       else
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+}
+
+void navigation_goalrating_timeout_force(entity this)
+{
+       this.bot_strategytime = 0;
+}
+
+bool navigation_goalrating_timeout(entity this)
+{
+       return this.bot_strategytime < time;
+}
+
 void navigation_dynamicgoal_init(entity this, bool initially_static)
 {
        this.navigation_dynamicgoal = true;
@@ -1577,7 +1595,7 @@ void navigation_unstuck(entity this)
                        {
                                LOG_DEBUG(this.netname, " stuck, reachable waypoint found, heading to it");
                                navigation_routetogoal(this, bot_waypoint_queue_bestgoal, this.origin);
-                               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+                               navigation_goalrating_timeout_set(this);
                                this.aistatus &= ~AI_STATUS_STUCK;
                        }
                        else
index 1424b94c776af20629e7376506fad4d065a74b4a..d9dd089cb42ec36b04d49b965867331c9bc3876e 100644 (file)
@@ -157,6 +157,9 @@ void navigation_routerating(entity this, entity e, float f, float rangebias);
 int navigation_poptouchedgoals(entity this);
 void navigation_goalrating_start(entity this);
 void navigation_goalrating_end(entity this);
+void navigation_goalrating_timeout_set(entity this);
+void navigation_goalrating_timeout_force(entity this);
+bool navigation_goalrating_timeout(entity this);
 void navigation_unstuck(entity this);
 
 void botframe_updatedangerousobjects(float maxupdate);
index affa033de1da73e3082bd12b1c8925cf7ac85330..50861c32f7d005bf40435df9449128e62eb1d05e 100644 (file)
@@ -461,7 +461,7 @@ void havocbot_role_ast_offense(entity this)
        if(this.havocbot_attack_time>time)
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
@@ -469,7 +469,7 @@ void havocbot_role_ast_offense(entity this)
                havocbot_goalrating_items(this, 15000, this.origin, 10000);
                navigation_goalrating_end(this);
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -495,7 +495,7 @@ void havocbot_role_ast_defense(entity this)
        if(this.havocbot_attack_time>time)
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                navigation_goalrating_start(this);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 3000);
@@ -503,7 +503,7 @@ void havocbot_role_ast_defense(entity this)
                havocbot_goalrating_items(this, 15000, this.origin, 10000);
                navigation_goalrating_end(this);
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index 3cf560ebedf752c3fc99b33cfc2aa3248bcaad2b..cd891b6bfb4a8dc49c99798bd9adca340e687f29 100644 (file)
@@ -1653,11 +1653,10 @@ void havocbot_role_ctf_carrier(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
+
                if(ctf_oneflag)
                        havocbot_goalrating_ctf_enemybase(this, 50000);
                else
@@ -1668,6 +1667,8 @@ void havocbot_role_ctf_carrier(entity this)
 
                navigation_goalrating_end(this);
 
+               navigation_goalrating_timeout_set(this);
+
                if (this.goalentity)
                        this.havocbot_cantfindflag = time + 10;
                else if (time > this.havocbot_cantfindflag)
@@ -1729,14 +1730,17 @@ void havocbot_role_ctf_escort(entity this)
        }
 
        // Chase the flag carrier
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_enemyflag(this, 30000);
                havocbot_goalrating_ctf_ourstolenflag(this, 40000);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1809,15 +1813,18 @@ void havocbot_role_ctf_offense(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_enemybase(this, 20000);
                havocbot_goalrating_items(this, 5000, this.origin, 1000);
                havocbot_goalrating_items(this, 1000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1845,7 +1852,7 @@ void havocbot_role_ctf_retriever(entity this)
                if(this.goalcurrent == mf)
                {
                        navigation_clearroute(this);
-                       this.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(this);
                }
                havocbot_ctf_reset_role(this);
                return;
@@ -1860,18 +1867,21 @@ void havocbot_role_ctf_retriever(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                float rt_radius;
                rt_radius = 10000;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_droppedflags(this, 40000, this.origin, rt_radius);
                havocbot_goalrating_ctf_enemybase(this, 30000);
                havocbot_goalrating_items(this, 500, this.origin, rt_radius);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1907,22 +1917,25 @@ void havocbot_role_ctf_middle(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                vector org;
 
                org = havocbot_middlepoint;
                org.z = this.origin.z;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_droppedflags(this, 30000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 10000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 5000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 2500, this.origin, 10000);
                havocbot_goalrating_ctf_enemybase(this, 2500);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1958,11 +1971,10 @@ void havocbot_role_ctf_defense(entity this)
                havocbot_ctf_reset_role(this);
                return;
        }
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                vector org = mf.dropped_origin;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                // if enemies are closer to our base, go there
@@ -1988,7 +2000,10 @@ void havocbot_role_ctf_defense(entity this)
                havocbot_goalrating_enemyplayers(this, 15000, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 10000, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 5000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -2002,7 +2017,7 @@ void havocbot_role_ctf_setrole(entity bot, int role)
                        bot.havocbot_role = havocbot_role_ctf_carrier;
                        bot.havocbot_role_timeout = 0;
                        bot.havocbot_cantfindflag = time + 10;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
                case HAVOCBOT_CTF_ROLE_DEFENSE:
                        s = "defense";
@@ -2024,14 +2039,14 @@ void havocbot_role_ctf_setrole(entity bot, int role)
                        bot.havocbot_previous_role = bot.havocbot_role;
                        bot.havocbot_role = havocbot_role_ctf_retriever;
                        bot.havocbot_role_timeout = time + 10;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
                case HAVOCBOT_CTF_ROLE_ESCORT:
                        s = "escort";
                        bot.havocbot_previous_role = bot.havocbot_role;
                        bot.havocbot_role = havocbot_role_ctf_escort;
                        bot.havocbot_role_timeout = time + 30;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
        }
        LOG_TRACE(bot.netname, " switched to ", s);
index 20f4b383d11296c1c2265dd5e65e9550762ea954..b942447954d69f79280c0c2637cc57ec7990f85f 100644 (file)
@@ -13,9 +13,8 @@ void havocbot_role_cts(entity this)
        if(IS_DEAD(this))
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                IL_EACH(g_racecheckpoints, true,
@@ -27,6 +26,8 @@ void havocbot_role_cts(entity this)
                });
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index be38553c9588bcd4ba1bfd79042432f79aebd583..5980cfbaf38241826244c3f27e3b44d4998017aa 100644 (file)
@@ -402,15 +402,16 @@ void havocbot_role_dom(entity this)
        if(IS_DEAD(this))
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
                havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000);
                havocbot_goalrating_items(this, 8000, this.origin, 8000);
                //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index 88afaa755d7b9f995419411e912d431b7d4ec166..2ea70c1f1ac16971c6af11a3aa33a4b3f3b0f9d5 100644 (file)
@@ -257,16 +257,16 @@ void havocbot_role_ft_offense(entity this)
                return;
        }
 
-       if (time > this.bot_strategytime)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -286,16 +286,16 @@ void havocbot_role_ft_freeing(entity this)
                return;
        }
 
-       if (time > this.bot_strategytime)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 8000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
                havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index 7b33bea6f374dd585755e6a31f572830b514b73d..aeca28fa32de06f157658bb3192a9c33f0ae5b14 100644 (file)
@@ -232,21 +232,21 @@ void havocbot_role_ka_carrier(entity this)
        if (IS_DEAD(this))
                return;
 
-       if (time > this.bot_strategytime)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
                havocbot_goalrating_waypoints(this, 1, this.origin, 3000);
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 
        if (!this.ballcarried)
        {
                this.havocbot_role = havocbot_role_ka_collector;
-               this.bot_strategytime = 0;
+               navigation_goalrating_timeout_force(this);
        }
 }
 
@@ -255,21 +255,21 @@ void havocbot_role_ka_collector(entity this)
        if (IS_DEAD(this))
                return;
 
-       if (time > this.bot_strategytime)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 1000, this.origin, 10000);
                havocbot_goalrating_ball(this, 20000, this.origin);
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 
        if (this.ballcarried)
        {
                this.havocbot_role = havocbot_role_ka_carrier;
-               this.bot_strategytime = 0;
+               navigation_goalrating_timeout_force(this);
        }
 }
 
index 15b6e0f4a6251d81a94d9501858abca0ee0ae602..e6253b091fe49136f822a7e26c9b6df51de7bab4 100644 (file)
@@ -1071,9 +1071,8 @@ void havocbot_role_kh_carrier(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                if(kh_Key_AllOwnedByWhichTeam() == this.team)
@@ -1082,6 +1081,8 @@ void havocbot_role_kh_carrier(entity this)
                        havocbot_goalrating_kh(this, 4, 4, 1); // play defensively
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1108,10 +1109,9 @@ void havocbot_role_kh_defense(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                float key_owner_team;
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
@@ -1123,6 +1123,8 @@ void havocbot_role_kh_defense(entity this)
                        havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1149,11 +1151,10 @@ void havocbot_role_kh_offense(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                float key_owner_team;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
@@ -1165,6 +1166,8 @@ void havocbot_role_kh_offense(entity this)
                        havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK! EMERGENCY!
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1199,9 +1202,8 @@ void havocbot_role_kh_freelancer(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                int key_owner_team = kh_Key_AllOwnedByWhichTeam();
@@ -1213,6 +1215,8 @@ void havocbot_role_kh_freelancer(entity this)
                        havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
index 2f581d8c433af0c6b8047e71ab7571825eb7ceba..c4ba8e91819b57f859cfe1fd3036b59ec72d88a7 100644 (file)
@@ -14,24 +14,21 @@ void havocbot_role_race(entity this)
        if(IS_DEAD(this))
                return;
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                IL_EACH(g_racecheckpoints, true,
                {
                        if(it.cnt == this.race_checkpoint)
-                       {
                                navigation_routerating(this, it, 1000000, 5000);
-                       }
                        else if(this.race_checkpoint == -1)
-                       {
                                navigation_routerating(this, it, 1000000, 5000);
-                       }
                });
 
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }