]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: while targetting an enemy try to pick a new target after some seconds (bot_ai...
authorterencehill <piuntn@gmail.com>
Thu, 13 Feb 2020 14:39:57 +0000 (15:39 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 13 Feb 2020 14:39:57 +0000 (15:39 +0100)
qcsrc/server/bot/default/cvars.qh
qcsrc/server/bot/default/havocbot/havocbot.qc
qcsrc/server/bot/default/havocbot/havocbot.qh
xonotic-server.cfg

index 682555238ece51016bad120b685eb095c9655c71..269cd68044fe5902009a8fe610b3e67da8472985 100644 (file)
@@ -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;
index 219da7090a502c4e5eac18d1ae7b8ed79452c7d7..86b8be7c6dcb917ea320066da47713388afffa2b 100644 (file)
@@ -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)
index a45e072c75a6b4d062a1ae1449bcb608e6c8dea8..02c0f3e7d76b3d8912afcea77f8f0ea5fb779df1 100644 (file)
@@ -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;
index a763b5d71eebb0df17721dffc6e40bb1e88284d7..9523a12518f211fbfc2665e121b521691a59491f 100644 (file)
@@ -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"