]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Bot AI: Optimize path finding CPU cost when bot switches to certain CTF/Keepaway...
authorterencehill <piuntn@gmail.com>
Mon, 20 Nov 2017 15:33:51 +0000 (16:33 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 20 Nov 2017 15:33:51 +0000 (16:33 +0100)
qcsrc/server/bot/api.qh
qcsrc/server/mutators/mutator/gamemode_assault.qh
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/utils.qh

index 1e29a25fc30f9d584d17145811ca7fa81d2f1c15..c503f605dce9b7616f791b6e9ea3193e4e737499 100644 (file)
@@ -32,6 +32,8 @@ float skill;
 .float(entity player, entity item) bot_pickupevalfunc;
 .string cleanname;
 .float havocbot_role_timeout;
+.void(entity this) havocbot_role;
+.void(entity this) havocbot_previous_role;
 .float isbot; // true if this client is actually a bot
 .float lastteleporttime;
 .float navigation_hasgoals;
@@ -77,6 +79,7 @@ vector havocbot_middlepoint;
 float havocbot_middlepoint_radius;
 vector havocbot_symmetryaxis_equation;
 
+.float goalentity_lock_timeout;
 .float ignoregoaltime;
 .entity ignoregoal;
 
index f437d98b52c837c6db59520c37d840660ece1003..ea714e6a23ba4528f38b6e189386a69215dd6603 100644 (file)
@@ -31,9 +31,6 @@ const int HAVOCBOT_AST_ROLE_OFFENSE = 4;
 .int havocbot_role_flags;
 .float havocbot_attack_time;
 
-.void(entity this) havocbot_role;
-.void(entity this) havocbot_previous_role;
-
 void(entity this) havocbot_role_ast_defense;
 void(entity this) havocbot_role_ast_offense;
 
index ae26c7e39965fce871779a23164db9ddfad39f15..3c714ad5396bbb2bf237a24782722d42162d551b 100644 (file)
@@ -2034,7 +2034,8 @@ 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;
-                       navigation_goalrating_timeout_force(bot);
+                       if (bot.havocbot_previous_role != bot.havocbot_role)
+                               navigation_goalrating_timeout_force(bot);
                        break;
                case HAVOCBOT_CTF_ROLE_DEFENSE:
                        s = "defense";
@@ -2056,14 +2057,16 @@ 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;
-                       navigation_goalrating_timeout_force(bot);
+                       if (bot.havocbot_previous_role != bot.havocbot_role)
+                               navigation_goalrating_timeout_expire(bot, 2);
                        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;
-                       navigation_goalrating_timeout_force(bot);
+                       if (bot.havocbot_previous_role != bot.havocbot_role)
+                               navigation_goalrating_timeout_expire(bot, 2);
                        break;
        }
        LOG_TRACE(bot.netname, " switched to ", s);
index aeca28fa32de06f157658bb3192a9c33f0ae5b14..badae12c2d4897090aaec805bc594d4f1cc9de76 100644 (file)
@@ -246,7 +246,7 @@ void havocbot_role_ka_carrier(entity this)
        if (!this.ballcarried)
        {
                this.havocbot_role = havocbot_role_ka_collector;
-               navigation_goalrating_timeout_force(this);
+               navigation_goalrating_timeout_expire(this, 2);
        }
 }
 
@@ -269,7 +269,7 @@ void havocbot_role_ka_collector(entity this)
        if (this.ballcarried)
        {
                this.havocbot_role = havocbot_role_ka_carrier;
-               navigation_goalrating_timeout_force(this);
+               navigation_goalrating_timeout_expire(this, 2);
        }
 }
 
index a0b7b596541b57e4cd88c95f49f2401ddd18caa4..097685abf1766820a9e3f964928da71172c31d5b 100644 (file)
@@ -22,7 +22,7 @@ const string STR_OBSERVER = "observer";
 #define IS_VEHICLE(v) (v.vehicle_flags & VHF_ISVEHICLE)
 #define IS_TURRET(v) (v.turret_flags & TUR_FLAG_ISTURRET)
 
-#define IS_MOVABLE(v) (((IS_PLAYER(v) || IS_MONSTER(v)) && !STAT(FROZEN, v)) || IS_VEHICLE(v))
+#define IS_MOVABLE(v) ((IS_PLAYER(v) || IS_MONSTER(v)) && !STAT(FROZEN, v))
 
 // NOTE: FOR_EACH_CLIENTSLOT deprecated! Use the following instead: FOREACH_CLIENTSLOT(true, { code; });
 // NOTE: FOR_EACH_CLIENT deprecated! Use the following instead: FOREACH_CLIENT(true, { code; });