Purge self from bot roles
authorMario <mario@smbclan.net>
Tue, 22 Mar 2016 11:06:43 +0000 (21:06 +1000)
committerMario <mario@smbclan.net>
Tue, 22 Mar 2016 11:06:43 +0000 (21:06 +1000)
16 files changed:
qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc
qcsrc/server/bot/havocbot/havocbot.qc
qcsrc/server/bot/havocbot/havocbot.qh
qcsrc/server/bot/havocbot/roles.qc
qcsrc/server/bot/havocbot/roles.qh
qcsrc/server/bot/navigation.qc
qcsrc/server/bot/navigation.qh
qcsrc/server/cl_impulse.qc
qcsrc/server/mutators/mutator/gamemode_assault.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_domination.qc
qcsrc/server/mutators/mutator/gamemode_freezetag.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc
qcsrc/server/mutators/mutator/gamemode_keyhunt.qc
qcsrc/server/mutators/mutator/gamemode_race.qc

index f477638..93afb72 100644 (file)
@@ -110,13 +110,13 @@ const int HAVOCBOT_ONS_ROLE_OFFENSE       = 8;
 .int havocbot_role_flags;
 .float havocbot_attack_time;
 
-void havocbot_role_ons_defense();
-void havocbot_role_ons_offense();
-void havocbot_role_ons_assistant();
+void havocbot_role_ons_defense(entity this);
+void havocbot_role_ons_offense(entity this);
+void havocbot_role_ons_assistant(entity this);
 
-void havocbot_ons_reset_role(entity bot);
-void havocbot_goalrating_items(float ratingscale, vector org, float sradius);
-void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradius);
+void havocbot_ons_reset_role(entity this);
+void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius);
+void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius);
 
 // score rule declarations
 const int ST_ONS_CAPS = 1;
@@ -1304,20 +1304,20 @@ void Onslaught_RoundStart()
 
 // NOTE: LEGACY CODE, needs to be re-written!
 
