]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/minelayer.qc
Weapons: pass weapon index
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / minelayer.qc
index fb2cdc850d6a1eba56014c6fed488b40cd371159..abed99b8d059aee66eb887899c7b2839cbad8032 100644 (file)
@@ -59,7 +59,7 @@ void W_MineLayer_Think(void);
 #endif
 #ifdef IMPLEMENTATION
 #ifdef SVQC
-void spawnfunc_weapon_minelayer(void) { weapon_defaultspawnfunc(WEP_MINE_LAYER.m_id); }
+spawnfunc(weapon_minelayer) { weapon_defaultspawnfunc(WEP_MINE_LAYER.m_id); }
 
 void W_MineLayer_Stick(entity to)
 {SELFPARAM();
@@ -125,7 +125,8 @@ void W_MineLayer_Explode(void)
        if(self.realowner.weapon == WEP_MINE_LAYER.m_id)
        {
                setself(self.realowner);
-               if(!WEP_ACTION(WEP_MINE_LAYER, WR_CHECKAMMO1))
+               Weapon w = WEP_MINE_LAYER;
+               if(!w.wr_checkammo1(w))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
                        ATTACK_FINISHED(self) = time;
@@ -150,7 +151,8 @@ void W_MineLayer_DoRemoteExplode(void)
        if(self.realowner.weapon == WEP_MINE_LAYER.m_id)
        {
                setself(self.realowner);
-               if(!WEP_ACTION(WEP_MINE_LAYER, WR_CHECKAMMO1))
+               Weapon w = WEP_MINE_LAYER;
+               if(!w.wr_checkammo1(w))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
                        ATTACK_FINISHED(self) = time;
@@ -323,7 +325,7 @@ void W_MineLayer_Attack(Weapon thiswep)
                }
        }
 
-       W_DecreaseAmmo(thiswep, WEP_CVAR(minelayer, ammo));
+       W_DecreaseAmmo(thiswep, self, WEP_CVAR(minelayer, ammo));
 
        W_SetupShot_ProjectileSize(self, '-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);
@@ -369,7 +371,7 @@ void W_MineLayer_Attack(Weapon thiswep)
        setmodel(flash, MDL_MINELAYER_MUZZLEFLASH); // precision set below
        SUB_SetFade(flash, time, 0.1);
        flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
-       W_AttachToShotorg(flash, '5 0 0');
+       W_AttachToShotorg(self, flash, '5 0 0');
 
        // common properties
 
@@ -399,7 +401,7 @@ float W_MineLayer_PlacedMines(float detonate)
        return minfound;
 }
 
-               METHOD(MineLayer, wr_aim, bool(entity thiswep))
+               METHOD(MineLayer, wr_aim, void(entity thiswep))
                {
                        // aim and decide to fire if appropriate
                        if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
@@ -496,38 +498,35 @@ float W_MineLayer_PlacedMines(float detonate)
                                //      dprint(ftos(desirabledamage),"\n");
                                if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false;
                        }
-
-                       return true;
                }
-               METHOD(MineLayer, wr_think, bool(entity thiswep, bool fire1, bool fire2))
+               METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, int slot, int fire))
                {
-                       if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
+                       if(autocvar_g_balance_minelayer_reload_ammo && actor.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(false) && self.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo)))
-                                       _WEP_ACTION(self.weapon, WR_RELOAD);
+                               if(!(W_MineLayer_PlacedMines(false) && actor.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo))) {
+                                       Weapon w = get_weaponinfo(actor.weapon);
+                                       w.wr_reload(w);
+                               }
                        }
-                       else if(fire1)
+                       else if(fire & 1)
                        {
-                               if(weapon_prepareattack(0, WEP_CVAR(minelayer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(minelayer, refire)))
                                {
                                        W_MineLayer_Attack(thiswep);
-                                       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
+                                       weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
                                }
                        }
 
-                       if(fire2)
+                       if(fire & 2)
                        {
                                if(W_MineLayer_PlacedMines(true))
-                                       sound(self, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
+                                       sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
                        }
-
-                       return true;
                }
-               METHOD(MineLayer, wr_init, bool(entity thiswep))
+               METHOD(MineLayer, wr_init, void(entity thiswep))
                {
                        MINELAYER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
-                       return true;
                }
                METHOD(MineLayer, wr_checkammo1, bool(entity thiswep))
                {
@@ -547,26 +546,23 @@ float W_MineLayer_PlacedMines(float detonate)
                        else
                                return false;
                }
-               METHOD(MineLayer, wr_config, bool(entity thiswep))
+               METHOD(MineLayer, wr_config, void(entity thiswep))
                {
                        MINELAYER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
-                       return true;
                }
-               METHOD(MineLayer, wr_resetplayers, bool(entity thiswep))
+               METHOD(MineLayer, wr_resetplayers, void(entity thiswep))
                {
                        self.minelayer_mines = 0;
-                       return true;
                }
-               METHOD(MineLayer, wr_reload, bool(entity thiswep))
+               METHOD(MineLayer, wr_reload, void(entity thiswep))
                {
-                       W_Reload(WEP_CVAR(minelayer, ammo), SND(RELOAD));
-                       return true;
+                       W_Reload(self, WEP_CVAR(minelayer, ammo), SND(RELOAD));
                }
-               METHOD(MineLayer, wr_suicidemessage, bool(entity thiswep))
+               METHOD(MineLayer, wr_suicidemessage, int(entity thiswep))
                {
                        return WEAPON_MINELAYER_SUICIDE;
                }
-               METHOD(MineLayer, wr_killmessage, bool(entity thiswep))
+               METHOD(MineLayer, wr_killmessage, int(entity thiswep))
                {
                        return WEAPON_MINELAYER_MURDER;
                }
@@ -574,24 +570,13 @@ float W_MineLayer_PlacedMines(float detonate)
 #endif
 #ifdef CSQC
 
-               METHOD(MineLayer, wr_impacteffect, bool(entity thiswep))
+               METHOD(MineLayer, wr_impacteffect, void(entity thiswep))
                {
                        vector org2;
                        org2 = w_org + w_backoff * 12;
                        pointparticles(particleeffectnum(EFFECT_ROCKET_EXPLODE), org2, '0 0 0', 1);
                        if(!w_issilent)
                                sound(self, CH_SHOTS, SND_MINE_EXP, VOL_BASE, ATTN_NORM);
-
-                       return true;
-               }
-               METHOD(MineLayer, wr_init, bool(entity thiswep))
-               {
-                       return true;
-               }
-               METHOD(MineLayer, wr_zoomreticle, bool(entity thiswep))
-               {
-                       // no weapon specific image for this weapon
-                       return false;
                }
 
 #endif