]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_lms.qc
Merge branch 'terencehill/hud_no_joypad_keys' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_lms.qc
index 6b293a0642de7dbc9219ad5284f4614ea4988d4b..98eb9cdcf301fcc1b64c63578d69fc2a51d9235b 100644 (file)
@@ -1,3 +1,4 @@
+#include "gamemode_lms.qh"
 #ifndef GAMEMODE_LMS_H
 #define GAMEMODE_LMS_H
 
@@ -12,7 +13,7 @@ REGISTER_MUTATOR(lms, false)
                        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, -1, -1);
+               SetLimits(((!autocvar_g_lms_lives_override) ? -1 : autocvar_g_lms_lives_override), 0, autocvar_timelimit_override, -1);
        }
 
        MUTATOR_ONROLLBACK_OR_REMOVE
@@ -44,8 +45,9 @@ float LMS_NewPlayerLives();
 
 #ifdef IMPLEMENTATION
 
-#include "../../campaign.qh"
-#include "../../command/cmd.qh"
+#include <common/mutators/mutator/instagib/items.qc>
+#include <server/campaign.qh>
+#include <server/command/cmd.qh>
 
 int autocvar_g_lms_extra_lives;
 bool autocvar_g_lms_join_anytime;
@@ -71,24 +73,23 @@ float LMS_NewPlayerLives()
        return bound(1, lms_lowest_lives, fl);
 }
 
+void ClearWinners();
+
 // LMS winning condition: game terminates if and only if there's at most one
 // one player who's living lives. Top two scores being equal cancels the time
 // limit.
-float WinningCondition_LMS()
+int WinningCondition_LMS()
 {
        entity head, head2;
-       float have_player;
-       float have_players;
-       float l;
+       bool have_player = false;
+       bool have_players = false;
 
-       have_player = false;
-       have_players = false;
-       l = LMS_NewPlayerLives();
+       int l = LMS_NewPlayerLives();
 
-       head = find(world, classname, "player");
+       head = find(world, classname, STR_PLAYER);
        if(head)
                have_player = true;
-       head2 = find(head, classname, "player");
+       head2 = find(head, classname, STR_PLAYER);
        if(head2)
                have_players = true;
 
@@ -160,10 +161,9 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_global)
 }
 
 MUTATOR_HOOKFUNCTION(lms, reset_map_players)
-{SELFPARAM();
+{
        if(restart_mapalreadyrestarted || (time < game_starttime))
-       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(WITH(entity, self, it, PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives()))));
-
+       FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(PlayerScore_Add(it, SP_LMS_LIVES, LMS_NewPlayerLives())));
        return false;
 }
 
@@ -173,17 +173,14 @@ MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
        // FIXME fix LMS scoring for new system
        if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
        {
-               self.classname = STR_OBSERVER;
+               TRANSMUTE(Observer, self);
                Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
        }
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, PlayerDies)
-{SELFPARAM();
-       self.respawn_flags |= RESPAWN_FORCE;
-
+{
+       frag_target.respawn_flags |= RESPAWN_FORCE;
        return false;
 }
 
@@ -209,15 +206,16 @@ MUTATOR_HOOKFUNCTION(lms, ClientDisconnect)
 }
 
 MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
-{SELFPARAM();
-       lms_RemovePlayer(self);
-       return false;
+{
+    SELFPARAM();
+       lms_RemovePlayer(this);
+       return true;  // prevent team reset
 }
 
 MUTATOR_HOOKFUNCTION(lms, ClientConnect)
 {SELFPARAM();
-       self.classname = STR_PLAYER;
-       campaign_bots_may_start = 1;
+       TRANSMUTE(Player, self);
+       campaign_bots_may_start = true;
 
        if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
        {
@@ -230,8 +228,8 @@ MUTATOR_HOOKFUNCTION(lms, ClientConnect)
 
 MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
 {SELFPARAM();
-       if(self.deadflag == DEAD_DYING)
-               self.deadflag = DEAD_RESPAWNING;
+       if(this.deadflag == DEAD_DYING)
+               this.deadflag = DEAD_RESPAWNING;
 
        return false;
 }
@@ -300,8 +298,8 @@ MUTATOR_HOOKFUNCTION(lms, FilterItem)
        return true;
 }
 
-void lms_extralife()
-{SELFPARAM();
+void lms_extralife(entity this)
+{
        StartItem(this, ITEM_ExtraLife);
 }
 
@@ -314,7 +312,7 @@ MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
        if (self.classname != "item_health_mega") return false;
 
        entity e = spawn();
-       e.think = lms_extralife;
+       setthink(e, lms_extralife);
 
        e.nextthink = time + 0.1;
        e.spawnflags = self.spawnflags;
@@ -348,6 +346,7 @@ MUTATOR_HOOKFUNCTION(lms, Bot_FixCount, CBC_ORDER_EXCLUSIVE)
 
 MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate)
 {
+    SELFPARAM();
        if(self.lms_spectate_warning)
        {
                // for the forfeit message...