-void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float sradius)
-{SELFPARAM();
+void havocbot_goalrating_ons_offenseitems(entity this, float ratingscale, vector org, float sradius)
+{
        entity head;
        float t, c;
        bool needarmor = false, needweapons = false;
 
        // Needs armor/health?
-       if(self.health<100)
+       if(this.health<100)
                needarmor = true;
 
        // Needs weapons?
        c = 0;
        FOREACH(Weapons, it != WEP_Null, {
-               if(self.weapons & (it.m_wepset))
+               if(this.weapons & (it.m_wepset))
                if(++c >= 4)
                        break;
        });
@@ -1328,8 +1328,8 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
        if(!needweapons && !needarmor)
                return;
 
-       LOG_DEBUG(strcat(self.netname, " needs weapons ", ftos(needweapons) , "\n"));
-       LOG_DEBUG(strcat(self.netname, " needs armor ", ftos(needarmor) , "\n"));
+       LOG_DEBUG(strcat(this.netname, " needs weapons ", ftos(needweapons) , "\n"));
+       LOG_DEBUG(strcat(this.netname, " needs armor ", ftos(needarmor) , "\n"));
 
        // See what is around
        head = findchainfloat(bot_pickup, true);
@@ -1340,43 +1340,43 @@ void havocbot_goalrating_ons_offenseitems(float ratingscale, vector org, float s
                if ( ((head.health || head.armorvalue) && needarmor) || (head.weapons && needweapons ) )
                if (vlen(head.origin - org) < sradius)
                {
-                       t = head.bot_pickupevalfunc(self, head);
+                       t = head.bot_pickupevalfunc(this, head);
                        if (t > 0)
-                               navigation_routerating(head, t * ratingscale, 500);
+                               navigation_routerating(this, head, t * ratingscale, 500);
                }
                head = head.chain;
        }
 }
 
-void havocbot_role_ons_setrole(entity bot, int role)
+void havocbot_role_ons_setrole(entity this, int role)
 {
-       LOG_DEBUG(strcat(bot.netname," switched to "));
+       LOG_DEBUG(strcat(this.netname," switched to "));
        switch(role)
        {
                case HAVOCBOT_ONS_ROLE_DEFENSE:
                        LOG_DEBUG("defense");
-                       bot.havocbot_role = havocbot_role_ons_defense;
-                       bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_DEFENSE;
-                       bot.havocbot_role_timeout = 0;
+                       this.havocbot_role = havocbot_role_ons_defense;
+                       this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_DEFENSE;
+                       this.havocbot_role_timeout = 0;
                        break;
                case HAVOCBOT_ONS_ROLE_ASSISTANT:
                        LOG_DEBUG("assistant");
-                       bot.havocbot_role = havocbot_role_ons_assistant;
-                       bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_ASSISTANT;
-                       bot.havocbot_role_timeout = 0;
+                       this.havocbot_role = havocbot_role_ons_assistant;
+                       this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_ASSISTANT;
+                       this.havocbot_role_timeout = 0;
                        break;
                case HAVOCBOT_ONS_ROLE_OFFENSE:
                        LOG_DEBUG("offense");
-                       bot.havocbot_role = havocbot_role_ons_offense;
-                       bot.havocbot_role_flags = HAVOCBOT_ONS_ROLE_OFFENSE;
-                       bot.havocbot_role_timeout = 0;
+                       this.havocbot_role = havocbot_role_ons_offense;
+                       this.havocbot_role_flags = HAVOCBOT_ONS_ROLE_OFFENSE;
+                       this.havocbot_role_timeout = 0;
                        break;
        }
        LOG_DEBUG("\n");
 }
 
-void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ons_controlpoints_attack(entity this, float ratingscale)
+{
        entity cp, cp1, cp2, best, wp;
        float radius, bestvalue;
        int c;
@@ -1392,13 +1392,13 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                        continue;
 
                // Ignore owned controlpoints
-               if(!(cp2.isgenneighbor[self.team] || cp2.iscpneighbor[self.team]))
+               if(!(cp2.isgenneighbor[this.team] || cp2.iscpneighbor[this.team]))
                        continue;
 
                // Count team mates interested in this control point
                // (easier and cleaner than keeping counters per cp and teams)
                FOREACH_CLIENT(IS_PLAYER(it), {
-                       if(SAME_TEAM(it, self))
+                       if(SAME_TEAM(it, this))
                        if(it.havocbot_role_flags & HAVOCBOT_ONS_ROLE_OFFENSE)
                        if(it.havocbot_ons_target == cp2)
                                ++c;
@@ -1421,14 +1421,14 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                {
                        bestvalue = cp1.wpcost;
                        cp = cp1;
-                       self.havocbot_ons_target = cp1;
+                       this.havocbot_ons_target = cp1;
                }
        }
 
        if (!cp)
                return;
 
-       LOG_DEBUG(strcat(self.netname, " chose cp ranked ", ftos(bestvalue), "\n"));
+       LOG_DEBUG(strcat(this.netname, " chose cp ranked ", ftos(bestvalue), "\n"));
 
        if(cp.goalentity)
        {
@@ -1457,24 +1457,24 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
 
                if(best)
                {
-                       navigation_routerating(best, ratingscale, 10000);
+                       navigation_routerating(this, best, ratingscale, 10000);
                        best.cnt += 1;
 
-                       self.havocbot_attack_time = 0;
-                       if(checkpvs(self.view_ofs,cp))
-                       if(checkpvs(self.view_ofs,best))
-                               self.havocbot_attack_time = time + 2;
+                       this.havocbot_attack_time = 0;
+                       if(checkpvs(this.view_ofs,cp))
+                       if(checkpvs(this.view_ofs,best))
+                               this.havocbot_attack_time = time + 2;
                }
                else
                {
-                       navigation_routerating(cp, ratingscale, 10000);
+                       navigation_routerating(this, cp, ratingscale, 10000);
                }
-               LOG_DEBUG(strcat(self.netname, " found an attackable controlpoint at ", vtos(cp.origin) ,"\n"));
+               LOG_DEBUG(strcat(this.netname, " found an attackable controlpoint at ", vtos(cp.origin) ,"\n"));
        }
        else
        {
                // Should be touched
-               LOG_DEBUG(strcat(self.netname, " found a touchable controlpoint at ", vtos(cp.origin) ,"\n"));
+               LOG_DEBUG(strcat(this.netname, " found a touchable controlpoint at ", vtos(cp.origin) ,"\n"));
                found = false;
 
                // Look for auto generated waypoint
@@ -1483,26 +1483,26 @@ void havocbot_goalrating_ons_controlpoints_attack(float ratingscale)
                {
                        if(wp.classname=="waypoint")
                        {
-                               navigation_routerating(wp, ratingscale, 10000);
+                               navigation_routerating(this, wp, ratingscale, 10000);
                                found = true;
                        }
                }
 
                // Nothing found, rate the controlpoint itself
                if (!found)
-                       navigation_routerating(cp, ratingscale, 10000);
+                       navigation_routerating(this, cp, ratingscale, 10000);
        }
 }
 
-bool havocbot_goalrating_ons_generator_attack(float ratingscale)
-{SELFPARAM();
+bool havocbot_goalrating_ons_generator_attack(entity this, float ratingscale)
+{
        entity g, wp, bestwp;
        bool found;
        int best;
 
        for(g = ons_worldgeneratorlist; g; g = g.ons_worldgeneratornext)
        {
-               if(SAME_TEAM(g, self) || g.isshielded)
+               if(SAME_TEAM(g, this) || g.isshielded)
                        continue;
 
                // Should be attacked
@@ -1528,13 +1528,13 @@ bool havocbot_goalrating_ons_generator_attack(float ratingscale)
                if(bestwp)
                {
                        LOG_DEBUG("waypoints found around generator\n");
-                       navigation_routerating(bestwp, ratingscale, 10000);
+                       navigation_routerating(this, bestwp, ratingscale, 10000);
                        bestwp.cnt += 1;
 
-                       self.havocbot_attack_time = 0;
-                       if(checkpvs(self.view_ofs,g))
-                       if(checkpvs(self.view_ofs,bestwp))
-                               self.havocbot_attack_time = time + 5;
+                       this.havocbot_attack_time = 0;
+                       if(checkpvs(this.view_ofs,g))
+                       if(checkpvs(this.view_ofs,bestwp))
+                               this.havocbot_attack_time = time + 5;
 
                        return true;
                }
@@ -1542,69 +1542,69 @@ bool havocbot_goalrating_ons_generator_attack(float ratingscale)
                {
                        LOG_DEBUG("generator found without waypoints around\n");
                        // if there aren't waypoints near the generator go straight to it
-                       navigation_routerating(g, ratingscale, 10000);
-                       self.havocbot_attack_time = 0;
+                       navigation_routerating(this, g, ratingscale, 10000);
+                       this.havocbot_attack_time = 0;
                        return true;
                }
        }
        return false;
 }
 
-void havocbot_role_ons_offense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ons_offense(entity this)
+{
+       if(IS_DEAD(this))
        {
-               self.havocbot_attack_time = 0;
-               havocbot_ons_reset_role(self);
+               this.havocbot_attack_time = 0;
+               havocbot_ons_reset_role(this);
                return;
        }
 
        // Set the role timeout if necessary
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 120;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 120;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ons_reset_role(self);
+               havocbot_ons_reset_role(this);
                return;
        }
 
-       if(self.havocbot_attack_time>time)
+       if(this.havocbot_attack_time>time)
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               navigation_goalrating_start();
-               havocbot_goalrating_enemyplayers(20000, self.origin, 650);
-               if(!havocbot_goalrating_ons_generator_attack(20000))
-                       havocbot_goalrating_ons_controlpoints_attack(20000);
-               havocbot_goalrating_ons_offenseitems(10000, self.origin, 10000);
-               navigation_goalrating_end();
+               navigation_goalrating_start(this);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
+               if(!havocbot_goalrating_ons_generator_attack(this, 20000))
+                       havocbot_goalrating_ons_controlpoints_attack(this, 20000);
+               havocbot_goalrating_ons_offenseitems(this, 10000, this.origin, 10000);
+               navigation_goalrating_end(this);
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
        }
 }
 
-void havocbot_role_ons_assistant()
-{SELFPARAM();
-       havocbot_ons_reset_role(self);
+void havocbot_role_ons_assistant(entity this)
+{
+       havocbot_ons_reset_role(this);
 }
 
-void havocbot_role_ons_defense()
-{SELFPARAM();
-       havocbot_ons_reset_role(self);
+void havocbot_role_ons_defense(entity this)
+{
+       havocbot_ons_reset_role(this);
 }
 
-void havocbot_ons_reset_role(entity bot)
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_ons_reset_role(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       bot.havocbot_ons_target = world;
+       this.havocbot_ons_target = world;
 
        // TODO: Defend control points or generator if necessary
 
-       havocbot_role_ons_setrole(bot, HAVOCBOT_ONS_ROLE_OFFENSE);
+       havocbot_role_ons_setrole(this, HAVOCBOT_ONS_ROLE_OFFENSE);
 }
 
 
index 5e8dc36..ee2bfc5 100644 (file)
@@ -35,7 +35,7 @@ void havocbot_ai(entity this)
                else
                {
                        if (!this.jumppadcount)
-                               WITH(entity, self, this, this.havocbot_role()); // little too far down the rabbit hole
+                               this.havocbot_role(this); // little too far down the rabbit hole
                }
 
                // TODO: tracewalk() should take care of this job (better path finding under water)
@@ -1126,14 +1126,14 @@ void havocbot_aim(entity this)
                lag_additem(this, time + this.ping, 0, 0, world, this.origin, selfvel, ( this.goalcurrent.absmin + this.goalcurrent.absmax ) * 0.5, '0 0 0');
 }
 
-float havocbot_moveto_refresh_route(entity this)
+bool havocbot_moveto_refresh_route(entity this)
 {
        // Refresh path to goal if necessary
        entity wp;
        wp = this.havocbot_personal_waypoint;
-       WITH(entity, self, this, navigation_goalrating_start());
-       WITH(entity, self, this, navigation_routerating(wp, 10000, 10000));
-       WITH(entity, self, this, navigation_goalrating_end());
+       navigation_goalrating_start(this);
+       navigation_routerating(this, wp, 10000, 10000);
+       navigation_goalrating_end(this);
        return this.navigation_hasgoals;
 }
 
@@ -1265,7 +1265,7 @@ void havocbot_setupbot(entity this)
        this.cmd_moveto = havocbot_moveto;
        this.cmd_resetgoal = havocbot_resetgoal;
 
-       WITH(entity, self, this, havocbot_chooserole());
+       havocbot_chooserole(this);
 }
 
 vector havocbot_dodge()
index 8beb687..36b4c33 100644 (file)
@@ -37,7 +37,7 @@ void havocbot_ai(entity this);
 void havocbot_aim(entity this);
 void havocbot_setupbot(entity this);
 void havocbot_movetogoal(entity this);
-void havocbot_chooserole();
+void havocbot_chooserole(entity this);
 void havocbot_chooseenemy(entity this);
 void havocbot_chooseweapon(entity this);
 void havocbot_bunnyhop(entity this, vector dir);
@@ -49,11 +49,11 @@ float havocbot_moveto_refresh_route(entity this);
 
 vector havocbot_dodge();
 
-.void() havocbot_role;
-.void() havocbot_previous_role;
+.void(entity this) havocbot_role;
+.void(entity this) havocbot_previous_role;
 
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
+void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
+void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
 
 /*
  * Imports
index a4c7699..2a354d9 100644 (file)
@@ -8,11 +8,11 @@
 .float max_armorvalue;
 .float havocbot_role_timeout;
 
-.void() havocbot_previous_role;
-.void() havocbot_role;
+.void(entity this) havocbot_previous_role;
+.void(entity this) havocbot_role;
 
-void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
-{SELFPARAM();
+void havocbot_goalrating_items(entity this, float ratingscale, vector org, float sradius)
+{
        entity head;
        float rating, d, discard, distance, friend_distance, enemy_distance;
        vector o;
@@ -26,7 +26,7 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
                friend_distance = 10000; enemy_distance = 10000;
                rating = 0;
 
-               if(!head.solid || distance > sradius || (head == self.ignoregoal && time < self.ignoregoaltime) )
+               if(!head.solid || distance > sradius || (head == this.ignoregoal && time < this.ignoregoaltime) )
                {
                        head = head.chain;
                        continue;
@@ -64,10 +64,10 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
                {
                        discard = false;
 
-                       FOREACH_CLIENT(IS_PLAYER(it) && it != self && !IS_DEAD(it), LAMBDA(
+                       FOREACH_CLIENT(IS_PLAYER(it) && it != this && !IS_DEAD(it), LAMBDA(
                                d = vlen(it.origin - o); // distance between player and item
 
-                               if ( it.team == self.team )
+                               if ( it.team == this.team )
                                {
                                        if ( !IS_REAL_CLIENT(it) || discard )
                                                continue;
@@ -79,29 +79,29 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
 
                                        discard = true;
 
-                                       if( head.health && it.health > self.health )
+                                       if( head.health && it.health > this.health )
                                                continue;
 
-                                       if( head.armorvalue && it.armorvalue > self.armorvalue)
+                                       if( head.armorvalue && it.armorvalue > this.armorvalue)
                                                continue;
 
                                        if( head.weapons )
                                        if( head.weapons & ~it.weapons )
                                                continue;
 
-                                       if (head.ammo_shells && it.ammo_shells > self.ammo_shells)
+                                       if (head.ammo_shells && it.ammo_shells > this.ammo_shells)
                                                continue;
 
-                                       if (head.ammo_nails && it.ammo_nails > self.ammo_nails)
+                                       if (head.ammo_nails && it.ammo_nails > this.ammo_nails)
                                                continue;
 
-                                       if (head.ammo_rockets && it.ammo_rockets > self.ammo_rockets)
+                                       if (head.ammo_rockets && it.ammo_rockets > this.ammo_rockets)
                                                continue;
 
-                                       if (head.ammo_cells && it.ammo_cells > self.ammo_cells)
+                                       if (head.ammo_cells && it.ammo_cells > this.ammo_cells)
                                                continue;
 
-                                       if (head.ammo_plasma && it.ammo_plasma > self.ammo_plasma)
+                                       if (head.ammo_plasma && it.ammo_plasma > this.ammo_plasma)
                                                continue;
 
                                        discard = false;
@@ -118,56 +118,56 @@ void havocbot_goalrating_items(float ratingscale, vector org, float sradius)
                        // Rate the item only if no one needs it, or if an enemy is closer to it
                        if ( (enemy_distance < friend_distance && distance < enemy_distance) ||
                                (friend_distance > autocvar_bot_ai_friends_aware_pickup_radius ) || !discard )
-                               rating = head.bot_pickupevalfunc(self, head);
+                               rating = head.bot_pickupevalfunc(this, head);
 
                }
                else
-                       rating = head.bot_pickupevalfunc(self, head);
+                       rating = head.bot_pickupevalfunc(this, head);
 
                if(rating > 0)
-                       navigation_routerating(head, rating * ratingscale, 2000);
+                       navigation_routerating(this, head, rating * ratingscale, 2000);
                head = head.chain;
        }
 }
 
-void havocbot_goalrating_controlpoints(float ratingscale, vector org, float sradius)
-{SELFPARAM();
+void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius)
+{
        entity head;
        head = findchain(classname, "dom_controlpoint");
        while (head)
        {
-               if (vlen(( ( head.absmin + head.absmax ) * 0.5 ) - org) < sradius)
+               if(vdist((((head.absmin + head.absmax) * 0.5) - org), <, sradius))
                {
                        if(head.cnt > -1) // this is just being fought for
-                               navigation_routerating(head, ratingscale, 5000);
+                               navigation_routerating(this, head, ratingscale, 5000);
                        else if(head.goalentity.cnt == 0) // unclaimed point
-                               navigation_routerating(head, ratingscale * 0.5, 5000);
-                       else if(head.goalentity.team != self.team) // other team's point
-                               navigation_routerating(head, ratingscale * 0.2, 5000);
+                               navigation_routerating(this, head, ratingscale * 0.5, 5000);
+                       else if(head.goalentity.team != this.team) // other team's point
+                               navigation_routerating(this, head, ratingscale * 0.2, 5000);
                }
                head = head.chain;
        }
 }
 
-void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradius)
-{SELFPARAM();
+void havocbot_goalrating_enemyplayers(entity this, float ratingscale, vector org, float sradius)
+{
        if (autocvar_bot_nofire)
                return;
 
        // don't chase players if we're under water
-       if(self.waterlevel>WATERLEVEL_WETFEET)
+       if(this.waterlevel>WATERLEVEL_WETFEET)
                return;
 
        int t;
 
-       FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(self, it), LAMBDA(
+       FOREACH_CLIENT(IS_PLAYER(it) && bot_shouldattack(this, it), LAMBDA(
                // TODO: Merge this logic with the bot_shouldattack function
                if(vdist(it.origin - org, <, 100) || vdist(it.origin - org, >, sradius))
                        continue;
 
                // rate only visible enemies
                /*
-               traceline(self.origin + self.view_ofs, it.origin, MOVE_NOMONSTERS, self);
+               traceline(this.origin + this.view_ofs, it.origin, MOVE_NOMONSTERS, this);
                if (trace_fraction < 1 || trace_ent != it)
                        continue;
                */
@@ -187,42 +187,42 @@ void havocbot_goalrating_enemyplayers(float ratingscale, vector org, float sradi
                                continue;
                }
 
-               // TODO: rate waypoints near the targetted player at that moment, instead of the player itself
+               // TODO: rate waypoints near the targetted player at that moment, instead of the player itthis
                //               adding a player as a goal seems to be quite dangerous, especially on space maps
                //               remove hack in navigation_poptouchedgoals() after performing this change
 
-               t = (self.health + self.armorvalue ) / (it.health + it.armorvalue );
-               navigation_routerating(it, t * ratingscale, 2000);
+               t = (this.health + this.armorvalue ) / (it.health + it.armorvalue );
+               navigation_routerating(this, it, t * ratingscale, 2000);
        ));
 }
 
 // legacy bot role for standard gamemodes
 // go to best items
