void M_Mage_Attack_Push();
METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bool fire2)) {
if (fire1)
- if (!IS_PLAYER(actor) || weapon_prepareattack(actor, false, 0.2)) {
+ if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, false, 0.2)) {
if (!actor.target_range) actor.target_range = autocvar_g_monsters_target_range;
actor.enemy = Monster_FindTarget(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready);
}
if (fire2)
- if (!IS_PLAYER(actor) || weapon_prepareattack(actor, true, 0.5)) {
+ if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, true, 0.5)) {
M_Mage_Attack_Push();
weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
}
METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(actor, false, autocvar_g_monster_spider_attack_web_delay)) {
+ if ((!isPlayer && time >= actor.spider_web_delay) || weapon_prepareattack(thiswep, actor, false, autocvar_g_monster_spider_attack_web_delay)) {
if (!isPlayer) {
actor.spider_web_delay = time + 3;
setanim(actor, actor.anim_shoot, true, true, true);
return;
}
if (fire2)
- if (!isPlayer || weapon_prepareattack(actor, true, 0.5)) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, true, 0.5)) {
if (isPlayer) {
actor.enemy = Monster_FindTarget(actor);
actor.attack_range = 60;
METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) {
if (fire1)
- if (time > actor.attack_finished_single || weapon_prepareattack(actor, false, 1.2)) {
+ if (time > actor.attack_finished_single || weapon_prepareattack(thiswep, actor, false, 1.2)) {
if (IS_PLAYER(actor)) W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
if (IS_MONSTER(actor)) {
actor.attack_finished_single = time + 1.2;
METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
{
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
{
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
{
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR(machinegun, sustained_refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
{
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) {
bool isPlayer = IS_PLAYER(actor);
if (fire1)
- if (!isPlayer || weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire))) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) {
if (isPlayer) {
turret_initparams(actor);
W_SetupShot_Dir(actor, v_forward, false, 0, W_Sound("electro_fire"), CH_WEAPON_B, 0);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
if (fire1)
- if (weapon_prepareattack(player, false, autocvar_g_vehicle_racer_cannon_refire)) {
+ if (weapon_prepareattack(thiswep, player, false, autocvar_g_vehicle_racer_cannon_refire)) {
if (veh) {
veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost;
veh.wait = time;
weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready);
}
if (fire2)
- if (!isPlayer || weapon_prepareattack(actor, false, 0.2)) {
+ if (!isPlayer || weapon_prepareattack(thiswep, actor, false, 0.2)) {
if (isPlayer) W_SetupShot_Dir(actor, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
racer_fire_rocket(w_shotorg, w_shotdir, NULL);
weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready);
// 1 [wait] 1 [wait] 2 [wait] 2 [wait] [wait]
float t = autocvar_g_vehicle_raptor_cannon_refire * (1 + veh.misc_bulletcounter == 4);
if (fire1)
- if (weapon_prepareattack(player, false, t)) {
+ if (weapon_prepareattack(thiswep, player, false, t)) {
if (isPlayer) W_SetupShot_Dir(player, v_forward, false, 0, SND(Null), CH_WEAPON_B, 0);
vector org = w_shotorg;
vector dir = w_shotdir;
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
if (fire2)
- if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_bombs_refire)) {
+ if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_bombs_refire)) {
if (veh) setself(veh);
raptor_bombdrop();
weapon_thinkf(player, WFRAME_FIRE2, 0, w_ready);
entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
if (fire2)
- if (!isPlayer || weapon_prepareattack(player, true, autocvar_g_vehicle_raptor_flare_refire)) {
+ if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_flare_refire)) {
for(int i = 0; i < 3; ++i) {
entity _flare = spawn();
setmodel(_flare, MDL_VEH_RAPTOR_FLARE);
if((!actor.arc_beam) || wasfreed(actor.arc_beam))
{
- if(weapon_prepareattack(actor, fire2, 0))
+ if(weapon_prepareattack(thiswep, actor, fire2, 0))
{
W_Arc_Beam(fire2);
#if 0
if(fire2)
- if(weapon_prepareattack(actor, true, autocvar_g_balance_arc_secondary_refire))
+ if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_arc_secondary_refire))
{
W_Arc_Attack2();
actor.arc_count = autocvar_g_balance_arc_secondary_count;
{
if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(blaster, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(blaster, refire)))
{
W_Blaster_Attack(
actor,
case 1: // normal projectile secondary
{
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(blaster, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(blaster, refire)))
{
W_Blaster_Attack(
actor,
if(fire1)
{
if(actor.crylink_waitrelease != 1)
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(crylink, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(crylink, refire)))
{
W_Crylink_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(crylink, animtime), w_ready);
if(fire2 && autocvar_g_balance_crylink_secondary)
{
if(actor.crylink_waitrelease != 2)
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(crylink, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(crylink, refire)))
{
W_Crylink_Attack2(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(crylink, animtime), w_ready);
if(fire1)
{
if(actor.rl_release || WEP_CVAR(devastator, guidestop))
- if(weapon_prepareattack(actor, false, WEP_CVAR(devastator, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(devastator, refire)))
{
W_Devastator_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
{SELFPARAM();
if(self.electro_count > 1)
if(self.BUTTON_ATCK2)
- if(weapon_prepareattack(actor, true, -1))
+ if(weapon_prepareattack(thiswep, actor, true, -1))
{
W_Electro_Attack_Orb(WEP_ELECTRO);
self.electro_count -= 1;
if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(electro, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire)))
{
W_Electro_Attack_Bolt(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready);
else if(fire2)
{
if(time >= actor.electro_secondarytime)
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(electro, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(electro, refire)))
{
W_Electro_Attack_Orb(thiswep);
actor.electro_count = WEP_CVAR_SEC(electro, count);
if(fire1)
{
if(time >= actor.fireball_primarytime)
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(fireball, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(fireball, refire)))
{
W_Fireball_Attack1_Frame0(thiswep, actor, fire1, fire2);
actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
}
else if(fire2)
{
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(fireball, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(fireball, refire)))
{
W_Fireball_Attack2();
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(fireball, animtime), w_ready);
w.wr_reload(w);
} else if(fire1 && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hagar, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hagar, refire)))
{
W_Hagar_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
}
else if(fire2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
{
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hagar, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hagar, refire)))
{
W_Hagar_Attack2(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
w.wr_reload(w);
} else if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(hlac, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hlac, refire)))
{
actor.misc_bulletcounter = 0;
W_HLAC_Attack(thiswep);
else if(fire2 && WEP_CVAR(hlac, secondary))
{
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hlac, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hlac, refire)))
{
W_HLAC_Attack2_Frame(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hlac, animtime), w_ready);
} else
{
if (fire1)
- if (weapon_prepareattack(actor, false, 0))
+ if (weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 0;
W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
REGISTER_WEAPON(HOOK, NEW(Hook));
CLASS(OffhandHook, OffhandWeapon)
- METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity player, bool key_pressed))
+ METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed))
{
Weapon wep = WEP_HOOK;
- WITH(entity, self, player, wep.wr_think(wep, self, key_pressed, false));
+ wep.wr_think(wep, actor, key_pressed, false);
}
ENDCLASS(OffhandHook)
OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); }
METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
{
- if(fire1 || actor.BUTTON_HOOK)
- {
+ if (fire1) {
if(!actor.hook)
if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE))
- if(!(actor.hook_state & HOOK_FIRING))
if(time > actor.hook_refire)
- if(weapon_prepareattack(actor, false, -1))
+ if(weapon_prepareattack(thiswep, actor, false, -1))
{
W_DecreaseAmmo(thiswep, actor, WEP_CVAR_PRI(hook, ammo));
actor.hook_state |= HOOK_FIRING;
+ actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hook, animtime), w_ready);
}
+ } else {
+ actor.hook_state |= HOOK_REMOVING;
+ actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
}
if(fire2)
{
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(hook, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hook, refire)))
{
W_Hook_Attack2(thiswep, actor);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(hook, animtime), w_ready);
actor.hook_time_fueldecrease = time + WEP_CVAR_PRI(hook, hooked_time_free);
}
- if(actor.BUTTON_CROUCH)
+ actor.hook_state = BITSET(actor.hook_state, HOOK_PULLING, (!actor.BUTTON_CROUCH || !autocvar_g_balance_grapplehook_crouchslide));
+
+ if (actor.hook_state & HOOK_FIRING)
{
- actor.hook_state &= ~HOOK_PULLING;
- if(fire1 || actor.BUTTON_HOOK)
- actor.hook_state &= ~HOOK_RELEASING;
- else
- actor.hook_state |= HOOK_RELEASING;
+ if (actor.hook)
+ RemoveGrapplingHook(actor);
+ WITH(entity, self, actor, FireGrapplingHook());
+ actor.hook_state &= ~HOOK_FIRING;
+ actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor());
}
- else
+ else if (actor.hook_state & HOOK_REMOVING)
{
- actor.hook_state |= HOOK_PULLING;
- actor.hook_state &= ~HOOK_RELEASING;
-
- if(fire1 || actor.BUTTON_HOOK)
- {
- // already fired
- if(actor.hook)
- actor.hook_state |= HOOK_WAITING_FOR_RELEASE;
- }
- else
- {
- actor.hook_state |= HOOK_REMOVING;
- actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
- }
+ if (actor.hook)
+ RemoveGrapplingHook(actor);
+ actor.hook_state &= ~HOOK_REMOVING;
}
-
- _GrapplingHookFrame();
}
METHOD(Hook, wr_init, void(entity thiswep))
{
if(WEP_CVAR(machinegun, mode) == 1)
{
if(fire1)
- if(weapon_prepareattack(actor, false, 0))
+ if(weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 0;
W_MachineGun_Attack_Auto(thiswep, actor, fire1, fire2);
}
if(fire2)
- if(weapon_prepareattack(actor, true, 0))
+ if(weapon_prepareattack(thiswep, actor, true, 0))
{
Weapon w = get_weaponinfo(actor.weapon);
if(!w.wr_checkammo2(w))
{
if(fire1)
- if(weapon_prepareattack(actor, false, 0))
+ if(weapon_prepareattack(thiswep, actor, false, 0))
{
actor.misc_bulletcounter = 1;
W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); // sets attack_finished
}
if(fire2 && WEP_CVAR(machinegun, first))
- if(weapon_prepareattack(actor, true, 0))
+ if(weapon_prepareattack(thiswep, actor, true, 0))
{
actor.misc_bulletcounter = 1;
W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished
}
else if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(minelayer, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(minelayer, refire)))
{
W_MineLayer_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
w.wr_reload(w);
} else if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(mortar, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(mortar, refire)))
{
W_Mortar_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready);
if(nadefound)
sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
}
- else if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(mortar, refire)))
+ else if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(mortar, refire)))
{
W_Mortar_Attack2(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(mortar, animtime), w_ready);
if(fire1)
if(!actor.porto_current)
if(!actor.porto_forbidden)
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
{
W_Porto_Attack(0);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
if(fire2)
if(!actor.porto_current)
if(!actor.porto_forbidden)
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(porto, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(porto, refire)))
{
W_Porto_Attack(1);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(porto, animtime), w_ready);
if(fire1)
if(!actor.porto_current)
if(!actor.porto_forbidden)
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(porto, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire)))
{
W_Porto_Attack(-1);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready);
actor.switchweapon = actor.weapon;
ATTACK_FINISHED(actor) = time;
LOG_INFO(ftos(actor.WEP_AMMO(RIFLE)), "\n");
- r = weapon_prepareattack(actor, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
+ r = weapon_prepareattack(thiswep, actor, actor.rifle_bullethail_frame == WFRAME_FIRE2, actor.rifle_bullethail_refire);
if(actor.switchweapon == actor.weapon)
actor.switchweapon = sw;
if(r)
{
actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time);
if(fire1)
- if(weapon_prepareattack_check(actor, false, WEP_CVAR_PRI(rifle, refire)))
+ if(weapon_prepareattack_check(thiswep, actor, false, WEP_CVAR_PRI(rifle, refire)))
if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost))
{
weapon_prepareattack_do(actor, false, WEP_CVAR_PRI(rifle, refire));
w.wr_reload(w);
} else
{
- if(weapon_prepareattack_check(actor, true, WEP_CVAR_SEC(rifle, refire)))
+ if(weapon_prepareattack_check(thiswep, actor, true, WEP_CVAR_SEC(rifle, refire)))
if(time >= actor.rifle_accumulator + WEP_CVAR_SEC(rifle, burstcost))
{
weapon_prepareattack_do(actor, true, WEP_CVAR_SEC(rifle, refire));
{
if (fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(rpc, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(rpc, refire)))
{
W_RocketPropelledChainsaw_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(rpc, animtime), w_ready);
{
if(WEP_CVAR(seeker, type) == 1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, missile_refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, missile_refire)))
{
W_Seeker_Attack();
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, missile_animtime), w_ready);
}
else
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, tag_refire)))
{
W_Seeker_Fire_Tag(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
{
if(WEP_CVAR(seeker, type) == 1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, tag_refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, tag_refire)))
{
W_Seeker_Fire_Tag(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, tag_animtime), w_ready);
}
else
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(seeker, flac_refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(seeker, flac_refire)))
{
W_Seeker_Fire_Flac(thiswep);
weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(seeker, flac_animtime), w_ready);
{
if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary
{
- if(weapon_prepareattack(actor, false, WEP_CVAR(shockwave, blast_animtime)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(shockwave, blast_animtime)))
{
W_Shockwave_Attack();
actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor();
{
//if(actor.clip_load >= 0) // we are not currently reloading
if(!actor.crouch) // no crouchmelee please
- if(weapon_prepareattack(actor, true, WEP_CVAR(shockwave, melee_refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR(shockwave, melee_refire)))
{
// attempt forcing playback of the anim by switching to another anim (that we never play) here...
weapon_thinkf(actor, WFRAME_FIRE1, 0, W_Shockwave_Melee);
{
if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(shotgun, animtime)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(shotgun, animtime)))
{
W_Shotgun_Attack(thiswep, true);
actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor();
{
if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_SEC(shotgun, alt_animtime)))
{
W_Shotgun_Attack(thiswep, false);
actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor();
if(!actor.crouch) // no crouchmelee please
if(WEP_CVAR(shotgun, secondary) == 1)
if((fire1 && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || fire2)
- if(weapon_prepareattack(actor, true, WEP_CVAR_SEC(shotgun, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(shotgun, refire)))
{
// attempt forcing playback of the anim by switching to another anim (that we never play) here...
weapon_thinkf(actor, WFRAME_FIRE1, 0, W_Shotgun_Attack2);
METHOD(Tuba, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2))
{
if(fire1)
- if(weapon_prepareattack(actor, false, WEP_CVAR(tuba, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(0);
//weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_tuba_animtime, w_ready);
weapon_thinkf(actor, WFRAME_IDLE, WEP_CVAR(tuba, animtime), w_ready);
}
if(fire2)
- if(weapon_prepareattack(actor, true, WEP_CVAR(tuba, refire)))
+ if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR(tuba, refire)))
{
W_Tuba_NoteOn(HITTYPE_SECONDARY);
//weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_tuba_animtime, w_ready);
}
if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor))
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vaporizer, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vaporizer, refire)))
{
W_Vaporizer_Attack(thiswep);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready);
{
if(fire1)
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_PRI(vortex, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vortex, refire)))
{
W_Vortex_Attack(thiswep, 0);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready);
}
else if(WEP_CVAR(vortex, secondary))
{
- if(weapon_prepareattack(actor, false, WEP_CVAR_SEC(vortex, refire)))
+ if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_SEC(vortex, refire)))
{
W_Vortex_Attack(thiswep, 1);
weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(vortex, animtime), w_ready);
FixPlayermodel();
- GrapplingHookFrame();
-
// LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers
//if(frametime)
{
============================================*/
.float hook_length;
-.float hook_switchweapon;
void RemoveGrapplingHook(entity pl)
{
Net_LinkEntity(missile, false, 0, GrapplingHookSend);
}
-// void GrapplingHookFrame()
-// {
-// // this function has been modified for Xonotic
-// - if (self.BUTTON_HOOK && g_grappling_hook)
-// {
-// - if (!self.hook && self.hook_time <= time && !self.button6_pressed_before)
-// - if (timeoutStatus != 2) //only allow the player to fire the grappling hook if the game is not paused (timeout)
-// - FireGrapplingHook();
-// }
-// - else
-// {
-// if (self.hook)
-// RemoveGrapplingHook(self);
-// }
-// - self.button6_pressed_before = self.BUTTON_HOOK;
-// /*
-// // if I have no hook or it's not pulling yet, make sure I'm not flying!
-// if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
-
-void _GrapplingHookFrame();
-void GrapplingHookFrame()
-{SELFPARAM();
- if (self.offhand == OFFHAND_HOOK) {
- if (timeout_status != TIMEOUT_ACTIVE && self.weapon != WEP_HOOK.m_id && !self.vehicle) {
- // offhand hook controls
- if (self.BUTTON_HOOK) {
- if (!(self.hook || (self.hook_state & HOOK_WAITING_FOR_RELEASE)) && (time > self.hook_refire)) {
- self.hook_state |= HOOK_FIRING;
- self.hook_state |= HOOK_WAITING_FOR_RELEASE;
- }
- } else {
- self.hook_state |= HOOK_REMOVING;
- self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
- }
-
- self.hook_state &= ~HOOK_RELEASING;
- if (self.BUTTON_CROUCH && autocvar_g_balance_grapplehook_crouchslide) {
- self.hook_state &= ~HOOK_PULLING;
- //self.hook_state |= HOOK_RELEASING;
- } else {
- self.hook_state |= HOOK_PULLING;
- //self.hook_state &= ~HOOK_RELEASING;
- }
- }
- } else {
- if (self.switchweapon != WEP_HOOK.m_id && !self.vehicle) {
- if (self.BUTTON_HOOK && !self.hook_switchweapon)
- W_SwitchWeapon(WEP_HOOK.m_id);
- }
- if (self.weapon != WEP_HOOK.m_id && self.offhand != OFFHAND_HOOK) {
- self.hook_state &= ~HOOK_FIRING;
- self.hook_state |= HOOK_REMOVING;
- }
- }
- self.hook_switchweapon = self.BUTTON_HOOK;
- _GrapplingHookFrame();
-}
-
-void _GrapplingHookFrame()
-{
- if (self.hook_state & HOOK_FIRING)
- {
- if (self.hook)
- RemoveGrapplingHook(self);
- FireGrapplingHook();
- self.hook_state &= ~HOOK_FIRING;
- self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor());
- }
- else if(self.hook_state & HOOK_REMOVING)
- {
- if (self.hook)
- RemoveGrapplingHook(self);
- self.hook_state &= ~HOOK_REMOVING;
- }
-
- /*
- // if I have no hook or it's not pulling yet, make sure I'm not flying!
- if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
- {
- self.movetype = MOVETYPE_WALK;
- }
- if(self.impulse == GRAPHOOK_FIRE && self.hook_time <= time && g_grappling_hook)
- {
- // fire hook
- FireGrapplingHook();
- return;
- }
- else if(self.hookimpulse == GRAPHOOK_RELEASE)
- {
- // remove hook, reset movement type
- RemoveGrapplingHook(self);
- return;
- }
- */
- /*else // make sure the player's movetype is correct
- {
- //if(self.hook == world && self.movetype == MOVETYPE_FLY)
- if((self.hook == world || !self.hook.state) && self.movetype == MOVETYPE_FLY)
- {
- self.movetype = MOVETYPE_WALK;
- }
- }*/
- // note: The hook entity does the actual pulling
-}
-
void GrappleHookInit()
{
if(g_grappling_hook)
// Wazat's grappling hook
.entity hook;
-void GrapplingHookFrame();
-void _GrapplingHookFrame();
void RemoveGrapplingHook(entity pl);
void SetGrappleHookBindings();
// (note: you can change the hook impulse #'s to whatever you please)
METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2))
{
if(fire1)
- if(weapon_prepareattack(actor, false, autocvar_g_balance_nexball_primary_refire))
+ if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire))
if(autocvar_g_nexball_basketball_meter)
{
if(self.ballcarried && !self.metertime)
weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready);
}
if(fire2)
- if(weapon_prepareattack(actor, true, autocvar_g_balance_nexball_secondary_refire))
+ if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_nexball_secondary_refire))
{
W_Nexball_Attack2();
weapon_thinkf(actor, WFRAME_FIRE2, autocvar_g_balance_nexball_secondary_animtime, w_ready);
.float prevdryfire;
.float prevwarntime;
-bool weapon_prepareattack_checkammo(entity actor, float secondary)
+bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondary)
{
- Weapon w = get_weaponinfo(actor.weapon);
- if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
- if (!w.(secondary ? wr_checkammo2 : wr_checkammo1)(w))
- {
- // always keep the Mine Layer if we placed mines, so that we can detonate them
- entity mine;
- if(actor.weapon == WEP_MINE_LAYER.m_id)
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == actor)
- return false;
+ if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
+ bool ammo = false;
+ if (secondary) {
+ WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+ } else {
+ WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
+ }
+ if (ammo) return true;
+ // always keep the Mine Layer if we placed mines, so that we can detonate them
+ entity mine;
+ if(actor.weapon == WEP_MINE_LAYER.m_id)
+ for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == actor)
+ return false;
- if(actor.weapon == WEP_SHOTGUN.m_id)
- if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
- return false; // no clicking, just allow
+ if(actor.weapon == WEP_SHOTGUN.m_id)
+ if(!secondary && WEP_CVAR(shotgun, secondary) == 1)
+ return false; // no clicking, just allow
- if(actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
- {
- sound (actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
- actor.prevdryfire = time;
- }
+ if(actor.weapon == actor.switchweapon && time - actor.prevdryfire > 1) // only play once BEFORE starting to switch weapons
+ {
+ sound (actor, CH_WEAPON_A, SND_DRYFIRE, VOL_BASE, ATTEN_NORM);
+ actor.prevdryfire = time;
+ }
- if(w.(secondary ? wr_checkammo1 : wr_checkammo2)(w)) // check if the other firing mode has enough ammo
- {
- if(time - actor.prevwarntime > 1)
- {
- Send_Notification(
- NOTIF_ONE,
- actor,
- MSG_MULTI,
- ITEM_WEAPON_PRIMORSEC,
- actor.weapon,
- secondary,
- (1 - secondary)
- );
- }
- actor.prevwarntime = time;
- }
- else // this weapon is totally unable to fire, switch to another one
+ // check if the other firing mode has enough ammo
+ bool ammo_other = false;
+ if (secondary) {
+ WITH(entity, self, actor, ammo = thiswep.wr_checkammo1(thiswep));
+ } else {
+ WITH(entity, self, actor, ammo = thiswep.wr_checkammo2(thiswep));
+ }
+ if (ammo_other)
+ {
+ if (time - actor.prevwarntime > 1)
{
- W_SwitchToOtherWeapon(actor);
+ Send_Notification(
+ NOTIF_ONE,
+ actor,
+ MSG_MULTI,
+ ITEM_WEAPON_PRIMORSEC,
+ actor.weapon,
+ secondary,
+ (1 - secondary)
+ );
}
-
- return false;
+ actor.prevwarntime = time;
}
- return true;
+ else // this weapon is totally unable to fire, switch to another one
+ {
+ W_SwitchToOtherWeapon(actor);
+ }
+
+ return false;
}
.float race_penalty;
-bool weapon_prepareattack_check(entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, float attacktime)
{
- if(!weapon_prepareattack_checkammo(actor, secondary))
+ if(!weapon_prepareattack_checkammo(thiswep, actor, secondary))
return false;
//if sv_ready_restart_after_countdown is set, don't allow the player to shoot
actor.bulletcounter += 1;
//dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n");
}
-bool weapon_prepareattack(entity actor, bool secondary, float attacktime)
+bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime)
{
- if (weapon_prepareattack_check(actor, secondary, attacktime)) {
+ if (weapon_prepareattack_check(thiswep, actor, secondary, attacktime)) {
weapon_prepareattack_do(actor, secondary, attacktime);
return true;
}
return 0;
}
+.bool hook_switchweapon;
+
void W_WeaponFrame(entity actor)
{
vector fo, ri, up;
v_right = ri;
v_up = up;
+ bool block_weapon = false;
{
- bool key_pressed = actor.BUTTON_HOOK;
- Weapon wpn = actor.offhand;
- if (wpn.offhand_think) wpn.offhand_think(wpn, actor, key_pressed);
+ bool key_pressed = actor.BUTTON_HOOK && !actor.vehicle;
+ Weapon off = actor.offhand;
+ if (off) {
+ if (off.offhand_think) off.offhand_think(off, actor, key_pressed);
+ } else {
+ if (key_pressed && actor.switchweapon != WEP_HOOK.m_id && !actor.hook_switchweapon) {
+ W_SwitchWeapon(WEP_HOOK.m_id);
+ }
+ actor.hook_switchweapon = key_pressed;
+ Weapon h = WEP_HOOK;
+ block_weapon = (actor.weapon == h.m_id && (actor.BUTTON_ATCK || key_pressed));
+ h.wr_think(h, actor, block_weapon, false);
+ }
}
+ if (!block_weapon)
if (w) {
Weapon e = get_weaponinfo(actor.weapon);
e.wr_think(e, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2);
float W_WeaponSpeedFactor();
-bool weapon_prepareattack(entity actor, bool secondary, float attacktime);
+bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime);
-bool weapon_prepareattack_check(entity actor, float secondary, float attacktime);
+bool weapon_prepareattack_check(Weapon thiswep, entity actor, float secondary, float attacktime);
void weapon_prepareattack_do(entity actor, float secondary, float attacktime);