]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
LMS, g_lms_extra_lives enabled: turn MegaHealth into Extralife powerup (like in Instagib)
authorterencehill <piuntn@gmail.com>
Wed, 11 Nov 2015 20:22:02 +0000 (21:22 +0100)
committerterencehill <piuntn@gmail.com>
Wed, 11 Nov 2015 20:22:02 +0000 (21:22 +0100)
qcsrc/server/mutators/mutator/gamemode_lms.qc

index 9fa7f4739715b39269c9b4e600ee8ce6705a0d69..9843f236958ec352afaf5fe021de3b5816ced855 100644 (file)
@@ -299,22 +299,44 @@ MUTATOR_HOOKFUNCTION(lms, ForbidPlayerScore_Clear)
 MUTATOR_HOOKFUNCTION(lms, FilterItem)
 {SELFPARAM();
        if(autocvar_g_lms_extra_lives)
-       if(self.itemdef == ITEM_HealthMega)
-       {
-               self.max_health = 1;
+       if(self.itemdef == ITEM_ExtraLife)
                return false;
-       }
+
+       return true;
+}
+
+void lms_extralife()
+{SELFPARAM();
+       self.max_health = 1;
+       StartItem(this, ITEM_ExtraLife);
+}
+
+MUTATOR_HOOKFUNCTION(lms, OnEntityPreSpawn)
+{SELFPARAM();
+       if (!autocvar_g_powerups) return false;
+       if (!autocvar_g_lms_extra_lives) return false;
+
+       // Can't use .itemdef here
+       if (self.classname != "item_health_mega") return false;
+
+       entity e = spawn();
+       e.think = lms_extralife;
+
+       e.nextthink = time + 0.1;
+       e.spawnflags = self.spawnflags;
+       e.noalign = self.noalign;
+       setorigin(e, self.origin);
 
        return true;
 }
 
 MUTATOR_HOOKFUNCTION(lms, ItemTouch)
 {SELFPARAM();
-       // give extra lives for mega health
-       if (self.items & ITEM_HealthMega.m_itemid)
+       if(self.max_health)
        {
                Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
                PlayerScore_Add(other, SP_LMS_LIVES, autocvar_g_lms_extra_lives);
+               return MUT_ITEMTOUCH_PICKUP;
        }
 
        return MUT_ITEMTOUCH_CONTINUE;