]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Attempt to implement friend protection (the mine not exploding if it would hurt the...
authorMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 4 Oct 2010 13:58:10 +0000 (16:58 +0300)
committerMircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Mon, 4 Oct 2010 13:58:10 +0000 (16:58 +0300)
qcsrc/server/w_minelayer.qc

index 3127a8169f813057eec02b3c36441a773174b0be..d03ae635e68755e70573e814d23f71339cb03d1c 100644 (file)
@@ -98,10 +98,16 @@ void W_Mine_Think (void)
                return;
        }
 
-       // detect players who are close the mine and explode if the player should detonate it
+       // remote detonation
+       if (self.owner.weapon == WEP_MINE_LAYER)
+       if (self.owner.deadflag == DEAD_NO)
+       if (self.minelayer_detonate)
+               W_Mine_RemoteExplode();
+
        entity head;
-       head = findradius(self.origin, cvar("g_balance_minelayer_detectionradius"));
 
+       // detect players who are close to the mine and explode if anyone should detonate it
+       head = findradius(self.origin, cvar("g_balance_minelayer_detectionradius"));
        while(head)
        {
                if(head.classname == "player" && head.deadflag == DEAD_NO)
@@ -112,22 +118,25 @@ void W_Mine_Think (void)
                        spamsound (self, CHAN_PROJECTILE, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
                        self.mine_time = time + cvar("g_balance_minelayer_time");
                }
+
                head = head.chain;
        }
 
-       // explode if it's time
+       // if it's time for the mine to explode, make sure no friend is in its radius
+       // if an ally is detected, the explosion is delayed until he's at a safe distance
        if(self.mine_time && time >= self.mine_time)
        {
+               head = findradius(self.origin, cvar("g_balance_minelayer_radius"));
+               while(head)
+               {
+                       if(head == self.owner || !IsDifferentTeam(head, self.owner))
+                               return;
+                       head = head.chain;
+               }
                self.mine_time = 0;
                W_Mine_Explode();
        }
 
-       // remote detonation
-       if (self.owner.weapon == WEP_MINE_LAYER)
-       if (self.owner.deadflag == DEAD_NO)
-       if (self.minelayer_detonate)
-               W_Mine_RemoteExplode();
-
        if(self.csqcprojectile_clientanimate == 0)
                UpdateCSQCProjectile(self);
 }