#ifdef SVQC
ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
.entity arc_beam;
-.float arc_BUTTON_ATCK_prev; // for better animation control
+.bool arc_BUTTON_ATCK_prev; // for better animation control
.float beam_prev;
.float beam_initialized;
.float beam_bursting;
Arc_Player_SetHeat(self);
Arc_Smoke();
- if ( self.arc_overheat <= time )
- if(fire1 || fire2 || self.arc_beam.beam_bursting )
+ if (time >= self.arc_overheat)
+ if (fire1 || fire2 || self.arc_beam.beam_bursting)
{
if(self.arc_BUTTON_ATCK_prev)
if(!self.arc_BUTTON_ATCK_prev)
{
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
- self.arc_BUTTON_ATCK_prev = 1;
+ self.arc_BUTTON_ATCK_prev = true;
}
}
}
return true;
}
- if(self.arc_BUTTON_ATCK_prev != 0)
+ if(self.arc_BUTTON_ATCK_prev)
{
sound(self, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor();
}
- self.arc_BUTTON_ATCK_prev = 0;
+ self.arc_BUTTON_ATCK_prev = false;
#if 0
if(fire2)
MUTATOR_CALLHOOK(EditProjectile, self, proj);
}
-void W_Electro_CheckAttack(void)
+void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if(self.electro_count > 1)
if(self.BUTTON_ATCK2)
return;
}
// WEAPONTODO: when the player releases the button, cut down the length of refire2?
- w_ready();
+ w_ready(thiswep, fire1, fire2);
}
.float bot_secondary_electromooth;
Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
}
-void W_Fireball_Attack1_Frame4(void)
+void W_Fireball_Attack1_Frame4(Weapon thiswep, bool fire1, bool fire2)
{
W_Fireball_Attack1();
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
}
-void W_Fireball_Attack1_Frame3(void)
+void W_Fireball_Attack1_Frame3(Weapon thiswep, bool fire1, bool fire2)
{
W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
}
-void W_Fireball_Attack1_Frame2(void)
+void W_Fireball_Attack1_Frame2(Weapon thiswep, bool fire1, bool fire2)
{
W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
}
-void W_Fireball_Attack1_Frame1(void)
+void W_Fireball_Attack1_Frame1(Weapon thiswep, bool fire1, bool fire2)
{
W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
}
-void W_Fireball_Attack1_Frame0(void)
+void W_Fireball_Attack1_Frame0(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
if(time >= self.fireball_primarytime)
if(weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
{
- W_Fireball_Attack1_Frame0();
+ W_Fireball_Attack1_Frame0(thiswep, fire1, fire2);
self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
}
}
}
// weapon frames
-void W_HLAC_Attack_Frame(void)
+void W_HLAC_Attack_Frame(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if(self.weapon != self.switchweapon) // abort immediately if switching
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); }
-void W_HeavyMachineGun_Attack_Auto()
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if (!self.BUTTON_ATCK)
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if (weapon_prepareattack(0, 0))
{
self.misc_bulletcounter = 0;
- W_HeavyMachineGun_Attack_Auto();
+ W_HeavyMachineGun_Attack_Auto(thiswep, fire1, fire2);
}
}
}
// weapon frames
-void W_MachineGun_Attack_Frame(void)
+void W_MachineGun_Attack_Frame(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if(self.weapon != self.switchweapon) // abort immediately if switching
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(self.BUTTON_ATCK)
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
self.misc_bulletcounter = self.misc_bulletcounter + 1;
}
-void W_MachineGun_Attack_Auto(void)
+void W_MachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
float machinegun_spread;
- if(!self.BUTTON_ATCK)
+ if(!fire1)
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
}
-void W_MachineGun_Attack_Burst(void)
+void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
if(!autocvar_g_norecoil)
{
if(WEP_CVAR(machinegun, reload_ammo) && self.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) // forced reload
_WEP_ACTION(self.weapon, WR_RELOAD);
- else if(WEP_CVAR(machinegun, mode) == 1)
+ else
+ if(WEP_CVAR(machinegun, mode) == 1)
{
if(fire1)
if(weapon_prepareattack(0, 0))
{
self.misc_bulletcounter = 0;
- W_MachineGun_Attack_Auto();
+ W_MachineGun_Attack_Auto(thiswep, fire1, fire2);
}
if(fire2)
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return false;
}
W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, burst_ammo));
self.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
- W_MachineGun_Attack_Burst();
+ W_MachineGun_Attack_Burst(thiswep, fire1, fire2);
}
}
else
.float rifle_bullethail_frame;
.float rifle_bullethail_animtime;
.float rifle_bullethail_refire;
-void W_Rifle_BulletHail_Continue(void)
+void W_Rifle_BulletHail_Continue(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
float r, sw, af;
}
}
-void W_Shockwave_Melee(void)
+void W_Shockwave_Melee(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
}
}
-void W_Shotgun_Attack2(void)
+void W_Shotgun_Attack2(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM);
weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
}
// alternate secondary weapon frames
-void W_Shotgun_Attack3_Frame2()
+void W_Shotgun_Attack3_Frame2(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2))
if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
}
-void W_Shotgun_Attack3_Frame1()
+void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2))
if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
.float autoswitch;
//float _WEP_ACTION(float wpn, float wrequest);
float client_hasweapon(entity cl, float wpn, float andammo, float complain);
-void w_clear();
-void w_ready();
+void w_clear(Weapon thiswep, bool fire1, bool fire2);
+void w_ready(Weapon thiswep, bool fire1, bool fire2);
// VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
.float weapon_nextthink;
-.void() weapon_think;
+.void(Weapon thiswep, bool fire1, bool fire2) weapon_think;
// weapon states (self.weaponentity.state)
self.ok_notice_time = time + 2;
play2(self, SND(DRYFIRE));
}
+ Weapon wpn = get_weaponinfo(self.weapon);
if(self.weaponentity.state != WS_CLEAR)
- w_ready();
+ w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
self.weapon_blocked = true;
}
}
-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;
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;
}
{
bool key_pressed = self.BUTTON_HOOK;
- entity e = self.offhand;
- if (e.offhand_think) e.offhand_think(e, self, key_pressed);
+ Weapon wpn = self.offhand;
+ if (wpn.offhand_think) wpn.offhand_think(wpn, self, key_pressed);
}
if (w) {
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");
.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)
float weapon_prepareattack_do(float secondary, float attacktime);
-void weapon_thinkf(float fr, float t, void() func);
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func);
#endif