}
-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();
// if there is a child entity, hide it until we're sure we use it
if (self.weaponentity)
self.weaponentity.model = "";
- setmodel(self, W_Model(strcat("v_", name, ".md3")));
+ _setmodel(self, W_Model(strcat("v_", name, ".md3")));
v_shot_idx = gettagindex(self, "shot"); // used later
if(!v_shot_idx)
v_shot_idx = gettagindex(self, "tag_shot");
- setmodel(self, W_Model(strcat("h_", name, ".iqm")));
+ _setmodel(self, W_Model(strcat("h_", name, ".iqm")));
// preset some defaults that work great for renamed zym files (which don't need an animinfo)
self.anim_fire1 = animfixfps(self, '0 1 0.01', '0 0 0');
self.anim_fire2 = animfixfps(self, '1 1 0.01', '0 0 0');
{
if (!self.weaponentity)
self.weaponentity = spawn();
- setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
+ _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
setattachment(self.weaponentity, self, "weapon");
}
else if(gettagindex(self, "tag_weapon"))
{
if (!self.weaponentity)
self.weaponentity = spawn();
- setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
+ _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3")));
setattachment(self.weaponentity, self, "tag_weapon");
}
else
self.dmg = self.owner.modelindex;
self.deadflag = self.owner.deadflag;
if (self.owner.weaponname != "")
- setmodel(self, W_Model(strcat("v_", self.owner.weaponname, ".md3")));
+ _setmodel(self, W_Model(strcat("v_", self.owner.weaponname, ".md3")));
else
self.model = "";
view.classname = "weaponentity";
view.solid = SOLID_NOT;
view.owner = e;
- setmodel(view, ""); // precision set when changed
+ setmodel(view, MDL_Null); // precision set when changed
setorigin(view, '0 0 0');
view.angles = '0 0 0';
view.viewmodelforclient = e;
}
// 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);
}