-void havocbot_role_generic()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_generic(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               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_waypoints(1, self.origin, 1000);
-               navigation_goalrating_end();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
+               havocbot_goalrating_items(this, 10000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_chooserole_generic()
-{SELFPARAM();
-       self.havocbot_role = havocbot_role_generic;
+void havocbot_chooserole_generic(entity this)
+{
+       this.havocbot_role = havocbot_role_generic;
 }
 
-void havocbot_chooserole()
-{SELFPARAM();
+void havocbot_chooserole(entity this)
+{
        LOG_TRACE("choosing a role...\n");
-       self.bot_strategytime = 0;
-       if(!MUTATOR_CALLHOOK(HavocBot_ChooseRole, self))
-               havocbot_chooserole_generic();
+       this.bot_strategytime = 0;
+       if(!MUTATOR_CALLHOOK(HavocBot_ChooseRole, this))
+               havocbot_chooserole_generic(this);
 }
index 6120ce0..5b1f2b5 100644 (file)
@@ -1,2 +1,2 @@
 #pragma once
-void havocbot_goalrating_controlpoints(float ratingscale, vector org, float sradius);
+void havocbot_goalrating_controlpoints(entity this, float ratingscale, vector org, float sradius);
index ab74732..beccf1b 100644 (file)
@@ -513,8 +513,8 @@ void navigation_markroutes_checkwaypoint(entity w, entity wp, float cost2, vecto
 }
 
 // queries the entire spawnfunc_waypoint network for pathes leading away from the bot
-void navigation_markroutes(entity fixed_source_waypoint)
-{SELFPARAM();
+void navigation_markroutes(entity this, entity fixed_source_waypoint)
+{
        entity w, wp, waylist;
        float searching, cost, cost2;
        vector p;
@@ -542,7 +542,7 @@ void navigation_markroutes(entity fixed_source_waypoint)
                // try a short range search for the nearest waypoints, and expand the search repeatedly if none are found
                // as this search is expensive we will use lower values if the bot is on the air
                float i, increment, maxdistance;
-               if(IS_ONGROUND(self))
+               if(IS_ONGROUND(this))
                {
                        increment = 750;
                        maxdistance = 50000;
@@ -672,8 +672,8 @@ void navigation_markroutes_inverted(entity fixed_source_waypoint)
 }
 
 // updates the best goal according to a weighted calculation of travel cost and item value of a new proposed item
-void navigation_routerating(entity e, float f, float rangebias)
-{SELFPARAM();
+void navigation_routerating(entity this, entity e, float f, float rangebias)
+{
        entity nwp;
        vector o;
        if (!e)
@@ -688,16 +688,16 @@ void navigation_routerating(entity e, float f, float rangebias)
 
        // Evaluate path using jetpack
        if(g_jetpack)
-       if(self.items & IT_JETPACK)
+       if(this.items & IT_JETPACK)
        if(autocvar_bot_ai_navigation_jetpack)
-       if(vlen(self.origin - o) > autocvar_bot_ai_navigation_jetpack_mindistance)
+       if(vlen(this.origin - o) > autocvar_bot_ai_navigation_jetpack_mindistance)
        {
                vector pointa, pointb;
 
                LOG_DEBUG("jetpack ai: evaluating path for ", e.classname, "\n");
 
                // Point A
-               traceline(self.origin, self.origin + '0 0 65535', MOVE_NORMAL, self);
+               traceline(this.origin, this.origin + '0 0 65535', MOVE_NORMAL, this);
                pointa = trace_endpos - '0 0 1';
 
                // Point B
@@ -705,7 +705,7 @@ void navigation_routerating(entity e, float f, float rangebias)
                pointb = trace_endpos - '0 0 1';
 
                // Can I see these two points from the sky?
-               traceline(pointa, pointb, MOVE_NORMAL, self);
+               traceline(pointa, pointb, MOVE_NORMAL, this);
 
                if(trace_fraction==1)
                {
@@ -721,13 +721,13 @@ void navigation_routerating(entity e, float f, float rangebias)
                                npa = pointa + down;
                                npb = pointb + down;
 
-                               if(npa.z<=self.absmax.z)
+                               if(npa.z<=this.absmax.z)
                                        break;
 
                                if(npb.z<=e.absmax.z)
                                        break;
 
-                               traceline(npa, npb, MOVE_NORMAL, self);
+                               traceline(npa, npb, MOVE_NORMAL, this);
                                if(trace_fraction==1)
                                {
                                        pointa = npa;
@@ -740,16 +740,16 @@ void navigation_routerating(entity e, float f, float rangebias)
                        // Rough estimation of fuel consumption
                        // (ignores acceleration and current xyz velocity)
                        xydistance = vlen(pointa - pointb);
-                       zdistance = fabs(pointa.z - self.origin.z);
+                       zdistance = fabs(pointa.z - this.origin.z);
 
                        t = zdistance / autocvar_g_jetpack_maxspeed_up;
                        t += xydistance / autocvar_g_jetpack_maxspeed_side;
                        fuel = t * autocvar_g_jetpack_fuel * 0.8;
 
-                       LOG_DEBUG(strcat("jetpack ai: required fuel ", ftos(fuel), " self.ammo_fuel ", ftos(self.ammo_fuel), "\n"));
+                       LOG_DEBUG(strcat("jetpack ai: required fuel ", ftos(fuel), " this.ammo_fuel ", ftos(this.ammo_fuel), "\n"));
 
                        // enough fuel ?
-                       if(self.ammo_fuel>fuel)
+                       if(this.ammo_fuel>fuel)
                        {
                                // Estimate cost
                                // (as onground costs calculation is mostly based on distances, here we do the same establishing some relationship
@@ -767,8 +767,8 @@ void navigation_routerating(entity e, float f, float rangebias)
                                        LOG_DEBUG(strcat("jetpack path: added goal ", e.classname, " (with rating ", ftos(f), ")\n"));
                                        navigation_bestrating = f;
                                        navigation_bestgoal = e;
-                                       self.navigation_jetpack_goal = e;
-                                       self.navigation_jetpack_point = pointb;
+                                       this.navigation_jetpack_goal = e;
+                                       this.navigation_jetpack_point = pointb;
                                }
                                return;
                        }
@@ -986,39 +986,39 @@ void navigation_poptouchedgoals()
 }
 
 // begin a goal selection session (queries spawnfunc_waypoint network)
-void navigation_goalrating_start()
-{SELFPARAM();
-       if(self.aistatus & AI_STATUS_STUCK)
+void navigation_goalrating_start(entity this)
+{
+       if(this.aistatus & AI_STATUS_STUCK)
                return;
 
-       self.navigation_jetpack_goal = world;
+       this.navigation_jetpack_goal = world;
        navigation_bestrating = -1;
-       self.navigation_hasgoals = false;
-       navigation_clearroute(self);
+       this.navigation_hasgoals = false;
+       navigation_clearroute(this);
        navigation_bestgoal = world;
-       navigation_markroutes(world);
+       navigation_markroutes(this, world);
 }
 
 // ends a goal selection session (updates goal stack to the best goal)
-void navigation_goalrating_end()
-{SELFPARAM();
-       if(self.aistatus & AI_STATUS_STUCK)
+void navigation_goalrating_end(entity this)
+{
+       if(this.aistatus & AI_STATUS_STUCK)
                return;
 
-       navigation_routetogoal(self, navigation_bestgoal, self.origin);
-       LOG_DEBUG(strcat("best goal ", self.goalcurrent.classname , "\n"));
+       navigation_routetogoal(this, navigation_bestgoal, this.origin);
+       LOG_DEBUG(strcat("best goal ", this.goalcurrent.classname , "\n"));
 
        // If the bot got stuck then try to reach the farthest waypoint
-       if (!self.navigation_hasgoals)
+       if (!this.navigation_hasgoals)
        if (autocvar_bot_wander_enable)
        {
-               if (!(self.aistatus & AI_STATUS_STUCK))
+               if (!(this.aistatus & AI_STATUS_STUCK))
                {
-                       LOG_DEBUG(strcat(self.netname, " cannot walk to any goal\n"));
-                       self.aistatus |= AI_STATUS_STUCK;
+                       LOG_DEBUG(strcat(this.netname, " cannot walk to any goal\n"));
+                       this.aistatus |= AI_STATUS_STUCK;
                }
 
-               self.navigation_hasgoals = false; // Reset this value
+               this.navigation_hasgoals = false; // Reset this value
        }
 }
 
index e3da4bb..584a012 100644 (file)
@@ -64,12 +64,12 @@ void navigation_clearroute(entity this);
 void navigation_pushroute(entity this, entity e);
 void navigation_poproute();
 void navigation_markroutes_checkwaypoint(entity w, entity wp, float cost2, vector p);
-void navigation_markroutes(entity fixed_source_waypoint);
+void navigation_markroutes(entity this, entity fixed_source_waypoint);
 void navigation_markroutes_inverted(entity fixed_source_waypoint);
-void navigation_routerating(entity e, float f, float rangebias);
+void navigation_routerating(entity this, entity e, float f, float rangebias);
 void navigation_poptouchedgoals();
-void navigation_goalrating_start();
-void navigation_goalrating_end();
+void navigation_goalrating_start(entity this);
+void navigation_goalrating_end(entity this);
 void navigation_unstuck(entity this);
 
 void botframe_updatedangerousobjects(float maxupdate);
index bfd2489..1477952 100644 (file)
@@ -518,7 +518,7 @@ IMPULSE(navwaypoint_unreachable)
                e.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
        }
        entity e2 = navigation_findnearestwaypoint(this, false);
-       navigation_markroutes(e2);
+       navigation_markroutes(this, e2);
 
        int i, m;
 
index 9baa24a..ae5166c 100644 (file)
@@ -45,17 +45,17 @@ const int HAVOCBOT_AST_ROLE_OFFENSE = 4;
 .int havocbot_role_flags;
 .float havocbot_attack_time;
 
-.void() havocbot_role;
-.void() havocbot_previous_role;
+.void(entity this) havocbot_role;
+.void(entity this) havocbot_previous_role;
 
-void() havocbot_role_ast_defense;
-void() havocbot_role_ast_offense;
+void(entity this) havocbot_role_ast_defense;
+void(entity this) havocbot_role_ast_offense;
 .entity havocbot_ast_target;
 
 void(entity bot) havocbot_ast_reset_role;
 
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_items;
-void(float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
+void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_items;
+void(entity this, float ratingscale, vector org, float sradius) havocbot_goalrating_enemyplayers;
 
 // scoreboard stuff
 const float ST_ASSAULT_OBJECTIVES = 1;
@@ -438,8 +438,8 @@ spawnfunc(target_assault_roundstart)
 }
 
 // legacy bot code
-void havocbot_goalrating_ast_targets(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ast_targets(entity this, float ratingscale)
+{
        entity ad, best, wp, tod;
        float radius, found, bestvalue;
        vector p;
@@ -509,115 +509,115 @@ void havocbot_goalrating_ast_targets(float ratingscale)
                //      te_lightning2(world, '0 0 0', best.origin);
                //      te_knightspike(best.origin);
 
-                       navigation_routerating(best, ratingscale, 4000);
+                       navigation_routerating(this, best, ratingscale, 4000);
                        best.cnt += 1;
 
-                       self.havocbot_attack_time = 0;
+                       this.havocbot_attack_time = 0;
 
-                       if(checkpvs(self.view_ofs,ad))
-                       if(checkpvs(self.view_ofs,best))
+                       if(checkpvs(this.view_ofs,ad))
+                       if(checkpvs(this.view_ofs,best))
                        {
                        //      dprint("increasing attack time for this target\n");
-                               self.havocbot_attack_time = time + 2;
+                               this.havocbot_attack_time = time + 2;
                        }
                }
        }
 }
 
-void havocbot_role_ast_offense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ast_offense(entity this)
+{
+       if(IS_DEAD(this))
        {
-               self.havocbot_attack_time = 0;
-               havocbot_ast_reset_role(self);
+               this.havocbot_attack_time = 0;
+               havocbot_ast_reset_role(this);
                return;
        }
 
        // Set the role timeout if necessary
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 120;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 120;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ast_reset_role(self);
+               havocbot_ast_reset_role(this);
                return;
        }
 
-       if(self.havocbot_attack_time>time)
+       if(this.havocbot_attack_time>time)
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               navigation_goalrating_start();
-               havocbot_goalrating_enemyplayers(20000, self.origin, 650);
-               havocbot_goalrating_ast_targets(20000);
-               havocbot_goalrating_items(15000, self.origin, 10000);
-               navigation_goalrating_end();
+               navigation_goalrating_start(this);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 650);
+               havocbot_goalrating_ast_targets(this, 20000);
+               havocbot_goalrating_items(this, 15000, this.origin, 10000);
+               navigation_goalrating_end(this);
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
        }
 }
 
-void havocbot_role_ast_defense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ast_defense(entity this)
+{
+       if(IS_DEAD(this))
        {
-               self.havocbot_attack_time = 0;
-               havocbot_ast_reset_role(self);
+               this.havocbot_attack_time = 0;
+               havocbot_ast_reset_role(this);
                return;
        }
 
        // Set the role timeout if necessary
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 120;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 120;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ast_reset_role(self);
+               havocbot_ast_reset_role(this);
                return;
        }
 
-       if(self.havocbot_attack_time>time)
+       if(this.havocbot_attack_time>time)
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               navigation_goalrating_start();
-               havocbot_goalrating_enemyplayers(20000, self.origin, 3000);
-               havocbot_goalrating_ast_targets(20000);
-               havocbot_goalrating_items(15000, self.origin, 10000);
-               navigation_goalrating_end();
+               navigation_goalrating_start(this);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 3000);
+               havocbot_goalrating_ast_targets(this, 20000);
+               havocbot_goalrating_items(this, 15000, this.origin, 10000);
+               navigation_goalrating_end(this);
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
        }
 }
 
-void havocbot_role_ast_setrole(entity bot, float role)
+void havocbot_role_ast_setrole(entity this, float role)
 {
        switch(role)
        {
                case HAVOCBOT_AST_ROLE_DEFENSE:
-                       bot.havocbot_role = havocbot_role_ast_defense;
-                       bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
-                       bot.havocbot_role_timeout = 0;
+                       this.havocbot_role = havocbot_role_ast_defense;
+                       this.havocbot_role_flags = HAVOCBOT_AST_ROLE_DEFENSE;
+                       this.havocbot_role_timeout = 0;
                        break;
                case HAVOCBOT_AST_ROLE_OFFENSE:
-                       bot.havocbot_role = havocbot_role_ast_offense;
-                       bot.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
-                       bot.havocbot_role_timeout = 0;
+                       this.havocbot_role = havocbot_role_ast_offense;
+                       this.havocbot_role_flags = HAVOCBOT_AST_ROLE_OFFENSE;
+                       this.havocbot_role_timeout = 0;
                        break;
        }
 }
 
-void havocbot_ast_reset_role(entity bot)
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_ast_reset_role(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if(bot.team == assault_attacker_team)
-               havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_OFFENSE);
+       if(this.team == assault_attacker_team)
+               havocbot_role_ast_setrole(this, HAVOCBOT_AST_ROLE_OFFENSE);
        else
-               havocbot_role_ast_setrole(bot, HAVOCBOT_AST_ROLE_DEFENSE);
+               havocbot_role_ast_setrole(this, HAVOCBOT_AST_ROLE_DEFENSE);
 }
 
 // mutator hooks
index a29e3d5..ba1e7a8 100644 (file)
@@ -1381,95 +1381,95 @@ int havocbot_ctf_teamcount(entity bot, vector org, float tc_radius)
        return c;
 }
 
-void havocbot_goalrating_ctf_ourflag(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ctf_ourflag(entity this, float ratingscale)
+{
        entity head;
        head = ctf_worldflaglist;
        while (head)
        {
-               if (CTF_SAMETEAM(self, head))
+               if (CTF_SAMETEAM(this, head))
                        break;
                head = head.ctf_worldflagnext;
        }
        if (head)
-               navigation_routerating(head, ratingscale, 10000);
+               navigation_routerating(this, head, ratingscale, 10000);
 }
 
-void havocbot_goalrating_ctf_ourbase(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ctf_ourbase(entity this, float ratingscale)
+{
        entity head;
        head = ctf_worldflaglist;
        while (head)
        {
-               if (CTF_SAMETEAM(self, head))
+               if (CTF_SAMETEAM(this, head))
                        break;
                head = head.ctf_worldflagnext;
        }
        if (!head)
                return;
 
-       navigation_routerating(head.bot_basewaypoint, ratingscale, 10000);
+       navigation_routerating(this, head.bot_basewaypoint, ratingscale, 10000);
 }
 
-void havocbot_goalrating_ctf_enemyflag(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ctf_enemyflag(entity this, float ratingscale)
+{
        entity head;
        head = ctf_worldflaglist;
        while (head)
        {
                if(ctf_oneflag)
                {
-                       if(CTF_DIFFTEAM(self, head))
+                       if(CTF_DIFFTEAM(this, head))
                        {
                                if(head.team)
                                {
-                                       if(self.flagcarried)
+                                       if(this.flagcarried)
                                                break;
                                }
-                               else if(!self.flagcarried)
+                               else if(!this.flagcarried)
                                        break;
                        }
                }
-               else if(CTF_DIFFTEAM(self, head))
+               else if(CTF_DIFFTEAM(this, head))
                        break;
                head = head.ctf_worldflagnext;
        }
        if (head)
-               navigation_routerating(head, ratingscale, 10000);
+               navigation_routerating(this, head, ratingscale, 10000);
 }
 
-void havocbot_goalrating_ctf_enemybase(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ctf_enemybase(entity this, float ratingscale)
+{
        if (!bot_waypoints_for_items)
        {
-               havocbot_goalrating_ctf_enemyflag(ratingscale);
+               havocbot_goalrating_ctf_enemyflag(this, ratingscale);
                return;
        }
 
        entity head;
 
-       head = havocbot_ctf_find_enemy_flag(self);
+       head = havocbot_ctf_find_enemy_flag(this);
 
        if (!head)
                return;
 
-       navigation_routerating(head.bot_basewaypoint, ratingscale, 10000);
+       navigation_routerating(this, head.bot_basewaypoint, ratingscale, 10000);
 }
 
-void havocbot_goalrating_ctf_ourstolenflag(float ratingscale)
-{SELFPARAM();
+void havocbot_goalrating_ctf_ourstolenflag(entity this, float ratingscale)
+{
        entity mf;
 
-       mf = havocbot_ctf_find_flag(self);
+       mf = havocbot_ctf_find_flag(this);
 
        if(mf.ctf_status == FLAG_BASE)
                return;
 
        if(mf.tag_entity)
-               navigation_routerating(mf.tag_entity, ratingscale, 10000);
+               navigation_routerating(this, mf.tag_entity, ratingscale, 10000);
 }
 
-void havocbot_goalrating_ctf_droppedflags(float ratingscale, vector org, float df_radius)
+void havocbot_goalrating_ctf_droppedflags(entity this, float ratingscale, vector org, float df_radius)
 {
        entity head;
        head = ctf_worldflaglist;
@@ -1482,18 +1482,18 @@ void havocbot_goalrating_ctf_droppedflags(float ratingscale, vector org, float d
                        if(df_radius)
                        {
                                if(vlen(org-head.origin)<df_radius)
-                                       navigation_routerating(head, ratingscale, 10000);
+                                       navigation_routerating(self, head, ratingscale, 10000);
                        }
                        else
-                               navigation_routerating(head, ratingscale, 10000);
+                               navigation_routerating(self, head, ratingscale, 10000);
                }
 
                head = head.ctf_worldflagnext;
        }
 }
 
-void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float sradius)
-{SELFPARAM();
+void havocbot_goalrating_ctf_carrieritems(entity this, float ratingscale, vector org, float sradius)
+{
        entity head;
        float t;
        head = findchainfloat(bot_pickup, true);
@@ -1505,199 +1505,199 @@ void havocbot_goalrating_ctf_carrieritems(float ratingscale, vector org, float s
                if (vlen(head.origin - org) < sradius)
                {
                        // get the value of the item
-                       t = head.bot_pickupevalfunc(self, head) * 0.0001;
+                       t = head.bot_pickupevalfunc(this, head) * 0.0001;
                        if (t > 0)
-                               navigation_routerating(head, t * ratingscale, 500);
+                               navigation_routerating(this, head, t * ratingscale, 500);
                }
                head = head.chain;
        }
 }
 
-void havocbot_ctf_reset_role(entity bot)
+void havocbot_ctf_reset_role(entity this)
 {
        float cdefense, cmiddle, coffense;
        entity mf, ef;
        float c;
 
-       if(IS_DEAD(bot))
+       if(IS_DEAD(this))
                return;
 
-       if(vlen(havocbot_ctf_middlepoint)==0)
+       if(havocbot_ctf_middlepoint == '0 0 0')
                havocbot_calculate_middlepoint();
 
        // Check ctf flags
-       if (bot.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
-       mf = havocbot_ctf_find_flag(bot);
-       ef = havocbot_ctf_find_enemy_flag(bot);
+       mf = havocbot_ctf_find_flag(this);
+       ef = havocbot_ctf_find_enemy_flag(this);
 
        // Retrieve stolen flag
        if(mf.ctf_status!=FLAG_BASE)
        {
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_RETRIEVER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
        }
 
        // If enemy flag is taken go to the middle to intercept pursuers
        if(ef.ctf_status!=FLAG_BASE)
        {
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_MIDDLE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
                return;
        }
 
        // if there is only me on the team switch to offense
        c = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, bot), LAMBDA(++c));
+       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this), LAMBDA(++c));
 
        if(c==1)
        {
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_OFFENSE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_OFFENSE);
                return;
        }
 
        // Evaluate best position to take
        // Count mates on middle position
-       cmiddle = havocbot_ctf_teamcount(bot, havocbot_ctf_middlepoint, havocbot_ctf_middlepoint_radius * 0.5);
+       cmiddle = havocbot_ctf_teamcount(this, havocbot_ctf_middlepoint, havocbot_ctf_middlepoint_radius * 0.5);
 
        // Count mates on defense position
-       cdefense = havocbot_ctf_teamcount(bot, mf.dropped_origin, havocbot_ctf_middlepoint_radius * 0.5);
+       cdefense = havocbot_ctf_teamcount(this, mf.dropped_origin, havocbot_ctf_middlepoint_radius * 0.5);
 
        // Count mates on offense position
-       coffense = havocbot_ctf_teamcount(bot, ef.dropped_origin, havocbot_ctf_middlepoint_radius);
+       coffense = havocbot_ctf_teamcount(this, ef.dropped_origin, havocbot_ctf_middlepoint_radius);
 
        if(cdefense<=coffense)
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_DEFENSE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_DEFENSE);
        else if(coffense<=cmiddle)
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_OFFENSE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_OFFENSE);
        else
