]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/bot/havocbot/role_onslaught.qc
Rename the underscore headers
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / bot / havocbot / role_onslaught.qc
index 3268daefa5a5ae601056dc02a1b6d6142ee3662f..6924f5122949e8edf715cded97d9c9ea6e98f159 100644 (file)
@@ -1,9 +1,21 @@
-#define HAVOCBOT_ONS_ROLE_NONE                 0
-#define HAVOCBOT_ONS_ROLE_DEFENSE      2
-#define HAVOCBOT_ONS_ROLE_ASSISTANT    4
-#define HAVOCBOT_ONS_ROLE_OFFENSE      8
+#include "../../_all.qh"
 
-.float havocbot_role_flags;
+#include "havocbot.qh"
+
+#include "../bot.qh"
+#include "../navigation.qh"
+#include "../waypoints.qh"
+
+#include "../../mutators/mutators_include.qh"
+
+#include "../../../common/teams.qh"
+
+const int HAVOCBOT_ONS_ROLE_NONE               = 0;
+const int HAVOCBOT_ONS_ROLE_DEFENSE    = 2;
+const int HAVOCBOT_ONS_ROLE_ASSISTANT  = 4;
+const int HAVOCBOT_ONS_ROLE_OFFENSE    = 8;
+
+.int havocbot_role_flags;
 .float havocbot_attack_time;
 
 .void() havocbot_role;
@@ -27,24 +39,25 @@ void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplay
 
 void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float sradius)
 {
-       local entity head;
-       local float t, i, c, needarmor, needweapons;
+       entity head;
+       float t, i, c, needarmor = false, needweapons = false;
 
        // Needs armor/health?
        if(self.health<100)
-               needarmor = TRUE;
+               needarmor = true;
 
        // Needs weapons?
-       for(i = WEP_FIRST; i < WEP_LAST ; ++i)
+       c = 0;
+       for(i = WEP_FIRST; i <= WEP_LAST ; ++i)
        {
                // Find weapon
-               if(power2of(i-1) & self.weapons)
+               if(self.weapons & WepSet_FromWeapon(i))
                if(++c>=4)
                        break;
        }
 
        if(c<4)
-               needweapons = TRUE;
+               needweapons = true;
 
        if(!needweapons && !needarmor)
                return;
@@ -53,7 +66,7 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
 //     dprint(self.netname, " needs armor ", ftos(needarmor) , "\n");
 
        // See what is around
-       head = findchainfloat(bot_pickup, TRUE);
+       head = findchainfloat(bot_pickup, true);
        while (head)
        {
                // gather health and armor only
@@ -67,7 +80,7 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
                }
                head = head.chain;
        }
-};
+}
 
 void havocbot_role_ons_setrole(entity bot, float role)
 {
@@ -94,12 +107,12 @@ void havocbot_role_ons_setrole(entity bot, float role)
                        break;
        }
        dprint("\n");
-};
+}
 
