]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_race.qc
Port race_completed to ClientState and move prevorigin to the campcheck code (only...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_race.qc
index 756d975b156ad197febcbe333455f85d9eaf246f..b1759fb6a62c2b2daafa47aed9532838ddd5d4bd 100644 (file)
@@ -14,23 +14,22 @@ void havocbot_role_race(entity this)
        if(IS_DEAD(this))
                return;
 
-       entity e;
        if (this.bot_strategytime < time)
        {
                this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
                navigation_goalrating_start(this);
 
-               for(e = NULL; (e = find(e, classname, "trigger_race_checkpoint")) != NULL; )
+               IL_EACH(g_racecheckpoints, true,
                {
-                       if(e.cnt == this.race_checkpoint)
+                       if(it.cnt == this.race_checkpoint)
                        {
-                               navigation_routerating(this, e, 1000000, 5000);
+                               navigation_routerating(this, it, 1000000, 5000);
                        }
                        else if(this.race_checkpoint == -1)
                        {
-                               navigation_routerating(this, e, 1000000, 5000);
+                               navigation_routerating(this, it, 1000000, 5000);
                        }
-               }
+               });
 
                navigation_goalrating_end(this);
        }
@@ -74,7 +73,7 @@ float WinningCondition_Race(float fraglimit)
        c = 0;
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
                ++n;
-               if(it.race_completed)
+               if(CS(it).race_completed)
                        ++c;
        ));
        if(n && (n == c))
@@ -103,6 +102,20 @@ float WinningCondition_QualifyingThenRace(float limit)
        return wc;
 }
 
+MUTATOR_HOOKFUNCTION(rc, ClientKill)
+{
+       if(g_race_qualifying)
+               M_ARGV(1, float) = 0; // killtime
+}
+
+MUTATOR_HOOKFUNCTION(rc, AbortSpeedrun)
+{
+       entity player = M_ARGV(0, entity);
+
+       if(autocvar_g_allow_checkpoints)
+               race_PreparePlayer(player); // nice try
+}
+
 MUTATOR_HOOKFUNCTION(rc, PlayerPhysics)
 {
        entity player = M_ARGV(0, entity);
@@ -137,8 +150,8 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics)
        // ensure nothing EVIL is being done (i.e. div0_evade)
        // this hinders joystick users though
        // but it still gives SOME analog control
-       wishvel.x = fabs(player.movement.x);
-       wishvel.y = fabs(player.movement.y);
+       wishvel.x = fabs(CS(player).movement.x);
+       wishvel.y = fabs(CS(player).movement.y);
        if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y)
        {
                wishvel.z = 0;
@@ -146,32 +159,32 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics)
                if(wishvel.x >= 2 * wishvel.y)
                {
                        // pure X motion
-                       if(player.movement.x > 0)
-                               player.movement_x = wishspeed;
+                       if(CS(player).movement.x > 0)
+                               CS(player).movement_x = wishspeed;
                        else
-                               player.movement_x = -wishspeed;
-                       player.movement_y = 0;
+                               CS(player).movement_x = -wishspeed;
+                       CS(player).movement_y = 0;
                }
                else if(wishvel.y >= 2 * wishvel.x)
                {
                        // pure Y motion
-                       player.movement_x = 0;
-                       if(player.movement.y > 0)
-                               player.movement_y = wishspeed;
+                       CS(player).movement_x = 0;
+                       if(CS(player).movement.y > 0)
+                               CS(player).movement_y = wishspeed;
                        else
-                               player.movement_y = -wishspeed;
+                               CS(player).movement_y = -wishspeed;
                }
                else
                {
                        // diagonal
-                       if(player.movement.x > 0)
-                               player.movement_x = M_SQRT1_2 * wishspeed;
+                       if(CS(player).movement.x > 0)
+                               CS(player).movement_x = M_SQRT1_2 * wishspeed;
                        else
-                               player.movement_x = -M_SQRT1_2 * wishspeed;
-                       if(player.movement.y > 0)
-                               player.movement_y = M_SQRT1_2 * wishspeed;
+                               CS(player).movement_x = -M_SQRT1_2 * wishspeed;
+                       if(CS(player).movement.y > 0)
+                               CS(player).movement_y = M_SQRT1_2 * wishspeed;
                        else
-                               player.movement_y = -M_SQRT1_2 * wishspeed;
+                               CS(player).movement_y = -M_SQRT1_2 * wishspeed;
                }
        }
 }
@@ -268,9 +281,9 @@ MUTATOR_HOOKFUNCTION(rc, PutClientInServer)
        entity player = M_ARGV(0, entity);
 
        if(IS_PLAYER(player))
-       if(!gameover)
+       if(!game_stopped)
        {
-               if(player.killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
+               if(CS(player).killcount == FRAGS_SPECTATOR /* initial spawn */ || g_race_qualifying) // spawn
                        race_PreparePlayer(player);
                else // respawn
                        race_RetractPlayer(player);
@@ -344,7 +357,7 @@ MUTATOR_HOOKFUNCTION(rc, ForbidPlayerScore_Clear)
                return true; // in qualifying, you don't lose score by observing
 }
 
-MUTATOR_HOOKFUNCTION(rc, GetTeamCount, CBC_ORDER_EXCLUSIVE)
+MUTATOR_HOOKFUNCTION(rc, CheckAllowedTeams, CBC_ORDER_EXCLUSIVE)
 {
        M_ARGV(0, float) = race_teams;
 }
@@ -378,6 +391,11 @@ MUTATOR_HOOKFUNCTION(rc, GetRecords)
        M_ARGV(1, string) = ret_string;
 }
 
+MUTATOR_HOOKFUNCTION(rc, HideTeamNagger)
+{
+       return true; // doesn't work so well
+}
+
 MUTATOR_HOOKFUNCTION(rc, FixClientCvars)
 {
        entity player = M_ARGV(0, entity);