]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_minelayer.qc
Mines only have their lanching speed, so don't keep two speed cvars
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_minelayer.qc
index 681925ba563697e8eecdcaf47fe4949a56b7099c..31091d3f99bb974949f208f6d2b324a5a0a15629 100644 (file)
@@ -1,5 +1,10 @@
+/*TODO list (things left to do before this weapon should be ready, delete once it's all done):
+- The weapon currently uses sounds and models from other weapons. We need a modeler and sound artist to make this weapon its own (the gun model should probably be something between the porto and rocket launcher design-wise).
+- The mine model needs to face properly when it sticks to a surface. Once we'll have a correct mine model, we can't afford the model facing any way it falls to the ground. Should probably look at the porto code to see how portals face in the right direction when sticking to walls. 
+*/
+
 #ifdef REGISTER_WEAPON
-REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 9, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "minelayer", "minelayer", "Mine Layer");
+REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 4, WEP_FLAG_NORMAL | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "minelayer", "minelayer", "Mine Layer");
 #else
 #ifdef SVQC
 .float minelayer_detonate;
@@ -79,8 +84,29 @@ void W_Mine_RemoteExplode()
        }
 }
 
+void W_Mine_ProximityExplode()
+{
+       // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
+       if(cvar("g_balance_minelayer_protection"))
+       {
+               entity head;
+               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();
+}
+
 void W_Mine_Think (void)
 {
+       entity head;
+
        self.nextthink = time;
        if (time > self.cnt)
        {
@@ -90,28 +116,23 @@ void W_Mine_Think (void)
                return;
        }
 
-       // detect players who are close the mine and explode if the player should detonate it
-       entity head;
+       // set the mine for detonation when a foe gets too close
        head = findradius(self.origin, cvar("g_balance_minelayer_detectionradius"));
-
        while(head)
        {
                if(head.classname == "player" && head.deadflag == DEAD_NO)
-               if(head != self.owner)
-               if(IsDifferentTeam(head, self.owner)) // don't detonate for team mates
+               if(head != self.owner && IsDifferentTeam(head, self.owner)) // don't trigger for team mates
                if(!self.mine_time)
                {
+                       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
+       // explode if it's time to
        if(self.mine_time && time >= self.mine_time)
-       {
-               self.mine_time = 0;
-               W_Mine_Explode();
-       }
+               W_Mine_ProximityExplode();
 
        // remote detonation
        if (self.owner.weapon == WEP_MINE_LAYER)
@@ -126,9 +147,13 @@ void W_Mine_Think (void)
 void W_Mine_Touch (void)
 {
        PROJECTILE_TOUCH;
-       spamsound (self, CHAN_PROJECTILE, "weapons/mine_stick.wav", VOL_BASE, ATTN_NORM);
-       self.movetype = MOVETYPE_NONE; // lock the mine in place
-       // TODO: make sure this doesn't cause the mine to get stuck in the air if it falls over a moving entity
+       if(!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))
+       {
+               spamsound (self, CHAN_PROJECTILE, "weapons/mine_stick.wav", VOL_BASE, ATTN_NORM);
+               self.movetype = MOVETYPE_NONE; // lock the mine in place
+       }
+       else if(self.movetype != MOVETYPE_NONE) // don't unstick a locked mine when someone touches it
+               self.velocity = '0 0 0';
 }
 
 void W_Mine_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
@@ -191,7 +216,7 @@ void W_Mine_Attack (void)
        setsize (mine, '-4 -4 -4', '4 4 4'); // give it some size so it can be shot
 
        setorigin (mine, w_shotorg - v_forward * 4); // move it back so it hits the wall at the right point
-       W_SetupProjectileVelocity(mine, cvar("g_balance_minelayer_speedstart"), 0);
+       W_SetupProjectileVelocity(mine, cvar("g_balance_minelayer_speed"), 0);
        mine.angles = vectoangles (mine.velocity);
 
        mine.touch = W_Mine_Touch;
@@ -348,6 +373,7 @@ float w_minelayer(float req)
                precache_sound ("weapons/mine_det.wav");
                precache_sound ("weapons/mine_fire.wav");
                precache_sound ("weapons/mine_stick.wav");
+               precache_sound ("weapons/mine_trigger.wav");
        }
        else if (req == WR_SETUP)
        {