-               havocbot_role_ctf_setrole(bot, HAVOCBOT_CTF_ROLE_MIDDLE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
 }
 
-void havocbot_role_ctf_carrier()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ctf_carrier(entity this)
+{
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried == world)
+       if (this.flagcarried == world)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
 
-               navigation_goalrating_start();
+               navigation_goalrating_start(this);
                if(ctf_oneflag)
-                       havocbot_goalrating_ctf_enemybase(50000);
+                       havocbot_goalrating_ctf_enemybase(this, 50000);
                else
-                       havocbot_goalrating_ctf_ourbase(50000);
+                       havocbot_goalrating_ctf_ourbase(this, 50000);
 
-               if(self.health<100)
-                       havocbot_goalrating_ctf_carrieritems(1000, self.origin, 1000);
+               if(this.health<100)
+                       havocbot_goalrating_ctf_carrieritems(this, 1000, this.origin, 1000);
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
 
-               if (self.navigation_hasgoals)
-                       self.havocbot_cantfindflag = time + 10;
-               else if (time > self.havocbot_cantfindflag)
+               if (this.navigation_hasgoals)
+                       this.havocbot_cantfindflag = time + 10;
+               else if (time > this.havocbot_cantfindflag)
                {
                        // Can't navigate to my own base, suicide!
                        // TODO: drop it and wander around
-                       Damage(self, self, self, 100000, DEATH_KILL.m_id, self.origin, '0 0 0');
+                       Damage(this, this, this, 100000, DEATH_KILL.m_id, this.origin, '0 0 0');
                        return;
                }
        }
 }
 
