actor.punchangle_y = random () - 0.5;
}
- float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * actor.misc_bulletcounter), WEP_CVAR(hmg, spread_max));
+ float hmg_spread = bound(WEP_CVAR(hmg, spread_min), WEP_CVAR(hmg, spread_min) + (WEP_CVAR(hmg, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR(hmg, spread_max));
fireBullet(actor, weaponentity, w_shotorg, w_shotdir, hmg_spread, WEP_CVAR(hmg, solidpenetration), WEP_CVAR(hmg, damage), WEP_CVAR(hmg, force), WEP_HMG.m_id, 0);
- actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
+ actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
if (fire & 1)
if (weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
{
- actor.misc_bulletcounter = 0;
+ actor.(weaponentity).misc_bulletcounter = 0;
W_HeavyMachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
}
}
);
Weapon thiswep = WEP_DEVASTATOR;
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
+ .entity weaponentity = this.weaponentity_fld;
if(this.realowner.(weaponentity).m_weapon == thiswep)
{
if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
{
this.realowner.cnt = WEP_DEVASTATOR.m_id;
- int slot = 0; // TODO: unhardcode
+ int slot = weaponslot(weaponentity);
ATTACK_FINISHED(this.realowner, slot) = time;
this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner);
}
this.velocity = this.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor(this.realowner) * frametime, velspeed);
// laser guided, or remote detonation
- if(PS(this.realowner).m_weapon == WEP_DEVASTATOR)
+ .entity weaponentity = this.weaponentity_fld;
+ if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR)
{
- .entity weaponentity = this.weaponentity_fld;
int slot = weaponslot(weaponentity);
if(this == this.realowner.(weaponentity).lastrocket)
void W_Electro_CheckAttack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if(actor.electro_count > 1)
+ if(actor.(weaponentity).electro_count > 1)
if(PHYS_INPUT_BUTTON_ATCK2(actor))
if(weapon_prepareattack(thiswep, actor, weaponentity, true, -1))
{
W_Electro_Attack_Orb(WEP_ELECTRO, actor, weaponentity);
- actor.electro_count -= 1;
+ actor.(weaponentity).electro_count -= 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
return;
}
}
else if(fire & 2)
{
- if(time >= actor.electro_secondarytime)
+ if(time >= actor.(weaponentity).electro_secondarytime)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, WEP_CVAR_SEC(electro, refire)))
{
W_Electro_Attack_Orb(thiswep, actor, weaponentity);
- actor.electro_count = WEP_CVAR_SEC(electro, count);
+ actor.(weaponentity).electro_count = WEP_CVAR_SEC(electro, count);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack);
- actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor);
}
}
}
}
METHOD(Electro, wr_resetplayer, void(entity thiswep, entity actor))
{
- actor.electro_secondarytime = time;
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ actor.(weaponentity).electro_secondarytime = time;
+ }
}
METHOD(Electro, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
vector s;
vector forward, right, up;
- if(!actor.hagar_load)
+ if(!actor.(weaponentity).hagar_load)
return;
weapon_prepareattack_do(actor, weaponentity, true, WEP_CVAR_SEC(hagar, refire));
right = v_right;
up = v_up;
- shots = actor.hagar_load;
+ shots = actor.(weaponentity).hagar_load;
missile = NULL;
for(counter = 0; counter < shots; ++counter)
{
}
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
- actor.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(actor);
- actor.hagar_load = 0;
+ actor.(weaponentity).hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).hagar_load = 0;
+
+ if(weaponslot(weaponentity) == 0)
+ actor.hagar_load = 0;
}
void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity)
if(time < game_starttime)
return;
- bool loaded = actor.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
+ bool loaded = actor.(weaponentity).hagar_load >= WEP_CVAR_SEC(hagar, load_max);
// this is different than WR_CHECKAMMO when it comes to reloading
bool enough_ammo;
{
if(PHYS_INPUT_BUTTON_ATCK(actor) && WEP_CVAR_SEC(hagar, load_abort))
{
- if(actor.hagar_load)
+ if(actor.(weaponentity).hagar_load)
{
// if we pressed primary fire while loading, unload all rockets and abort
actor.(weaponentity).state = WS_READY;
- W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.hagar_load * -1, weaponentity); // give back ammo
- actor.hagar_load = 0;
+ W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.(weaponentity).hagar_load * -1, weaponentity); // give back ammo
+ actor.(weaponentity).hagar_load = 0;
+ if(weaponslot(weaponentity) == 0)
+ actor.hagar_load = 0;
sound(actor, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM);
// pause until we can load rockets again, once we re-press the alt fire button
- actor.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor);
// require letting go of the alt fire button before we can load again
- actor.hagar_loadblock = true;
+ actor.(weaponentity).hagar_loadblock = true;
}
}
else
// check if we can attempt to load another rocket
if(!stopped)
{
- if(!actor.hagar_loadblock && actor.hagar_loadstep < time)
+ if(!actor.(weaponentity).hagar_loadblock && actor.(weaponentity).hagar_loadstep < time)
{
W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo), weaponentity);
actor.(weaponentity).state = WS_INUSE;
- actor.hagar_load += 1;
+ actor.(weaponentity).hagar_load += 1;
sound(actor, CH_WEAPON_B, SND_HAGAR_LOAD, VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
- if(actor.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
+ if(actor.(weaponentity).hagar_load >= WEP_CVAR_SEC(hagar, load_max))
stopped = true;
else
- actor.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor);
}
}
- if(stopped && !actor.hagar_loadbeep && actor.hagar_load) // prevents the beep from playing each frame
+ if(stopped && !actor.(weaponentity).hagar_loadbeep && actor.(weaponentity).hagar_load) // prevents the beep from playing each frame
{
// if this is the last rocket we can load, play a beep sound to notify the player
sound(actor, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM);
- actor.hagar_loadbeep = true;
- actor.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor(actor);
+ actor.(weaponentity).hagar_loadbeep = true;
+ actor.(weaponentity).hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor(actor);
}
}
}
- else if(actor.hagar_loadblock)
+ else if(actor.(weaponentity).hagar_loadblock)
{
// the alt fire button has been released, so re-enable loading if blocked
- actor.hagar_loadblock = false;
+ actor.(weaponentity).hagar_loadblock = false;
}
- if(actor.hagar_load)
+ if(actor.(weaponentity).hagar_load)
{
// play warning sound if we're about to release
- if(stopped && actor.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
+ if(stopped && actor.(weaponentity).hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
{
- if(!actor.hagar_warning) // prevents the beep from playing each frame
+ if(!actor.(weaponentity).hagar_warning) // prevents the beep from playing each frame
{
// we're about to automatically release after holding time, play a beep sound to notify the player
sound(actor, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM);
- actor.hagar_warning = true;
+ actor.(weaponentity).hagar_warning = true;
}
}
// release if player let go of button or if they've held it in too long
- if(!PHYS_INPUT_BUTTON_ATCK2(actor) || (stopped && actor.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
+ if(!PHYS_INPUT_BUTTON_ATCK2(actor) || (stopped && actor.(weaponentity).hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
{
actor.(weaponentity).state = WS_READY;
W_Hagar_Attack2_Load_Release(actor, weaponentity);
}
else
{
- actor.hagar_loadbeep = false;
- actor.hagar_warning = false;
+ actor.(weaponentity).hagar_loadbeep = false;
+ actor.(weaponentity).hagar_warning = false;
// we aren't checking ammo during an attack, so we must do it here
if(!(thiswep.wr_checkammo1(thiswep, actor) + thiswep.wr_checkammo2(thiswep, actor)))
void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if(!(fire & 1) || actor.hagar_load || actor.hagar_loadblock)
+ if(!(fire & 1) || actor.(weaponentity).hagar_load || actor.(weaponentity).hagar_loadblock)
{
w_ready(thiswep, actor, weaponentity, fire);
return;
{
float loadable_secondary;
loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
+ if(weaponslot(weaponentity) == 0)
+ actor.hagar_load = actor.(weaponentity).hagar_load;
if(loadable_secondary)
W_Hagar_Attack2_Load(thiswep, actor, weaponentity); // must always run each frame
if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload
thiswep.wr_reload(thiswep, actor, weaponentity);
}
- else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
+ else if((fire & 1) && !actor.(weaponentity).hagar_load && !actor.(weaponentity).hagar_loadblock) // not while secondary is loaded or awaiting reset
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
W_Hagar_Attack_Auto(thiswep, actor, weaponentity, fire);
METHOD(Hagar, wr_gonethink, void(entity thiswep, entity actor, .entity weaponentity))
{
// we lost the weapon and want to prepare switching away
- if(actor.hagar_load)
+ if(actor.(weaponentity).hagar_load)
{
actor.(weaponentity).state = WS_READY;
W_Hagar_Attack2_Load_Release(actor, weaponentity);
}
METHOD(Hagar, wr_setup, void(entity thiswep, entity actor))
{
- actor.hagar_loadblock = false;
-
- if(actor.hagar_load)
+ actor.hagar_load = 0;
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
- W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.hagar_load * -1, weaponentity); // give back ammo if necessary
- actor.hagar_load = 0;
+ .entity weaponentity = weaponentities[slot];
+ actor.(weaponentity).hagar_loadblock = false;
+ if(actor.(weaponentity).hagar_load)
+ {
+ W_DecreaseAmmo(thiswep, actor, WEP_CVAR_SEC(hagar, ammo) * actor.(weaponentity).hagar_load * -1, weaponentity); // give back ammo if necessary
+ actor.(weaponentity).hagar_load = 0;
+ }
}
}
METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
METHOD(Hagar, wr_resetplayer, void(entity thiswep, entity actor))
{
actor.hagar_load = 0;
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ actor.(weaponentity).hagar_load = 0;
+ }
}
METHOD(Hagar, wr_playerdeath, void(entity thiswep, entity actor, .entity weaponentity))
{
// if we have any rockets loaded when we die, release them
- if(actor.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
+ if(actor.(weaponentity).hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
W_Hagar_Attack2_Load_Release(actor, weaponentity);
}
METHOD(Hagar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- if(!actor.hagar_load) // require releasing loaded rockets first
+ if(!actor.(weaponentity).hagar_load) // require releasing loaded rockets first
W_Reload(actor, weaponentity, min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), SND_RELOAD);
}
METHOD(Hagar, wr_suicidemessage, Notification(entity thiswep))
W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hlac, ammo), weaponentity);
- spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.misc_bulletcounter);
+ spread = WEP_CVAR_PRI(hlac, spread_min) + (WEP_CVAR_PRI(hlac, spread_add) * actor.(weaponentity).misc_bulletcounter);
spread = min(spread,WEP_CVAR_PRI(hlac, spread_max));
if(actor.crouch)
spread = spread * WEP_CVAR_PRI(hlac, spread_crouchmod);
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor);
W_HLAC_Attack(WEP_HLAC, actor, weaponentity);
- actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
+ actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
}
else
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(hlac, refire)))
{
- actor.misc_bulletcounter = 0;
+ actor.(weaponentity).misc_bulletcounter = 0;
W_HLAC_Attack(thiswep, actor, weaponentity);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame);
}
InterpolateOrigin_Do(this);
- int s = W_GunAlign(NULL, STAT(GUNALIGN));
+ int s = viewmodels[this.cnt].m_gunalign; //W_GunAlign(NULL, STAT(GUNALIGN));
switch(this.HookType)
{
void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity weaponentity)
{
- W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
+ W_SetupShot(actor, weaponentity, true, 0, SND_UZI_FIRE, CH_WEAPON_A, ((actor.(weaponentity).misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
if(!autocvar_g_norecoil)
{
actor.punchangle_x = random() - 0.5;
// this attack_finished just enforces a cooldown at the end of a burst
ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor);
- if(actor.misc_bulletcounter == 1)
+ if(actor.(weaponentity).misc_bulletcounter == 1)
fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, 0);
else
fireBullet(actor, weaponentity, w_shotorg, w_shotdir, WEP_CVAR(machinegun, sustained_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), deathtype, 0);
SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
}
- if(actor.misc_bulletcounter == 1)
+ if(actor.(weaponentity).misc_bulletcounter == 1)
W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, first_ammo), weaponentity);
else
W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, sustained_ammo), weaponentity);
w_ready(thiswep, actor, weaponentity, fire);
return;
}
- actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
+ actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
actor.punchangle_y = random() - 0.5;
}
- machinegun_spread = bound(WEP_CVAR(machinegun, spread_min), WEP_CVAR(machinegun, spread_min) + (WEP_CVAR(machinegun, spread_add) * actor.misc_bulletcounter), WEP_CVAR(machinegun, spread_max));
+ machinegun_spread = bound(WEP_CVAR(machinegun, spread_min), WEP_CVAR(machinegun, spread_min) + (WEP_CVAR(machinegun, spread_add) * actor.(weaponentity).misc_bulletcounter), WEP_CVAR(machinegun, spread_max));
fireBullet(actor, weaponentity, w_shotorg, w_shotdir, machinegun_spread, WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, sustained_damage), WEP_CVAR(machinegun, sustained_force), WEP_MACHINEGUN.m_id, 0);
- actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
+ actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
Send_Effect(EFFECT_MACHINEGUN_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor, weaponentity);
}
- actor.misc_bulletcounter = actor.misc_bulletcounter + 1;
- if(actor.misc_bulletcounter == 0)
+ actor.(weaponentity).misc_bulletcounter = actor.(weaponentity).misc_bulletcounter + 1;
+ if(actor.(weaponentity).misc_bulletcounter == 0)
{
int slot = weaponslot(weaponentity);
ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor);
if(fire & 1)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
{
- actor.misc_bulletcounter = 0;
+ actor.(weaponentity).misc_bulletcounter = 0;
W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
}
W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo), weaponentity);
- actor.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
+ actor.(weaponentity).misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
}
}
if(fire & 1)
if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
{
- actor.misc_bulletcounter = 1;
+ actor.(weaponentity).misc_bulletcounter = 1;
W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id, actor, weaponentity); // sets attack_finished
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
if((fire & 2) && WEP_CVAR(machinegun, first))
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
- actor.misc_bulletcounter = 1;
+ actor.(weaponentity).misc_bulletcounter = 1;
W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
}