From: Rudolf Polzer Date: Sun, 14 Aug 2011 15:10:49 +0000 (+0200) Subject: bots: take the ability to jump into account when linking waypoints (EXPERIMENTAL) X-Git-Tag: xonotic-v0.5.0~148^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a07a805399754434816c3ecc346eb605f949ebbb;p=xonotic%2Fxonotic-data.pk3dir.git bots: take the ability to jump into account when linking waypoints (EXPERIMENTAL) --- diff --git a/qcsrc/server/bot/bot.qc b/qcsrc/server/bot/bot.qc index 6bcafcb99..9972999fc 100644 --- a/qcsrc/server/bot/bot.qc +++ b/qcsrc/server/bot/bot.qc @@ -532,6 +532,9 @@ void autoskill(float factor) void bot_calculate_stepheightvec(void) { stepheightvec = autocvar_sv_stepheight * '0 0 1'; + jumpstepheightvec = stepheightvec + + ((autocvar_sv_jumpvelocity * autocvar_sv_jumpvelocity) / (2 * autocvar_sv_gravity)) * '0 0 0.9'; + // 0.9 factor is for safety to make the jumps always work } void bot_serverframe() diff --git a/qcsrc/server/bot/bot.qh b/qcsrc/server/bot/bot.qh index 55f3250ee..6823841d9 100644 --- a/qcsrc/server/bot/bot.qh +++ b/qcsrc/server/bot/bot.qh @@ -114,3 +114,5 @@ void() havocbot_setupbot; float c1, c2, c3, c4; void CheckAllowedTeams(entity for_whom); void GetTeamCounts(entity other); float JoinBestTeam(entity pl, float only_return_best, float forcebestteam); + +void bot_calculate_stepheightvec(void); diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index 377dc2ef9..1d9054952 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -714,12 +714,12 @@ void havocbot_movetogoal() if (trace_plane_normal_z < 0.7) { s = trace_fraction; - tracebox(self.origin + '0 0 16', self.mins, self.maxs, self.origin + self.velocity * 0.2 + '0 0 16', FALSE, self); + tracebox(self.origin + stepheightvec, self.mins, self.maxs, self.origin + self.velocity * 0.2 + stepheightvec, FALSE, self); if (trace_fraction < s + 0.01) if (trace_plane_normal_z < 0.7) { s = trace_fraction; - tracebox(self.origin + '0 0 48', self.mins, self.maxs, self.origin + self.velocity * 0.2 + '0 0 48', FALSE, self); + tracebox(self.origin + jumpstepheightvec, self.mins, self.maxs, self.origin + self.velocity * 0.2 + jumpstepheightvec, FALSE, self); if (trace_fraction > s) self.BUTTON_JUMP = 1; } diff --git a/qcsrc/server/bot/navigation.qc b/qcsrc/server/bot/navigation.qc index ebaf210b3..749b78fed 100644 --- a/qcsrc/server/bot/navigation.qc +++ b/qcsrc/server/bot/navigation.qc @@ -133,8 +133,8 @@ float tracewalk(entity e, vector start, vector m1, vector m2, vector end, float // hit something if (trace_fraction < 1) { - // check if we can walk over this obstacle - tracebox(org + stepheightvec, m1, m2, move + stepheightvec, movemode, e); + // check if we can walk over this obstacle, possibly by jumpstepping + tracebox(org + jumpstepheightvec, m1, m2, move + jumpstepheightvec, movemode, e); if (trace_fraction < 1 || trace_startsolid) { if(autocvar_bot_debug_tracewalk) diff --git a/qcsrc/server/bot/navigation.qh b/qcsrc/server/bot/navigation.qh index 0a9bf1401..8971692de 100644 --- a/qcsrc/server/bot/navigation.qh +++ b/qcsrc/server/bot/navigation.qh @@ -6,6 +6,7 @@ float navigation_bestrating; float bot_navigation_movemode; float navigation_testtracewalk; +vector jumpstepheightvec; vector stepheightvec; entity botframe_dangerwaypoint;