]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move pinata to the mutator system
authorMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 01:48:47 +0000 (11:48 +1000)
committerMario <mario.mario@y7mail.com>
Thu, 6 Jun 2013 01:48:47 +0000 (11:48 +1000)
qcsrc/server/cl_player.qc
qcsrc/server/defs.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/mutators/mutator_pinata.qc [new file with mode: 0644]
qcsrc/server/mutators/mutators.qh
qcsrc/server/progs.src
qcsrc/server/teamplay.qc

index 68a2de343901fba60b3c926e7a9a42121cc68e69..5eb8247c2aa7bb8ebe42877717015deb39be1760 100644 (file)
@@ -262,22 +262,9 @@ void player_anim (void)
 
 void SpawnThrownWeapon (vector org, float w)
 {
-       if(g_pinata)
-       {
-               float j;
-               for(j = WEP_FIRST; j <= WEP_LAST; ++j)
-               {
-                       if(WEPSET_CONTAINS_EW(self, j))
-                               if(W_IsWeaponThrowable(j))
-                                       W_ThrowNewWeapon(self, j, FALSE, org, randomvec() * 175 + '0 0 325');
-               }
-       }
-       else
-       {
-               if(WEPSET_CONTAINS_EW(self, self.weapon))
-                       if(W_IsWeaponThrowable(self.weapon))
-                               W_ThrowNewWeapon(self, self.weapon, FALSE, org, randomvec() * 125 + '0 0 200');
-       }
+       if(WEPSET_CONTAINS_EW(self, self.weapon))
+               if(W_IsWeaponThrowable(self.weapon))
+                       W_ThrowNewWeapon(self, self.weapon, FALSE, org, randomvec() * 125 + '0 0 200');
 }
 
 void PlayerCorpseDamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
index 7d3585725d2544ecd4dab000d907c51cbab6354e..d3490a209106ef59faab7905ee68c5b769ae1083 100644 (file)
@@ -16,7 +16,7 @@ noref float require_spawnfunc_prefix; // if this float exists, only functions wi
 
 // Globals
 
-float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_pinata, g_norecoil, g_bloodloss;
+float g_cloaked, g_footsteps, g_jump_grunt, g_grappling_hook, g_midair, g_minstagib, g_norecoil, g_bloodloss;
 float g_warmup_limit;
 float g_warmup_allguns;
 float g_warmup_allow_timeout;
index f69b133213f50666be3099491ce665f7f9767abf..61c96e14c6653a007c66104e4a00b91f049fe61b 100644 (file)
@@ -767,7 +767,6 @@ void readplayerstartcvars()
 
        if (g_weaponarena)
        {
-               g_pinata = 0; // incompatible
                g_weapon_stay = 0; // incompatible
                WEPSET_COPY_AA(start_weapons, g_weaponarena_weapons);
                start_items |= IT_UNLIMITED_AMMO;
@@ -919,6 +918,7 @@ void readlevelcvars(void)
        CHECK_MUTATOR_ADD("g_rocket_flying", mutator_rocketflying, !cvar("g_minstagib"));
        CHECK_MUTATOR_ADD("g_vampire", mutator_vampire, !cvar("g_minstagib"));
        CHECK_MUTATOR_ADD("g_superspectate", mutator_superspec, 1);
+       CHECK_MUTATOR_ADD("g_pinata", mutator_pinata, !cvar("g_minstagib"));
        CHECK_MUTATOR_ADD("g_sandbox", sandbox, 1);
        
        #undef CHECK_MUTATOR_ADD
@@ -1029,8 +1029,6 @@ void readlevelcvars(void)
        g_pickup_ammo_anyway = cvar("g_pickup_ammo_anyway");
        g_pickup_weapons_anyway = cvar("g_pickup_weapons_anyway");
 
-       g_pinata = cvar("g_pinata");
-
     g_weapon_stay = cvar(strcat("g_", GetGametype(), "_weapon_stay"));
     if(!g_weapon_stay)
         g_weapon_stay = cvar("g_weapon_stay");
diff --git a/qcsrc/server/mutators/mutator_pinata.qc b/qcsrc/server/mutators/mutator_pinata.qc
new file mode 100644 (file)
index 0000000..e32c08a
--- /dev/null
@@ -0,0 +1,32 @@
+MUTATOR_HOOKFUNCTION(pinata_PlayerDies)
+{
+       float j;
+       for(j = WEP_FIRST; j <= WEP_LAST; ++j)
+       if(WEPSET_CONTAINS_EW(self, j))
+       if(self.switchweapon != j)
+       if(W_IsWeaponThrowable(j))
+               W_ThrowNewWeapon(self, j, FALSE, self.origin + (self.mins + self.maxs) * 0.5, randomvec() * 175 + '0 0 325');
+               
+       return TRUE;
+}
+
+MUTATOR_HOOKFUNCTION(pinata_BuildMutatorsString)
+{
+       ret_string = strcat(ret_string, ":Pinata");
+       return FALSE;
+}
+
+MUTATOR_HOOKFUNCTION(pinata_BuildMutatorsPrettyString)
+{
+       ret_string = strcat(ret_string, ", Piñata");
+       return FALSE;
+}
+
+MUTATOR_DEFINITION(mutator_pinata)
+{
+       MUTATOR_HOOK(PlayerDies, pinata_PlayerDies, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsString, pinata_BuildMutatorsString, CBC_ORDER_ANY);
+       MUTATOR_HOOK(BuildMutatorsPrettyString, pinata_BuildMutatorsPrettyString, CBC_ORDER_ANY);
+
+       return FALSE;
+}
index 3f9f020affc086c1968fbe80a2bfc64bd9a3d5e3..2cf318b203a9535df5f53e68f24864a9cee4632f 100644 (file)
@@ -21,5 +21,6 @@ MUTATOR_DECLARATION(mutator_vampire);
 MUTATOR_DECLARATION(mutator_superspec);
 MUTATOR_DECLARATION(mutator_minstagib);
 MUTATOR_DECLARATION(mutator_touchexplode);
+MUTATOR_DECLARATION(mutator_pinata);
 
 MUTATOR_DECLARATION(sandbox);
index df5623f0535a42bd3c5b1a4b04baa0b516aa57b8..95906022c2e70c163fb7409e577675ab6ee35e3a 100644 (file)
@@ -248,6 +248,7 @@ mutators/sandbox.qc
 mutators/mutator_superspec.qc
 mutators/mutator_minstagib.qc
 mutators/mutator_touchexplode.qc
+mutators/mutator_pinata.qc
 
 ../warpzonelib/anglestransform.qc
 ../warpzonelib/mathlib.qc
index 0ba1e7c8481db848019a0f856fdf70ee236e0b32..031151674fed560f9c72e8214f306afb2dd6381f 100644 (file)
@@ -288,8 +288,6 @@ string getwelcomemessage(void)
                modifications = strcat(modifications, ", Hook");
        if(g_midair)
                modifications = strcat(modifications, ", Midair");
-       if(g_pinata)
-               modifications = strcat(modifications, ", Piñata");
        if(g_weapon_stay && !g_cts)
                modifications = strcat(modifications, ", Weapons stay");
        if(g_bloodloss > 0)