From: terencehill Date: Tue, 29 May 2018 12:50:33 +0000 (+0200) Subject: Bot AI: make bots release movement keys after a small random delay on jumppad touch... X-Git-Tag: xonotic-v0.8.5~1923^2~45 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2b09761ae36d26b965b863364bcf8b9190f6ae94;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: make bots release movement keys after a small random delay on jumppad touch to prevent bots getting stuck on certain jumppads that require an extra initial horizontal speed (e.g. jumppad near the devastator in the map Go) --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 1aa305ab3..429254a5e 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -540,8 +540,8 @@ void havocbot_movetogoal(entity this) if(this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT) { this.aistatus |= AI_STATUS_OUT_JUMPPAD; - navigation_poptouchedgoals(this); - return; + if(navigation_poptouchedgoals(this)) + return; } else if(this.aistatus & AI_STATUS_OUT_JUMPPAD) { @@ -849,11 +849,14 @@ void havocbot_movetogoal(entity this) bool bunnyhop_forbidden = false; vector destorg = get_closer_dest(this.goalcurrent, this.origin); - - // in case bot ends up inside the teleport waypoint without touching - // the teleport itself, head to the teleport origin - if(this.goalcurrent.wpisbox && boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z)) + if (this.jumppadcount && this.goalcurrent.wpflags & WAYPOINTFLAG_TELEPORT) + { + // if bot used the jumppad, push towards jumppad origin until jumppad waypoint gets removed + destorg = this.goalcurrent.origin; + } + else if (this.goalcurrent.wpisbox && boxesoverlap(this.goalcurrent.absmin, this.goalcurrent.absmax, this.origin + eZ * this.mins.z, this.origin + eZ * this.maxs.z)) { + // if bot is inside the teleport waypoint, head to teleport origin until teleport gets used bunnyhop_forbidden = true; destorg = this.goalcurrent.origin; if(destorg.z > this.origin.z) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 8c7e776b7..22e6b0d19 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1599,6 +1599,16 @@ int navigation_poptouchedgoals(entity this) this.aistatus &= ~AI_STATUS_WAYPOINT_PERSONAL_GOING; this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_REACHED; } + if(this.jumppadcount) + { + // remove jumppad waypoint after a random delay to prevent bots getting + // stuck on certain jumppads that require an extra initial horizontal speed + float max_delay = 0.1; + if (vdist(vec2(this.velocity), >, 2 * autocvar_sv_maxspeed)) + max_delay = 0.05; + if (time - this.lastteleporttime < random() * max_delay) + return removed_goals; + } navigation_poproute(this); this.lastteleporttime = 0; ++removed_goals;