#ifndef IMPLEMENTATION
-REGISTER_WEAPON(
-/* WEP_##id */ TUBA,
-/* function */ W_Tuba,
-/* ammotype */ ammo_none,
-/* impulse */ 1,
-/* flags */ WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH,
-/* rating */ BOT_PICKUP_RATING_MID,
-/* color */ '0 1 0',
-/* modelname */ "tuba",
-/* simplemdl */ "foobar",
-/* crosshair */ "gfx/crosshairtuba",
-/* wepimg */ "weapontuba",
-/* refname */ "tuba",
+CLASS(Tuba, Weapon)
+/* ammotype */ //ATTRIB(Tuba, ammo_field, .int, ammo_none)
+/* impulse */ ATTRIB(Tuba, impulse, int, 1)
+/* flags */ ATTRIB(Tuba, spawnflags, int, WEP_FLAG_HIDDEN | WEP_TYPE_SPLASH);
+/* rating */ ATTRIB(Tuba, bot_pickupbasevalue, float, BOT_PICKUP_RATING_MID);
+/* color */ ATTRIB(Tuba, wpcolor, vector, '0 1 0');
+/* modelname */ ATTRIB(Tuba, mdl, string, "tuba");
+#ifndef MENUQC
+/* model */ ATTRIB(Tuba, m_model, Model, MDL_TUBA_ITEM);
+#endif
+/* crosshair */ ATTRIB(Tuba, w_crosshair, string, "gfx/crosshairtuba");
+/* crosshair */ //ATTRIB(Tuba, w_crosshair_size, float, 0.65);
+/* wepimg */ ATTRIB(Tuba, model2, string, "weapontuba");
+/* refname */ ATTRIB(Tuba, netname, string, "tuba");
/* xgettext:no-c-format */
-/* wepname */ _("@!#%'n Tuba")
-);
-
-#define TUBA_SETTINGS(w_cvar,w_prop) TUBA_SETTINGS_LIST(w_cvar, w_prop, TUBA, tuba)
-#define TUBA_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
- w_cvar(id, sn, NONE, animtime) \
- w_cvar(id, sn, NONE, attenuation) \
- w_cvar(id, sn, NONE, damage) \
- w_cvar(id, sn, NONE, edgedamage) \
- w_cvar(id, sn, NONE, fadetime) \
- w_cvar(id, sn, NONE, force) \
- w_cvar(id, sn, NONE, pitchstep) \
- w_cvar(id, sn, NONE, radius) \
- w_cvar(id, sn, NONE, refire) \
- w_cvar(id, sn, NONE, volume) \
- w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
- w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
- w_prop(id, sn, string, weaponreplace, weaponreplace) \
- w_prop(id, sn, float, weaponstart, weaponstart) \
- w_prop(id, sn, float, weaponstartoverride, weaponstartoverride) \
- w_prop(id, sn, float, weaponthrowable, weaponthrowable)
+/* wepname */ ATTRIB(Tuba, m_name, string, _("@!#%'n Tuba"));
+
+#define X(BEGIN, P, END, class, prefix) \
+ BEGIN(class) \
+ P(class, prefix, animtime, float, NONE) \
+ P(class, prefix, attenuation, float, NONE) \
+ P(class, prefix, damage, float, NONE) \
+ P(class, prefix, edgedamage, float, NONE) \
+ P(class, prefix, fadetime, float, NONE) \
+ P(class, prefix, force, float, NONE) \
+ P(class, prefix, pitchstep, float, NONE) \
+ P(class, prefix, radius, float, NONE) \
+ P(class, prefix, refire, float, NONE) \
+ P(class, prefix, switchdelay_drop, float, NONE) \
+ P(class, prefix, switchdelay_raise, float, NONE) \
+ P(class, prefix, volume, float, NONE) \
+ P(class, prefix, weaponreplace, string, NONE) \
+ P(class, prefix, weaponstartoverride, float, NONE) \
+ P(class, prefix, weaponstart, float, NONE) \
+ P(class, prefix, weaponthrowable, float, NONE) \
+ END()
+ W_PROPS(X, Tuba, tuba)
+#undef X
+
+ENDCLASS(Tuba)
+REGISTER_WEAPON(TUBA, tuba, NEW(Tuba));
+
#ifdef SVQC
-TUBA_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
-float W_Tuba_MarkClientOnlyFieldsAsUsed() {
- // These variables are only used by client/tuba.qc. TODO: move client/tuba.qc code here.
- return WEP_CVAR(tuba, fadetime) + WEP_CVAR(tuba, pitchstep) + WEP_CVAR(tuba, volume);
-}
.entity tuba_note;
.float tuba_smoketime;
#endif
#ifdef IMPLEMENTATION
#ifdef SVQC
-void spawnfunc_weapon_tuba(void) { weapon_defaultspawnfunc(WEP_TUBA.m_id); }
+spawnfunc(weapon_tuba) { weapon_defaultspawnfunc(this, WEP_TUBA); }
bool W_Tuba_HasPlayed(entity pl, string melody, int instrument, bool ignorepitch, float mintempo, float maxtempo)
{
return true;
}
-void W_Tuba_NoteOff(void)
+void W_Tuba_NoteOff()
{SELFPARAM();
// we have a note:
// on: self.spawnshieldtime
return note;
}
-bool W_Tuba_NoteSendEntity(entity to, int sf)
-{SELFPARAM();
+bool W_Tuba_NoteSendEntity(entity this, entity to, int sf)
+{
int f;
msg_entity = to;
if(!sound_allowed(MSG_ONE, self.realowner))
return false;
- WriteByte(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
+ WriteHeader(MSG_ENTITY, ENT_CLIENT_TUBANOTE);
WriteByte(MSG_ENTITY, sf);
if(sf & 1)
{
return true;
}
-void W_Tuba_NoteThink(void)
+void W_Tuba_NoteThink()
{SELFPARAM();
float dist_mult;
float vol0, vol1;
}
}
-bool W_Tuba(int req)
-{SELFPARAM();
- switch(req)
- {
- case WR_AIM:
+ METHOD(Tuba, wr_aim, void(entity thiswep))
{
// bots cannot play the Tuba well yet
// I think they should start with the recorder first
else
self.BUTTON_ATCK2 = 1;
}
-
- return true;
}
- case WR_THINK:
+ METHOD(Tuba, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
{
- if(self.BUTTON_ATCK)
- if(weapon_prepareattack(0, WEP_CVAR(tuba, refire)))
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(0);
- //weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
- weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+ //weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
}
- if(self.BUTTON_ATCK2)
- if(weapon_prepareattack(1, WEP_CVAR(tuba, refire)))
+ if(fire & 2)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(HITTYPE_SECONDARY);
- //weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
- weapon_thinkf(WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
+ //weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
+ weapon_thinkf(actor, weaponentity, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
}
- if(self.tuba_note)
+ if(actor.tuba_note)
{
- if(!self.BUTTON_ATCK && !self.BUTTON_ATCK2)
+ if(!(fire & 1) && !(fire & 2))
{
- WITH(entity, self, self.tuba_note, W_Tuba_NoteOff());
+ WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff());
}
}
-
- return true;
- }
- case WR_INIT:
- {
- TUBA_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP);
- return true;
}
- case WR_SETUP:
+ METHOD(Tuba, wr_setup, void(entity thiswep))
{
self.ammo_field = ammo_none;
self.tuba_instrument = 0;
- return true;
}
- case WR_RELOAD:
+ METHOD(Tuba, wr_reload, void(entity thiswep))
{
+ .entity weaponentity = weaponentities[0]; // TODO: unhardcode
// switch to alternate instruments :)
- if(self.weaponentity.state == WS_READY)
+ if(self.(weaponentity).state == WS_READY)
{
switch(self.tuba_instrument)
{
}
W_SetupShot(self, false, 0, "", 0, 0);
Send_Effect(EFFECT_TELEPORT, w_shotorg, '0 0 0', 1);
- self.weaponentity.state = WS_INUSE;
- weapon_thinkf(WFRAME_RELOAD, 0.5, w_ready);
+ self.(weaponentity).state = WS_INUSE;
+ weapon_thinkf(self, weaponentity, WFRAME_RELOAD, 0.5, w_ready);
}
-
- return true;
}
- case WR_CHECKAMMO1:
- case WR_CHECKAMMO2:
+ METHOD(Tuba, wr_checkammo1, bool(entity thiswep))
{
- return true; // tuba has infinite ammo
+ return true; // infinite ammo
}
- case WR_CONFIG:
+ METHOD(Tuba, wr_checkammo2, bool(entity thiswep))
{
- TUBA_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS);
- return true;
+ return true; // tuba has infinite ammo
}
- case WR_SUICIDEMESSAGE:
+ METHOD(Tuba, wr_suicidemessage, int(entity thiswep))
{
if(w_deathtype & HITTYPE_BOUNCE)
return WEAPON_KLEINBOTTLE_SUICIDE;
else
return WEAPON_TUBA_SUICIDE;
}
- case WR_KILLMESSAGE:
+ METHOD(Tuba, wr_killmessage, int(entity thiswep))
{
if(w_deathtype & HITTYPE_BOUNCE)
return WEAPON_KLEINBOTTLE_MURDER;
else
return WEAPON_TUBA_MURDER;
}
- }
- return false;
-}
-#endif
-#ifdef CSQC
-bool W_Tuba(int req)
-{SELFPARAM();
- // nothing to do here; particles of tuba are handled differently
- // WEAPONTODO
-
- switch(req)
- {
- case WR_ZOOMRETICLE:
- {
- // no weapon specific image for this weapon
- return false;
- }
- }
- return false;
-}
#endif
#endif