-void havocbot_role_ctf_escort()
-{SELFPARAM();
+void havocbot_role_ctf_escort(entity this)
+{
        entity mf, ef;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
        // If enemy flag is back on the base switch to previous role
-       ef = havocbot_ctf_find_enemy_flag(self);
+       ef = havocbot_ctf_find_enemy_flag(this);
        if(ef.ctf_status==FLAG_BASE)
        {
-               self.havocbot_role = self.havocbot_previous_role;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = this.havocbot_previous_role;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
        // If the flag carrier reached the base switch to defense
-       mf = havocbot_ctf_find_flag(self);
+       mf = havocbot_ctf_find_flag(this);
        if(mf.ctf_status!=FLAG_BASE)
        if(vlen(ef.origin - mf.dropped_origin) < 300)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_DEFENSE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_DEFENSE);
                return;
        }
 
        // Set the role timeout if necessary
-       if (!self.havocbot_role_timeout)
+       if (!this.havocbot_role_timeout)
        {
-               self.havocbot_role_timeout = time + random() * 30 + 60;
+               this.havocbot_role_timeout = time + random() * 30 + 60;
        }
 
        // If nothing happened just switch to previous role
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               self.havocbot_role = self.havocbot_previous_role;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = this.havocbot_previous_role;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
        // Chase the flag carrier
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_ctf_enemyflag(30000);
-               havocbot_goalrating_ctf_ourstolenflag(40000);
-               havocbot_goalrating_items(10000, self.origin, 10000);
-               navigation_goalrating_end();
+               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);
        }
 }
 
