From 020203bfc55c480b73af2611bea0f0198b4fd314 Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 28 Oct 2015 15:12:26 +1100 Subject: [PATCH] Weapons: use bitflags for fire modes --- .../gamemodes/gamemode/nexball/nexball.qc | 8 +- qcsrc/common/monsters/monster/mage.qc | 10 +- qcsrc/common/monsters/monster/spider.qc | 10 +- qcsrc/common/monsters/monster/wyvern.qc | 6 +- qcsrc/common/turrets/turret.qh | 2 +- qcsrc/common/turrets/turret/ewheel_weapon.qc | 4 +- qcsrc/common/turrets/turret/flac_weapon.qc | 4 +- qcsrc/common/turrets/turret/hellion_weapon.qc | 4 +- qcsrc/common/turrets/turret/hk_weapon.qc | 4 +- .../turrets/turret/machinegun_weapon.qc | 4 +- qcsrc/common/turrets/turret/mlrs_weapon.qc | 4 +- qcsrc/common/turrets/turret/phaser_weapon.qc | 4 +- qcsrc/common/turrets/turret/plasma_weapon.qc | 4 +- qcsrc/common/turrets/turret/tesla_weapon.qc | 4 +- qcsrc/common/turrets/turret/walker_weapon.qc | 4 +- qcsrc/common/vehicles/vehicle/racer.qc | 2 +- qcsrc/common/vehicles/vehicle/racer_weapon.qc | 6 +- qcsrc/common/vehicles/vehicle/raptor.qc | 6 +- .../common/vehicles/vehicle/raptor_weapons.qc | 12 +- qcsrc/common/weapons/weapon.qh | 2 +- qcsrc/common/weapons/weapon/arc.qc | 10 +- qcsrc/common/weapons/weapon/blaster.qc | 6 +- qcsrc/common/weapons/weapon/crylink.qc | 8 +- qcsrc/common/weapons/weapon/devastator.qc | 6 +- qcsrc/common/weapons/weapon/electro.qc | 10 +- qcsrc/common/weapons/weapon/fireball.qc | 18 +- qcsrc/common/weapons/weapon/hagar.qc | 6 +- qcsrc/common/weapons/weapon/hlac.qc | 12 +- qcsrc/common/weapons/weapon/hmg.qc | 12 +- qcsrc/common/weapons/weapon/hook.qc | 8 +- qcsrc/common/weapons/weapon/machinegun.qc | 32 +- qcsrc/common/weapons/weapon/minelayer.qc | 6 +- qcsrc/common/weapons/weapon/mortar.qc | 6 +- qcsrc/common/weapons/weapon/porto.qc | 12 +- qcsrc/common/weapons/weapon/rifle.qc | 8 +- qcsrc/common/weapons/weapon/rpc.qc | 6 +- qcsrc/common/weapons/weapon/seeker.qc | 6 +- qcsrc/common/weapons/weapon/shockwave.qc | 8 +- qcsrc/common/weapons/weapon/shotgun.qc | 18 +- qcsrc/common/weapons/weapon/tuba.qc | 8 +- qcsrc/common/weapons/weapon/vaporizer.qc | 6 +- qcsrc/common/weapons/weapon/vortex.qc | 8 +- qcsrc/server/defs.qh | 8 +- .../mutators/mutator/mutator_overkill.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 428 +++++++++--------- qcsrc/server/weapons/weaponsystem.qh | 2 +- 46 files changed, 374 insertions(+), 390 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 4349a1e5e..490951459 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -854,9 +854,9 @@ float ball_customize() return true; } - METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, bool fire1, bool fire2)) + METHOD(BallStealer, wr_think, void(BallStealer thiswep, entity actor, int fire)) { - if(fire1) + if(fire & 1) if(weapon_prepareattack(thiswep, actor, false, autocvar_g_balance_nexball_primary_refire)) if(autocvar_g_nexball_basketball_meter) { @@ -870,14 +870,14 @@ float ball_customize() W_Nexball_Attack(-1); weapon_thinkf(actor, WFRAME_FIRE1, autocvar_g_balance_nexball_primary_animtime, w_ready); } - if(fire2) + if(fire & 2) 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); } - if(!fire1 && self.metertime && self.ballcarried) + if(!(fire & 1) && self.metertime && self.ballcarried) { W_Nexball_Attack(time - self.metertime); // DropBall or stealing will set metertime back to 0 diff --git a/qcsrc/common/monsters/monster/mage.qc b/qcsrc/common/monsters/monster/mage.qc index 7388ee66f..611e3b884 100644 --- a/qcsrc/common/monsters/monster/mage.qc +++ b/qcsrc/common/monsters/monster/mage.qc @@ -41,8 +41,8 @@ REGISTER_WEAPON(MAGE_SPIKE, NEW(MageSpike)); 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) +METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, int fire)) { + if (fire & 1) 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); @@ -51,7 +51,7 @@ METHOD(MageSpike, wr_think, void(MageSpike thiswep, entity actor, bool fire1, bo M_Mage_Attack_Spike(w_shotdir); weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); } - if (fire2) + if (fire & 2) if (!IS_PLAYER(actor) || weapon_prepareattack(thiswep, actor, true, 0.5)) { M_Mage_Attack_Push(); weapon_thinkf(actor, WFRAME_FIRE2, 0, w_ready); @@ -363,7 +363,7 @@ float M_Mage_Attack(float attack_type, entity targ) if(random() <= 0.7) { Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, self, false, true); + wep.wr_think(wep, self, 2); return true; } @@ -385,7 +385,7 @@ float M_Mage_Attack(float attack_type, entity targ) self.attack_finished_single = time + (autocvar_g_monster_mage_attack_spike_delay); self.anim_finished = time + 1; Weapon wep = WEP_MAGE_SPIKE; - wep.wr_think(wep, self, true, false); + wep.wr_think(wep, self, 1); return true; } } diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 208ae1079..52bda4ec9 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -50,9 +50,9 @@ float autocvar_g_monster_spider_attack_bite_delay; void M_Spider_Attack_Web(); -METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) 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; @@ -67,7 +67,7 @@ METHOD(SpiderAttack, wr_think, void(SpiderAttack thiswep, entity actor, bool fir weapon_thinkf(actor, WFRAME_FIRE1, 0, w_ready); return; } - if (fire2) + if (fire & 2) if (!isPlayer || weapon_prepareattack(thiswep, actor, true, 0.5)) { if (isPlayer) { actor.enemy = Monster_FindTarget(actor); @@ -160,12 +160,12 @@ bool M_Spider_Attack(int attack_type, entity targ) Weapon wep = WEP_SPIDER_ATTACK; case MONSTER_ATTACK_MELEE: { - wep.wr_think(wep, self, false, true); + wep.wr_think(wep, self, 2); return true; } case MONSTER_ATTACK_RANGED: { - wep.wr_think(wep, self, true, false); + wep.wr_think(wep, self, 1); return true; } } diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index ac9f32205..b3bb5bfe8 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -48,8 +48,8 @@ float autocvar_g_monster_wyvern_attack_fireball_speed; void M_Wyvern_Attack_Fireball_Explode(); void M_Wyvern_Attack_Fireball_Touch(); -METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, bool fire1, bool fire2)) { - if (fire1) +METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, int fire)) { + if (fire & 1) 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)) { @@ -128,7 +128,7 @@ float M_Wyvern_Attack(float attack_type, entity targ) { w_shotdir = normalize((self.enemy.origin + '0 0 10') - self.origin); Weapon wep = WEP_WYVERN_ATTACK; - wep.wr_think(wep, self, true, false); + wep.wr_think(wep, self, 1); return true; } } diff --git a/qcsrc/common/turrets/turret.qh b/qcsrc/common/turrets/turret.qh index 8862f47d7..32f92a675 100644 --- a/qcsrc/common/turrets/turret.qh +++ b/qcsrc/common/turrets/turret.qh @@ -46,7 +46,7 @@ CLASS(Turret, Object) /** (SERVER) called when turret attacks */ METHOD(Turret, tr_attack, void(Turret this)) { Weapon w = this.m_weapon; - w.wr_think(w, self, true, false); + w.wr_think(w, self, 1); } /** (ALL) */ METHOD(Turret, tr_config, void(Turret this)) { diff --git a/qcsrc/common/turrets/turret/ewheel_weapon.qc b/qcsrc/common/turrets/turret/ewheel_weapon.qc index 34e5a5986..904260300 100644 --- a/qcsrc/common/turrets/turret/ewheel_weapon.qc +++ b/qcsrc/common/turrets/turret/ewheel_weapon.qc @@ -16,9 +16,9 @@ REGISTER_WEAPON(EWHEEL, NEW(EWheelAttack)); #ifdef SVQC void turret_initparams(entity); -METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(EWheelAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/flac_weapon.qc b/qcsrc/common/turrets/turret/flac_weapon.qc index 834f255da..afba577f1 100644 --- a/qcsrc/common/turrets/turret/flac_weapon.qc +++ b/qcsrc/common/turrets/turret/flac_weapon.qc @@ -16,9 +16,9 @@ REGISTER_WEAPON(FLAC, NEW(FlacAttack)); #ifdef SVQC void turret_flac_projectile_think_explode(); -METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(FlacAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/hellion_weapon.qc b/qcsrc/common/turrets/turret/hellion_weapon.qc index 2d754e877..94e6d5f41 100644 --- a/qcsrc/common/turrets/turret/hellion_weapon.qc +++ b/qcsrc/common/turrets/turret/hellion_weapon.qc @@ -19,9 +19,9 @@ float autocvar_g_turrets_unit_hellion_shot_speed_gain; float autocvar_g_turrets_unit_hellion_shot_speed_max; void turret_hellion_missile_think(); -METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(HellionAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/hk_weapon.qc b/qcsrc/common/turrets/turret/hk_weapon.qc index 98bff5757..c7c781872 100644 --- a/qcsrc/common/turrets/turret/hk_weapon.qc +++ b/qcsrc/common/turrets/turret/hk_weapon.qc @@ -23,10 +23,10 @@ float autocvar_g_turrets_unit_hk_shot_speed_max; float autocvar_g_turrets_unit_hk_shot_speed_turnrate; void turret_hk_missile_think(); -METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) +METHOD(HunterKillerAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/machinegun_weapon.qc b/qcsrc/common/turrets/turret/machinegun_weapon.qc index a20bdb22c..9dfff9e43 100644 --- a/qcsrc/common/turrets/turret/machinegun_weapon.qc +++ b/qcsrc/common/turrets/turret/machinegun_weapon.qc @@ -17,10 +17,10 @@ REGISTER_WEAPON(TUR_MACHINEGUN, NEW(MachineGunTurretAttack)); void W_MachineGun_MuzzleFlash(); -METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) +METHOD(MachineGunTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/mlrs_weapon.qc b/qcsrc/common/turrets/turret/mlrs_weapon.qc index 059335913..45a125438 100644 --- a/qcsrc/common/turrets/turret/mlrs_weapon.qc +++ b/qcsrc/common/turrets/turret/mlrs_weapon.qc @@ -15,10 +15,10 @@ REGISTER_WEAPON(TUR_MLRS, NEW(MLRSTurretAttack)); #ifdef SVQC -METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) +METHOD(MLRSTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR(machinegun, sustained_refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/phaser_weapon.qc b/qcsrc/common/turrets/turret/phaser_weapon.qc index c4529ae26..d493486f7 100644 --- a/qcsrc/common/turrets/turret/phaser_weapon.qc +++ b/qcsrc/common/turrets/turret/phaser_weapon.qc @@ -18,10 +18,10 @@ void beam_think(); .int fireflag; -METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) +METHOD(PhaserTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/plasma_weapon.qc b/qcsrc/common/turrets/turret/plasma_weapon.qc index 2141fe64f..3a032f2a7 100644 --- a/qcsrc/common/turrets/turret/plasma_weapon.qc +++ b/qcsrc/common/turrets/turret/plasma_weapon.qc @@ -15,9 +15,9 @@ REGISTER_WEAPON(PLASMA, NEW(PlasmaAttack)); #ifdef SVQC -METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(PlasmaAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/tesla_weapon.qc b/qcsrc/common/turrets/turret/tesla_weapon.qc index 4391472f7..de3a6d3a8 100644 --- a/qcsrc/common/turrets/turret/tesla_weapon.qc +++ b/qcsrc/common/turrets/turret/tesla_weapon.qc @@ -16,9 +16,9 @@ REGISTER_WEAPON(TESLA, NEW(TeslaCoilTurretAttack)); #ifdef SVQC entity toast(entity from, float range, float damage); -METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(TeslaCoilTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/turrets/turret/walker_weapon.qc b/qcsrc/common/turrets/turret/walker_weapon.qc index 4da45df7f..b4c8a5d9f 100644 --- a/qcsrc/common/turrets/turret/walker_weapon.qc +++ b/qcsrc/common/turrets/turret/walker_weapon.qc @@ -15,9 +15,9 @@ REGISTER_WEAPON(WALKER, NEW(WalkerTurretAttack)); #ifdef SVQC -METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(WalkerTurretAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); - if (fire1) + if (fire & 1) if (!isPlayer || weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { if (isPlayer) { turret_initparams(actor); diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index 8c45b4aa9..1c3d33129 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -321,7 +321,7 @@ float racer_frame() // Fix z-aim (for chase mode) crosshair_trace(player); w_shotdir.z = normalize(trace_endpos - org).z * 0.5; - wep1.wr_think(wep1, self, true, false); + wep1.wr_think(wep1, self, 1); } if(autocvar_g_vehicle_racer_rocket_locktarget) diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index 6a2339f1e..d58705b59 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -42,12 +42,12 @@ float autocvar_g_vehicle_racer_rocket_climbspeed; float autocvar_g_vehicle_racer_rocket_locked_maxangle; void racer_fire_rocket(vector org, vector dir, entity trg); -METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) +METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - if (fire1) + if (fire & 1) if (weapon_prepareattack(thiswep, player, false, autocvar_g_vehicle_racer_cannon_refire)) { if (veh) { veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost; @@ -63,7 +63,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, bool fire1, boo bolt.velocity = normalize(dir) * autocvar_g_vehicle_racer_cannon_speed; weapon_thinkf(player, WFRAME_FIRE1, 0, w_ready); } - if (fire2) + if (fire & 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); diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 58a189a85..422dd8a64 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -392,7 +392,7 @@ float raptor_frame() if(player.BUTTON_ATCK) if (wep1.wr_checkammo1(wep1)) { - wep1.wr_think(wep1, self, true, false); + wep1.wr_think(wep1, self, 1); } if(self.vehicle_flags & VHF_SHIELDREGEN) @@ -411,7 +411,7 @@ float raptor_frame() if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire) if(player.BUTTON_ATCK2) { - wep2a.wr_think(wep2a, self, false, true); + wep2a.wr_think(wep2a, self, 2); raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire; raptor.lip = time; } @@ -422,7 +422,7 @@ float raptor_frame() if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire) if(player.BUTTON_ATCK2) { - wep2b.wr_think(wep2b, self, false, true); + wep2b.wr_think(wep2b, self, 2); raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire; raptor.lip = time; } diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index 69d981beb..32752c9ce 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -51,13 +51,13 @@ float autocvar_g_vehicle_raptor_bomblet_radius; float autocvar_g_vehicle_raptor_bomblet_force; float autocvar_g_vehicle_raptor_bomblet_explode_delay; -METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; // 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 (fire & 1) 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; @@ -88,11 +88,11 @@ METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) { float autocvar_g_vehicle_raptor_bombs_refire; void raptor_bombdrop(); -METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(RaptorBomb, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - if (fire2) + if (fire & 2) if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_bombs_refire)) { if (veh) setself(veh); raptor_bombdrop(); @@ -109,11 +109,11 @@ void raptor_flare_think(); void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force); void raptor_flare_touch(); -METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) { +METHOD(RaptorFlare, wr_think, void(entity thiswep, entity actor, int fire)) { bool isPlayer = IS_PLAYER(actor); entity player = isPlayer ? actor : actor.owner; entity veh = player.vehicle; - if (fire2) + if (fire & 2) if (!isPlayer || weapon_prepareattack(thiswep, player, true, autocvar_g_vehicle_raptor_flare_refire)) { for(int i = 0; i < 3; ++i) { entity _flare = spawn(); diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index a4eb7b71d..61629595d 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -47,7 +47,7 @@ CLASS(Weapon, Object) /** (SERVER) setup weapon data */ METHOD(Weapon, wr_setup, void(Weapon this)) {} /** (SERVER) logic to run every frame */ - METHOD(Weapon, wr_think, void(Weapon this, entity actor, bool fire1, bool fire2)) {} + METHOD(Weapon, wr_think, void(Weapon this, entity actor, int fire)) {} /** (SERVER) checks ammo for weapon primary */ METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;} /** (SERVER) checks ammo for weapon second */ diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index b05132cb1..08be8f7d2 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -656,13 +656,13 @@ void Arc_Smoke() ); } } - METHOD(Arc, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Arc, wr_think, void(entity thiswep, entity actor, int fire)) { Arc_Player_SetHeat(actor); Arc_Smoke(); if (time >= actor.arc_overheat) - if (fire1 || fire2 || actor.arc_beam.beam_bursting) + if ((fire & 1) || (fire & 2) || actor.arc_beam.beam_bursting) { if(actor.arc_BUTTON_ATCK_prev) @@ -677,9 +677,9 @@ void Arc_Smoke() if((!actor.arc_beam) || wasfreed(actor.arc_beam)) { - if(weapon_prepareattack(thiswep, actor, fire2, 0)) + if(weapon_prepareattack(thiswep, actor, boolean(fire & 2), 0)) { - W_Arc_Beam(fire2); + W_Arc_Beam(boolean(fire & 2)); if(!actor.arc_BUTTON_ATCK_prev) { @@ -701,7 +701,7 @@ void Arc_Smoke() actor.arc_BUTTON_ATCK_prev = false; #if 0 - if(fire2) + if(fire & 2) if(weapon_prepareattack(thiswep, actor, true, autocvar_g_balance_arc_secondary_refire)) { W_Arc_Attack2(); diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index d7792fac4..69b97bf66 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -161,9 +161,9 @@ void W_Blaster_Attack( { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(blaster, speed), 0, WEP_CVAR_PRI(blaster, lifetime), false); } } - METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Blaster, wr_think, void(Blaster thiswep, entity actor, int fire)) { - if(fire1) + if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(blaster, refire))) { @@ -183,7 +183,7 @@ void W_Blaster_Attack( weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(blaster, animtime), w_ready); } } - else if(fire2) + else if(fire & 2) { switch(WEP_CVAR(blaster, secondary)) { diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 75d8146de..8875dac4e 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -574,14 +574,14 @@ void W_Crylink_Attack2(Weapon thiswep) else self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(crylink, speed), 0, WEP_CVAR_SEC(crylink, middle_lifetime), false); } - METHOD(Crylink, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Crylink, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_crylink_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(crylink, ammo), WEP_CVAR_SEC(crylink, ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } - if(fire1) + if(fire & 1) { if(actor.crylink_waitrelease != 1) if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(crylink, refire))) @@ -591,7 +591,7 @@ void W_Crylink_Attack2(Weapon thiswep) } } - if(fire2 && autocvar_g_balance_crylink_secondary) + if((fire & 2) && autocvar_g_balance_crylink_secondary) { if(actor.crylink_waitrelease != 2) if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(crylink, refire))) @@ -601,7 +601,7 @@ void W_Crylink_Attack2(Weapon thiswep) } } - if((actor.crylink_waitrelease == 1 && !fire1) || (actor.crylink_waitrelease == 2 && !fire2)) + if((actor.crylink_waitrelease == 1 && !(fire & 1)) || (actor.crylink_waitrelease == 2 && !(fire & 2))) { if(!actor.crylink_lastgroup || time > actor.crylink_lastgroup.teleport_time) { diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index b9cc0358b..fc6b8af19 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -520,13 +520,13 @@ void W_Devastator_Attack(Weapon thiswep) } } #endif - METHOD(Devastator, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Devastator, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(devastator, reload_ammo) && actor.clip_load < WEP_CVAR(devastator, ammo)) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { - if(fire1) + if(fire & 1) { if(actor.rl_release || WEP_CVAR(devastator, guidestop)) if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(devastator, refire))) @@ -539,7 +539,7 @@ void W_Devastator_Attack(Weapon thiswep) else actor.rl_release = 1; - if(fire2) + if(fire & 2) if(actor.switchweapon == WEP_DEVASTATOR.m_id) { entity rock; diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 7321d38f2..a85f43ea3 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -406,7 +406,7 @@ void W_Electro_Attack_Orb(Weapon thiswep) MUTATOR_CALLHOOK(EditProjectile, self, proj); } -void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Electro_CheckAttack(Weapon thiswep, entity actor, int fire) {SELFPARAM(); if(self.electro_count > 1) if(self.BUTTON_ATCK2) @@ -418,7 +418,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) return; } // WEAPONTODO: when the player releases the button, cut down the length of refire2? - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); } .float bot_secondary_electromooth; @@ -451,7 +451,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) } } } - METHOD(Electro, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Electro, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_electro_reload_ammo) // forced reload // WEAPONTODO { @@ -469,7 +469,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) } } - if(fire1) + if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(electro, refire))) { @@ -477,7 +477,7 @@ void W_Electro_CheckAttack(Weapon thiswep, entity actor, bool fire1, bool fire2) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(electro, animtime), w_ready); } } - else if(fire2) + else if(fire & 2) { if(time >= actor.electro_secondarytime) if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(electro, refire))) diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index b0761b2c2..f56d06857 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -226,31 +226,31 @@ void W_Fireball_AttackEffect(float i, vector f_diff) Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1); } -void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame4(Weapon thiswep, entity actor, int fire) { W_Fireball_Attack1(); weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready); } -void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame3(Weapon thiswep, entity actor, int fire) { W_Fireball_AttackEffect(0, '+1.25 +3.75 0'); weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4); } -void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame2(Weapon thiswep, entity actor, int fire) { W_Fireball_AttackEffect(0, '-1.25 +3.75 0'); weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3); } -void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame1(Weapon thiswep, entity actor, int fire) { W_Fireball_AttackEffect(1, '+1.25 -3.75 0'); weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2); } -void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Fireball_Attack1_Frame0(Weapon thiswep, entity actor, int fire) {SELFPARAM(); W_Fireball_AttackEffect(0, '-1.25 -3.75 0'); sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM); @@ -371,18 +371,18 @@ void W_Fireball_Attack2(void) } } } - METHOD(Fireball, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Fireball, wr_think, void(entity thiswep, entity actor, int fire)) { - if(fire1) + if(fire & 1) { if(time >= actor.fireball_primarytime) if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(fireball, refire))) { - W_Fireball_Attack1_Frame0(thiswep, actor, fire1, fire2); + W_Fireball_Attack1_Frame0(thiswep, actor, fire); actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(); } } - else if(fire2) + else if(fire & 2) { if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(fireball, refire))) { diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 37f6875b5..c88c91e7c 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -407,7 +407,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), false); } - METHOD(Hagar, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Hagar, wr_think, void(entity thiswep, entity actor, int fire)) { float loadable_secondary; loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary)); @@ -417,7 +417,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) if(autocvar_g_balance_hagar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(fire1 && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset + } else if((fire & 1) && !actor.hagar_load && !actor.hagar_loadblock) // not while secondary is loaded or awaiting reset { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hagar, refire))) { @@ -425,7 +425,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready); } } - else if(fire2 && !loadable_secondary && WEP_CVAR(hagar, secondary)) + else if((fire & 2) && !loadable_secondary && WEP_CVAR(hagar, secondary)) { if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hagar, refire))) { diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 616939d1e..d738c81d3 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -161,11 +161,11 @@ void W_HLAC_Attack2(void) } // weapon frames -void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, int fire) { if(actor.weapon != actor.switchweapon) // abort immediately if switching { - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -176,7 +176,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2) if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -211,12 +211,12 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) { self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hlac, speed), 0, WEP_CVAR_PRI(hlac, lifetime), false); } - METHOD(HLAC, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(HLAC, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_hlac_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(hlac, ammo), WEP_CVAR_SEC(hlac, ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(fire1) + } else if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(hlac, refire))) { @@ -226,7 +226,7 @@ void W_HLAC_Attack2_Frame(Weapon thiswep) } } - else if(fire2 && WEP_CVAR(hlac, secondary)) + else if((fire & 2) && WEP_CVAR(hlac, secondary)) { if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hlac, refire))) { diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index 6707a7c32..fc9811713 100644 --- a/qcsrc/common/weapons/weapon/hmg.qc +++ b/qcsrc/common/weapons/weapon/hmg.qc @@ -45,11 +45,11 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) spawnfunc(weapon_hmg) { weapon_defaultspawnfunc(WEP_HMG.m_id); } -void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, int fire) { if (!actor.BUTTON_ATCK) { - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -58,7 +58,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, boo if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -96,18 +96,18 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, boo else self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); } - METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(hmg, reload_ammo) && actor.clip_load < WEP_CVAR(hmg, ammo)) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { - if (fire1) + if (fire & 1) if (weapon_prepareattack(thiswep, actor, false, 0)) { actor.misc_bulletcounter = 0; - W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire1, fire2); + W_HeavyMachineGun_Attack_Auto(thiswep, actor, fire); } } } diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index c158d1c32..56c280079 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -22,7 +22,7 @@ CLASS(OffhandHook, OffhandWeapon) METHOD(OffhandHook, offhand_think, void(OffhandHook this, entity actor, bool key_pressed)) { Weapon wep = WEP_HOOK; - wep.wr_think(wep, actor, key_pressed, false); + wep.wr_think(wep, actor, key_pressed ? 1 : 0); } ENDCLASS(OffhandHook) OffhandHook OFFHAND_HOOK; STATIC_INIT(OFFHAND_HOOK) { OFFHAND_HOOK = NEW(OffhandHook); } @@ -174,9 +174,9 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) MUTATOR_CALLHOOK(EditProjectile, actor, gren); } - METHOD(Hook, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Hook, wr_think, void(entity thiswep, entity actor, int fire)) { - if (fire1) { + if (fire & 1) { if(!actor.hook) if(!(actor.hook_state & HOOK_WAITING_FOR_RELEASE)) if(time > actor.hook_refire) @@ -192,7 +192,7 @@ void W_Hook_Attack2(Weapon thiswep, entity actor) actor.hook_state &= ~HOOK_WAITING_FOR_RELEASE; } - if(fire2) + if(fire & 2) { if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(hook, refire))) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 90a4471f1..8241d1eca 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -137,11 +137,11 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype) } // weapon frames -void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, int fire) { if(actor.weapon != actor.switchweapon) // abort immediately if switching { - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } if(actor.BUTTON_ATCK) @@ -151,7 +151,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fi if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } actor.misc_bulletcounter = actor.misc_bulletcounter + 1; @@ -163,13 +163,13 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, bool fire1, bool fi } -void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, int fire) { float machinegun_spread; - if(!fire1) + if(!(fire & 1)) { - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -178,7 +178,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fir if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -208,7 +208,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, bool fire1, bool fir weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); } -void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, int fire) { W_SetupShot(actor, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) @@ -247,7 +247,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi else self.BUTTON_ATCK2 = bot_aim(1000000, 0, 0.001, false); } - METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(machinegun, reload_ammo) && actor.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); @@ -255,14 +255,14 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi } else if(WEP_CVAR(machinegun, mode) == 1) { - if(fire1) + if(fire & 1) if(weapon_prepareattack(thiswep, actor, false, 0)) { actor.misc_bulletcounter = 0; - W_MachineGun_Attack_Auto(thiswep, actor, fire1, fire2); + W_MachineGun_Attack_Auto(thiswep, actor, fire); } - if(fire2) + if(fire & 2) if(weapon_prepareattack(thiswep, actor, true, 0)) { Weapon w = get_weaponinfo(actor.weapon); @@ -270,20 +270,20 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo)); actor.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; - W_MachineGun_Attack_Burst(thiswep, actor, fire1, fire2); + W_MachineGun_Attack_Burst(thiswep, actor, fire); } } else { - if(fire1) + if(fire & 1) if(weapon_prepareattack(thiswep, actor, false, 0)) { actor.misc_bulletcounter = 1; @@ -291,7 +291,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, bool fire1, bool fi weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame); } - if(fire2 && WEP_CVAR(machinegun, first)) + if((fire & 2) && WEP_CVAR(machinegun, first)) if(weapon_prepareattack(thiswep, actor, true, 0)) { actor.misc_bulletcounter = 1; diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 548ede966..b2f9d161d 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -499,7 +499,7 @@ float W_MineLayer_PlacedMines(float detonate) if(self.BUTTON_ATCK2 == true) self.BUTTON_ATCK = false; } } - METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_minelayer_reload_ammo && actor.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload { @@ -509,7 +509,7 @@ float W_MineLayer_PlacedMines(float detonate) w.wr_reload(w); } } - else if(fire1) + else if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(minelayer, refire))) { @@ -518,7 +518,7 @@ float W_MineLayer_PlacedMines(float detonate) } } - if(fire2) + if(fire & 2) { if(W_MineLayer_PlacedMines(true)) sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM); diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index c19957458..d788e7b88 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -334,12 +334,12 @@ void W_Mortar_Attack2(Weapon thiswep) wepinfo_sec_dps = (WEP_CVAR_SEC(mortar, damage) * (1 / max3(sys_frametime, WEP_CVAR_SEC(mortar, refire), WEP_CVAR_SEC(mortar, animtime)))); wepinfo_ter_dps = 0; */ - METHOD(Mortar, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Mortar, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_mortar_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(mortar, ammo), WEP_CVAR_SEC(mortar, ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(fire1) + } else if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(mortar, refire))) { @@ -347,7 +347,7 @@ void W_Mortar_Attack2(Weapon thiswep) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(mortar, animtime), w_ready); } } - else if(fire2) + else if(fire & 2) { if(WEP_CVAR_SEC(mortar, remote_detonateprimary)) { diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index 790ab53ca..b02edd055 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -306,11 +306,11 @@ void W_Porto_Attack(float type) { PORTO_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS); } - METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(porto, secondary)) { - if(fire1) + if(fire & 1) if(!actor.porto_current) if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire))) @@ -319,7 +319,7 @@ void W_Porto_Attack(float type) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(porto, animtime), w_ready); } - if(fire2) + if(fire & 2) if(!actor.porto_current) if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR_SEC(porto, refire))) @@ -332,7 +332,7 @@ void W_Porto_Attack(float type) { if(actor.porto_v_angle_held) { - if(!fire2) + if(!(fire & 2)) { actor.porto_v_angle_held = 0; @@ -341,7 +341,7 @@ void W_Porto_Attack(float type) } else { - if(fire2) + if(fire & 2) { actor.porto_v_angle = actor.v_angle; actor.porto_v_angle_held = 1; @@ -352,7 +352,7 @@ void W_Porto_Attack(float type) if(actor.porto_v_angle_held) makevectors(actor.porto_v_angle); // override the previously set angles - if(fire1) + if(fire & 1) if(!actor.porto_current) if(!actor.porto_forbidden) if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(porto, refire))) diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 49b393156..9ac992669 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -90,7 +90,7 @@ void W_Rifle_Attack2(void) .float rifle_bullethail_frame; .float rifle_bullethail_animtime; .float rifle_bullethail_refire; -void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Rifle_BulletHail_Continue(Weapon thiswep, entity actor, int fire) { float r, sw, af; @@ -160,7 +160,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt } } } - METHOD(Rifle, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Rifle, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_rifle_reload_ammo && actor.clip_load < min(WEP_CVAR_PRI(rifle, ammo), WEP_CVAR_SEC(rifle, ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); @@ -168,7 +168,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt } else { actor.rifle_accumulator = bound(time - WEP_CVAR(rifle, bursttime), actor.rifle_accumulator, time); - if(fire1) + if(fire & 1) if(weapon_prepareattack_check(thiswep, actor, false, WEP_CVAR_PRI(rifle, refire))) if(time >= actor.rifle_accumulator + WEP_CVAR_PRI(rifle, burstcost)) { @@ -176,7 +176,7 @@ void W_Rifle_BulletHail(float mode, void(void) AttackFunc, float fr, float animt W_Rifle_BulletHail(WEP_CVAR_PRI(rifle, bullethail), W_Rifle_Attack, WFRAME_FIRE1, WEP_CVAR_PRI(rifle, animtime), WEP_CVAR_PRI(rifle, refire)); actor.rifle_accumulator += WEP_CVAR_PRI(rifle, burstcost); } - if(fire2) + if(fire & 2) { if(WEP_CVAR(rifle, secondary)) { diff --git a/qcsrc/common/weapons/weapon/rpc.qc b/qcsrc/common/weapons/weapon/rpc.qc index 71ddaa6b5..5d9052363 100644 --- a/qcsrc/common/weapons/weapon/rpc.qc +++ b/qcsrc/common/weapons/weapon/rpc.qc @@ -153,14 +153,14 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) { self.BUTTON_ATCK = bot_aim(WEP_CVAR(rpc, speed), 0, WEP_CVAR(rpc, lifetime), false); } - METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(rpc, reload_ammo) && actor.clip_load < WEP_CVAR(rpc, ammo)) { Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } else { - if (fire1) + if (fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR(rpc, refire))) { @@ -169,7 +169,7 @@ void W_RocketPropelledChainsaw_Attack (Weapon thiswep) } } - if (fire2) + if (fire & 2) { // to-do } diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 645bd9eb9..78a65129f 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -608,12 +608,12 @@ void W_Seeker_Fire_Tag(Weapon thiswep) else self.BUTTON_ATCK = bot_aim(WEP_CVAR(seeker, tag_speed), 0, WEP_CVAR(seeker, tag_lifetime), false); } - METHOD(Seeker, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Seeker, wr_think, void(entity thiswep, entity actor, int fire)) { if(autocvar_g_balance_seeker_reload_ammo && actor.clip_load < min(WEP_CVAR(seeker, missile_ammo), WEP_CVAR(seeker, tag_ammo))) { // forced reload Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); - } else if(fire1) + } else if(fire & 1) { if(WEP_CVAR(seeker, type) == 1) { @@ -633,7 +633,7 @@ void W_Seeker_Fire_Tag(Weapon thiswep) } } - else if(fire2) + else if(fire & 2) { if(WEP_CVAR(seeker, type) == 1) { diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index cc4daf048..47f6e36b1 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -229,7 +229,7 @@ void W_Shockwave_Melee_Think(void) } } -void W_Shockwave_Melee(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Shockwave_Melee(Weapon thiswep, entity actor, int fire) { sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM); weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready); @@ -675,9 +675,9 @@ void W_Shockwave_Attack(void) else { self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); } } - METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, int fire)) { - if(fire1) + if(fire & 1) { if(time >= actor.shockwave_blasttime) // handle refire separately so the secondary can be fired straight after a primary { @@ -689,7 +689,7 @@ void W_Shockwave_Attack(void) } } } - else if(fire2) + else if(fire & 2) { //if(actor.clip_load >= 0) // we are not currently reloading if(!actor.crouch) // no crouchmelee please diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index a5cb39773..cd1e2ea78 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -181,7 +181,7 @@ void W_Shotgun_Melee_Think(void) } } -void W_Shotgun_Attack2(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Shotgun_Attack2(Weapon thiswep, entity actor, int fire) { sound(actor, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM); weapon_thinkf(actor, WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready); @@ -195,14 +195,14 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, bool fire1, bool fire2) } // alternate secondary weapon frames -void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, int fire) { Weapon w = get_weaponinfo(actor.weapon); if (!w.wr_checkammo2(w)) if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -210,14 +210,14 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, bool fire1, bool fir W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); } -void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, int fire) { Weapon w = get_weaponinfo(actor.weapon); if (!w.wr_checkammo2(w)) if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); - w_ready(thiswep, actor, fire1, fire2); + w_ready(thiswep, actor, fire); return; } @@ -234,7 +234,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir else self.BUTTON_ATCK = bot_aim(1000000, 0, 0.001, false); } - METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(shotgun, reload_ammo) && actor.clip_load < WEP_CVAR_PRI(shotgun, ammo)) // forced reload { @@ -246,7 +246,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir } else { - if(fire1) + if(fire & 1) { if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { @@ -258,7 +258,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir } } } - else if(fire2 && WEP_CVAR(shotgun, secondary) == 2) + else if((fire & 2) && WEP_CVAR(shotgun, secondary) == 2) { if(time >= actor.shotgun_primarytime) // handle refire separately so the secondary can be fired straight after a primary { @@ -274,7 +274,7 @@ void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, bool fire1, bool fir if(actor.clip_load >= 0) // we are not currently reloading 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(((fire & 1) && actor.WEP_AMMO(SHOTGUN) <= 0 && !(actor.items & IT_UNLIMITED_WEAPON_AMMO)) || (fire & 2)) 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... diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 66ea8f7b5..46c409511 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -379,16 +379,16 @@ void W_Tuba_NoteOn(float hittype) self.BUTTON_ATCK2 = 1; } } - METHOD(Tuba, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Tuba, wr_think, void(entity thiswep, entity actor, int fire)) { - if(fire1) + if(fire & 1) 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(fire & 2) if(weapon_prepareattack(thiswep, actor, true, WEP_CVAR(tuba, refire))) { W_Tuba_NoteOn(HITTYPE_SECONDARY); @@ -397,7 +397,7 @@ void W_Tuba_NoteOn(float hittype) } if(actor.tuba_note) { - if(!fire1 && !fire2) + if(!(fire & 1) && !(fire & 2)) { WITH(entity, self, actor.tuba_note, W_Tuba_NoteOff()); } diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index f7aceee20..bbdeb69ac 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -244,7 +244,7 @@ void W_RocketMinsta_Attack3 (void) else self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_SEC(vaporizer, speed), 0, WEP_CVAR_SEC(vaporizer, lifetime), false); // WEAPONTODO: replace with proper vaporizer cvars } - METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, int fire)) { float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo)); // if the laser uses load, we also consider its ammo for reloading @@ -255,7 +255,7 @@ void W_RocketMinsta_Attack3 (void) Weapon w = get_weaponinfo(actor.weapon); w.wr_reload(w); } - if(fire1 && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor)) + if((fire & 1) && (actor.ammo_cells || !autocvar_g_rm) && !forbidWeaponUse(actor)) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vaporizer, refire))) { @@ -263,7 +263,7 @@ void W_RocketMinsta_Attack3 (void) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vaporizer, animtime), w_ready); } } - if(fire2 || (fire1 && !actor.ammo_cells && autocvar_g_rm)) + if((fire & 2) || ((fire & 1) && !actor.ammo_cells && autocvar_g_rm)) { if((autocvar_g_rm && autocvar_g_rm_laser) || autocvar_g_rm_laser == 2) { diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 5aca18183..f8e33f636 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -143,7 +143,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) self.BUTTON_ATCK2 = true; } } - METHOD(Vortex, wr_think, void(entity thiswep, entity actor, bool fire1, bool fire2)) + METHOD(Vortex, wr_think, void(entity thiswep, entity actor, int fire)) { if(WEP_CVAR(vortex, charge) && actor.vortex_charge < WEP_CVAR(vortex, charge_limit)) actor.vortex_charge = min(1, actor.vortex_charge + WEP_CVAR(vortex, charge_rate) * frametime / W_TICSPERFRAME); @@ -161,7 +161,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) w.wr_reload(w); } else { - if(fire1) + if(fire & 1) { if(weapon_prepareattack(thiswep, actor, false, WEP_CVAR_PRI(vortex, refire))) { @@ -169,7 +169,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) weapon_thinkf(actor, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); } } - if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : fire2) + if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (actor.BUTTON_ZOOM | actor.BUTTON_ZOOMSCRIPT) : (fire & 2)) { if(WEP_CVAR(vortex, charge)) { @@ -196,7 +196,7 @@ void W_Vortex_Attack(Weapon thiswep, float issecondary) else if(WEP_CVAR_SEC(vortex, ammo)) { - if(fire2) // only eat ammo when the button is pressed + if(fire & 2) // only eat ammo when the button is pressed { dt = min(dt, (1 - actor.vortex_charge) / WEP_CVAR(vortex, charge_rate)); if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index 4f7900149..a15309274 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -3,7 +3,7 @@ #include "../common/weapons/all.qh" -#define INDEPENDENT_ATTACK_FINISHED +#define INDEPENDENT_ATTACK_FINISHED 1 #define BUTTON_ATCK button0 #define BUTTON_JUMP button2 @@ -163,11 +163,11 @@ const float MAX_DAMAGEEXTRARADIUS = 16; // WEAPONTODO .float autoswitch; float client_hasweapon(entity cl, float wpn, float andammo, float complain); -void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2); -void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2); +void w_clear(Weapon thiswep, entity actor, int fire); +void w_ready(Weapon thiswep, entity actor, int fire); // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies) .float weapon_nextthink; -.void(Weapon thiswep, entity actor, bool fire1, bool fire2) weapon_think; +.void(Weapon thiswep, entity actor, int fire) weapon_think; // weapon states (self.weaponentity.state) diff --git a/qcsrc/server/mutators/mutator/mutator_overkill.qc b/qcsrc/server/mutators/mutator/mutator_overkill.qc index ea5adbf5a..c86626395 100644 --- a/qcsrc/server/mutators/mutator/mutator_overkill.qc +++ b/qcsrc/server/mutators/mutator/mutator_overkill.qc @@ -208,7 +208,7 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) } Weapon wpn = get_weaponinfo(self.weapon); if(self.weaponentity.state != WS_CLEAR) - w_ready(wpn, self, self.BUTTON_ATCK, self.BUTTON_ATCK2); + w_ready(wpn, self, (self.BUTTON_ATCK ? 1 : 0) | (self.BUTTON_ATCK2 ? 2 : 0)); self.weapon_blocked = true; } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index a52f95a71..a29f1b5ec 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -92,14 +92,13 @@ float W_WeaponSpeedFactor() } -void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func); +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func); -float CL_Weaponentity_CustomizeEntityForClient() +bool CL_Weaponentity_CustomizeEntityForClient() { SELFPARAM(); - self.viewmodelforclient = self.owner; - if (IS_SPEC(other)) - if (other.enemy == self.owner) self.viewmodelforclient = other; + this.viewmodelforclient = this.owner; + if (IS_SPEC(other) && other.enemy == this.owner) this.viewmodelforclient = other; return true; } @@ -146,85 +145,83 @@ float CL_Weaponentity_CustomizeEntityForClient() */ // writes: -// self.origin, self.angles -// self.weaponentity -// self.movedir, self.view_ofs +// this.origin, this.angles +// this.weaponentity +// this.movedir, this.view_ofs // attachment stuff // anim stuff // to free: // call again with "" // remove the ent -void CL_WeaponEntity_SetModel(string name) +void CL_WeaponEntity_SetModel(entity this, string name) { - SELFPARAM(); - float v_shot_idx; if (name != "") { // if there is a child entity, hide it until we're sure we use it - if (self.weaponentity) self.weaponentity.model = ""; - _setmodel(self, W_Model(strcat("v_", name, ".md3"))); - v_shot_idx = gettagindex(self, "shot"); // used later - if (!v_shot_idx) v_shot_idx = gettagindex(self, "tag_shot"); + if (this.weaponentity) this.weaponentity.model = ""; + _setmodel(this, W_Model(strcat("v_", name, ".md3"))); + int v_shot_idx = gettagindex(this, "shot"); // used later + if (!v_shot_idx) v_shot_idx = gettagindex(this, "tag_shot"); - _setmodel(self, W_Model(strcat("h_", name, ".iqm"))); + _setmodel(this, W_Model(strcat("h_", name, ".iqm"))); // preset some defaults that work great for renamed zym files (which don't need an animinfo) - self.anim_fire1 = animfixfps(self, '0 1 0.01', '0 0 0'); - self.anim_fire2 = animfixfps(self, '1 1 0.01', '0 0 0'); - self.anim_idle = animfixfps(self, '2 1 0.01', '0 0 0'); - self.anim_reload = animfixfps(self, '3 1 0.01', '0 0 0'); + this.anim_fire1 = animfixfps(this, '0 1 0.01', '0 0 0'); + this.anim_fire2 = animfixfps(this, '1 1 0.01', '0 0 0'); + this.anim_idle = animfixfps(this, '2 1 0.01', '0 0 0'); + this.anim_reload = animfixfps(this, '3 1 0.01', '0 0 0'); // if we have a "weapon" tag, let's attach the v_ model to it ("invisible hand" style model) // if we don't, this is a "real" animated model - if (gettagindex(self, "weapon")) + if (gettagindex(this, "weapon")) { - if (!self.weaponentity) self.weaponentity = spawn(); - _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3"))); - setattachment(self.weaponentity, self, "weapon"); + if (!this.weaponentity) this.weaponentity = spawn(); + _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3"))); + setattachment(this.weaponentity, this, "weapon"); } - else if (gettagindex(self, "tag_weapon")) + else if (gettagindex(this, "tag_weapon")) { - if (!self.weaponentity) self.weaponentity = spawn(); - _setmodel(self.weaponentity, W_Model(strcat("v_", name, ".md3"))); - setattachment(self.weaponentity, self, "tag_weapon"); + if (!this.weaponentity) this.weaponentity = spawn(); + _setmodel(this.weaponentity, W_Model(strcat("v_", name, ".md3"))); + setattachment(this.weaponentity, this, "tag_weapon"); } else { - if (self.weaponentity) remove(self.weaponentity); - self.weaponentity = world; + if (this.weaponentity) remove(this.weaponentity); + this.weaponentity = world; } - setorigin(self, '0 0 0'); - self.angles = '0 0 0'; - self.frame = 0; - self.viewmodelforclient = world; + setorigin(this, '0 0 0'); + this.angles = '0 0 0'; + this.frame = 0; + this.viewmodelforclient = world; float idx; if (v_shot_idx) // v_ model attached to invisible h_ model { - self.movedir = gettaginfo(self.weaponentity, v_shot_idx); + this.movedir = gettaginfo(this.weaponentity, v_shot_idx); } else { - idx = gettagindex(self, "shot"); - if (!idx) idx = gettagindex(self, "tag_shot"); + idx = gettagindex(this, "shot"); + if (!idx) idx = gettagindex(this, "tag_shot"); if (idx) { - self.movedir = gettaginfo(self, idx); + this.movedir = gettaginfo(this, idx); } else { - LOG_INFO("WARNING: weapon model ", self.model, + LOG_INFO("WARNING: weapon model ", this.model, " does not support the 'shot' tag, will display shots TOTALLY wrong\n"); - self.movedir = '0 0 0'; + this.movedir = '0 0 0'; } } - if (self.weaponentity) // v_ model attached to invisible h_ model + if (this.weaponentity) // v_ model attached to invisible h_ model { - idx = gettagindex(self.weaponentity, "shell"); - if (!idx) idx = gettagindex(self.weaponentity, "tag_shell"); - if (idx) self.spawnorigin = gettaginfo(self.weaponentity, idx); + idx = gettagindex(this.weaponentity, "shell"); + if (!idx) idx = gettagindex(this.weaponentity, "tag_shell"); + if (idx) this.spawnorigin = gettaginfo(this.weaponentity, idx); } else { @@ -232,215 +229,211 @@ void CL_WeaponEntity_SetModel(string name) } if (!idx) { - idx = gettagindex(self, "shell"); - if (!idx) idx = gettagindex(self, "tag_shell"); + idx = gettagindex(this, "shell"); + if (!idx) idx = gettagindex(this, "tag_shell"); if (idx) { - self.spawnorigin = gettaginfo(self, idx); + this.spawnorigin = gettaginfo(this, idx); } else { - LOG_INFO("WARNING: weapon model ", self.model, + LOG_INFO("WARNING: weapon model ", this.model, " does not support the 'shell' tag, will display casings wrong\n"); - self.spawnorigin = self.movedir; + this.spawnorigin = this.movedir; } } if (v_shot_idx) { - self.oldorigin = '0 0 0'; // use regular attachment + this.oldorigin = '0 0 0'; // use regular attachment } else { - if (self.weaponentity) + if (this.weaponentity) { - idx = gettagindex(self, "weapon"); - if (!idx) idx = gettagindex(self, "tag_weapon"); + idx = gettagindex(this, "weapon"); + if (!idx) idx = gettagindex(this, "tag_weapon"); } else { - idx = gettagindex(self, "handle"); - if (!idx) idx = gettagindex(self, "tag_handle"); + idx = gettagindex(this, "handle"); + if (!idx) idx = gettagindex(this, "tag_handle"); } if (idx) { - self.oldorigin = self.movedir - gettaginfo(self, idx); + this.oldorigin = this.movedir - gettaginfo(this, idx); } else { - LOG_INFO("WARNING: weapon model ", self.model, + LOG_INFO("WARNING: weapon model ", this.model, " does not support the 'handle' tag and neither does the v_ model support the 'shot' tag, will display muzzle flashes TOTALLY wrong\n"); - self.oldorigin = '0 0 0'; // there is no way to recover from this + this.oldorigin = '0 0 0'; // there is no way to recover from this } } - self.viewmodelforclient = self.owner; + this.viewmodelforclient = this.owner; } else { - self.model = ""; - if (self.weaponentity) remove(self.weaponentity); - self.weaponentity = world; - self.movedir = '0 0 0'; - self.spawnorigin = '0 0 0'; - self.oldorigin = '0 0 0'; - self.anim_fire1 = '0 1 0.01'; - self.anim_fire2 = '0 1 0.01'; - self.anim_idle = '0 1 0.01'; - self.anim_reload = '0 1 0.01'; + this.model = ""; + if (this.weaponentity) remove(this.weaponentity); + this.weaponentity = world; + this.movedir = '0 0 0'; + this.spawnorigin = '0 0 0'; + this.oldorigin = '0 0 0'; + this.anim_fire1 = '0 1 0.01'; + this.anim_fire2 = '0 1 0.01'; + this.anim_idle = '0 1 0.01'; + this.anim_reload = '0 1 0.01'; } - self.view_ofs = '0 0 0'; + this.view_ofs = '0 0 0'; - if (self.movedir.x >= 0) + if (this.movedir.x >= 0) { - vector v0; - v0 = self.movedir; - self.movedir = shotorg_adjust(v0, false, false, self.owner.cvar_cl_gunalign); - self.view_ofs = shotorg_adjust(v0, false, true, self.owner.cvar_cl_gunalign) - v0; + vector v0 = this.movedir; + this.movedir = shotorg_adjust(v0, false, false, this.owner.cvar_cl_gunalign); + this.view_ofs = shotorg_adjust(v0, false, true, this.owner.cvar_cl_gunalign) - v0; } - self.owner.stat_shotorg = compressShotOrigin(self.movedir); - self.movedir = decompressShotOrigin(self.owner.stat_shotorg); // make them match perfectly + this.owner.stat_shotorg = compressShotOrigin(this.movedir); + this.movedir = decompressShotOrigin(this.owner.stat_shotorg); // make them match perfectly - self.spawnorigin += self.view_ofs; // offset the casings origin by the same amount + this.spawnorigin += this.view_ofs; // offset the casings origin by the same amount // check if an instant weapon switch occurred - setorigin(self, self.view_ofs); + setorigin(this, this.view_ofs); // reset animstate now - self.wframe = WFRAME_IDLE; - setanim(self, self.anim_idle, true, false, true); + this.wframe = WFRAME_IDLE; + setanim(this, this.anim_idle, true, false, true); } vector CL_Weapon_GetShotOrg(float wpn) { - SELFPARAM(); entity wi = get_weaponinfo(wpn); - setself(spawn()); - CL_WeaponEntity_SetModel(wi.mdl); - vector ret = self.movedir; - CL_WeaponEntity_SetModel(""); - remove(self); - setself(this); + entity e = spawn(); + CL_WeaponEntity_SetModel(e, wi.mdl); + vector ret = e.movedir; + CL_WeaponEntity_SetModel(e, ""); + remove(e); return ret; } void CL_Weaponentity_Think() { SELFPARAM(); - int tb; - self.nextthink = time; - if (intermission_running) self.frame = self.anim_idle.x; - if (self.owner.weaponentity != self) + this.nextthink = time; + if (intermission_running) this.frame = this.anim_idle.x; + if (this.owner.weaponentity != this) { - if (self.weaponentity) remove(self.weaponentity); - remove(self); + if (this.weaponentity) remove(this.weaponentity); + remove(this); return; } - if (self.owner.deadflag != DEAD_NO) + if (this.owner.deadflag != DEAD_NO) { - self.model = ""; - if (self.weaponentity) self.weaponentity.model = ""; + this.model = ""; + if (this.weaponentity) this.weaponentity.model = ""; return; } - if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex - || self.deadflag != self.owner.deadflag) + if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex + || this.deadflag != this.owner.deadflag) { - self.weaponname = self.owner.weaponname; - self.dmg = self.owner.modelindex; - self.deadflag = self.owner.deadflag; + this.weaponname = this.owner.weaponname; + this.dmg = this.owner.modelindex; + this.deadflag = this.owner.deadflag; - CL_WeaponEntity_SetModel(self.owner.weaponname); + CL_WeaponEntity_SetModel(this, this.owner.weaponname); } - tb = (self.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT)); - self.effects = self.owner.effects & EFMASK_CHEAP; - self.effects &= ~EF_LOWPRECISION; - self.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it - self.effects &= ~EF_TELEPORT_BIT; - self.effects &= ~EF_RESTARTANIM_BIT; - self.effects |= tb; - - if (self.owner.alpha == default_player_alpha) self.alpha = default_weapon_alpha; - else if (self.owner.alpha != 0) self.alpha = self.owner.alpha; - else self.alpha = 1; - - self.glowmod = self.owner.weaponentity_glowmod; - self.colormap = self.owner.colormap; - if (self.weaponentity) + int tb = (this.effects & (EF_TELEPORT_BIT | EF_RESTARTANIM_BIT)); + this.effects = this.owner.effects & EFMASK_CHEAP; + this.effects &= ~EF_LOWPRECISION; + this.effects &= ~EF_FULLBRIGHT; // can mask team color, so get rid of it + this.effects &= ~EF_TELEPORT_BIT; + this.effects &= ~EF_RESTARTANIM_BIT; + this.effects |= tb; + + if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha; + else if (this.owner.alpha != 0) this.alpha = this.owner.alpha; + else this.alpha = 1; + + this.glowmod = this.owner.weaponentity_glowmod; + this.colormap = this.owner.colormap; + if (this.weaponentity) { - self.weaponentity.effects = self.effects; - self.weaponentity.alpha = self.alpha; - self.weaponentity.colormap = self.colormap; - self.weaponentity.glowmod = self.glowmod; + this.weaponentity.effects = this.effects; + this.weaponentity.alpha = this.alpha; + this.weaponentity.colormap = this.colormap; + this.weaponentity.glowmod = this.glowmod; } - self.angles = '0 0 0'; + this.angles = '0 0 0'; - float f = (self.owner.weapon_nextthink - time); - if (self.state == WS_RAISE && !intermission_running) + float f = (this.owner.weapon_nextthink - time); + if (this.state == WS_RAISE && !intermission_running) { - entity newwep = get_weaponinfo(self.owner.switchweapon); + entity newwep = get_weaponinfo(this.owner.switchweapon); f = f * g_weaponratefactor / max(f, newwep.switchdelay_raise); - self.angles_x = -90 * f * f; + this.angles_x = -90 * f * f; } - else if (self.state == WS_DROP && !intermission_running) + else if (this.state == WS_DROP && !intermission_running) { - entity oldwep = get_weaponinfo(self.owner.weapon); + entity oldwep = get_weaponinfo(this.owner.weapon); f = 1 - f * g_weaponratefactor / max(f, oldwep.switchdelay_drop); - self.angles_x = -90 * f * f; + this.angles_x = -90 * f * f; } - else if (self.state == WS_CLEAR) + else if (this.state == WS_CLEAR) { f = 1; - self.angles_x = -90 * f * f; + this.angles_x = -90 * f * f; } } void CL_ExteriorWeaponentity_Think() { SELFPARAM(); - float tag_found; - self.nextthink = time; - if (self.owner.exteriorweaponentity != self) + this.nextthink = time; + if (this.owner.exteriorweaponentity != this) { - remove(self); + remove(this); return; } - if (self.owner.deadflag != DEAD_NO) + if (this.owner.deadflag != DEAD_NO) { - self.model = ""; + this.model = ""; return; } - if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex - || self.deadflag != self.owner.deadflag) + if (this.weaponname != this.owner.weaponname || this.dmg != this.owner.modelindex + || this.deadflag != this.owner.deadflag) { - self.weaponname = self.owner.weaponname; - self.dmg = self.owner.modelindex; - self.deadflag = self.owner.deadflag; - if (self.owner.weaponname != "") _setmodel(self, W_Model(strcat("v_", self.owner.weaponname, ".md3"))); - else self.model = ""; - - if ((tag_found = gettagindex(self.owner, "tag_weapon"))) + this.weaponname = this.owner.weaponname; + this.dmg = this.owner.modelindex; + this.deadflag = this.owner.deadflag; + if (this.owner.weaponname != "") _setmodel(this, W_Model(strcat("v_", this.owner.weaponname, ".md3"))); + else this.model = ""; + + int tag_found; + if ((tag_found = gettagindex(this.owner, "tag_weapon"))) { - self.tag_index = tag_found; - self.tag_entity = self.owner; + this.tag_index = tag_found; + this.tag_entity = this.owner; } else { - setattachment(self, self.owner, "bip01 r hand"); + setattachment(this, this.owner, "bip01 r hand"); } } - self.effects = self.owner.effects; - self.effects |= EF_LOWPRECISION; - self.effects = self.effects & EFMASK_CHEAP; // eat performance - if (self.owner.alpha == default_player_alpha) self.alpha = default_weapon_alpha; - else if (self.owner.alpha != 0) self.alpha = self.owner.alpha; - else self.alpha = 1; + this.effects = this.owner.effects; + this.effects |= EF_LOWPRECISION; + this.effects = this.effects & EFMASK_CHEAP; // eat performance + if (this.owner.alpha == default_player_alpha) this.alpha = default_weapon_alpha; + else if (this.owner.alpha != 0) this.alpha = this.owner.alpha; + else this.alpha = 1; - self.glowmod = self.owner.weaponentity_glowmod; - self.colormap = self.owner.colormap; + this.glowmod = this.owner.weaponentity_glowmod; + this.colormap = this.owner.colormap; - CSQCMODEL_AUTOUPDATE(self); + CSQCMODEL_AUTOUPDATE(this); } // spawning weaponentity for client @@ -473,7 +466,7 @@ void CL_SpawnWeaponentity(entity e) } // Weapon subs -void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2) +void w_clear(Weapon thiswep, entity actor, int fire) { if (actor.weapon != -1) { @@ -487,7 +480,7 @@ void w_clear(Weapon thiswep, entity actor, bool fire1, bool fire2) } } -void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2) +void w_ready(Weapon thiswep, entity actor, int fire) { if (actor.weaponentity) actor.weaponentity.state = WS_READY; weapon_thinkf(actor, WFRAME_IDLE, 1000000, w_ready); @@ -495,7 +488,7 @@ void w_ready(Weapon thiswep, entity actor, bool fire1, bool fire2) .float prevdryfire; .float prevwarntime; -bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondary) +bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary) { if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true; bool ammo = false; @@ -503,16 +496,14 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondar 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 (thiswep == WEP_MINE_LAYER) + for (entity mine; (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 (thiswep == WEP_SHOTGUN) + 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 + if (thiswep == get_weaponinfo(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; @@ -520,8 +511,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondar // 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 (secondary) WITH(entity, self, actor, ammo_other = thiswep.wr_checkammo1(thiswep)); + else WITH(entity, self, actor, ammo_other = thiswep.wr_checkammo2(thiswep)); if (ammo_other) { if (time - actor.prevwarntime > 1) @@ -531,7 +522,7 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondar actor, MSG_MULTI, ITEM_WEAPON_PRIMORSEC, - actor.weapon, + thiswep, secondary, (1 - secondary) ); @@ -545,6 +536,7 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, float secondar return false; } + .float race_penalty; bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, float attacktime) { @@ -569,6 +561,7 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, bool secondary, fl } return true; } + void weapon_prepareattack_do(entity actor, bool secondary, float attacktime) { actor.weaponentity.state = WS_INUSE; @@ -588,6 +581,7 @@ void weapon_prepareattack_do(entity actor, bool secondary, float attacktime) actor.bulletcounter += 1; // dprint("attack finished ", ftos(ATTACK_FINISHED(actor)), "\n"); } + bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float attacktime) { if (weapon_prepareattack_check(thiswep, actor, secondary, attacktime)) @@ -598,12 +592,9 @@ bool weapon_prepareattack(Weapon thiswep, entity actor, bool secondary, float at return false; } -void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func) +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func) { - vector a; - vector of, or, ou; - float restartanim; - + bool restartanim; if (fr == WFRAME_DONTCHANGE) { fr = actor.weaponentity.wframe; @@ -618,14 +609,14 @@ void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity restartanim = true; } - of = v_forward; - or = v_right; - ou = v_up; + vector of = v_forward; + vector or = v_right; + vector ou = v_up; if (actor.weaponentity) { actor.weaponentity.wframe = fr; - a = '0 0 0'; + vector a = '0 0 0'; if (fr == WFRAME_IDLE) a = actor.weaponentity.anim_idle; else if (fr == WFRAME_FIRE1) a = actor.weaponentity.anim_fire1; else if (fr == WFRAME_FIRE2) a = actor.weaponentity.anim_fire2; @@ -673,22 +664,20 @@ void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity } } -float forbidWeaponUse(entity player) +bool forbidWeaponUse(entity player) { - if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return 1; - if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return 1; - if (player.player_blocked) return 1; - if (player.frozen) return 1; - if (player.weapon_blocked) return 1; - return 0; + if (time < game_starttime && !autocvar_sv_ready_restart_after_countdown) return true; + if (round_handler_IsActive() && !round_handler_IsRoundStarted()) return true; + if (player.player_blocked) return true; + if (player.frozen) return true; + if (player.weapon_blocked) return true; + return false; } .bool hook_switchweapon; void W_WeaponFrame(entity actor) { - vector fo, ri, up; - if (frametime) actor.weapon_frametime = frametime; if (!actor.weaponentity || actor.health < 1) return; // Dead player can't use weapons and injure impulse commands @@ -698,7 +687,7 @@ void W_WeaponFrame(entity actor) if (actor.weaponentity.state != WS_CLEAR) { Weapon wpn = get_weaponinfo(actor.weapon); - w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); + w_ready(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0)); return; } } @@ -714,9 +703,9 @@ void W_WeaponFrame(entity actor) } makevectors(actor.v_angle); - fo = v_forward; // save them in case the weapon think functions change it - ri = v_right; - up = v_up; + vector fo = v_forward; // save them in case the weapon think functions change it + vector ri = v_right; + vector up = v_up; // Change weapon if (actor.weapon != actor.switchweapon) @@ -761,16 +750,18 @@ void W_WeaponFrame(entity actor) entity oldwep = get_weaponinfo(actor.weapon); // set up weapon switch think in the future, and start drop anim -#ifndef INDEPENDENT_ATTACK_FINISHED - if (ATTACK_FINISHED(actor) <= time + actor.weapon_frametime * 0.5) - { -#endif - sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM); - actor.weaponentity.state = WS_DROP; - weapon_thinkf(actor, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); -#ifndef INDEPENDENT_ATTACK_FINISHED - } + if ( +#if INDEPENDENT_ATTACK_FINISHED + true +#else + ATTACK_FINISHED(actor) <= time + actor.weapon_frametime * 0.5 #endif + ) + { + sound(actor, CH_WEAPON_SINGLE, SND_WEAPON_SWITCH, VOL_BASE, ATTN_NORM); + actor.weaponentity.state = WS_DROP; + weapon_thinkf(actor, WFRAME_DONTCHANGE, oldwep.switchdelay_drop, w_clear); + } } } @@ -778,17 +769,15 @@ void W_WeaponFrame(entity actor) // if (actor.button0) // print(ftos(frametime), " ", ftos(time), " >= ", ftos(ATTACK_FINISHED(actor)), " >= ", ftos(actor.weapon_nextthink), "\n"); - float w; - w = actor.weapon; + int w = actor.weapon; // call the think code which may fire the weapon // and do so multiple times to resolve framerate dependency issues if the // server framerate is very low and the weapon fire rate very high - float c; - c = 0; + int c = 0; while (c < W_TICSPERFRAME) { - c = c + 1; + c += 1; if (w && !(actor.weapons & WepSet_FromWeapon(w))) { if (actor.weapon == actor.switchweapon) W_SwitchWeapon_Force(actor, w_getbestweapon(actor)); @@ -814,7 +803,7 @@ void W_WeaponFrame(entity actor) 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); + h.wr_think(h, actor, block_weapon ? 1 : 0); } } @@ -823,7 +812,7 @@ void W_WeaponFrame(entity actor) if (w) { Weapon e = get_weaponinfo(actor.weapon); - e.wr_think(e, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); + e.wr_think(e, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0)); } else { @@ -840,7 +829,7 @@ void W_WeaponFrame(entity actor) v_right = ri; v_up = up; Weapon wpn = get_weaponinfo(actor.weapon); - actor.weapon_think(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); + actor.weapon_think(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0)); } else { @@ -852,7 +841,6 @@ void W_WeaponFrame(entity actor) void W_AttachToShotorg(entity actor, entity flash, vector offset) { - entity xflash; flash.owner = actor; flash.angles_z = random() * 360; @@ -860,7 +848,7 @@ void W_AttachToShotorg(entity actor, entity flash, vector offset) else setattachment(flash, actor.weaponentity, "tag_shot"); setorigin(flash, offset); - xflash = spawn(); + entity xflash = spawn(); copyentity(flash, xflash); flash.viewmodelforclient = actor; @@ -921,7 +909,7 @@ void W_DecreaseAmmo(Weapon wep, entity actor, float ammo_use) .float reload_complain; .string reload_sound; -void W_ReloadedAndReady(Weapon thiswep, entity actor, bool fire1, bool fire2) +void W_ReloadedAndReady(Weapon thiswep, entity actor, int fire) { // finish the reloading process, and do the ammo transfer @@ -948,14 +936,13 @@ void W_ReloadedAndReady(Weapon thiswep, entity actor, bool fire1, bool fire2) // ATTACK_FINISHED(actor) -= actor.reload_time - 1; Weapon wpn = get_weaponinfo(actor.weapon); - w_ready(wpn, actor, actor.BUTTON_ATCK, actor.BUTTON_ATCK2); + w_ready(wpn, actor, (actor.BUTTON_ATCK ? 1 : 0) | (actor.BUTTON_ATCK2 ? 2 : 0)); } void W_Reload(entity actor, float sent_ammo_min, string sent_sound) { // set global values to work with - entity e; - e = get_weaponinfo(actor.weapon); + entity e = get_weaponinfo(actor.weapon); if (cvar("g_overkill")) if (actor.ok_use_ammocharge) return; @@ -1032,10 +1019,7 @@ void W_Reload(entity actor, float sent_ammo_min, string sent_sound) void W_DropEvent(.void(Weapon) event, entity player, float weapon_type, entity weapon_item) { - SELFPARAM(); - setself(player); - weapon_dropevent_item = weapon_item; Weapon w = get_weaponinfo(weapon_type); - w.event(w); - setself(this); + weapon_dropevent_item = weapon_item; + WITH(entity, self, player, w.event(w)); } diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 86d311195..ee84a7c61 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -44,6 +44,6 @@ bool weapon_prepareattack_check(Weapon thiswep, entity actor, float secondary, f void weapon_prepareattack_do(entity actor, float secondary, float attacktime); -void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, bool fire1, bool fire2) func); +void weapon_thinkf(entity actor, float fr, float t, void(Weapon thiswep, entity actor, int fire) func); #endif -- 2.39.2