]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/minelayer.qc
Hold weapon clip on the weapon entity
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / minelayer.qc
index f58a8f254927d10b1e4b596f5983b6e593c41c9b..c8d242fa41ea19e8f22c83d460dea9f64d99eafb 100644 (file)
@@ -1,12 +1,13 @@
+#include "minelayer.qh"
 #ifndef IMPLEMENTATION
 CLASS(MineLayer, Weapon)
-/* ammotype  */ ATTRIB(MineLayer, ammo_field, .int, ammo_rockets)
-/* impulse   */ ATTRIB(MineLayer, impulse, int, 4)
+/* ammotype  */ ATTRIB(MineLayer, ammo_field, .int, ammo_rockets);
+/* impulse   */ ATTRIB(MineLayer, impulse, int, 4);
 /* flags     */ ATTRIB(MineLayer, spawnflags, int, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
 /* rating    */ ATTRIB(MineLayer, bot_pickupbasevalue, float, BOT_PICKUP_RATING_HIGH);
 /* color     */ ATTRIB(MineLayer, wpcolor, vector, '0.75 1 0');
 /* modelname */ ATTRIB(MineLayer, mdl, string, "minelayer");
-#ifndef MENUQC
+#ifdef GAMEQC
 /* model     */ ATTRIB(MineLayer, m_model, Model, MDL_MINELAYER_ITEM);
 #endif
 /* crosshair */ ATTRIB(MineLayer, w_crosshair, string, "gfx/crosshairminelayer");
@@ -71,6 +72,7 @@ void W_MineLayer_Stick(entity this, entity to)
 
        entity newmine = spawn();
        IL_PUSH(g_mines, newmine);
+       newmine.weaponentity_fld = this.weaponentity_fld;
        newmine.classname = this.classname;
 
        newmine.bot_dodge = this.bot_dodge;
@@ -103,6 +105,7 @@ void W_MineLayer_Stick(entity this, entity to)
        newmine.cnt = this.cnt;
        newmine.flags = this.flags;
        IL_PUSH(g_projectiles, newmine);
+       IL_PUSH(g_bot_dodge, newmine);
 
        delete(this);
 
@@ -124,17 +127,17 @@ void W_MineLayer_Explode(entity this, entity directhitentity)
 
        RadiusDamage(this, this.realowner, WEP_CVAR(minelayer, damage), WEP_CVAR(minelayer, edgedamage), WEP_CVAR(minelayer, radius), NULL, NULL, WEP_CVAR(minelayer, force), this.projectiledeathtype, directhitentity);
 
-       if(PS(this.realowner).m_weapon == WEP_MINE_LAYER)
+       .entity weaponentity = this.weaponentity_fld;
+       if(this.realowner.(weaponentity).m_weapon == WEP_MINE_LAYER)
        {
                entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w, own))
+               if(!w.wr_checkammo1(w, own, weaponentity))
                {
                        own.cnt = WEP_MINE_LAYER.m_id;
-                       .entity weaponentity = this.weaponentity_fld;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(own, slot) = time;
-                       PS(own).m_switchweapon = w_getbestweapon(own);
+                       own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
        this.realowner.minelayer_mines -= 1;
@@ -156,17 +159,17 @@ void W_MineLayer_DoRemoteExplode(entity this)
 
        RadiusDamage(this, this.realowner, WEP_CVAR(minelayer, remote_damage), WEP_CVAR(minelayer, remote_edgedamage), WEP_CVAR(minelayer, remote_radius), NULL, NULL, WEP_CVAR(minelayer, remote_force), this.projectiledeathtype | HITTYPE_BOUNCE, NULL);
 
-       if(PS(this.realowner).m_weapon == WEP_MINE_LAYER)
+       .entity weaponentity = this.weaponentity_fld;
+       if(this.realowner.(weaponentity).m_weapon == WEP_MINE_LAYER)
        {
                entity own = this.realowner;
                Weapon w = WEP_MINE_LAYER;
-               if(!w.wr_checkammo1(w, own))
+               if(!w.wr_checkammo1(w, own, weaponentity))
                {
                        own.cnt = WEP_MINE_LAYER.m_id;
-                       .entity weaponentity = this.weaponentity_fld;
                        int slot = weaponslot(weaponentity);
                        ATTACK_FINISHED(own, slot) = time;
-                       PS(own).m_switchweapon = w_getbestweapon(own);
+                       own.(weaponentity).m_switchweapon = w_getbestweapon(own, weaponentity);
                }
        }
        this.realowner.minelayer_mines -= 1;
@@ -271,7 +274,8 @@ void W_MineLayer_Think(entity this)
        }
 
        // remote detonation
-       if(PS(this.realowner).m_weapon == WEP_MINE_LAYER)
+       .entity weaponentity = this.weaponentity_fld;
+       if(this.realowner.(weaponentity).m_weapon == WEP_MINE_LAYER)
        if(!IS_DEAD(this.realowner))
        if(this.minelayer_detonate)
                W_MineLayer_RemoteExplode(this);
@@ -334,7 +338,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
                }
        }
 
-       W_DecreaseAmmo(thiswep, actor, WEP_CVAR(minelayer, ammo));
+       W_DecreaseAmmo(thiswep, actor, WEP_CVAR(minelayer, ammo), weaponentity);
 
        W_SetupShot_ProjectileSize(actor, weaponentity, '-4 -4 -4', '4 4 4', false, 5, SND_MINE_FIRE, CH_WEAPON_A, WEP_CVAR(minelayer, damage));
        Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
@@ -372,6 +376,7 @@ void W_MineLayer_Attack(Weapon thiswep, entity actor, .entity weaponentity)
        mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
        mine.flags = FL_PROJECTILE;
        IL_PUSH(g_projectiles, mine);
+       IL_PUSH(g_bot_dodge, mine);
        mine.missile_flags = MIF_SPLASH | MIF_ARC | MIF_PROXY;
 
        if(mine.cnt > 0) { mine.cnt += time; }
@@ -435,7 +440,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
         IL_EACH(g_mines, it.realowner == actor,
         {
                entity mine = it;
-               FOREACH_ENTITY_FLOAT(bot_attack, true,
+               IL_EACH(g_bot_targets, it.bot_attack,
                {
                        float d = vlen(it.origin + (it.mins + it.maxs) * 0.5 - mine.origin);
                        d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000);
@@ -462,7 +467,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
             if(skill > 9) // normal players only do this for the target they are tracking
             {
                    entity mine = it;
-                   FOREACH_ENTITY_FLOAT(bot_attack, true,
+                   IL_EACH(g_bot_targets, it.bot_attack,
                    {
                        if((v_forward * normalize(mine.origin - it.origin) < 0.1)
                            && desirabledamage > 0.1 * coredamage
@@ -498,7 +503,7 @@ METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
 }
 METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
 {
-    if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
+    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
         if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
@@ -520,7 +525,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent
             sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
     }
 }
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
+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
@@ -532,7 +537,7 @@ METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
     //}
     //return true;
 }
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
 {
     if(W_MineLayer_PlacedMines(actor, false))
         return true;