]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge remote branch 'origin/pooga/freezetagbots' after adjusting history
authorRudolf Polzer <divVerent@xonotic.org>
Mon, 20 Jun 2011 08:26:28 +0000 (10:26 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 20 Jun 2011 08:26:47 +0000 (10:26 +0200)
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/role_freezetag.qc [new file with mode: 0644]
qcsrc/server/bot/havocbot/roles.qc

index dd111d9f00400f376eedd8ea6462ec90c3caaddd..265731f690d1d4ea231d976491301eb842f623ab 100644 (file)
@@ -2,6 +2,7 @@
 #include "role_ctf.qc"
 #include "role_onslaught.qc"
 #include "role_keyhunt.qc"
+#include "role_freezetag.qc"
 #include "roles.qc"
 
 void havocbot_ai()
diff --git a/qcsrc/server/bot/havocbot/role_freezetag.qc b/qcsrc/server/bot/havocbot/role_freezetag.qc
new file mode 100644 (file)
index 0000000..c81d7d0
--- /dev/null
@@ -0,0 +1,109 @@
+void() havocbot_role_ft_freeing;
+void() havocbot_role_ft_offense;
+
+void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
+{
+       local entity head;
+       float distance;
+
+       FOR_EACH_PLAYER(head)
+       {
+               if ((head != self) && (head.team == self.team))
+               {
+                       if (head.freezetag_frozen)
+                       {
+                               distance = vlen(head.origin - org);
+                               if (distance > sradius)
+                                       continue;
+                               navigation_routerating(head, ratingscale, 2000);
+                       }
+                       else
+                       {
+                               // If teamate is not frozen still seek them out as fight better
+                               // in a group.
+                               navigation_routerating(head, ratingscale/3, 2000);
+                       }
+               }
+       }
+};
+
+void havocbot_role_ft_offense()
+{
+       local entity head;
+       float unfrozen;
+
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (!self.havocbot_role_timeout)
+               self.havocbot_role_timeout = time + random() * 10 + 20;
+
+       // Count how many players on team are unfrozen.
+       unfrozen = 0;
+       FOR_EACH_PLAYER(head)
+       {
+               if ((head.team == self.team) && (!head.freezetag_frozen))
+                       unfrozen++;
+       }
+
+       // If only one left on team or if role has timed out then start trying to free players.
+       if (((unfrozen == 0) && (!self.freezetag_frozen)) || (time > self.havocbot_role_timeout))
+       {
+               dprint("changing role to freeing\n");
+               self.havocbot_role = havocbot_role_ft_freeing;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (time > self.bot_strategytime)
+       {
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start();
+               havocbot_goalrating_items(10000, self.origin, 10000);
+               havocbot_goalrating_enemyplayers(20000, self.origin, 10000);
+               havocbot_goalrating_freeplayers(9000, self.origin, 10000);
+               //havocbot_goalrating_waypoints(1, self.origin, 1000);
+               navigation_goalrating_end();
+       }
+};
+
+void havocbot_role_ft_freeing()
+{
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (!self.havocbot_role_timeout)
+               self.havocbot_role_timeout = time + random() * 10 + 20;
+
+       if (time > self.havocbot_role_timeout)
+       {
+               dprint("changing role to offense\n");
+               self.havocbot_role = havocbot_role_ft_offense;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (time > self.bot_strategytime)
+       {
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start();
+               havocbot_goalrating_items(8000, self.origin, 10000);
+               havocbot_goalrating_enemyplayers(10000, self.origin, 10000);
+               havocbot_goalrating_freeplayers(20000, self.origin, 10000);
+               //havocbot_goalrating_waypoints(1, self.origin, 1000);
+               navigation_goalrating_end();
+       }
+};
+
+void havocbot_chooserole_ft()
+{
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (random() < 0.5)
+               self.havocbot_role = havocbot_role_ft_freeing;
+       else
+               self.havocbot_role = havocbot_role_ft_offense;
+};
index ebd0d4e44d1cc28458c547c46df2c8c2906b7d07..96c901f9e9f301821d7cca6cedf05871f65bf731 100644 (file)
@@ -168,6 +168,9 @@ void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradi
                        if (distance < 100 || distance > sradius)
                                continue;
 
+                       if (head.freezetag_frozen)
+                               continue;
+
                        if(g_minstagib)
                        if(head.items & IT_STRENGTH)
                                continue;
@@ -310,7 +313,7 @@ void havocbot_chooserole_dom()
 void havocbot_chooserole_ka()
 {
        self.havocbot_role = havocbot_role_ka;
-}
+};
 
 void havocbot_chooserole()
 {
@@ -328,6 +331,8 @@ void havocbot_chooserole()
                havocbot_chooserole_ons();
        else if (g_keepaway)
                havocbot_chooserole_ka();
+       else if (g_freezetag)
+               havocbot_chooserole_ft();
        else // assume anything else is deathmatch
                havocbot_chooserole_dm();
 };