]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_ctf.qc
Bot AI: slightly increase timeout for finding a new goal when bot is chasing a player...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_ctf.qc
index 3cf560ebedf752c3fc99b33cfc2aa3248bcaad2b..cd891b6bfb4a8dc49c99798bd9adca340e687f29 100644 (file)
@@ -1653,11 +1653,10 @@ void havocbot_role_ctf_carrier(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-
                navigation_goalrating_start(this);
+
                if(ctf_oneflag)
                        havocbot_goalrating_ctf_enemybase(this, 50000);
                else
@@ -1668,6 +1667,8 @@ void havocbot_role_ctf_carrier(entity this)
 
                navigation_goalrating_end(this);
 
+               navigation_goalrating_timeout_set(this);
+
                if (this.goalentity)
                        this.havocbot_cantfindflag = time + 10;
                else if (time > this.havocbot_cantfindflag)
@@ -1729,14 +1730,17 @@ void havocbot_role_ctf_escort(entity this)
        }
 
        // Chase the flag carrier
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_enemyflag(this, 30000);
                havocbot_goalrating_ctf_ourstolenflag(this, 40000);
                havocbot_goalrating_items(this, 10000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1809,15 +1813,18 @@ void havocbot_role_ctf_offense(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_enemybase(this, 20000);
                havocbot_goalrating_items(this, 5000, this.origin, 1000);
                havocbot_goalrating_items(this, 1000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1845,7 +1852,7 @@ void havocbot_role_ctf_retriever(entity this)
                if(this.goalcurrent == mf)
                {
                        navigation_clearroute(this);
-                       this.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(this);
                }
                havocbot_ctf_reset_role(this);
                return;
@@ -1860,18 +1867,21 @@ void havocbot_role_ctf_retriever(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                float rt_radius;
                rt_radius = 10000;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_droppedflags(this, 40000, this.origin, rt_radius);
                havocbot_goalrating_ctf_enemybase(this, 30000);
                havocbot_goalrating_items(this, 500, this.origin, rt_radius);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1907,22 +1917,25 @@ void havocbot_role_ctf_middle(entity this)
                return;
        }
 
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                vector org;
 
                org = havocbot_middlepoint;
                org.z = this.origin.z;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
+
                havocbot_goalrating_ctf_ourstolenflag(this, 50000);
                havocbot_goalrating_ctf_droppedflags(this, 30000, this.origin, 10000);
                havocbot_goalrating_enemyplayers(this, 10000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 5000, org, havocbot_middlepoint_radius * 0.5);
                havocbot_goalrating_items(this, 2500, this.origin, 10000);
                havocbot_goalrating_ctf_enemybase(this, 2500);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -1958,11 +1971,10 @@ void havocbot_role_ctf_defense(entity this)
                havocbot_ctf_reset_role(this);
                return;
        }
-       if (this.bot_strategytime < time)
+       if (navigation_goalrating_timeout(this))
        {
                vector org = mf.dropped_origin;
 
-               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
                // if enemies are closer to our base, go there
@@ -1988,7 +2000,10 @@ void havocbot_role_ctf_defense(entity this)
                havocbot_goalrating_enemyplayers(this, 15000, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 10000, org, havocbot_middlepoint_radius);
                havocbot_goalrating_items(this, 5000, this.origin, 10000);
+
                navigation_goalrating_end(this);
+
+               navigation_goalrating_timeout_set(this);
        }
 }
 
@@ -2002,7 +2017,7 @@ void havocbot_role_ctf_setrole(entity bot, int role)
                        bot.havocbot_role = havocbot_role_ctf_carrier;
                        bot.havocbot_role_timeout = 0;
                        bot.havocbot_cantfindflag = time + 10;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
                case HAVOCBOT_CTF_ROLE_DEFENSE:
                        s = "defense";
@@ -2024,14 +2039,14 @@ void havocbot_role_ctf_setrole(entity bot, int role)
                        bot.havocbot_previous_role = bot.havocbot_role;
                        bot.havocbot_role = havocbot_role_ctf_retriever;
                        bot.havocbot_role_timeout = time + 10;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
                case HAVOCBOT_CTF_ROLE_ESCORT:
                        s = "escort";
                        bot.havocbot_previous_role = bot.havocbot_role;
                        bot.havocbot_role = havocbot_role_ctf_escort;
                        bot.havocbot_role_timeout = time + 30;
-                       bot.bot_strategytime = 0;
+                       navigation_goalrating_timeout_force(bot);
                        break;
        }
        LOG_TRACE(bot.netname, " switched to ", s);