]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
If health or armor are above set limits, send items to piggybacker
authorMario <zacjardine@y7mail.com>
Sat, 7 Feb 2015 17:17:16 +0000 (04:17 +1100)
committerMario <zacjardine@y7mail.com>
Sat, 7 Feb 2015 17:17:16 +0000 (04:17 +1100)
qcsrc/server/mutators/mutator_piggyback.qc

index ea8cbfad3f4d63334865a0112af2204aff30cd58..f596dbfa0a2d110061f797b9c806edbaf75078ad 100644 (file)
@@ -251,11 +251,12 @@ MUTATOR_HOOKFUNCTION(pb_PlayerDies)
 
 MUTATOR_HOOKFUNCTION(pb_ItemTouch)
 {
+       entity p = other;
        if(self.weapon)
        if(other.piggybacker)
        if(other.weapons & self.weapons)
        {
-               entity p = other;
+               p = other;
                while(p.piggybacker)
                {
                        p = p.piggybacker;
@@ -267,6 +268,40 @@ MUTATOR_HOOKFUNCTION(pb_ItemTouch)
                }
        }
 
+       if(self.health || self.armorvalue)
+       if(other.piggybacker)
+       {
+               if(self.health)
+               if(other.health > start_health)
+               {
+                       p = other;
+                       while(p.piggybacker)
+                       {
+                               p = p.piggybacker;
+                               if(p.health < start_health)
+                               {
+                                       other = p;
+                                       break;
+                               }
+                       }
+               }
+
+               if(self.armorvalue)
+               if(other.armorvalue > 50) // can't use start value here, as players don't start with armor
+               {
+                       p = other;
+                       while(p.piggybacker)
+                       {
+                               p = p.piggybacker;
+                               if(p.armorvalue < 50)
+                               {
+                                       other = p;
+                                       break;
+                               }
+                       }
+               }
+       }
+
        return false;
 }