From: terencehill Date: Thu, 6 Dec 2018 00:14:12 +0000 (+0100) Subject: Bot AI: fix bots not being able to get unstuck from a perfectly vertical jumppad X-Git-Tag: xonotic-v0.8.5~1705^2~1 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b3fcf1ca4a769582bfb87c24337793a1402f2b9d;p=xonotic%2Fxonotic-data.pk3dir.git Bot AI: fix bots not being able to get unstuck from a perfectly vertical jumppad --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index a8e10194e..d6658a084 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -577,7 +577,7 @@ void havocbot_movetogoal(entity this) this.aistatus &= ~AI_STATUS_OUT_JUMPPAD; } } - else + else //if (this.goalcurrent) { if (this.goalcurrent.bot_pickup) { @@ -601,9 +601,9 @@ void havocbot_movetogoal(entity this) return; } } - else + else //if (!(this.aistatus & AI_STATUS_OUT_JUMPPAD)) { - if(time - this.lastteleporttime > 0.2 && this.velocity.z > 0) + if(this.origin.z - this.lastteleport_origin.z > (this.maxs.z - this.mins.z) * 0.5) { vector velxy = this.velocity; velxy_z = 0; if(vdist(velxy, <, autocvar_sv_maxspeed * 0.2)) diff --git a/qcsrc/server/bot/default/navigation.qc b/qcsrc/server/bot/default/navigation.qc index 1a491530a..5e509506d 100644 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@ -1611,11 +1611,12 @@ int navigation_poptouchedgoals(entity this) if (!this.goalcurrent.wpisbox // warpzone && vlen2(this.origin - this.goalstack01.origin) < vlen2(this.origin - this.goalcurrent.origin)) { + // immediately remove origin and destination waypoints navigation_poproute(this); ++removed_goals; navigation_poproute(this); ++removed_goals; - return removed_goals; + this.lastteleporttime = 0; } // make sure jumppad is really hit, don't rely on distance based checks @@ -1638,12 +1639,17 @@ int navigation_poptouchedgoals(entity this) if (time - this.lastteleporttime < random() * max_delay) return removed_goals; } + else if (this.goalcurrent.wpisbox) // teleport + { + // immediately remove origin and destination waypoints + navigation_poproute(this); + ++removed_goals; + } navigation_poproute(this); this.lastteleporttime = 0; ++removed_goals; } - else - return removed_goals; + return removed_goals; } else if (this.lastteleporttime > 0) { @@ -1675,6 +1681,9 @@ int navigation_poptouchedgoals(entity this) ++removed_goals; return removed_goals; } + // reset of lastteleporttime can be overriden by a jumppad when it's set + // in more than one frame: make sure it's reset + this.lastteleporttime = 0; } // Loose goal touching check when running diff --git a/qcsrc/server/bot/default/navigation.qh b/qcsrc/server/bot/default/navigation.qh index b8b067c3b..d002ae29d 100644 --- a/qcsrc/server/bot/default/navigation.qh +++ b/qcsrc/server/bot/default/navigation.qh @@ -52,8 +52,7 @@ entity navigation_bestgoal; waypoint_addlink_customcost(to_item, from_wp, waypoint_getlinkcost(from_wp, to_item)) #define TELEPORT_USED(pl, tele_wp) \ - (time - pl.lastteleporttime < ((tele_wp.wpflags & WAYPOINTFLAG_PERSONAL) ? 2 : 0.15) \ - && boxesoverlap(tele_wp.absmin, tele_wp.absmax, pl.lastteleport_origin + STAT(PL_MIN, pl), pl.lastteleport_origin + STAT(PL_MAX, pl))) + boxesoverlap(tele_wp.absmin, tele_wp.absmax, pl.lastteleport_origin + STAT(PL_MIN, pl), pl.lastteleport_origin + STAT(PL_MAX, pl)) vector tracewalk_dest; float tracewalk_dest_height;