#ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id */ CRYLINK,
-/* function */ W_Crylink,
-/* ammotype */ ammo_cells,
-/* impulse */ 6,
-/* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
-/* rating */ BOT_PICKUP_RATING_MID,
-/* color */ '1 0.5 1',
-/* modelname */ "crylink",
-/* simplemdl */ "foobar",
-/* crosshair */ "gfx/crosshaircrylink 0.5",
-/* wepimg */ "weaponcrylink",
-/* refname */ "crylink",
-/* wepname */ _("Crylink")
-);
+CLASS(Crylink, Weapon)
+/* ammotype */ ATTRIB(Crylink, ammo_field, .int, ammo_cells)
+/* impulse */ ATTRIB(Crylink, impulse, int, 6)
+/* flags */ ATTRIB(Crylink, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH);
+/* rating */ ATTRIB(Crylink, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color */ ATTRIB(Crylink, wpcolor, vector, '1 0.5 1');
+/* modelname */ ATTRIB(Crylink, mdl, string, "crylink");
+#ifndef MENUQC
+/* model */ ATTRIB(Crylink, m_model, Model, MDL_CRYLINK_ITEM);
+#endif
+/* crosshair */ ATTRIB(Crylink, w_crosshair, string, "gfx/crosshaircrylink");
+/* crosshair */ ATTRIB(Crylink, w_crosshair_size, float, 0.5);
+/* wepimg */ ATTRIB(Crylink, model2, string, "weaponcrylink");
+/* refname */ ATTRIB(Crylink, netname, string, "crylink");
+/* wepname */ ATTRIB(Crylink, message, string, _("Crylink"));
+ENDCLASS(Crylink)
+REGISTER_WEAPON(CRYLINK, NEW(Crylink));
#define CRYLINK_SETTINGS(w_cvar,w_prop) CRYLINK_SETTINGS_LIST(w_cvar, w_prop, CRYLINK, crylink)
#define CRYLINK_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
}
void W_Crylink_Reset(void)
-{
+{SELFPARAM();
W_Crylink_Dequeue(self);
remove(self);
}
}
void W_Crylink_LinkJoinEffect_Think(void)
-{
+{SELFPARAM();
// is there at least 2 projectiles very close?
entity e, p;
float n;
// NO bounce protection, as bounces are limited!
void W_Crylink_Touch(void)
-{
+{SELFPARAM();
float finalhit;
float f;
float isprimary = !(self.projectiledeathtype & HITTYPE_SECONDARY);
}
void W_Crylink_Fadethink(void)
-{
+{SELFPARAM();
W_Crylink_Dequeue(self);
remove(self);
}
-void W_Crylink_Attack(void)
-{
+void W_Crylink_Attack(Weapon thiswep)
+{SELFPARAM();
float counter, shots;
entity proj, prevproj, firstproj;
vector s;
vector forward, right, up;
float maxdmg;
- W_DecreaseAmmo(WEP_CVAR_PRI(crylink, ammo));
+ W_DecreaseAmmo(thiswep, WEP_CVAR_PRI(crylink, ammo));
maxdmg = WEP_CVAR_PRI(crylink, damage) * WEP_CVAR_PRI(crylink, shots);
maxdmg *= 1 + WEP_CVAR_PRI(crylink, bouncedamagefactor) * WEP_CVAR_PRI(crylink, bounces);
if(WEP_CVAR_PRI(crylink, joinexplode))
maxdmg += WEP_CVAR_PRI(crylink, joinexplode_damage);
- W_SetupShot(self, false, 2, W_Sound("crylink_fire"), CH_WEAPON_A, maxdmg);
+ W_SetupShot(self, false, 2, SND(CRYLINK_FIRE), CH_WEAPON_A, maxdmg);
forward = v_forward;
right = v_right;
up = v_up;
}
}
-void W_Crylink_Attack2(void)
-{
+void W_Crylink_Attack2(Weapon thiswep)
+{SELFPARAM();
float counter, shots;
entity proj, prevproj, firstproj;
vector s;
vector forward, right, up;
float maxdmg;
- W_DecreaseAmmo(WEP_CVAR_SEC(crylink, ammo));
+ W_DecreaseAmmo(thiswep, WEP_CVAR_SEC(crylink, ammo));
maxdmg = WEP_CVAR_SEC(crylink, damage) * WEP_CVAR_SEC(crylink, shots);
maxdmg *= 1 + WEP_CVAR_SEC(crylink, bouncedamagefactor) * WEP_CVAR_SEC(crylink, bounces);
if(WEP_CVAR_SEC(crylink, joinexplode))
maxdmg += WEP_CVAR_SEC(crylink, joinexplode_damage);
- W_SetupShot(self, false, 2, W_Sound("crylink_fire2"), CH_WEAPON_A, maxdmg);
+ W_SetupShot(self, false, 2, SND(CRYLINK_FIRE2), CH_WEAPON_A, maxdmg);
forward = v_forward;
right = v_right;
up = v_up;
}
}
-bool W_Crylink(int req)
-{
- float ammo_amount;
- switch(req)
- {
- case WR_AIM:
+ METHOD(Crylink, wr_aim, bool(entity thiswep))
{
+ SELFPARAM();
if(random() < 0.10)
self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(crylink, speed), 0, WEP_CVAR_PRI(crylink, middle_lifetime), false);
else
return true;
}
- case WR_THINK:
+ METHOD(Crylink, wr_think, bool(entity thiswep, bool fire1, bool fire2))
{
- if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) // forced reload
- WEP_ACTION(self.weapon, WR_RELOAD);
+ SELFPARAM();
+ if(autocvar_g_balance_crylink_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload
+ Weapon w = get_weaponinfo(self.weapon);
+ w.wr_reload(w);
+ }
- if(self.BUTTON_ATCK)
+ if(fire1)
{
if(self.crylink_waitrelease != 1)
- if(weapon_prepareattack(0, WEP_CVAR_PRI(crylink, refire)))
+ if(weapon_prepareattack(false, WEP_CVAR_PRI(crylink, refire)))
{
- W_Crylink_Attack();
+ W_Crylink_Attack(thiswep);
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
}
}
- if(self.BUTTON_ATCK2 && autocvar_g_balance_crylink_secondary)
+ if(fire2 && autocvar_g_balance_crylink_secondary)
{
if(self.crylink_waitrelease != 2)
- if(weapon_prepareattack(1, WEP_CVAR_SEC(crylink, refire)))
+ if(weapon_prepareattack(true, WEP_CVAR_SEC(crylink, refire)))
{
- W_Crylink_Attack2();
+ W_Crylink_Attack2(thiswep);
weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
}
}
- if((self.crylink_waitrelease == 1 && !self.BUTTON_ATCK) || (self.crylink_waitrelease == 2 && !self.BUTTON_ATCK2))
+ if((self.crylink_waitrelease == 1 && !fire1) || (self.crylink_waitrelease == 2 && !fire2))
{
if(!self.crylink_lastgroup || time > self.crylink_lastgroup.teleport_time)
{
setorigin(linkjoineffect, pos);
}
self.crylink_waitrelease = 0;
- if(!W_Crylink(WR_CHECKAMMO1) && !W_Crylink(WR_CHECKAMMO2))
+ if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep))
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
// ran out of ammo!
return true;
}
- case WR_INIT:
+ METHOD(Crylink, wr_init, bool(entity thiswep))
{
- precache_model(W_Model("g_crylink.md3"));
- precache_model(W_Model("v_crylink.md3"));
- precache_model(W_Model("h_crylink.iqm"));
- precache_sound(W_Sound("crylink_fire"));
- precache_sound(W_Sound("crylink_fire2"));
- precache_sound(W_Sound("crylink_linkjoin"));
CRYLINK_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
return true;
}
- case WR_CHECKAMMO1:
+ METHOD(Crylink, wr_checkammo1, bool(entity thiswep))
{
+ SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
if(self.crylink_lastgroup && self.crylink_waitrelease)
return true;
- ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo);
+ float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_PRI(crylink, ammo);
ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
return ammo_amount;
}
- case WR_CHECKAMMO2:
+ METHOD(Crylink, wr_checkammo2, bool(entity thiswep))
{
+ SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
if(self.crylink_lastgroup && self.crylink_waitrelease)
return true;
- ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo);
+ float ammo_amount = self.WEP_AMMO(CRYLINK) >= WEP_CVAR_SEC(crylink, ammo);
ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
return ammo_amount;
}
- case WR_CONFIG:
+ METHOD(Crylink, wr_config, bool(entity thiswep))
{
CRYLINK_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
return true;
}
- case WR_RELOAD:
+ METHOD(Crylink, wr_reload, bool(entity thiswep))
{
- W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), W_Sound("reload"));
+ W_Reload(min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo)), SND(RELOAD));
return true;
}
- case WR_SUICIDEMESSAGE:
+ METHOD(Crylink, wr_suicidemessage, bool(entity thiswep))
{
return WEAPON_CRYLINK_SUICIDE;
}
- case WR_KILLMESSAGE:
+ METHOD(Crylink, wr_killmessage, bool(entity thiswep))
{
return WEAPON_CRYLINK_MURDER;
}
- }
- return false;
-}
#endif
#ifdef CSQC
-bool W_Crylink(int req)
-{
- switch(req)
- {
- case WR_IMPACTEFFECT:
+ METHOD(Crylink, wr_impacteffect, bool(entity thiswep))
{
+ SELFPARAM();
vector org2;
org2 = w_org + w_backoff * 2;
if(w_deathtype & HITTYPE_SECONDARY)
{
pointparticles(particleeffectnum(EFFECT_CRYLINK_IMPACT2), org2, '0 0 0', 1);
if(!w_issilent)
- sound(self, CH_SHOTS, W_Sound("crylink_impact2"), VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, SND_CRYLINK_IMPACT2, VOL_BASE, ATTN_NORM);
}
else
{
pointparticles(particleeffectnum(EFFECT_CRYLINK_IMPACT), org2, '0 0 0', 1);
if(!w_issilent)
- sound(self, CH_SHOTS, W_Sound("crylink_impact"), VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, SND_CRYLINK_IMPACT, VOL_BASE, ATTN_NORM);
}
return true;
}
- case WR_INIT:
+ METHOD(Crylink, wr_init, bool(entity thiswep))
{
- precache_sound(W_Sound("crylink_impact2"));
- precache_sound(W_Sound("crylink_impact"));
return true;
}
- case WR_ZOOMRETICLE:
+ METHOD(Crylink, wr_zoomreticle, bool(entity thiswep))
{
// no weapon specific image for this weapon
return false;
}
- }
- return false;
-}
#endif
#endif