]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_lms.qc
Merge branch 'master' into terencehill/ca_bots_fix
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_lms.qc
index d0ef8e1d432aa7b42e566f71c0810bfc67f55c0b..793cbf6b76f38fc2a38c9181581e750c32d02dd8 100644 (file)
@@ -1,53 +1,8 @@
 #include "gamemode_lms.qh"
-#ifndef GAMEMODE_LMS_H
-#define GAMEMODE_LMS_H
-
-#define autocvar_g_lms_lives_override cvar("g_lms_lives_override")
-void lms_Initialize();
-
-REGISTER_MUTATOR(lms, false)
-{
-       MUTATOR_ONADD
-       {
-               if (time > 1) // game loads at time 1
-                       error("This is a game type and it cannot be added at runtime.");
-               lms_Initialize();
-
-               SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, autocvar_timelimit_override, -1);
-       }
-
-       MUTATOR_ONROLLBACK_OR_REMOVE
-       {
-               // we actually cannot roll back lms_Initialize here
-               // BUT: we don't need to! If this gets called, adding always
-               // succeeds.
-       }
-
-       MUTATOR_ONREMOVE
-       {
-               LOG_INFO("This is a game type and it cannot be removed at runtime.");
-               return -1;
-       }
-
-       return 0;
-}
-
-// scoreboard stuff
-const float SP_LMS_LIVES = 4;
-const float SP_LMS_RANK = 5;
-
-// lives related defs
-float lms_lowest_lives;
-float lms_next_place;
-float LMS_NewPlayerLives();
-
-#endif
-
-#ifdef IMPLEMENTATION
 
 #include <common/mutators/mutator/instagib/items.qc>
 #include <server/campaign.qh>
-#include <server/command/cmd.qh>
+#include <server/command/_mod.qh>
 
 int autocvar_g_lms_extra_lives;
 bool autocvar_g_lms_join_anytime;
@@ -86,7 +41,7 @@ int WinningCondition_LMS()
 
        int l = LMS_NewPlayerLives();
 
-       head = find(world, classname, STR_PLAYER);
+       head = find(NULL, classname, STR_PLAYER);
        if(head)
                have_player = true;
        head2 = find(head, classname, STR_PLAYER);
@@ -132,7 +87,7 @@ int WinningCondition_LMS()
                {
                        // SNAFU (maybe a draw game?)
                        ClearWinners();
-                       LOG_TRACE("No players, ending game.\n");
+                       LOG_TRACE("No players, ending game.");
                        return WINNING_YES;
                }
        }
@@ -156,15 +111,12 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_global)
 {
        lms_lowest_lives = 999;
        lms_next_place = player_count;
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, reset_map_players)
 {
        if(restart_mapalreadyrestarted || (time < game_starttime))
        FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives())));
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
@@ -183,9 +135,8 @@ MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
 MUTATOR_HOOKFUNCTION(lms, PlayerDies)
 {
        entity frag_target = M_ARGV(2, entity);
-       
+
        frag_target.respawn_flags |= RESPAWN_FORCE;
-       return false;
 }
 
 void lms_RemovePlayer(entity player)
@@ -194,13 +145,17 @@ void lms_RemovePlayer(entity player)
        if(PlayerScore_Add(player, SP_LMS_RANK, 0) == 666)
                player.frags = FRAGS_SPECTATOR;
        else
+       {
+               if(IS_BOT_CLIENT(player))
+                       bot_clear(player);
                player.frags = FRAGS_LMS_LOSER;
+       }
 
        if(player.killcount != FRAGS_SPECTATOR)
                if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0 && player.lms_spectate_warning != 2)
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_NOLIVES, player.netname);
                else
-                       Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_LMS_FORFEIT, player.netname);
+                       Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_LMS_FORFEIT, player.netname);
 }
 
 MUTATOR_HOOKFUNCTION(lms, ClientDisconnect)
@@ -287,8 +242,6 @@ MUTATOR_HOOKFUNCTION(lms, SetStartItems)
        start_ammo_cells   = warmup_start_ammo_cells   = cvar("g_lms_start_ammo_cells");
        start_ammo_plasma  = warmup_start_ammo_plasma  = cvar("g_lms_start_ammo_plasma");
        start_ammo_fuel    = warmup_start_ammo_fuel    = cvar("g_lms_start_ammo_fuel");
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, ForbidPlayerScore_Clear)
@@ -398,9 +351,8 @@ MUTATOR_HOOKFUNCTION(lms, GetPlayerStatus)
 MUTATOR_HOOKFUNCTION(lms, AddPlayerScore)
 {
        if(gameover)
-       if(M_ARGV(0, int) == SP_LMS_RANK) // score field
+       if(M_ARGV(0, entity) == SP_LMS_RANK) // score field
                return true; // allow writing to this field in intermission as it is needed for newly joining players
-       return false;
 }
 
 // scoreboard stuff
@@ -419,6 +371,3 @@ void lms_Initialize()
 
        lms_ScoreRules();
 }
-
-
-#endif