-float havocbot_ons_teamcount(entity bot, float role)
+float havocbot_ons_teamcount(entity bot, int role)
 {
-       local float c;
-       local entity head;
+       float c = 0;
+       entity head;
 
        FOR_EACH_PLAYER(head)
        if(head.team==self.team)
@@ -107,7 +120,7 @@ float havocbot_ons_teamcount(entity bot, float role)
                ++c;
 
        return c;
-};
+}
 
 void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 {
@@ -120,18 +133,18 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        for (; cp2; cp2 = cp2.chain)
        {
                cp2.wpcost = c = 0;
-               cp2.wpconsidered = FALSE;
+               cp2.wpconsidered = false;
 
                if(cp2.isshielded)
                        continue;
 
                // Ignore owned controlpoints
-               if(self.team == COLOR_TEAM1)
+               if(self.team == NUM_TEAM_1)
                {
                        if( (cp2.isgenneighbor_blue || cp2.iscpneighbor_blue) && !(cp2.isgenneighbor_red || cp2.iscpneighbor_red) )
                                continue;
                }
-               else if(self.team == COLOR_TEAM2)
+               else if(self.team == NUM_TEAM_2)
                {
                        if( (cp2.isgenneighbor_red || cp2.iscpneighbor_red) && !(cp2.isgenneighbor_blue || cp2.iscpneighbor_blue) )
                                continue;
@@ -147,14 +160,15 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 
                // NOTE: probably decrease the cost of attackable control points
                cp2.wpcost = c;
-               cp2.wpconsidered = TRUE;
+               cp2.wpconsidered = true;
        }
 
        // We'll consider only the best case
        bestvalue = 99999999999;
+       cp = world;
        for (; cp1; cp1 = cp1.chain)
        {
-               if not(cp1.wpconsidered)
+               if (!cp1.wpconsidered)
                        continue;
 
                if(cp1.wpcost<bestvalue)
@@ -165,7 +179,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                }
        }
 
-       if not(cp)
+       if (!cp)
                return;
 
 //     dprint(self.netname, " chose cp ranked ", ftos(bestvalue), "\n");
@@ -174,7 +188,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        {
                // Should be attacked
                // Rate waypoints near it
-               found = FALSE;
+               found = false;
                best = world;
                bestvalue = 99999999999;
                for(radius=0; radius<1000 && !found; radius+=500)
@@ -185,7 +199,7 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                                if(wp.classname=="waypoint")
                                if(checkpvs(wp.origin,cp))
                                {
-                                       found = TRUE;
+                                       found = true;
                                        if(wp.cnt<bestvalue)
                                        {
                                                best = wp;
@@ -215,28 +229,29 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
        {
                // Should be touched
                // dprint(self.netname, " found a touchable controlpoint at ", vtos(cp.origin) ,"\n");
+               found = false;
 
                // Look for auto generated waypoint
-               if not(bot_waypoints_for_items)
+               if (!bot_waypoints_for_items)
                for (wp = findradius(cp.origin,100); wp; wp = wp.chain)
                {
                        if(wp.classname=="waypoint")
                        {
                                navigation_routerating(wp, ratingscale, 10000);
-                               found = TRUE;
+                               found = true;
                        }
                }
 
                // Nothing found, rate the controlpoint itself
-               if not(found)
+               if (!found)
                        navigation_routerating(cp, ratingscale, 10000);
        }
-};
+}
 
 float havocbot_goalrating_ons_generator_attack(float ratingscale)
 {
-       local entity g, wp, bestwp;
-       local float found, best;
+       entity g, wp, bestwp;
+       float found, best;
 
        for (g = findchain(classname, "onslaught_generator"); g; g = g.chain)
        {
@@ -245,7 +260,7 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
 
                // Should be attacked
                // Rate waypoints near it
-               found = FALSE;
+               found = false;
                bestwp = world;
                best = 99999999999;
 
@@ -254,7 +269,7 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
                        if(wp.classname=="waypoint")
                        if(checkpvs(wp.origin,g))
                        {
-                               found = TRUE;
+                               found = true;
                                if(wp.cnt<best)
                                {
                                        bestwp = wp;
@@ -274,7 +289,7 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
                        if(checkpvs(self.view_ofs,bestwp))
                                self.havocbot_attack_time = time + 5;
 
-                       return TRUE;
+                       return true;
                }
                else
                {
@@ -282,11 +297,11 @@ float havocbot_goalrating_ons_generator_attack(float ratingscale)
                        // if there aren't waypoints near the generator go straight to it
                        navigation_routerating(g, ratingscale, 10000);
                        self.havocbot_attack_time = 0;
-                       return TRUE;
+                       return true;
                }
        }
-       return FALSE;
-};
+       return false;
+}
 
 void havocbot_role_ons_offense()
 {
@@ -319,24 +334,24 @@ void havocbot_role_ons_offense()
                havocbot_goalrating_ons_offenseitems(10000, self.origin, 10000);
                navigation_goalrating_end();
 
-               self.bot_strategytime = time + cvar("bot_ai_strategyinterval");
+               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
        }
-};
+}
 
 void havocbot_role_ons_assistant()
 {
        havocbot_ons_reset_role(self);
-};
+}
 
 void havocbot_role_ons_defense()
 {
        havocbot_ons_reset_role(self);
-};
+}
 
 void havocbot_ons_reset_role(entity bot)
 {
-       local entity head;
-       local float c;
+       entity head;
+       float c;
 
        if(self.deadflag != DEAD_NO)
                return;
@@ -358,9 +373,9 @@ void havocbot_ons_reset_role(entity bot)
        }
 
        havocbot_role_ons_setrole(bot, HAVOCBOT_ONS_ROLE_OFFENSE);
-};
+}
 
 void havocbot_chooserole_ons()
 {
        havocbot_ons_reset_role(self);
-};
+}