From: terencehill Date: Sat, 2 Dec 2017 21:36:00 +0000 (+0100) Subject: Merge remote-tracking branch 'origin/terencehill/bot_waypoints' into terencehill... X-Git-Tag: xonotic-v0.8.5~2378^2~14 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=f84d4c215d826d9b035e1ba79a22af077f123f55;p=xonotic%2Fxonotic-data.pk3dir.git Merge remote-tracking branch 'origin/terencehill/bot_waypoints' into terencehill/bot_ai # Conflicts: # qcsrc/server/bot/default/navigation.qh --- f84d4c215d826d9b035e1ba79a22af077f123f55 diff --cc qcsrc/server/bot/default/navigation.qc index e28509618,86f2feebd..356c04b17 --- a/qcsrc/server/bot/default/navigation.qc +++ b/qcsrc/server/bot/default/navigation.qc @@@ -89,97 -39,6 +89,97 @@@ void navigation_dynamicgoal_unset(entit this.nearestwaypointtimeout = -1; } +// returns point of ent closer to org +vector get_closer_dest(entity ent, vector org) +{ + vector dest = '0 0 0'; + if ((ent.classname != "waypoint") || ent.wpisbox) + { - vector wm1 = ent.origin + ent.mins - eZ * (PL_MAX_CONST.z - 1); - vector wm2 = ent.origin + ent.maxs - eZ * (PL_MIN_CONST.z + 1); ++ vector wm1 = ent.origin + ent.mins; ++ vector wm2 = ent.origin + ent.maxs; + dest.x = bound(wm1.x, org.x, wm2.x); + dest.y = bound(wm1.y, org.y, wm2.y); + dest.z = bound(wm1.z, org.z, wm2.z); + } + else + dest = ent.origin; + return dest; +} + +void set_tracewalk_dest(entity ent, vector org, bool fix_player_dest) +{ + if ((ent.classname != "waypoint") || ent.wpisbox) + { - vector wm1 = ent.origin + ent.mins - eZ * (PL_MAX_CONST.z - 1); - vector wm2 = ent.origin + ent.maxs - eZ * (PL_MIN_CONST.z + 1); ++ vector wm1 = ent.origin + ent.mins; ++ vector wm2 = ent.origin + ent.maxs; + if (IS_PLAYER(ent) || IS_MONSTER(ent)) + { + // move destination point out of player bbox otherwise tracebox always fails + // (if bot_navigation_ignoreplayers is false) + wm1 += vec2(PL_MIN_CONST) + '-1 -1 0'; + wm2 += vec2(PL_MAX_CONST) + '1 1 0'; + } + // set destination point to x and y coords of ent that are closer to org + // z coord is set to ent's min height + tracewalk_dest.x = bound(wm1.x, org.x, wm2.x); + tracewalk_dest.y = bound(wm1.y, org.y, wm2.y); + tracewalk_dest.z = wm1.z; + tracewalk_dest_height = wm2.z - wm1.z; // destination height + } + else + { + tracewalk_dest = ent.origin; + tracewalk_dest_height = 0; + } + if (fix_player_dest && IS_PLAYER(ent) && !IS_ONGROUND(ent)) + { + // snap player to the ground + if (org.x == tracewalk_dest.x && org.y == tracewalk_dest.y) + { + // bot is right under the player + tracebox(ent.origin, ent.mins, ent.maxs, ent.origin - '0 0 700', MOVE_NORMAL, ent); + tracewalk_dest = trace_endpos; + tracewalk_dest_height = 0; + } + else + { + tracebox(tracewalk_dest, ent.mins, ent.maxs, tracewalk_dest - '0 0 700', MOVE_NORMAL, ent); + if (!trace_startsolid && tracewalk_dest.z - trace_endpos.z > 0) + { + tracewalk_dest_height = tracewalk_dest.z - trace_endpos.z; + tracewalk_dest.z = trace_endpos.z; + } + } + } +} + +// returns point of ent closer to org +vector set_tracewalk_dest_2(entity ent, vector org) +{ + vector closer_dest = '0 0 0'; + if ((ent.classname != "waypoint") || ent.wpisbox) + { - vector wm1 = ent.origin + ent.mins - eZ * (PL_MAX_CONST.z - 1); - vector wm2 = ent.origin + ent.maxs - eZ * (PL_MIN_CONST.z + 1); ++ vector wm1 = ent.origin + ent.mins; ++ vector wm2 = ent.origin + ent.maxs; + closer_dest.x = bound(wm1.x, org.x, wm2.x); + closer_dest.y = bound(wm1.y, org.y, wm2.y); + closer_dest.z = bound(wm1.z, org.z, wm2.z); + // set destination point to x and y coords of ent that are closer to org + // z coord is set to ent's min height + tracewalk_dest.x = closer_dest.x; + tracewalk_dest.y = closer_dest.y; + tracewalk_dest.z = wm1.z; + tracewalk_dest_height = wm2.z - wm1.z; // destination height + } + else + { + closer_dest = ent.origin; + tracewalk_dest = closer_dest; + tracewalk_dest_height = 0; + } + return closer_dest; +} + bool navigation_check_submerged_state(entity ent, vector pos) { bool submerged;