/* 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));
#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();
// 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;
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;
+ int slot = 0; // TODO: unhardcode
+ ATTACK_FINISHED(self, slot) = time;
self.switchweapon = w_getbestweapon(self);
}
setself(this);
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;
+ int slot = 0; // TODO: unhardcode
+ ATTACK_FINISHED(self, slot) = time;
self.switchweapon = w_getbestweapon(self);
}
setself(this);
W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode);
}
-void W_MineLayer_Attack(void)
+void W_MineLayer_Attack(Weapon thiswep)
{SELFPARAM();
entity mine;
entity flash;
}
}
- W_DecreaseAmmo(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);
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
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))
// 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, slot, false, WEP_CVAR(minelayer, refire)))
{
- W_MineLayer_Attack();
- weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
+ W_MineLayer_Attack(thiswep);
+ 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);
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;
}
#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