]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix powerups
authorMario <mario.mario@y7mail.com>
Tue, 9 Apr 2013 01:35:40 +0000 (11:35 +1000)
committerMario <mario.mario@y7mail.com>
Tue, 9 Apr 2013 01:35:40 +0000 (11:35 +1000)
qcsrc/server/autocvars.qh
qcsrc/server/mutators/mutator_minstagib.qc

index 73e071af017882a8f1e4e805eefd5abcedb51ed6..1febc23d26801842d3f916d02357612009789d63 100644 (file)
@@ -889,7 +889,7 @@ float autocvar_g_maxspeed;
 float autocvar_g_midair_shieldtime;
 #define autocvar_g_minstagib cvar("g_minstagib")
 float autocvar_g_minstagib_ammo_drop;
-//float autocvar_g_minstagib_extralives;
+float autocvar_g_minstagib_extralives;
 float autocvar_g_minstagib_speed_highspeed;
 #define autocvar_g_mirrordamage cvar("g_mirrordamage")
 #define autocvar_g_mirrordamage_virtual cvar("g_mirrordamage_virtual")
index 3a4bbfffdc2f57bd9702655bd92934eef425c2ed..980f2d53b6a0c614536a1d31b52c698d405c0d7e 100644 (file)
@@ -9,6 +9,14 @@ void spawnfunc_item_minst_cells (void)
                           "MinstaNex Ammo", IT_CELLS, 0, 0, generic_pickupevalfunc, 100);
 }
 
+void minstagib_health_mega()
+{
+       self.max_health = 1;
+       StartItem ("models/items/g_h100.md3",
+                          "misc/megahealth.wav", g_pickup_respawntime_powerup, g_pickup_respawntimejitter_powerup,
+                          "Extralife", IT_NAILS, 0, FL_POWERUP, generic_pickupevalfunc, BOT_PICKUP_RATING_HIGH);
+}
+
 .float minstagib_nextthink;
 .float minstagib_needammo;
 void minstagib_stop_countdown(entity e)
@@ -336,10 +344,40 @@ MUTATOR_HOOKFUNCTION(minstagib_GiveItem)
                        
                player_pickedup = TRUE;
        }
+       
+       if(giveitem.max_health)
+       {
+               giveplayer.armorvalue = bound(giveplayer.armorvalue, 999, giveplayer.armorvalue + autocvar_g_minstagib_extralives);
+               sprint(giveplayer, "^3You picked up some extra lives\n");
+               player_pickedup = TRUE;
+       }
                
        return TRUE;
 }
 
+MUTATOR_HOOKFUNCTION(minstagib_OnEntityPreSpawn)
+{
+       if not(autocvar_g_powerups) { return FALSE; }
+       if not(self.classname == "item_strength" || self.classname == "item_invincible" || self.classname == "item_health_mega")
+               return FALSE;
+       
+       entity e = spawn();
+       
+       if(random() < 0.3)
+               e.think = spawnfunc_item_strength;
+       else if(random() < 0.6)
+               e.think = minstagib_health_mega;
+       else
+               e.think = spawnfunc_item_invincible;
+               
+       e.nextthink = time + 0.1;
+       e.spawnflags = self.spawnflags;
+       e.noalign = self.noalign;
+       setorigin(e, self.origin);
+       
+       return TRUE;
+}
+
 MUTATOR_HOOKFUNCTION(minstagib_BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":MinstaGib");
@@ -368,6 +406,7 @@ MUTATOR_DEFINITION(mutator_minstagib)
        MUTATOR_HOOK(PlayerPowerups, minstagib_PlayerPowerups, CBC_ORDER_ANY);
        MUTATOR_HOOK(ForbidThrowCurrentWeapon, minstagib_ForbidThrowing, CBC_ORDER_ANY);
        MUTATOR_HOOK(PlayerPreThink, minstagib_PlayerPreThink, CBC_ORDER_ANY);
+       MUTATOR_HOOK(OnEntityPreSpawn, minstagib_OnEntityPreSpawn, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsString, minstagib_BuildMutatorsString, CBC_ORDER_ANY);
        MUTATOR_HOOK(BuildMutatorsPrettyString, minstagib_BuildMutatorsPrettyString, CBC_ORDER_ANY);