]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/minelayer.qc
Merge branch 'master' into TimePath/debug_draw
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / minelayer.qc
index 0ecc4b73f45697c2143e694da12f71e6ea2a5734..4ea2e94617c02c110015906560ea4654f486f775 100644 (file)
@@ -13,7 +13,7 @@ CLASS(MineLayer, Weapon)
 /* crosshair */ ATTRIB(MineLayer, w_crosshair_size, float, 0.9);
 /* wepimg    */ ATTRIB(MineLayer, model2, string, "weaponminelayer");
 /* refname   */ ATTRIB(MineLayer, netname, string, "minelayer");
-/* wepname   */ ATTRIB(MineLayer, message, string, _("Mine Layer"));
+/* wepname   */ ATTRIB(MineLayer, m_name, string, _("Mine Layer"));
 ENDCLASS(MineLayer)
 REGISTER_WEAPON(MINE_LAYER, NEW(MineLayer));
 
@@ -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(this, WEP_MINE_LAYER); }
 
 void W_MineLayer_Stick(entity to)
 {SELFPARAM();
@@ -67,8 +67,7 @@ void W_MineLayer_Stick(entity to)
 
        // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
 
-       entity newmine;
-       newmine = spawn();
+       entity newmine = spawn();
        newmine.classname = self.classname;
 
        newmine.bot_dodge = self.bot_dodge;
@@ -129,7 +128,8 @@ void W_MineLayer_Explode(void)
                if(!w.wr_checkammo1(w))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
-                       ATTACK_FINISHED(self) = time;
+                       int slot = 0; // TODO: unhardcode
+                       ATTACK_FINISHED(self, slot) = time;
                        self.switchweapon = w_getbestweapon(self);
                }
                setself(this);
@@ -155,7 +155,8 @@ void W_MineLayer_DoRemoteExplode(void)
                if(!w.wr_checkammo1(w))
                {
                        self.cnt = WEP_MINE_LAYER.m_id;
-                       ATTACK_FINISHED(self) = time;
+                       int slot = 0; // TODO: unhardcode
+                       ATTACK_FINISHED(self, slot) = time;
                        self.switchweapon = w_getbestweapon(self);
                }
                setself(this);
@@ -325,7 +326,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);
@@ -371,7 +372,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
 
@@ -401,7 +402,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))
@@ -498,45 +499,41 @@ 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))) {
-                                       Weapon w = get_weaponinfo(self.weapon);
+                               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(false, WEP_CVAR(minelayer, refire)))
+                               if(weapon_prepareattack(thiswep, actor, slot, false, WEP_CVAR(minelayer, refire)))
                                {
                                        W_MineLayer_Attack(thiswep);
-                                       weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
+                                       weapon_thinkf(actor, slot, 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))
                {
+                       int slot = 0; // TODO: unhardcode
                        // don't switch while placing a mine
-                       if(ATTACK_FINISHED(self) <= time || self.weapon != WEP_MINE_LAYER.m_id)
+                       if(ATTACK_FINISHED(self, slot) <= time || self.weapon != WEP_MINE_LAYER.m_id)
                        {
                                float ammo_amount = self.WEP_AMMO(MINE_LAYER) >= WEP_CVAR(minelayer, ammo);
                                ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
@@ -551,26 +548,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;
                }
@@ -578,24 +572,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