]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/mutators/mutator/gamemode_lms.qc
Kill the ret_string global
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / mutators / mutator / gamemode_lms.qc
index a2f1f2507ed2bdf4d9da74d58dddc89b5bf2730f..4e89f2b27d72a87a210510aa50f0e04fe45499e9 100644 (file)
@@ -13,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
@@ -168,18 +168,22 @@ MUTATOR_HOOKFUNCTION(lms, reset_map_players)
 }
 
 MUTATOR_HOOKFUNCTION(lms, PutClientInServer)
-{SELFPARAM();
+{
+       entity player = M_ARGV(0, entity);
+
        // player is dead and becomes observer
        // FIXME fix LMS scoring for new system
-       if(PlayerScore_Add(self, SP_LMS_RANK, 0) > 0)
+       if(PlayerScore_Add(player, SP_LMS_RANK, 0) > 0)
        {
-               TRANSMUTE(Observer, self);
-               Send_Notification(NOTIF_ONE, self, MSG_CENTER, CENTER_LMS_NOLIVES);
+               TRANSMUTE(Observer, player);
+               Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_LMS_NOLIVES);
        }
 }
 
 MUTATOR_HOOKFUNCTION(lms, PlayerDies)
 {
+       entity frag_target = M_ARGV(2, entity);
+       
        frag_target.respawn_flags |= RESPAWN_FORCE;
        return false;
 }
@@ -200,30 +204,32 @@ void lms_RemovePlayer(entity player)
 }
 
 MUTATOR_HOOKFUNCTION(lms, ClientDisconnect)
-{SELFPARAM();
-       lms_RemovePlayer(self);
-       return false;
+{
+       entity player = M_ARGV(0, entity);
+
+       lms_RemovePlayer(player);
 }
 
 MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver)
 {
-    SELFPARAM();
-       lms_RemovePlayer(this);
+    entity player = M_ARGV(0, entity);
+
+       lms_RemovePlayer(player);
        return true;  // prevent team reset
 }
 
 MUTATOR_HOOKFUNCTION(lms, ClientConnect)
-{SELFPARAM();
-       TRANSMUTE(Player, self);
+{
+       entity player = M_ARGV(0, entity);
+
+       TRANSMUTE(Player, player);
        campaign_bots_may_start = true;
 
-       if(PlayerScore_Add(self, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
+       if(PlayerScore_Add(player, SP_LMS_LIVES, LMS_NewPlayerLives()) <= 0)
        {
-               PlayerScore_Add(self, SP_LMS_RANK, 666);
-               self.frags = FRAGS_SPECTATOR;
+               PlayerScore_Add(player, SP_LMS_RANK, 666);
+               player.frags = FRAGS_SPECTATOR;
        }
-
-       return false;
 }
 
 MUTATOR_HOOKFUNCTION(lms, PlayerPreThink)
@@ -249,6 +255,8 @@ MUTATOR_HOOKFUNCTION(lms, ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
 {
+       entity frag_target = M_ARGV(1, entity);
+
        // remove a life
        float tl;
        tl = PlayerScore_Add(frag_target, SP_LMS_LIVES, -1);
@@ -263,7 +271,7 @@ MUTATOR_HOOKFUNCTION(lms, GiveFragsForKill)
                PlayerScore_Add(frag_target, SP_LMS_RANK, lms_next_place); // won't ever spawn again
                --lms_next_place;
        }
-       frag_score = 0;
+       M_ARGV(2, float) = 0;
 
        return true;
 }
@@ -290,44 +298,51 @@ MUTATOR_HOOKFUNCTION(lms, ForbidPlayerScore_Clear)
 }
 
 MUTATOR_HOOKFUNCTION(lms, FilterItem)
-{SELFPARAM();
+{
+       entity item = M_ARGV(0, entity);
+
        if(autocvar_g_lms_extra_lives)
-       if(self.itemdef == ITEM_ExtraLife)
+       if(item.itemdef == ITEM_ExtraLife)
                return false;
 
        return true;
 }
 
-void lms_extralife()
-{SELFPARAM();
+void lms_extralife(entity this)
+{
        StartItem(this, ITEM_ExtraLife);
 }
 
 MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
-{SELFPARAM();
+{
        if (!autocvar_g_powerups) return false;
        if (!autocvar_g_lms_extra_lives) return false;
 
+       entity ent = M_ARGV(0, entity);
+
        // Can't use .itemdef here
-       if (self.classname != "item_health_mega") return false;
+       if (ent.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;
-       e.noalign = self.noalign;
-       setorigin(e, self.origin);
+       e.spawnflags = ent.spawnflags;
+       e.noalign = ent.noalign;
+       setorigin(e, ent.origin);
 
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(lms, ItemTouch)
-{SELFPARAM();
-       if(self.itemdef == ITEM_ExtraLife)
+{
+       entity item = M_ARGV(0, entity);
+       entity toucher = M_ARGV(1, entity);
+
+       if(item.itemdef == ITEM_ExtraLife)
        {
-               Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
-               PlayerScore_Add(other, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
+               Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_EXTRALIVES);
+               PlayerScore_Add(toucher, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
                return MUT_ITEMTOUCH_PICKUP;
        }
 
@@ -365,14 +380,13 @@ MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate)
 
 MUTATOR_HOOKFUNCTION(lms, CheckRules_World)
 {
-       ret_float = WinningCondition_LMS();
+       M_ARGV(0, float) = WinningCondition_LMS();
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(lms, WantWeapon)
 {
-       want_allguns = true;
-       return false;
+       M_ARGV(2, bool) = true; // all weapons
 }
 
 MUTATOR_HOOKFUNCTION(lms, GetPlayerStatus)
@@ -383,7 +397,7 @@ MUTATOR_HOOKFUNCTION(lms, GetPlayerStatus)
 MUTATOR_HOOKFUNCTION(lms, AddPlayerScore)
 {
        if(gameover)
-       if(score_field == SP_LMS_RANK)
+       if(M_ARGV(0, int) == SP_LMS_RANK) // score field
                return true; // allow writing to this field in intermission as it is needed for newly joining players
        return false;
 }