-void havocbot_role_ctf_offense()
-{SELFPARAM();
+void havocbot_role_ctf_offense(entity this)
+{
        entity mf, ef;
        vector pos;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
        // Check flags
-       mf = havocbot_ctf_find_flag(self);
-       ef = havocbot_ctf_find_enemy_flag(self);
+       mf = havocbot_ctf_find_flag(this);
+       ef = havocbot_ctf_find_enemy_flag(this);
 
        // Own flag stolen
        if(mf.ctf_status!=FLAG_BASE)
@@ -1708,9 +1708,9 @@ void havocbot_role_ctf_offense()
                        pos = mf.origin;
 
                // Try to get it if closer than the enemy base
-               if(vlen(self.origin-ef.dropped_origin)>vlen(self.origin-pos))
+               if(vlen(this.origin-ef.dropped_origin)>vlen(this.origin-pos))
                {
-                       havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
+                       havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_RETRIEVER);
                        return;
                }
        }
@@ -1725,173 +1725,173 @@ void havocbot_role_ctf_offense()
 
                if(vlen(pos-mf.dropped_origin)>700)
                {
-                       havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_ESCORT);
+                       havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_ESCORT);
                        return;
                }
        }
 
        // About to fail, switch to middlefield
-       if(self.health<50)
+       if(this.health<50)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_MIDDLE);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_MIDDLE);
                return;
        }
 
        // Set the role timeout if necessary
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 120;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 120;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_ctf_ourstolenflag(50000);
-               havocbot_goalrating_ctf_enemybase(20000);
-               havocbot_goalrating_items(5000, self.origin, 1000);
-               havocbot_goalrating_items(1000, self.origin, 10000);
-               navigation_goalrating_end();
+               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);
        }
 }
 
 // Retriever (temporary role):
-void havocbot_role_ctf_retriever()
-{SELFPARAM();
+void havocbot_role_ctf_retriever(entity this)
+{
        entity mf;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
        // If flag is back on the base switch to previous role
-       mf = havocbot_ctf_find_flag(self);
+       mf = havocbot_ctf_find_flag(this);
        if(mf.ctf_status==FLAG_BASE)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 20;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 20;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                float rt_radius;
                rt_radius = 10000;
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_ctf_ourstolenflag(50000);
-               havocbot_goalrating_ctf_droppedflags(40000, self.origin, rt_radius);
-               havocbot_goalrating_ctf_enemybase(30000);
-               havocbot_goalrating_items(500, self.origin, rt_radius);
-               navigation_goalrating_end();
+               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);
        }
 }
 
-void havocbot_role_ctf_middle()
-{SELFPARAM();
+void havocbot_role_ctf_middle(entity this)
+{
        entity mf;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
-       mf = havocbot_ctf_find_flag(self);
+       mf = havocbot_ctf_find_flag(this);
        if(mf.ctf_status!=FLAG_BASE)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
        }
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 10;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 10;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                vector org;
 
                org = havocbot_ctf_middlepoint;
-               org.z = self.origin.z;
+               org.z = this.origin.z;
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_ctf_ourstolenflag(50000);
-               havocbot_goalrating_ctf_droppedflags(30000, self.origin, 10000);
-               havocbot_goalrating_enemyplayers(10000, org, havocbot_ctf_middlepoint_radius * 0.5);
-               havocbot_goalrating_items(5000, org, havocbot_ctf_middlepoint_radius * 0.5);
-               havocbot_goalrating_items(2500, self.origin, 10000);
-               havocbot_goalrating_ctf_enemybase(2500);
-               navigation_goalrating_end();
+               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_ctf_middlepoint_radius * 0.5);
+               havocbot_goalrating_items(this, 5000, org, havocbot_ctf_middlepoint_radius * 0.5);
+               havocbot_goalrating_items(this, 2500, this.origin, 10000);
+               havocbot_goalrating_ctf_enemybase(this, 2500);
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_role_ctf_defense()
-{SELFPARAM();
+void havocbot_role_ctf_defense(entity this)
+{
        entity mf;
 
-       if(IS_DEAD(self))
+       if(IS_DEAD(this))
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
 
-       if (self.flagcarried)
+       if (this.flagcarried)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_CARRIER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_CARRIER);
                return;
        }
 
        // If own flag was captured
