From a25294ce213e9f8c02d064107be5281bbb95e274 Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 14 Apr 2018 16:17:57 +0200 Subject: [PATCH] Bot AI: don't rate flag instead of its base as flags always have a base waypoint; check proximity to base waypoint before locking goal --- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index e0d25e9e8..866d7daf3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -1518,12 +1518,14 @@ void havocbot_goalrating_ctf_enemyflag(entity this, float ratingscale) void havocbot_goalrating_ctf_enemybase(entity this, float ratingscale) { + // disabled because we always spawn waypoints for flags with waypoint_spawnforitem_force + /* if (!bot_waypoints_for_items) { havocbot_goalrating_ctf_enemyflag(this, ratingscale); return; } - + */ entity head; head = havocbot_ctf_find_enemy_flag(this); @@ -1579,7 +1581,6 @@ void havocbot_goalrating_ctf_carrieritems(entity this, float ratingscale, vector if (it.health || it.armorvalue) if (vdist(it.origin - org, <, sradius)) { - // get the value of the item float t = it.bot_pickupevalfunc(this, it) * 0.0001; if (t > 0) navigation_routerating(this, it, t * ratingscale, 500); @@ -1648,6 +1649,21 @@ void havocbot_ctf_reset_role(entity this) havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE); } +bool havocbot_ctf_is_basewaypoint(entity item) +{ + if (item.classname != "waypoint") + return false; + + entity head = ctf_worldflaglist; + while (head) + { + if (item == head.bot_basewaypoint) + return true; + head = head.ctf_worldflagnext; + } + return false; +} + void havocbot_role_ctf_carrier(entity this) { if(IS_DEAD(this)) @@ -1678,18 +1694,11 @@ void havocbot_role_ctf_carrier(entity this) navigation_goalrating_timeout_set(this); - entity head = ctf_worldflaglist; - while (head) - { - if (this.goalentity == head.bot_basewaypoint) - { - this.goalentity_lock_timeout = time + 5; - break; - } - head = head.ctf_worldflagnext; - } + entity goal = this.goalentity; + if (havocbot_ctf_is_basewaypoint(goal) && vdist(goal.origin - this.origin, <, 100)) + this.goalentity_lock_timeout = time + 5; - if (this.goalentity) + if (goal) this.havocbot_cantfindflag = time + 10; else if (time > this.havocbot_cantfindflag) { @@ -1725,6 +1734,11 @@ void havocbot_role_ctf_escort(entity this) this.havocbot_role_timeout = 0; return; } + if (ef.ctf_status == FLAG_DROPPED) + { + navigation_goalrating_timeout_expire(this, 1); + return; + } // If the flag carrier reached the base switch to defense mf = havocbot_ctf_find_flag(this); -- 2.39.2