From: terencehill Date: Sun, 14 Jan 2018 17:01:32 +0000 (+0100) Subject: Bot AI: workaround for untouchable race checkpoints that cause bot to get stuck ... X-Git-Tag: xonotic-v0.8.5~2378^2~3^2 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=1f1371d2ce1d6b49f22a8c1d4f449be4021c2d00 Bot AI: workaround for untouchable race checkpoints that cause bot to get stuck (e.g. in front of Stormkeep's warpzone) --- diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index ca892c52ff..0bfdc02fa2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -18,12 +18,25 @@ void havocbot_role_cts(entity this) this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; navigation_goalrating_start(this); + bool raw_touch_check = true; + int cp = this.race_checkpoint; + + LABEL(search_racecheckpoints) IL_EACH(g_racecheckpoints, true, { - if(it.cnt == this.race_checkpoint) - navigation_routerating(this, it, 1000000, 5000); - else if(this.race_checkpoint == -1) + if(it.cnt == cp || cp == -1) + { + // redirect bot to next goal if it touched the waypoint of an untouchable checkpoint + // e.g. checkpoint in front of Stormkeep's warpzone + // the same workaround is applied in Race game mode + if (raw_touch_check && vdist(this.origin - it.nearestwaypoint.origin, <, 30)) + { + cp = race_NextCheckpoint(cp); + raw_touch_check = false; + goto search_racecheckpoints; + } navigation_routerating(this, it, 1000000, 5000); + } }); navigation_goalrating_end(this); diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 2f581d8c43..9c2d60f38e 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -19,14 +19,23 @@ void havocbot_role_race(entity this) this.bot_strategytime = time + autocvar_bot_ai_strategyinterval; navigation_goalrating_start(this); + bool raw_touch_check = true; + int cp = this.race_checkpoint; + + LABEL(search_racecheckpoints) IL_EACH(g_racecheckpoints, true, { - if(it.cnt == this.race_checkpoint) - { - navigation_routerating(this, it, 1000000, 5000); - } - else if(this.race_checkpoint == -1) + if(it.cnt == cp || cp == -1) { + // redirect bot to next goal if it touched the waypoint of an untouchable checkpoint + // e.g. checkpoint in front of Stormkeep's warpzone + // the same workaround is applied in CTS game mode + if (raw_touch_check && vdist(this.origin - it.nearestwaypoint.origin, <, 30)) + { + cp = race_NextCheckpoint(cp); + raw_touch_check = false; + goto search_racecheckpoints; + } navigation_routerating(this, it, 1000000, 5000); } });