From 3970638a3718b851b497e57ae7eb2b70a76c1401 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 8 Sep 2017 17:00:30 +0200 Subject: [PATCH] Bot AI: slightly increase timeout for finding a new goal when bot is chasing a player (now in a separate cvar, still lower than normal); apply new timeout value for any movable target and in any gamemode --- defaultServer.cfg | 1 + .../gamemode/onslaught/sv_onslaught.qc | 4 +- qcsrc/server/autocvars.qh | 1 + qcsrc/server/bot/api.qh | 4 +- qcsrc/server/bot/default/bot.qc | 2 +- qcsrc/server/bot/default/havocbot/havocbot.qc | 16 +++--- qcsrc/server/bot/default/havocbot/roles.qc | 8 ++- qcsrc/server/bot/default/navigation.qc | 20 +++++++- qcsrc/server/bot/default/navigation.qh | 3 ++ .../mutators/mutator/gamemode_assault.qc | 8 +-- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 49 ++++++++++++------- qcsrc/server/mutators/mutator/gamemode_cts.qc | 5 +- .../mutators/mutator/gamemode_domination.qc | 5 +- .../mutators/mutator/gamemode_freezetag.qc | 12 ++--- .../mutators/mutator/gamemode_keepaway.qc | 16 +++--- .../mutators/mutator/gamemode_keyhunt.qc | 20 +++++--- .../server/mutators/mutator/gamemode_race.qc | 9 ++-- 17 files changed, 112 insertions(+), 71 deletions(-) diff --git a/defaultServer.cfg b/defaultServer.cfg index 596576a09..a63ad8345 100644 --- a/defaultServer.cfg +++ b/defaultServer.cfg @@ -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." diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc index 0150de392..5a0e0975e 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/sv_onslaught.qc @@ -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); } } diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index 4303aa976..dea758e48 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -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; diff --git a/qcsrc/server/bot/api.qh b/qcsrc/server/bot/api.qh index 27651bf81..89e9a84a8 100644 --- a/qcsrc/server/bot/api.qh +++ b/qcsrc/server/bot/api.qh @@ -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); diff --git a/qcsrc/server/bot/default/bot.qc b/qcsrc/server/bot/default/bot.qc index f599124db..0b591915d 100644 --- a/qcsrc/server/bot/default/bot.qc +++ b/qcsrc/server/bot/default/bot.qc @@ -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) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 69549f8e3..a03470e57 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -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); } } diff --git a/qcsrc/server/bot/default/havocbot/roles.qc b/qcsrc/server/bot/default/havocbot/roles.qc index d33aadfac..f20855d95 100644 --- a/qcsrc/server/bot/default/havocbot/roles.qc +++ b/qcsrc/server/bot/default/havocbot/roles.qc @@ -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); } diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index bdd20e179..d92d02f95 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -17,6 +17,24 @@ .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 diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index 1424b94c7..d9dd089cb 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index affa033de..50861c32f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 3cf560ebe..cd891b6bf 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -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); diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 20f4b383d..b94244795 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index be38553c9..5980cfbaf 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 88afaa755..2ea70c1f1 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 7b33bea6f..aeca28fa3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index 15b6e0f4a..e6253b091 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -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); } } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 2f581d8c4..c4ba8e918 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -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); } } -- 2.39.2