]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Another gamemode specific file and check
authorMario <mario@smbclan.net>
Wed, 14 Oct 2015 14:48:04 +0000 (00:48 +1000)
committerMario <mario@smbclan.net>
Wed, 14 Oct 2015 14:48:04 +0000 (00:48 +1000)
qcsrc/server/bot/havocbot/_all.inc
qcsrc/server/bot/havocbot/role_keyhunt.qc [deleted file]
qcsrc/server/bot/havocbot/role_keyhunt.qh [deleted file]
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/mutators/gamemode.qh
qcsrc/server/mutators/gamemode_keyhunt.qc
qcsrc/server/mutators/gamemode_keyhunt.qh
qcsrc/server/mutators/mutator.qh

index fb73954a1427109d13229a832daac7964fe812c5..2dd8c74b6250b8a660ab71a231b15864934e7e1a 100644 (file)
@@ -1,3 +1,2 @@
 #include "havocbot.qc"
-#include "role_keyhunt.qc"
 #include "roles.qc"
diff --git a/qcsrc/server/bot/havocbot/role_keyhunt.qc b/qcsrc/server/bot/havocbot/role_keyhunt.qc
deleted file mode 100644 (file)
index 0059dc9..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-#include "role_keyhunt.qh"
-
-#include "havocbot.qh"
-
-#include "../bot.qh"
-#include "../navigation.qh"
-
-#include "../../mutators/mutators_include.qh"
-
-void() havocbot_role_kh_carrier;
-void() havocbot_role_kh_defense;
-void() havocbot_role_kh_offense;
-void() havocbot_role_kh_freelancer;
-
-
-void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
-{SELFPARAM();
-       entity head;
-       for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
-       {
-               if(head.owner == self)
-                       continue;
-               if(!kh_tracking_enabled)
-               {
-                       // if it's carried by our team we know about it
-                       // otherwise we have to see it to know about it
-                       if(!head.owner || head.team != self.team)
-                       {
-                               traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
-                               if (trace_fraction < 1 && trace_ent != head)
-                                       continue; // skip what I can't see
-                       }
-               }
-               if(!head.owner)
-                       navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
-               else if(head.team == self.team)
-                       navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
-               else
-                       navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
-       }
-
-       havocbot_goalrating_items(1, self.origin, 10000);
-}
-
-void havocbot_role_kh_carrier()
-{SELFPARAM();
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       if (!(self.kh_next))
-       {
-               LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (self.bot_strategytime < time)
-       {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-
-               if(kh_Key_AllOwnedByWhichTeam() == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
-               else
-                       havocbot_goalrating_kh(4, 4, 1); // play defensively
-
-               navigation_goalrating_end();
-       }
-}
-
-void havocbot_role_kh_defense()
-{SELFPARAM();
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       if (self.kh_next)
-       {
-               LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
-       if (time > self.havocbot_role_timeout)
-       {
-               LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (self.bot_strategytime < time)
-       {
-               float key_owner_team;
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-
-               key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
-               else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(4, 1, 0.1); // play defensively
-               else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
-
-               navigation_goalrating_end();
-       }
-}
-
-void havocbot_role_kh_offense()
-{SELFPARAM();
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       if (self.kh_next)
-       {
-               LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
-       if (time > self.havocbot_role_timeout)
-       {
-               LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (self.bot_strategytime < time)
-       {
-               float key_owner_team;
-
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-
-               key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
-               else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(0.1, 1, 4); // play offensively
-               else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
-
-               navigation_goalrating_end();
-       }
-}
-
-void havocbot_role_kh_freelancer()
-{SELFPARAM();
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       if (self.kh_next)
-       {
-               LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 10;
-       if (time > self.havocbot_role_timeout)
-       {
-               if (random() < 0.5)
-               {
-                       LOG_TRACE("changing role to offense\n");
-                       self.havocbot_role = havocbot_role_kh_offense;
-               }
-               else
-               {
-                       LOG_TRACE("changing role to defense\n");
-                       self.havocbot_role = havocbot_role_kh_defense;
-               }
-               self.havocbot_role_timeout = 0;
-               return;
-       }
-
-       if (self.bot_strategytime < time)
-       {
-               float key_owner_team;
-
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-
-               key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
-               else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
-               else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
-
-               navigation_goalrating_end();
-       }
-}
-
-void havocbot_chooserole_kh()
-{SELFPARAM();
-       float r;
-
-       if(self.deadflag != DEAD_NO)
-               return;
-
-       r = random() * 3;
-       if (r < 1)
-               self.havocbot_role = havocbot_role_kh_offense;
-       else if (r < 2)
-               self.havocbot_role = havocbot_role_kh_defense;
-       else
-               self.havocbot_role = havocbot_role_kh_freelancer;
-}
diff --git a/qcsrc/server/bot/havocbot/role_keyhunt.qh b/qcsrc/server/bot/havocbot/role_keyhunt.qh
deleted file mode 100644 (file)
index f3136c6..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef ROLE_KEYHUNT_H
-#define ROLE_KEYHUNT_H
-
-entity kh_worldkeylist;
-.entity kh_worldkeynext;
-
-void havocbot_chooserole_kh();
-#endif
index a4357628eee88d6ae646e450f733e64f9363bd9c..acb24f51706a499bd0eaddf08ad340d98f072525 100644 (file)
@@ -1,6 +1,5 @@
 
 #include "havocbot.qh"
-#include "role_keyhunt.qh"
 
 #include "../bot.qh"
 #include "../navigation.qh"
@@ -237,10 +236,6 @@ void havocbot_chooserole()
 {SELFPARAM();
        LOG_TRACE("choosing a role...\n");
        self.bot_strategytime = 0;
-       if (MUTATOR_CALLHOOK(HavocBot_ChooseRole, self))
-               return;
-       else if (g_keyhunt)
-               havocbot_chooserole_kh();
-       else
+       if(!MUTATOR_CALLHOOK(HavocBot_ChooseRole, self))
                havocbot_chooserole_generic();
 }
index da11aefeeb0fbad8b186f1650ae340caa09f5b01..5e5675f40c81907054ed40dd68c86913101b007f 100644 (file)
@@ -17,7 +17,6 @@
 #include "../bot/navigation.qh"
 #include "../bot/waypoints.qh"
 #include "../bot/havocbot/roles.qh"
-#include "../bot/havocbot/role_keyhunt.qh"
 
 #include "../bot/havocbot/havocbot.qh"
 
index 1affe8ed04b1b1deb65301f01821857eae854e5c..71a65c6b596cd7935f287a5400037eabf9300339 100644 (file)
@@ -1042,6 +1042,204 @@ void kh_finalize()
        kh_controller = world;
 }
 
+// legacy bot role
+
+void() havocbot_role_kh_carrier;
+void() havocbot_role_kh_defense;
+void() havocbot_role_kh_offense;
+void() havocbot_role_kh_freelancer;
+
+
+void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
+{SELFPARAM();
+       entity head;
+       for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
+       {
+               if(head.owner == self)
+                       continue;
+               if(!kh_tracking_enabled)
+               {
+                       // if it's carried by our team we know about it
+                       // otherwise we have to see it to know about it
+                       if(!head.owner || head.team != self.team)
+                       {
+                               traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
+                               if (trace_fraction < 1 && trace_ent != head)
+                                       continue; // skip what I can't see
+                       }
+               }
+               if(!head.owner)
+                       navigation_routerating(head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
+               else if(head.team == self.team)
+                       navigation_routerating(head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
+               else
+                       navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
+       }
+
+       havocbot_goalrating_items(1, self.origin, 10000);
+}
+
+void havocbot_role_kh_carrier()
+{SELFPARAM();
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (!(self.kh_next))
+       {
+               LOG_TRACE("changing role to freelancer\n");
+               self.havocbot_role = havocbot_role_kh_freelancer;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (self.bot_strategytime < time)
+       {
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start();
+
+               if(kh_Key_AllOwnedByWhichTeam() == self.team)
+                       havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
+               else
+                       havocbot_goalrating_kh(4, 4, 1); // play defensively
+
+               navigation_goalrating_end();
+       }
+}
+
+void havocbot_role_kh_defense()
+{SELFPARAM();
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (self.kh_next)
+       {
+               LOG_TRACE("changing role to carrier\n");
+               self.havocbot_role = havocbot_role_kh_carrier;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (!self.havocbot_role_timeout)
+               self.havocbot_role_timeout = time + random() * 10 + 20;
+       if (time > self.havocbot_role_timeout)
+       {
+               LOG_TRACE("changing role to freelancer\n");
+               self.havocbot_role = havocbot_role_kh_freelancer;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (self.bot_strategytime < time)
+       {
+               float key_owner_team;
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start();
+
+               key_owner_team = kh_Key_AllOwnedByWhichTeam();
+               if(key_owner_team == self.team)
+                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
+               else if(key_owner_team == -1)
+                       havocbot_goalrating_kh(4, 1, 0.1); // play defensively
+               else
+                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
+
+               navigation_goalrating_end();
+       }
+}
+
+void havocbot_role_kh_offense()
+{SELFPARAM();
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (self.kh_next)
+       {
+               LOG_TRACE("changing role to carrier\n");
+               self.havocbot_role = havocbot_role_kh_carrier;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (!self.havocbot_role_timeout)
+               self.havocbot_role_timeout = time + random() * 10 + 20;
+       if (time > self.havocbot_role_timeout)
+       {
+               LOG_TRACE("changing role to freelancer\n");
+               self.havocbot_role = havocbot_role_kh_freelancer;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (self.bot_strategytime < time)
+       {
+               float key_owner_team;
+
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start();
+
+               key_owner_team = kh_Key_AllOwnedByWhichTeam();
+               if(key_owner_team == self.team)
+                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
+               else if(key_owner_team == -1)
+                       havocbot_goalrating_kh(0.1, 1, 4); // play offensively
+               else
+                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
+
+               navigation_goalrating_end();
+       }
+}
+
+void havocbot_role_kh_freelancer()
+{SELFPARAM();
+       if(self.deadflag != DEAD_NO)
+               return;
+
+       if (self.kh_next)
+       {
+               LOG_TRACE("changing role to carrier\n");
+               self.havocbot_role = havocbot_role_kh_carrier;
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (!self.havocbot_role_timeout)
+               self.havocbot_role_timeout = time + random() * 10 + 10;
+       if (time > self.havocbot_role_timeout)
+       {
+               if (random() < 0.5)
+               {
+                       LOG_TRACE("changing role to offense\n");
+                       self.havocbot_role = havocbot_role_kh_offense;
+               }
+               else
+               {
+                       LOG_TRACE("changing role to defense\n");
+                       self.havocbot_role = havocbot_role_kh_defense;
+               }
+               self.havocbot_role_timeout = 0;
+               return;
+       }
+
+       if (self.bot_strategytime < time)
+       {
+               float key_owner_team;
+
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start();
+
+               key_owner_team = kh_Key_AllOwnedByWhichTeam();
+               if(key_owner_team == self.team)
+                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
+               else if(key_owner_team == -1)
+                       havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
+               else
+                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
+
+               navigation_goalrating_end();
+       }
+}
+
+
 // register this as a mutator
 
 MUTATOR_HOOKFUNCTION(kh, ClientDisconnect)
@@ -1106,6 +1304,22 @@ MUTATOR_HOOKFUNCTION(kh, PlayerUseKey)
        return 0;
 }
 
+MUTATOR_HOOKFUNCTION(kh, HavocBot_ChooseRole)
+{
+       if(self.deadflag != DEAD_NO)
+               return true;
+
+       float r = random() * 3;
+       if (r < 1)
+               self.havocbot_role = havocbot_role_kh_offense;
+       else if (r < 2)
+               self.havocbot_role = havocbot_role_kh_defense;
+       else
+               self.havocbot_role = havocbot_role_kh_freelancer;
+
+       return true;
+}
+
 REGISTER_MUTATOR(kh, g_keyhunt)
 {
        ActivateTeamplay();
index 4d1645d02c0201ecebe82485e1f771f025e69b82..3fa347ea618b7e027336050f05495829122d6f35 100644 (file)
@@ -16,4 +16,7 @@ void kh_Controller_SetThink(float t, kh_Think_t func);
 
 void kh_Key_DropAll(entity player, float suicide);
 
+entity kh_worldkeylist;
+.entity kh_worldkeynext;
+
 #endif
index e8054bc0442bc3efa2ae451298c9bacaaa23c8f4..8dde34af3d8dc657f361ad85da1754821f0ee928 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "../bot/havocbot/havocbot.qh"
 #include "../bot/havocbot/roles.qh"
-#include "../bot/havocbot/role_keyhunt.qh"
 
 #include "../command/vote.qh"
 #include "../command/common.qh"