-       mf = havocbot_ctf_find_flag(self);
+       mf = havocbot_ctf_find_flag(this);
        if(mf.ctf_status!=FLAG_BASE)
        {
-               havocbot_role_ctf_setrole(self, HAVOCBOT_CTF_ROLE_RETRIEVER);
+               havocbot_role_ctf_setrole(this, HAVOCBOT_CTF_ROLE_RETRIEVER);
                return;
        }
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + 30;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + 30;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
-               havocbot_ctf_reset_role(self);
+               havocbot_ctf_reset_role(this);
                return;
        }
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                float mp_radius;
                vector org;
@@ -1899,8 +1899,8 @@ void havocbot_role_ctf_defense()
                org = mf.dropped_origin;
                mp_radius = havocbot_ctf_middlepoint_radius;
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                // if enemies are closer to our base, go there
                entity closestplayer = world;
@@ -1915,17 +1915,17 @@ void havocbot_role_ctf_defense()
                ));
 
                if(closestplayer)
-               if(DIFF_TEAM(closestplayer, self))
-               if(vlen(org - self.origin)>1000)
-               if(checkpvs(self.origin,closestplayer)||random()<0.5)
-                       havocbot_goalrating_ctf_ourbase(30000);
-
-               havocbot_goalrating_ctf_ourstolenflag(20000);
-               havocbot_goalrating_ctf_droppedflags(20000, org, mp_radius);
-               havocbot_goalrating_enemyplayers(15000, org, mp_radius);
-               havocbot_goalrating_items(10000, org, mp_radius);
-               havocbot_goalrating_items(5000, self.origin, 10000);
-               navigation_goalrating_end();
+               if(DIFF_TEAM(closestplayer, this))
+               if(vlen(org - this.origin)>1000)
+               if(checkpvs(this.origin,closestplayer)||random()<0.5)
+                       havocbot_goalrating_ctf_ourbase(this, 30000);
+
+               havocbot_goalrating_ctf_ourstolenflag(this, 20000);
+               havocbot_goalrating_ctf_droppedflags(this, 20000, org, mp_radius);
+               havocbot_goalrating_enemyplayers(this, 15000, org, mp_radius);
+               havocbot_goalrating_items(this, 10000, org, mp_radius);
+               havocbot_goalrating_items(this, 5000, this.origin, 10000);
+               navigation_goalrating_end(this);
        }
 }
 
index 256e7d7..1f99c93 100644 (file)
@@ -52,25 +52,25 @@ bool autocvar_g_cts_selfdamage;
 
 // legacy bot roles
 .float race_checkpoint;
-void havocbot_role_cts()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_cts(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                FOREACH_ENTITY_CLASS("trigger_race_checkpoint", true,
                {
-                       if(it.cnt == self.race_checkpoint)
-                               navigation_routerating(it, 1000000, 5000);
-                       else if(self.race_checkpoint == -1)
-                               navigation_routerating(it, 1000000, 5000);
+                       if(it.cnt == this.race_checkpoint)
+                               navigation_routerating(this, it, 1000000, 5000);
+                       else if(this.race_checkpoint == -1)
+                               navigation_routerating(this, it, 1000000, 5000);
                });
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }
 
index 108216d..ba6a48f 100644 (file)
@@ -451,20 +451,20 @@ void Domination_RoundStart()
 }
 
 //go to best items, or control points you don't own
-void havocbot_role_dom()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_dom(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
-               havocbot_goalrating_controlpoints(10000, self.origin, 15000);
-               havocbot_goalrating_items(8000, self.origin, 8000);
-               //havocbot_goalrating_enemyplayers(3000, self.origin, 2000);
-               //havocbot_goalrating_waypoints(1, self.origin, 1000);
-               navigation_goalrating_end();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
+               havocbot_goalrating_controlpoints(this, 10000, this.origin, 15000);
+               havocbot_goalrating_items(this, 8000, this.origin, 8000);
+               //havocbot_goalrating_enemyplayers(this, 3000, this.origin, 2000);
+               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               navigation_goalrating_end(this);
        }
 }
 
index 5bc82f1..bee23d1 100644 (file)
@@ -263,90 +263,87 @@ float freezetag_isEliminated(entity e)
 // Bot player logic
 // ================
 
-void() havocbot_role_ft_freeing;
-void() havocbot_role_ft_offense;
+void(entity this) havocbot_role_ft_freeing;
+void(entity this) havocbot_role_ft_offense;
 
