From: terencehill Date: Sun, 28 Oct 2018 19:39:24 +0000 (+0100) Subject: Bot AI: make bots with low movement skill slow down when they deviate too much from... X-Git-Tag: xonotic-v0.8.5~1705^2~14 X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=52de08a8dae0a5b71226ac9d1cb982cb2bb36c12 Bot AI: make bots with low movement skill slow down when they deviate too much from the path --- diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 969f291690..94499c2eb5 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -881,7 +881,8 @@ void havocbot_movetogoal(entity this) diff = destorg - this.origin; - if (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10)) + if (time < this.bot_stop_moving_timeout + || (this.goalcurrent == this.goalentity && time < this.goalentity_lock_timeout && vdist(diff, <, 10))) { // stop if the locked goal has been reached destorg = this.origin; @@ -1065,6 +1066,12 @@ void havocbot_movetogoal(entity this) // Check for water/slime/lava and dangerous edges // (only when the bot is on the ground or jumping intentionally) + if (skill + this.bot_moveskill <= 3 && time > this.bot_stop_moving_timeout + && current_speed > maxspeed * 0.9 && fabs(deviation.y) > 70) + { + this.bot_stop_moving_timeout = time + 0.4 + random() * 0.2; + } + offset = (vdist(this.velocity, >, 32) ? this.velocity * 0.2 : v_forward * 32); vector dst_ahead = this.origin + this.view_ofs + offset; vector dst_down = dst_ahead - '0 0 3000'; @@ -1189,7 +1196,12 @@ void havocbot_movetogoal(entity this) } if (!this.bot_aimdir_executed) - bot_aimdir(this, dir, -1); + { + if (time < this.bot_stop_moving_timeout) + bot_aimdir(this, normalize(this.goalcurrent.origin - this.origin), -1); + else + bot_aimdir(this, dir, -1); + } if (!ladder_zdir) { diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qh b/qcsrc/server/bot/default/havocbot/havocbot.qh index b3c0c3ea79..2ec6316917 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qh +++ b/qcsrc/server/bot/default/havocbot/havocbot.qh @@ -23,6 +23,7 @@ .float havocbot_stickenemy; .float havocbot_role_timeout; +.float bot_stop_moving_timeout; .float bot_tracewalk_time; .entity ignoregoal; .entity bot_lastseengoal;