From: TimePath Date: Tue, 6 Oct 2015 00:00:09 +0000 (+1100) Subject: Hook: merge offhand and weapon behaviour X-Git-Tag: xonotic-v0.8.2~1874^2~6 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0ee6791fda327d24c57a125513402f367d75ffb1;p=xonotic%2Fxonotic-data.pk3dir.git Hook: merge offhand and weapon behaviour Fixes offhand with nades Fixes ammo --- diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 54d17d934..9952063f6 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -42,7 +42,7 @@ void M_Mage_Attack_Spike(vector dir); 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); @@ -51,7 +51,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bo 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); } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index e262ca87d..35a320b9d 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -53,7 +53,7 @@ void M_Spider_Attack_Web(); 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); @@ -68,7 +68,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fir 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; diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index c901e3ae3..102fd6a5c 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -50,7 +50,7 @@ void M_Wyvern_Attack_Fireball_Touch(); 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; diff --git a/qcsrc/common/turrets/turret/ewheel_weapon.qc b/qcsrc/common/turrets/turret/ewheel_weapon.qc index 2e8e8dc29..86444bb48 100644 --- a/qcsrc/common/turrets/turret/ewheel_weapon.qc +++ b/qcsrc/common/turrets/turret/ewheel_weapon.qc @@ -19,7 +19,7 @@ void turret_initparams(entity); 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); diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index 31bc7cb7b..4c60805d2 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -19,7 +19,7 @@ void turret_flac_projectile_think_explode(); 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); diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 0503cbd90..491fa734e 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -22,7 +22,7 @@ void turret_hellion_missile_think(); 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); diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index 51ce0d983..9fe73f830 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -27,7 +27,7 @@ METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, bool fir { 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); diff --git a/qcsrc/common/turrets/turret/machinegun_weapon.qc b/qcsrc/common/turrets/turret/machinegun_weapon.qc index 264053fb6..9b1489829 100644 --- a/qcsrc/common/turrets/turret/machinegun_weapon.qc +++ b/qcsrc/common/turrets/turret/machinegun_weapon.qc @@ -21,7 +21,7 @@ METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, bool { 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); diff --git a/qcsrc/common/turrets/turret/mlrs_weapon.qc b/qcsrc/common/turrets/turret/mlrs_weapon.qc index f2d442df8..3b420f329 100644 --- a/qcsrc/common/turrets/turret/mlrs_weapon.qc +++ b/qcsrc/common/turrets/turret/mlrs_weapon.qc @@ -19,7 +19,7 @@ METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1 { 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); diff --git a/qcsrc/common/turrets/turret/phaser_weapon.qc b/qcsrc/common/turrets/turret/phaser_weapon.qc index aa71a47d0..2cb036bc5 100644 --- a/qcsrc/common/turrets/turret/phaser_weapon.qc +++ b/qcsrc/common/turrets/turret/phaser_weapon.qc @@ -22,7 +22,7 @@ METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fir { 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); diff --git a/qcsrc/common/turrets/turret/plasma_weapon.qc b/qcsrc/common/turrets/turret/plasma_weapon.qc index 83c205026..65a663057 100644 --- a/qcsrc/common/turrets/turret/plasma_weapon.qc +++ b/qcsrc/common/turrets/turret/plasma_weapon.qc @@ -18,7 +18,7 @@ REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack)); 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); diff --git a/qcsrc/common/turrets/turret/tesla_weapon.qc b/qcsrc/common/turrets/turret/tesla_weapon.qc index 8a4f55ed8..3a8eb1d52 100644 --- a/qcsrc/common/turrets/turret/tesla_weapon.qc +++ b/qcsrc/common/turrets/turret/tesla_weapon.qc @@ -19,7 +19,7 @@ entity toast(entity from, float range, float damage); 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); diff --git a/qcsrc/common/turrets/turret/walker_weapon.qc b/qcsrc/common/turrets/turret/walker_weapon.qc index 676bf896e..9a54f810f 100644 --- a/qcsrc/common/turrets/turret/walker_weapon.qc +++ b/qcsrc/common/turrets/turret/walker_weapon.qc @@ -18,7 +18,7 @@ REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack)); 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); diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index 094d12514..d5a4c1231 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -48,7 +48,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, boo 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; @@ -64,7 +64,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, boo 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); diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 62d8c12e5..ebc73787c 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -58,7 +58,7 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bo // 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; @@ -93,7 +93,7 @@ METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool 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); @@ -114,7 +114,7 @@ METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, boo 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); diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 0ec1d7a09..e1796bdf2 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -677,7 +677,7 @@ void Arc_Smoke() 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); @@ -702,7 +702,7 @@ void Arc_Smoke() #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; diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index 5d636674d..d7792fac4 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -165,7 +165,7 @@ void W_Blaster_Attack( { 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, @@ -196,7 +196,7 @@ void W_Blaster_Attack( 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, diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index d72320cf2..75d8146de 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -584,7 +584,7 @@ void W_Crylink_Attack2(Weapon thiswep) 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); @@ -594,7 +594,7 @@ void W_Crylink_Attack2(Weapon thiswep) 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); diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 3d0b46dcd..8c080862d 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -527,7 +527,7 @@ void W_Devastator_Attack(Weapon thiswep) 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); diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 8b643e57c..7321d38f2 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -410,7 +410,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) {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; @@ -471,7 +471,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) 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); @@ -480,7 +480,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) 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); diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index dd5d8c241..b0761b2c2 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -376,7 +376,7 @@ void W_Fireball_Attack2(void) 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(); @@ -384,7 +384,7 @@ void W_Fireball_Attack2(void) } 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); diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index c7712bf2f..37f6875b5 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -419,7 +419,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) 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); @@ -427,7 +427,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) } 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); diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index fb1d9fcdb..616939d1e 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -218,7 +218,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) 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); @@ -228,7 +228,7 @@ void W_HLAC_Attack2_Frame(Weapon 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); diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index bcbefbf82..6707a7c32 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -104,7 +104,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, boo } 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); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 48fdb6508..e279b798a 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -18,10 +18,10 @@ ENDCLASS(Hook) 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); } @@ -175,23 +175,25 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) 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); @@ -246,33 +248,22 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) 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)) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 688600cd7..90a4471f1 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -256,14 +256,14 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi 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)) @@ -284,7 +284,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi { 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 @@ -292,7 +292,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi } 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 diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 75cc7e4d7..548ede966 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -511,7 +511,7 @@ float W_MineLayer_PlacedMines(float detonate) } 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); diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 34d64f004..c19957458 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -341,7 +341,7 @@ void W_Mortar_Attack2(Weapon thiswep) 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); @@ -364,7 +364,7 @@ void W_Mortar_Attack2(Weapon thiswep) 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); diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index cf802ac7f..b17476632 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -305,7 +305,7 @@ void W_Porto_Attack(float type) 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); @@ -314,7 +314,7 @@ void W_Porto_Attack(float type) 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); @@ -347,7 +347,7 @@ void W_Porto_Attack(float type) 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); diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 73590a5d5..49b393156 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -99,7 +99,7 @@ void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, bool fire1, bool 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) @@ -169,7 +169,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt { 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)); @@ -185,7 +185,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt 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)); diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/weapons/weapon/rpc.qc index 700e66be2..71ddaa6b5 100644 --- a/qcsrc/common/weapons/weapon/rpc.qc +++ b/qcsrc/common/weapons/weapon/rpc.qc @@ -162,7 +162,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) { 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); diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 365061ec2..645bd9eb9 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -617,7 +617,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) { 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); @@ -625,7 +625,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) } 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); @@ -637,7 +637,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) { 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); @@ -645,7 +645,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) } 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); diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index a99c5192f..30ffaca32 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -681,7 +681,7 @@ void W_Shockwave_Attack(void) { 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(); @@ -693,7 +693,7 @@ void W_Shockwave_Attack(void) { //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); diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 813fce328..a5cb39773 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -250,7 +250,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir { 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(); @@ -262,7 +262,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir { 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(); @@ -275,7 +275,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir 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); diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index e6bd46cff..d1c86de30 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -382,14 +382,14 @@ void W_Tuba_NoteOn(float hittype) 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); diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 012bd852d..f7aceee20 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -257,7 +257,7 @@ void W_RocketMinsta_Attack3 (void) } 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); diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index d09746724..c51028b62 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -163,7 +163,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) { 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); @@ -235,7 +235,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) } 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); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 7914804b9..eedecf87b 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -2546,8 +2546,6 @@ void PlayerPreThink (void) FixPlayermodel(); - GrapplingHookFrame(); - // LordHavoc: allow firing on move frames (sub-ticrate), this gives better timing on slow servers //if(frametime) { diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 95b8c7ba3..87d7e0e52 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -65,7 +65,6 @@ And you should be done! ============================================*/ .float hook_length; -.float hook_switchweapon; void RemoveGrapplingHook(entity pl) { @@ -405,111 +404,6 @@ void FireGrapplingHook (void) 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) diff --git a/qcsrc/server/g_hook.qh b/qcsrc/server/g_hook.qh index 26189143c..140a93cfd 100644 --- a/qcsrc/server/g_hook.qh +++ b/qcsrc/server/g_hook.qh @@ -3,8 +3,6 @@ // 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) diff --git a/qcsrc/server/mutators/gamemode_nexball.qc b/qcsrc/server/mutators/gamemode_nexball.qc index 2e152bb68..f65e05843 100644 --- a/qcsrc/server/mutators/gamemode_nexball.qc +++ b/qcsrc/server/mutators/gamemode_nexball.qc @@ -842,7 +842,7 @@ float ball_customize() 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) @@ -856,7 +856,7 @@ float ball_customize() 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); diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 208948f28..0929d8bc6 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -457,57 +457,66 @@ void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2) .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 @@ -553,9 +562,9 @@ void weapon_prepareattack_do(entity actor, bool secondary, float attacktime) 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; } @@ -653,6 +662,8 @@ float forbidWeaponUse(entity player) return 0; } +.bool hook_switchweapon; + void W_WeaponFrame(entity actor) { vector fo, ri, up; @@ -766,12 +777,24 @@ void W_WeaponFrame(entity actor) 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); diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index d3d9f14fa..e1fc0922d 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -34,9 +34,9 @@ float W_WeaponRateFactor(); 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);