From 0dbe060bf006760aed632a7157abce7c70c211de Mon Sep 17 00:00:00 2001 From: terencehill Date: Thu, 13 Feb 2020 15:39:57 +0100 Subject: [PATCH] Bot AI: while targetting an enemy try to pick a new target after some seconds (bot_ai_enemydetectioninterval_stickingtoenemy) rather than when health is lower than 30. Fixed description of bot_ai_enemydetectioninterval --- qcsrc/server/bot/default/cvars.qh | 1 + qcsrc/server/bot/default/havocbot/havocbot.qc | 19 +++++++------------ qcsrc/server/bot/default/havocbot/havocbot.qh | 2 +- xonotic-server.cfg | 3 ++- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/qcsrc/server/bot/default/cvars.qh b/qcsrc/server/bot/default/cvars.qh index 682555238..269cd6804 100644 --- a/qcsrc/server/bot/default/cvars.qh +++ b/qcsrc/server/bot/default/cvars.qh @@ -33,6 +33,7 @@ string autocvar_bot_ai_custom_weapon_priority_mid; float autocvar_bot_ai_dangerdetectioninterval; float autocvar_bot_ai_dangerdetectionupdates; float autocvar_bot_ai_enemydetectioninterval; +float autocvar_bot_ai_enemydetectioninterval_stickingtoenemy; float autocvar_bot_ai_enemydetectionradius; float autocvar_bot_ai_friends_aware_pickup_radius; float autocvar_bot_ai_ignoregoal_timeout; diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qc b/qcsrc/server/bot/default/havocbot/havocbot.qc index 219da7090..86b8be7c6 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qc +++ b/qcsrc/server/bot/default/havocbot/havocbot.qc @@ -1250,6 +1250,7 @@ void havocbot_chooseenemy(entity this) this.enemy = NULL; return; } + if (this.enemy) { if (!bot_shouldattack(this, this.enemy)) @@ -1258,27 +1259,21 @@ void havocbot_chooseenemy(entity this) this.enemy = NULL; this.havocbot_chooseenemy_finished = time; } - else if (this.havocbot_stickenemy) + else if (this.havocbot_stickenemy_time && time < this.havocbot_stickenemy_time) { // tracking last chosen enemy - // if enemy is visible - // and not really really far away - // and we're not severely injured - // then keep tracking for a half second into the future vector targ_pos = (this.enemy.absmin + this.enemy.absmax) * 0.5; traceline(this.origin + this.view_ofs, targ_pos, false, NULL); if (trace_ent == this.enemy || trace_fraction == 1) if (vdist(targ_pos - this.origin, <, 1000)) - if (GetResource(this, RES_HEALTH) > 30) { // remain tracking him for a shot while (case he went after a small corner or pilar this.havocbot_chooseenemy_finished = time + 0.5; return; } - // enemy isn't visible, or is far away, or we're injured severely - // so stop preferring this enemy - // (it will still take a half second until a new one is chosen) - this.havocbot_stickenemy = 0; + + // stop preferring this enemy + this.havocbot_stickenemy_time = 0; } } if (time < this.havocbot_chooseenemy_finished) @@ -1353,9 +1348,9 @@ LABEL(scan_targets) this.dphitcontentsmask = hf; this.enemy = best; - this.havocbot_stickenemy = true; + this.havocbot_stickenemy_time = time + autocvar_bot_ai_enemydetectioninterval_stickingtoenemy; if(best && best.classname == "misc_breakablemodel") - this.havocbot_stickenemy = false; + this.havocbot_stickenemy_time = 0; } float havocbot_chooseweapon_checkreload(entity this, .entity weaponentity, int new_weapon) diff --git a/qcsrc/server/bot/default/havocbot/havocbot.qh b/qcsrc/server/bot/default/havocbot/havocbot.qh index a45e072c7..02c0f3e7d 100644 --- a/qcsrc/server/bot/default/havocbot/havocbot.qh +++ b/qcsrc/server/bot/default/havocbot/havocbot.qh @@ -18,7 +18,7 @@ .float havocbot_personal_waypoint_searchtime; .float havocbot_personal_waypoint_failcounter; .float havocbot_chooseenemy_finished; -.float havocbot_stickenemy; +.float havocbot_stickenemy_time; .float havocbot_role_timeout; .float bot_stop_moving_timeout; diff --git a/xonotic-server.cfg b/xonotic-server.cfg index a763b5d71..9523a1251 100644 --- a/xonotic-server.cfg +++ b/xonotic-server.cfg @@ -126,7 +126,8 @@ set bot_typefrag 0 "Allow bots to shoot players while they're typing" set bot_ai_thinkinterval 0.05 "Frame rate at which bots update their navigation and aiming, scales by skill" set bot_ai_strategyinterval 7 "How often a new objective is chosen" set bot_ai_strategyinterval_movingtarget 5.5 "How often a new objective is chosen when current objective can move" -set bot_ai_enemydetectioninterval 2 "How often bots pick a new target" +set bot_ai_enemydetectioninterval 2 "How often bots try to pick a new target if no suitable target is found" +set bot_ai_enemydetectioninterval_stickingtoenemy 4 "How often bots try to pick a new target while targetting an enemy" set bot_ai_enemydetectionradius 10000 "How far bots can see enemies" set bot_ai_dodgeupdateinterval 0.2 "How often scan for items to dodge. Currently not in use." set bot_ai_chooseweaponinterval 0.5 "How often the best weapon according to the situation will be chosen" -- 2.39.2