]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/gamemode_assault.qc
Remove oldself variables
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / gamemode_assault.qc
index f3b4786593b6f06c8a50c63b841cbd4bb31bc71a..2cab4918ddc5805541fc57be23f07d9a2398f968 100644 (file)
@@ -7,26 +7,26 @@
 
 // random functions
 void assault_objective_use()
-{
+{SELFPARAM();
        // activate objective
        self.health = 100;
        //print("^2Activated objective ", self.targetname, "=", etos(self), "\n");
        //print("Activator is ", activator.classname, "\n");
 
-       entity oldself;
-       oldself = self;
-
-       for(self = world; (self = find(self, target, oldself.targetname)); )
+       for (entity e = world; (e = find(e, target, this.targetname)); )
        {
-               if(self.classname == "target_objective_decrease")
-                       target_objective_decrease_activate();
+               if (e.classname == "target_objective_decrease")
+               {
+                       SELFCALL(e, target_objective_decrease_activate());
+                       SELFCALL_DONE();
+               }
        }
 
-       self = oldself;
+       setself(this);
 }
 
 vector target_objective_spawn_evalfunc(entity player, entity spot, vector current)
-{
+{SELFPARAM();
        if(self.health < 0 || self.health >= ASSAULT_VALUE_INACTIVE)
                return '-1 0 0';
        return current;
@@ -35,13 +35,13 @@ vector target_objective_spawn_evalfunc(entity player, entity spot, vector curren
 // reset this objective. Used when spawning an objective
 // and when a new round starts
 void assault_objective_reset()
-{
+{SELFPARAM();
        self.health = ASSAULT_VALUE_INACTIVE;
 }
 
 // decrease the health of targeted objectives
 void assault_objective_decrease_use()
-{
+{SELFPARAM();
        if(activator.team != assault_attacker_team)
        {
                // wrong team triggered decrease
@@ -70,25 +70,24 @@ void assault_objective_decrease_use()
                        PlayerTeamScore_Add(activator, SP_ASSAULT_OBJECTIVES, ST_ASSAULT_OBJECTIVES, 1);
                        self.enemy.health = -1;
 
-                       entity oldself, oldactivator, head;
+                       entity oldactivator, head;
 
-                       oldself = self;
-                       self = oldself.enemy;
+                       setself(this.enemy);
                        if(self.message)
                        FOR_EACH_PLAYER(head)
                                centerprint(head, self.message);
 
                        oldactivator = activator;
-                       activator = oldself;
+                       activator = this;
                        SUB_UseTargets();
                        activator = oldactivator;
-                       self = oldself;
+                       setself(this);
                }
        }
 }
 
 void assault_setenemytoobjective()
-{
+{SELFPARAM();
        entity objective;
        for(objective = world; (objective = find(objective, targetname, self.target)); )
        {
@@ -107,7 +106,7 @@ void assault_setenemytoobjective()
 }
 
 float assault_decreaser_sprite_visible(entity e)
-{
+{SELFPARAM();
        entity decreaser;
 
        decreaser = self.assault_decreaser;
@@ -119,7 +118,7 @@ float assault_decreaser_sprite_visible(entity e)
 }
 
 void target_objective_decrease_activate()
-{
+{SELFPARAM();
        entity ent, spr;
        self.owner = world;
        for(ent = world; (ent = find(ent, target, self.targetname)); )
@@ -131,20 +130,20 @@ void target_objective_decrease_activate()
                                ent.sprite = world;
                }
 
-               spr = WaypointSprite_SpawnFixed("<placeholder>", 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite, RADARICON_OBJECTIVE, '1 0.5 0');
+               spr = WaypointSprite_SpawnFixed(WP_Assault, 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite, RADARICON_OBJECTIVE);
                spr.assault_decreaser = self;
                spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
                spr.classname = "sprite_waypoint";
                WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
                if(ent.classname == "func_assault_destructible")
                {
-                       WaypointSprite_UpdateSprites(spr, "as-defend", "as-destroy", "as-destroy");
+                       WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy);
                        WaypointSprite_UpdateMaxHealth(spr, ent.max_health);
                        WaypointSprite_UpdateHealth(spr, ent.health);
                        ent.sprite = spr;
                }
                else
-                       WaypointSprite_UpdateSprites(spr, "as-defend", "as-push", "as-push");
+                       WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultPush, WP_AssaultPush);
        }
 }
 
@@ -154,46 +153,38 @@ void target_objective_decrease_findtarget()
 }
 
 void target_assault_roundend_reset()
-{
+{SELFPARAM();
        //print("round end reset\n");
        self.cnt = self.cnt + 1; // up round counter
        self.winning = 0; // up round
 }
 
 void target_assault_roundend_use()
-{
+{SELFPARAM();
        self.winning = 1; // round has been won by attackers
 }
 
 void assault_roundstart_use()
-{
+{SELFPARAM();
        activator = self;
        SUB_UseTargets();
 
-       entity ent, oldself;
-
        //(Re)spawn all turrets
-       oldself = self;
-       ent = find(world, classname, "turret_main");
-       while(ent) {
+       for(entity ent = NULL; (ent = find(ent, classname, "turret_main")); ) {
                // Swap turret teams
                if(ent.team == NUM_TEAM_1)
                        ent.team = NUM_TEAM_2;
                else
                        ent.team = NUM_TEAM_1;
 
-               self = ent;
-
                // Dubbles as teamchange
-               turret_respawn();
-
-               ent = find(ent, classname, "turret_main");
+               SELFCALL(ent, turret_respawn());
+               SELFCALL_DONE();
        }
-       self = oldself;
 }
 
 void assault_wall_think()
-{
+{SELFPARAM();
        if(self.enemy.health < 0)
        {
                self.model = "";
@@ -213,27 +204,28 @@ void assault_wall_think()
 void vehicles_clearreturn(entity veh);
 void vehicles_spawn();
 void assault_new_round()
-{
-    entity oldself;
+{SELFPARAM();
        //bprint("ASSAULT: new round\n");
 
-       oldself = self;
        // Eject players from vehicles
-    FOR_EACH_PLAYER(self)
+       entity e;
+    FOR_EACH_PLAYER(e)
     {
-        if(self.vehicle)
-            vehicles_exit(VHEF_RELEASE);
+        if(e.vehicle)
+        {
+               SELFCALL(e, vehicles_exit(VHEF_RELEASE));
+            SELFCALL_DONE();
+        }
     }
 
-    self = findchainflags(vehicle_flags, VHF_ISVEHICLE);
-    while(self)
+    for (entity e_ = findchainflags(vehicle_flags, VHF_ISVEHICLE); e_; e_ = e_.chain)
     {
+       setself(e_);
         vehicles_clearreturn(self);
         vehicles_spawn();
-        self = self.chain;
     }
 
-    self = oldself;
+    setself(this);
 
        // up round counter
        self.winning = self.winning + 1;
@@ -263,7 +255,7 @@ void assault_new_round()
 
 // spawnfuncs
 void spawnfunc_info_player_attacker()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_1; // red, gets swapped every round
@@ -271,7 +263,7 @@ void spawnfunc_info_player_attacker()
 }
 
 void spawnfunc_info_player_defender()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.team = NUM_TEAM_2; // blue, gets swapped every round
@@ -279,7 +271,7 @@ void spawnfunc_info_player_defender()
 }
 
 void spawnfunc_target_objective()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "target_objective";
@@ -290,7 +282,7 @@ void spawnfunc_target_objective()
 }
 
 void spawnfunc_target_objective_decrease()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "target_objective_decrease";
@@ -308,7 +300,7 @@ void spawnfunc_target_objective_decrease()
 
 // destructible walls that can be used to trigger target_objective_decrease
 void spawnfunc_func_assault_destructible()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.spawnflags = 3;
@@ -323,7 +315,7 @@ void spawnfunc_func_assault_destructible()
 }
 
 void spawnfunc_func_assault_wall()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.classname = "func_assault_wall";
@@ -336,7 +328,7 @@ void spawnfunc_func_assault_wall()
 }
 
 void spawnfunc_target_assault_roundend()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        self.winning = 0; // round not yet won by attackers
@@ -347,7 +339,7 @@ void spawnfunc_target_assault_roundend()
 }
 
 void spawnfunc_target_assault_roundstart()
-{
+{SELFPARAM();
        if (!g_assault) { remove(self); return; }
 
        assault_attacker_team = NUM_TEAM_1;
@@ -359,7 +351,7 @@ void spawnfunc_target_assault_roundstart()
 
 // legacy bot code
 void havocbot_goalrating_ast_targets(float ratingscale)
-{
+{SELFPARAM();
        entity ad, best, wp, tod;
        float radius, found, bestvalue;
        vector p;
@@ -445,7 +437,7 @@ void havocbot_goalrating_ast_targets(float ratingscale)
 }
 
 void havocbot_role_ast_offense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -479,7 +471,7 @@ void havocbot_role_ast_offense()
 }
 
 void havocbot_role_ast_defense()
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
        {
                self.havocbot_attack_time = 0;
@@ -530,7 +522,7 @@ void havocbot_role_ast_setrole(entity bot, float role)
 }
 
 void havocbot_ast_reset_role(entity bot)
-{
+{SELFPARAM();
        if(self.deadflag != DEAD_NO)
                return;
 
@@ -542,7 +534,7 @@ void havocbot_ast_reset_role(entity bot)
 
 // mutator hooks
 MUTATOR_HOOKFUNCTION(assault_PlayerSpawn)
-{
+{SELFPARAM();
        if(self.team == assault_attacker_team)
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_ASSAULT_ATTACKING);
        else
@@ -552,7 +544,7 @@ MUTATOR_HOOKFUNCTION(assault_PlayerSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(assault_TurretSpawn)
-{
+{SELFPARAM();
        if(!self.team || self.team == MAX_SHOT_DISTANCE)
                self.team = 5; // this gets reversed when match starts?
 
@@ -560,14 +552,14 @@ MUTATOR_HOOKFUNCTION(assault_TurretSpawn)
 }
 
 MUTATOR_HOOKFUNCTION(assault_VehicleSpawn)
-{
+{SELFPARAM();
        self.nextthink = time + 0.5;
 
        return false;
 }
 
 MUTATOR_HOOKFUNCTION(assault_BotRoles)
-{
+{SELFPARAM();
        havocbot_ast_reset_role(self);
        return true;
 }
@@ -610,7 +602,7 @@ MUTATOR_DEFINITION(gamemode_assault)
 
        MUTATOR_ONREMOVE
        {
-               print("This is a game type and it cannot be removed at runtime.");
+               LOG_INFO("This is a game type and it cannot be removed at runtime.");
                return -1;
        }