]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/minelayer.qc
Use the weapon entity as a parameter to ATTACK_FINISHED instead of the slot number...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / minelayer.qc
index bf1221bc32a6e21bb666086c129be12a4eda1f5d..6063c666eb5093b0aea9ba9af3b17730948f342d 100644 (file)
@@ -74,12 +74,10 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(own, slot) = time;
+                       ATTACK_FINISHED(own, weaponentity) = time;
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
-       this.realowner.(weaponentity).minelayer_mines -= 1;
        delete(this);
 }
 
@@ -107,12 +105,10 @@ void W_MineLayer_DoRemoteExplode(entity this)
                if(!thiswep.wr_checkammo1(thiswep, own, weaponentity))
                {
                        own.cnt = thiswep.m_id;
-                       int slot = weaponslot(weaponentity);
-                       ATTACK_FINISHED(own, slot) = time;
+                       ATTACK_FINISHED(own, weaponentity) = time;
                        own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
-       this.realowner.(weaponentity).minelayer_mines -= 1;
        delete(this);
 }
 
@@ -226,15 +222,7 @@ void W_MineLayer_Touch(entity this, entity toucher)
        if(this.move_movetype == MOVETYPE_NONE || this.move_movetype == MOVETYPE_FOLLOW)
                return; // we're already a stuck mine, why do we get called? TODO does this even happen?
 
-       if(WarpZone_Projectile_Touch(this, toucher))
-       {
-               if(wasfreed(this))
-               {
-                       .entity weaponentity = this.weaponentity_fld;
-                       this.realowner.(weaponentity).minelayer_mines -= 1;
-               }
-               return;
-       }
+       PROJECTILE_TOUCH(this, toucher);
 
        if((toucher && IS_PLAYER(toucher) && !IS_DEAD(toucher)) || toucher.owner == this.owner)
        {
@@ -272,7 +260,8 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        // scan how many mines we placed, and return if we reached our limit
        if(WEP_CVAR(minelayer, limit))
        {
-               if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit))
+               int minecount = W_MineLayer_Count(actor, weaponentity);
+               if(minecount >= WEP_CVAR(minelayer, limit))
                {
                        // the refire delay keeps this message from being spammed
                        Send_Notification(NOTIF_ONE, actor, MSG_MULTI, WEAPON_MINELAYER_LIMIT, WEP_CVAR(minelayer, limit));
@@ -338,8 +327,6 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        // common properties
 
        MUTATOR_CALLHOOK(EditProjectile, actor, mine);
-
-       actor.(weaponentity).minelayer_mines = W_MineLayer_Count(actor, weaponentity);
 }
 
 bool W_MineLayer_PlacedMines(entity this, .entity weaponentity, bool detonate)
@@ -365,7 +352,8 @@ bool W_MineLayer_PlacedMines(entity this, .entity weaponentity, bool detonate)
 METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
 {
     // aim and decide to fire if appropriate
-    if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit))
+    int minecount = W_MineLayer_Count(actor, weaponentity);
+    if(minecount >= WEP_CVAR(minelayer, limit))
         PHYS_INPUT_BUTTON_ATCK(actor) = false;
     else
         PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false);
@@ -448,6 +436,8 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentit
 }
 METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
+       actor.(weaponentity).minelayer_mines = W_MineLayer_Count(actor, weaponentity);
+
     if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
     {
         // not if we're holding the minelayer without enough ammo, but can detonate existing mines
@@ -472,9 +462,8 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
 }
 METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
 {
-    //int slot = 0; // TODO: unhardcode
     // actually do // don't switch while placing a mine
-    //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
+    //if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
     //{
         float ammo_amount = GetResourceAmount(actor, thiswep.ammo_type) >= WEP_CVAR(minelayer, ammo);
         ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(minelayer, ammo);