-void havocbot_goalrating_freeplayers(float ratingscale, vector org, float sradius)
-{SELFPARAM();
-       float distance;
-
-       FOREACH_CLIENT(IS_PLAYER(it) && it != self && SAME_TEAM(it, self), LAMBDA(
+void havocbot_goalrating_freeplayers(entity this, float ratingscale, vector org, float sradius)
+{
+       FOREACH_CLIENT(IS_PLAYER(it) && it != this && SAME_TEAM(it, this), LAMBDA(
                if (STAT(FROZEN, it) == 1)
                {
-                       distance = vlen(it.origin - org);
-                       if (distance > sradius)
+                       if(vdist(it.origin - org, >, sradius))
                                continue;
-                       navigation_routerating(it, ratingscale, 2000);
+                       navigation_routerating(this, it, ratingscale, 2000);
                }
                else
                {
                        // If teamate is not frozen still seek them out as fight better
                        // in a group.
-                       navigation_routerating(it, ratingscale/3, 2000);
+                       navigation_routerating(this, it, ratingscale/3, 2000);
                }
        ));
 }
 
-void havocbot_role_ft_offense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ft_offense(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + random() * 10 + 20;
 
        // Count how many players on team are unfrozen.
        int unfrozen = 0;
-       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, self) && !(STAT(FROZEN, it) != 1), LAMBDA(unfrozen++));
+       FOREACH_CLIENT(IS_PLAYER(it) && SAME_TEAM(it, this) && !(STAT(FROZEN, it) != 1), LAMBDA(unfrozen++));
 
        // If only one left on team or if role has timed out then start trying to free players.
-       if (((unfrozen == 0) && (!STAT(FROZEN, self))) || (time > self.havocbot_role_timeout))
+       if (((unfrozen == 0) && (!STAT(FROZEN, this))) || (time > this.havocbot_role_timeout))
        {
                LOG_TRACE("changing role to freeing\n");
-               self.havocbot_role = havocbot_role_ft_freeing;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_ft_freeing;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (time > self.bot_strategytime)
+       if (time > this.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();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start(this);
+               havocbot_goalrating_items(this, 10000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               havocbot_goalrating_freeplayers(this, 9000, this.origin, 10000);
+               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_role_ft_freeing()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_ft_freeing(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + random() * 10 + 20;
 
-       if (time > self.havocbot_role_timeout)
+       if (time > this.havocbot_role_timeout)
        {
                LOG_TRACE("changing role to offense\n");
-               self.havocbot_role = havocbot_role_ft_offense;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_ft_offense;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (time > self.bot_strategytime)
+       if (time > this.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();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+
+               navigation_goalrating_start(this);
+               havocbot_goalrating_items(this, 8000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 10000, this.origin, 10000);
+               havocbot_goalrating_freeplayers(this, 20000, this.origin, 10000);
+               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               navigation_goalrating_end(this);
        }
 }
 
index 28270b8..4654795 100644 (file)
@@ -36,8 +36,8 @@ const float SP_KEEPAWAY_PICKUPS = 4;
 const float SP_KEEPAWAY_CARRIERKILLS = 5;
 const float SP_KEEPAWAY_BCTIME = 6;
 
-void() havocbot_role_ka_carrier;
-void() havocbot_role_ka_collector;
+void(entity this) havocbot_role_ka_carrier;
+void(entity this) havocbot_role_ka_collector;
 
 void ka_DropEvent(entity plyr);
 #endif
@@ -243,68 +243,68 @@ void ka_Reset(entity this)
 // Bot player logic
 // ================
 
-void havocbot_goalrating_ball(float ratingscale, vector org)
-{SELFPARAM();
+void havocbot_goalrating_ball(entity this, float ratingscale, vector org)
+{
        float t;
        entity ball_owner;
        ball_owner = ka_ball.owner;
 
-       if (ball_owner == self)
+       if (ball_owner == this)
                return;
 
        // If ball is carried by player then hunt them down.
        if (ball_owner)
        {
-               t = (self.health + self.armorvalue) / (ball_owner.health + ball_owner.armorvalue);
-               navigation_routerating(ball_owner, t * ratingscale, 2000);
+               t = (this.health + this.armorvalue) / (ball_owner.health + ball_owner.armorvalue);
+               navigation_routerating(this, ball_owner, t * ratingscale, 2000);
        }
        else // Ball has been dropped so collect.
-               navigation_routerating(ka_ball, ratingscale, 2000);
+               navigation_routerating(this, ka_ball, ratingscale, 2000);
 }
 
-void havocbot_role_ka_carrier()
-{SELFPARAM();
-       if (IS_DEAD(self))
+void havocbot_role_ka_carrier(entity this)
+{
+       if (IS_DEAD(this))
                return;
 
-       if (time > self.bot_strategytime)
+       if (time > this.bot_strategytime)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.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_waypoints(1, self.origin, 1000);
-               navigation_goalrating_end();
+               navigation_goalrating_start(this);
+               havocbot_goalrating_items(this, 10000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 20000, this.origin, 10000);
+               //havocbot_goalrating_waypoints(1, this.origin, 1000);
+               navigation_goalrating_end(this);
        }
 
-       if (!self.ballcarried)
+       if (!this.ballcarried)
        {
-               self.havocbot_role = havocbot_role_ka_collector;
-               self.bot_strategytime = 0;
+               this.havocbot_role = havocbot_role_ka_collector;
+               this.bot_strategytime = 0;
        }
 }
 
-void havocbot_role_ka_collector()
-{SELFPARAM();
-       if (IS_DEAD(self))
+void havocbot_role_ka_collector(entity this)
+{
+       if (IS_DEAD(this))
                return;
 
-       if (time > self.bot_strategytime)
+       if (time > this.bot_strategytime)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
 
-               navigation_goalrating_start();
-               havocbot_goalrating_items(10000, self.origin, 10000);
-               havocbot_goalrating_enemyplayers(1000, self.origin, 10000);
-               havocbot_goalrating_ball(20000, self.origin);
-               navigation_goalrating_end();
+               navigation_goalrating_start(this);
+               havocbot_goalrating_items(this, 10000, this.origin, 10000);
+               havocbot_goalrating_enemyplayers(this, 1000, this.origin, 10000);
+               havocbot_goalrating_ball(this, 20000, this.origin);
+               navigation_goalrating_end(this);
        }
 
-       if (self.ballcarried)
+       if (this.ballcarried)
        {
-               self.havocbot_role = havocbot_role_ka_carrier;
-               self.bot_strategytime = 0;
+               this.havocbot_role = havocbot_role_ka_carrier;
+               this.bot_strategytime = 0;
        }
 }
 
index 344bedb..dbcaa5f 100644 (file)
@@ -1091,198 +1091,198 @@ void kh_finalize()
 
 // legacy bot role
 
-void() havocbot_role_kh_carrier;
-void() havocbot_role_kh_defense;
-void() havocbot_role_kh_offense;
-void() havocbot_role_kh_freelancer;
+void(entity this) havocbot_role_kh_carrier;
+void(entity this) havocbot_role_kh_defense;
+void(entity this) havocbot_role_kh_offense;
+void(entity this) havocbot_role_kh_freelancer;
 
 
-void havocbot_goalrating_kh(float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
-{SELFPARAM();
+void havocbot_goalrating_kh(entity this, float ratingscale_team, float ratingscale_dropped, float ratingscale_enemy)
+{
        entity head;
        for (head = kh_worldkeylist; head; head = head.kh_worldkeynext)
        {
-               if(head.owner == self)
+               if(head.owner == this)
                        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)
+                       if(!head.owner || head.team != this.team)
                        {
-                               traceline(self.origin + self.view_ofs, head.origin, MOVE_NOMONSTERS, self);
+                               traceline(this.origin + this.view_ofs, head.origin, MOVE_NOMONSTERS, this);
                                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);
+                       navigation_routerating(this, head, ratingscale_dropped * BOT_PICKUP_RATING_HIGH, 100000);
+               else if(head.team == this.team)
+                       navigation_routerating(this, head.owner, ratingscale_team * BOT_PICKUP_RATING_HIGH, 100000);
                else
-                       navigation_routerating(head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
+                       navigation_routerating(this, head.owner, ratingscale_enemy * BOT_PICKUP_RATING_HIGH, 100000);
        }
 
-       havocbot_goalrating_items(1, self.origin, 10000);
+       havocbot_goalrating_items(this, 1, this.origin, 10000);
 }
 
-void havocbot_role_kh_carrier()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_kh_carrier(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (!(self.kh_next))
+       if (!(this.kh_next))
        {
                LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_freelancer;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
-               if(kh_Key_AllOwnedByWhichTeam() == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // bring home
+               if(kh_Key_AllOwnedByWhichTeam() == this.team)
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // bring home
                else
-                       havocbot_goalrating_kh(4, 4, 1); // play defensively
+                       havocbot_goalrating_kh(this, 4, 4, 1); // play defensively
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_role_kh_defense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_kh_defense(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.kh_next)
+       if (this.kh_next)
        {
                LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_carrier;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
-       if (time > self.havocbot_role_timeout)
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + random() * 10 + 20;
+       if (time > this.havocbot_role_timeout)
        {
                LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_freelancer;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                float key_owner_team;
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend key carriers
+               if(key_owner_team == this.team)
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend key carriers
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(4, 1, 0.1); // play defensively
+                       havocbot_goalrating_kh(this, 4, 1, 0.1); // play defensively
                else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_role_kh_offense()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_kh_offense(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.kh_next)
+       if (this.kh_next)
        {
                LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_carrier;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (!self.havocbot_role_timeout)
-               self.havocbot_role_timeout = time + random() * 10 + 20;
-       if (time > self.havocbot_role_timeout)
+       if (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + random() * 10 + 20;
+       if (time > this.havocbot_role_timeout)
        {
                LOG_TRACE("changing role to freelancer\n");
-               self.havocbot_role = havocbot_role_kh_freelancer;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_freelancer;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                float key_owner_team;
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
+               if(key_owner_team == this.team)
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend anyway
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(0.1, 1, 4); // play offensively
+                       havocbot_goalrating_kh(this, 0.1, 1, 4); // play offensively
                else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK! EMERGENCY!
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK! EMERGENCY!
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }
 
-void havocbot_role_kh_freelancer()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_kh_freelancer(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
-       if (self.kh_next)
+       if (this.kh_next)
        {
                LOG_TRACE("changing role to carrier\n");
-               self.havocbot_role = havocbot_role_kh_carrier;
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role = havocbot_role_kh_carrier;
+               this.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 (!this.havocbot_role_timeout)
+               this.havocbot_role_timeout = time + random() * 10 + 10;
+       if (time > this.havocbot_role_timeout)
        {
                if (random() < 0.5)
                {
                        LOG_TRACE("changing role to offense\n");
-                       self.havocbot_role = havocbot_role_kh_offense;
+                       this.havocbot_role = havocbot_role_kh_offense;
                }
                else
                {
                        LOG_TRACE("changing role to defense\n");
-                       self.havocbot_role = havocbot_role_kh_defense;
+                       this.havocbot_role = havocbot_role_kh_defense;
                }
-               self.havocbot_role_timeout = 0;
+               this.havocbot_role_timeout = 0;
                return;
        }
 
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
                float key_owner_team;
 
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                key_owner_team = kh_Key_AllOwnedByWhichTeam();
-               if(key_owner_team == self.team)
-                       havocbot_goalrating_kh(10, 0.1, 0.1); // defend anyway
+               if(key_owner_team == this.team)
+                       havocbot_goalrating_kh(this, 10, 0.1, 0.1); // defend anyway
                else if(key_owner_team == -1)
-                       havocbot_goalrating_kh(1, 10, 4); // prefer dropped keys
+                       havocbot_goalrating_kh(this, 1, 10, 4); // prefer dropped keys
                else
-                       havocbot_goalrating_kh(0.1, 0.1, 10); // ATTACK ANYWAY
+                       havocbot_goalrating_kh(this, 0.1, 0.1, 10); // ATTACK ANYWAY
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }
 
index ce86e50..3f6a8a8 100644 (file)
@@ -46,30 +46,30 @@ int autocvar_g_race_teams;
 
 // legacy bot roles
 .float race_checkpoint;
-void havocbot_role_race()
-{SELFPARAM();
-       if(IS_DEAD(self))
+void havocbot_role_race(entity this)
+{
+       if(IS_DEAD(this))
                return;
 
        entity e;
-       if (self.bot_strategytime < time)
+       if (this.bot_strategytime < time)
        {
-               self.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
-               navigation_goalrating_start();
+               this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
+               navigation_goalrating_start(this);
 
                for(e = world; (e = find(e, classname, "trigger_race_checkpoint")) != world; )
                {
-                       if(e.cnt == self.race_checkpoint)
+                       if(e.cnt == this.race_checkpoint)
                        {
-                               navigation_routerating(e, 1000000, 5000);
+                               navigation_routerating(this, e, 1000000, 5000);
                        }
-                       else if(self.race_checkpoint == -1)
+                       else if(this.race_checkpoint == -1)
                        {
-                               navigation_routerating(e, 1000000, 5000);
+                               navigation_routerating(this, e, 1000000, 5000);
                        }
                }
 
-               navigation_goalrating_end();
+               navigation_goalrating_end(this);
        }
 }