]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/g_lms_extra_lives' into 'master'
authorMario <zacjardine@y7mail.com>
Sun, 15 Nov 2015 22:53:01 +0000 (22:53 +0000)
committerMario <zacjardine@y7mail.com>
Sun, 15 Nov 2015 22:53:01 +0000 (22:53 +0000)
Extralife for g_lms_extra_lives

See merge request !252

qcsrc/common/mutators/mutator/instagib/instagib.qc
qcsrc/server/mutators/mutator/gamemode_lms.qc

index 1810734c64b36d46e36a9f4b401e9eb7769c3244..6f35817149af1fc753a52b9691d95c5c93721d14 100644 (file)
@@ -37,7 +37,6 @@ void instagib_invisibility()
 
 void instagib_extralife()
 {SELFPARAM();
-       self.max_health = 1;
        StartItem(this, ITEM_ExtraLife);
 }
 
@@ -431,7 +430,7 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ItemTouch)
                return MUT_ITEMTOUCH_CONTINUE;
        }
 
-       if(self.max_health)
+       if(self.itemdef == ITEM_ExtraLife)
        {
                other.armorvalue = bound(other.armorvalue, 999, other.armorvalue + autocvar_g_instagib_extralives);
                Send_Notification(NOTIF_ONE, other, MSG_CENTER, CENTER_EXTRALIVES);
index 9fa7f4739715b39269c9b4e600ee8ce6705a0d69..575bc69040474805daee2fef54347a3887dd6f3e 100644 (file)
@@ -299,22 +299,43 @@ 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();
+       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.itemdef == ITEM_ExtraLife)
        {
                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;