}
-void(float fr, float t, void() func) weapon_thinkf;
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func);
float CL_Weaponentity_CustomizeEntityForClient()
{SELFPARAM();
}
// Weapon subs
-void w_clear()
+void w_clear(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if (self.weapon != -1)
{
}
}
-void w_ready()
+void w_ready(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if (self.weaponentity)
self.weaponentity.state = WS_READY;
float weapon_prepareattack_checkammo(float secondary)
{SELFPARAM();
if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
- if (!WEP_ACTION(self.weapon, WR_CHECKAMMO1 + secondary))
+ if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO1 + secondary))
{
// always keep the Mine Layer if we placed mines, so that we can detonate them
entity mine;
if(self.weapon == self.switchweapon && time - self.prevdryfire > 1) // only play once BEFORE starting to switch weapons
{
- sound (self, CH_WEAPON_A, W_Sound("dryfire"), VOL_BASE, ATTEN_NORM);
+ sound (self, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
self.prevdryfire = time;
}
- if(WEP_ACTION(self.weapon, WR_CHECKAMMO2 - secondary)) // check if the other firing mode has enough ammo
+ if(_WEP_ACTION(self.weapon, WR_CHECKAMMO2 - secondary)) // check if the other firing mode has enough ammo
{
if(time - self.prevwarntime > 1)
{
return false;
}
-void weapon_thinkf(float fr, float t, void() func)
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func)
{SELFPARAM();
vector a;
vector of, or, ou;
if(forbidWeaponUse(self))
if(self.weaponentity.state != WS_CLEAR)
{
- w_ready();
+ Weapon wpn = get_weaponinfo(self.weapon);
+ w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
return;
}
self.weaponname = newwep.mdl;
self.bulletcounter = 0;
self.ammo_field = newwep.ammo_field;
- WEP_ACTION(self.switchweapon, WR_SETUP);
+ _WEP_ACTION(self.switchweapon, WR_SETUP);
self.weaponentity.state = WS_RAISE;
// set our clip load to the load of the weapon we switched to, if it's reloadable
if(ATTACK_FINISHED(self) <= time + self.weapon_frametime * 0.5)
{
#endif
- sound(self, CH_WEAPON_SINGLE, W_Sound("weapon_switch"), VOL_BASE, ATTN_NORM);
+ sound(self, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM);
self.weaponentity.state = WS_DROP;
weapon_thinkf(WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear);
#ifndef INDEPENDENT_ATTACK_FINISHED
v_right = ri;
v_up = up;
- if(w)
- WEP_ACTION(self.weapon, WR_THINK);
- else
- WEP_ACTION(self.weapon, WR_GONETHINK);
+ {
+ bool key_pressed = self.BUTTON_HOOK;
+ Weapon wpn = self.offhand;
+ if (wpn.offhand_think) wpn.offhand_think(wpn, self, key_pressed);
+ }
+
+ if (w) {
+ entity e = get_weaponinfo(self.weapon);
+ if (e.wr_think) e.wr_think(e, self.BUTTON_ATCK, self.BUTTON_ATCK2);
+ } else {
+ _WEP_ACTION(self.weapon, WR_GONETHINK);
+ }
if (time + self.weapon_frametime * 0.5 >= self.weapon_nextthink)
{
v_forward = fo;
v_right = ri;
v_up = up;
- self.weapon_think();
+ Weapon wpn = get_weaponinfo(self.weapon);
+ self.weapon_think(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
}
else
bprint("\{1}^1ERROR: undefined weapon think function for ", self.netname, "\n");
}
}
-void W_DecreaseAmmo(float ammo_use)
+void W_DecreaseAmmo(Weapon wep, float ammo_use)
{SELFPARAM();
- entity wep = get_weaponinfo(self.weapon);
if(cvar("g_overkill"))
if(self.ok_use_ammocharge)
.float reload_complain;
.string reload_sound;
-void W_ReloadedAndReady()
+void W_ReloadedAndReady(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
// finish the reloading process, and do the ammo transfer
//ATTACK_FINISHED(self) -= self.reload_time - 1;
- w_ready();
+ Weapon wpn = get_weaponinfo(self.weapon);
+ w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
}
void W_Reload(float sent_ammo_min, string sent_sound)
{
if(IS_REAL_CLIENT(self) && self.reload_complain < time)
{
- play2(self, W_Sound("unavailable"));
+ play2(self, SND(UNAVAILABLE));
sprint(self, strcat("You don't have enough ammo to reload the ^2", WEP_NAME(self.weapon), "\n"));
self.reload_complain = time + 1;
}
// switch away if the amount of ammo is not enough to keep using this weapon
- if (!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
+ if (!(_WEP_ACTION(self.weapon, WR_CHECKAMMO1) + _WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
{
self.clip_load = -1; // reload later
W_SwitchToOtherWeapon(self);
// now begin the reloading process
- sound(self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTEN_NORM);
+ _sound(self, CH_WEAPON_SINGLE, self.reload_sound, VOL_BASE, ATTEN_NORM);
// do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon,
// then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there,
{SELFPARAM();
setself(player);
weapon_dropevent_item = weapon_item;
- WEP_ACTION(weapon_type, event);
+ _WEP_ACTION(weapon_type, event);
setself(this);
}