From 047e80d3190ef626c6029a655677ff1a08e66e3a Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 29 Sep 2015 18:20:40 +1000 Subject: [PATCH] Offhand: fix machinegun (still needs .clip_load > 0) --- qcsrc/common/weapons/weapon/arc.qc | 12 +++++------ qcsrc/common/weapons/weapon/electro.qc | 4 ++-- qcsrc/common/weapons/weapon/fireball.qc | 12 +++++------ qcsrc/common/weapons/weapon/hlac.qc | 6 +++--- qcsrc/common/weapons/weapon/hmg.qc | 8 ++++---- qcsrc/common/weapons/weapon/machinegun.qc | 25 ++++++++++++----------- qcsrc/common/weapons/weapon/rifle.qc | 2 +- qcsrc/common/weapons/weapon/shockwave.qc | 2 +- qcsrc/common/weapons/weapon/shotgun.qc | 10 ++++----- qcsrc/server/defs.qh | 6 +++--- qcsrc/server/mutators/mutator_overkill.qc | 3 ++- qcsrc/server/weapons/weaponsystem.qc | 23 ++++++++++++--------- qcsrc/server/weapons/weaponsystem.qh | 2 +- 13 files changed, 60 insertions(+), 55 deletions(-) diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 2853d857d..df5e88f69 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -84,7 +84,7 @@ const int ARC_SF_LOCALMASK = 14; #ifdef SVQC ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP) .entity arc_beam; -.float arc_BUTTON_ATCK_prev; // for better animation control +.bool arc_BUTTON_ATCK_prev; // for better animation control .float beam_prev; .float beam_initialized; .float beam_bursting; @@ -662,8 +662,8 @@ void Arc_Smoke() Arc_Player_SetHeat(self); Arc_Smoke(); - if ( self.arc_overheat <= time ) - if(fire1 || fire2 || self.arc_beam.beam_bursting ) + if (time >= self.arc_overheat) + if (fire1 || fire2 || self.arc_beam.beam_bursting) { if(self.arc_BUTTON_ATCK_prev) @@ -685,7 +685,7 @@ void Arc_Smoke() if(!self.arc_BUTTON_ATCK_prev) { weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); - self.arc_BUTTON_ATCK_prev = 1; + self.arc_BUTTON_ATCK_prev = true; } } } @@ -693,13 +693,13 @@ void Arc_Smoke() return true; } - if(self.arc_BUTTON_ATCK_prev != 0) + if(self.arc_BUTTON_ATCK_prev) { sound(self, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(); } - self.arc_BUTTON_ATCK_prev = 0; + self.arc_BUTTON_ATCK_prev = false; #if 0 if(fire2) diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index dbcbb76b9..420305d05 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(void) +void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if(self.electro_count > 1) if(self.BUTTON_ATCK2) @@ -418,7 +418,7 @@ void W_Electro_CheckAttack(void) return; } // WEAPONTODO: when the player releases the button, cut down the length of refire2? - w_ready(); + w_ready(thiswep, fire1, fire2); } .float bot_secondary_electromooth; diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 13d5ed3e4..df1c3c669 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(void) +void W_Fireball_Attack1_Frame4(Weapon thiswep, bool fire1, bool fire2) { W_Fireball_Attack1(); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready); } -void W_Fireball_Attack1_Frame3(void) +void W_Fireball_Attack1_Frame3(Weapon thiswep, bool fire1, bool fire2) { W_Fireball_AttackEffect(0, '+1.25 +3.75 0'); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4); } -void W_Fireball_Attack1_Frame2(void) +void W_Fireball_Attack1_Frame2(Weapon thiswep, bool fire1, bool fire2) { W_Fireball_AttackEffect(0, '-1.25 +3.75 0'); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3); } -void W_Fireball_Attack1_Frame1(void) +void W_Fireball_Attack1_Frame1(Weapon thiswep, bool fire1, bool fire2) { W_Fireball_AttackEffect(1, '+1.25 -3.75 0'); weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2); } -void W_Fireball_Attack1_Frame0(void) +void W_Fireball_Attack1_Frame0(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); W_Fireball_AttackEffect(0, '-1.25 -3.75 0'); sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM); @@ -380,7 +380,7 @@ void W_Fireball_Attack2(void) if(time >= self.fireball_primarytime) if(weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire))) { - W_Fireball_Attack1_Frame0(); + W_Fireball_Attack1_Frame0(thiswep, fire1, fire2); self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(); } } diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index ad21fd9ca..b8cf3485e 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(void) +void W_HLAC_Attack_Frame(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if(self.weapon != self.switchweapon) // abort immediately if switching { - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -175,7 +175,7 @@ void W_HLAC_Attack_Frame(void) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } diff --git a/qcsrc/common/weapons/weapon/hmg.qc b/qcsrc/common/weapons/weapon/hmg.qc index bb35d6783..5e48c2840 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) void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); } -void W_HeavyMachineGun_Attack_Auto() +void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if (!self.BUTTON_ATCK) { - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -57,7 +57,7 @@ void W_HeavyMachineGun_Attack_Auto() if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -107,7 +107,7 @@ void W_HeavyMachineGun_Attack_Auto() if (weapon_prepareattack(0, 0)) { self.misc_bulletcounter = 0; - W_HeavyMachineGun_Attack_Auto(); + W_HeavyMachineGun_Attack_Auto(thiswep, fire1, fire2); } } diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index a8437586f..7eb09b22b 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(void) +void W_MachineGun_Attack_Frame(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if(self.weapon != self.switchweapon) // abort immediately if switching { - w_ready(); + w_ready(thiswep, fire1, fire2); return; } if(self.BUTTON_ATCK) @@ -150,7 +150,7 @@ void W_MachineGun_Attack_Frame(void) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } self.misc_bulletcounter = self.misc_bulletcounter + 1; @@ -162,13 +162,13 @@ void W_MachineGun_Attack_Frame(void) } -void W_MachineGun_Attack_Auto(void) +void W_MachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); float machinegun_spread; - if(!self.BUTTON_ATCK) + if(!fire1) { - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -176,7 +176,7 @@ void W_MachineGun_Attack_Auto(void) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -206,7 +206,7 @@ void W_MachineGun_Attack_Auto(void) weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); } -void W_MachineGun_Attack_Burst(void) +void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage)); if(!autocvar_g_norecoil) @@ -251,13 +251,14 @@ void W_MachineGun_Attack_Burst(void) { if(WEP_CVAR(machinegun, reload_ammo) && self.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) // forced reload _WEP_ACTION(self.weapon, WR_RELOAD); - else if(WEP_CVAR(machinegun, mode) == 1) + else + if(WEP_CVAR(machinegun, mode) == 1) { if(fire1) if(weapon_prepareattack(0, 0)) { self.misc_bulletcounter = 0; - W_MachineGun_Attack_Auto(); + W_MachineGun_Attack_Auto(thiswep, fire1, fire2); } if(fire2) @@ -267,14 +268,14 @@ void W_MachineGun_Attack_Burst(void) if(!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return false; } W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, burst_ammo)); self.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; - W_MachineGun_Attack_Burst(); + W_MachineGun_Attack_Burst(thiswep, fire1, fire2); } } else diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 8aad95ef6..dc11b0158 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(void) +void W_Rifle_BulletHail_Continue(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); float r, sw, af; diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 713ac59c7..79262411e 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(void) +void W_Shockwave_Melee(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready); diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 809542a48..42c12fd7e 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(void) +void W_Shotgun_Attack2(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM); weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready); @@ -195,13 +195,13 @@ void W_Shotgun_Attack2(void) } // alternate secondary weapon frames -void W_Shotgun_Attack3_Frame2() +void W_Shotgun_Attack3_Frame2(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2)) if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } @@ -209,13 +209,13 @@ void W_Shotgun_Attack3_Frame2() W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready); } -void W_Shotgun_Attack3_Frame1() +void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2)) if (!(self.items & IT_UNLIMITED_WEAPON_AMMO)) { W_SwitchWeapon_Force(self, w_getbestweapon(self)); - w_ready(); + w_ready(thiswep, fire1, fire2); return; } diff --git a/qcsrc/server/defs.qh b/qcsrc/server/defs.qh index a165f9d44..f6f3d1b7a 100644 --- a/qcsrc/server/defs.qh +++ b/qcsrc/server/defs.qh @@ -166,11 +166,11 @@ const float MAX_DAMAGEEXTRARADIUS = 16; .float autoswitch; //float _WEP_ACTION(float wpn, float wrequest); float client_hasweapon(entity cl, float wpn, float andammo, float complain); -void w_clear(); -void w_ready(); +void w_clear(Weapon thiswep, bool fire1, bool fire2); +void w_ready(Weapon thiswep, bool fire1, bool fire2); // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies) .float weapon_nextthink; -.void() weapon_think; +.void(Weapon thiswep, bool fire1, bool fire2) weapon_think; // weapon states (self.weaponentity.state) diff --git a/qcsrc/server/mutators/mutator_overkill.qc b/qcsrc/server/mutators/mutator_overkill.qc index 3bc1e7958..69c9fffd7 100644 --- a/qcsrc/server/mutators/mutator_overkill.qc +++ b/qcsrc/server/mutators/mutator_overkill.qc @@ -176,8 +176,9 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink) self.ok_notice_time = time + 2; play2(self, SND(DRYFIRE)); } + Weapon wpn = get_weaponinfo(self.weapon); if(self.weaponentity.state != WS_CLEAR) - w_ready(); + w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); self.weapon_blocked = true; } diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index b682ab8fe..a6961aec8 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -47,7 +47,7 @@ float W_WeaponSpeedFactor() } -void(float fr, float t, void() func) weapon_thinkf; +void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func); float CL_Weaponentity_CustomizeEntityForClient() {SELFPARAM(); @@ -434,7 +434,7 @@ void CL_SpawnWeaponentity(entity e) } // Weapon subs -void w_clear() +void w_clear(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if (self.weapon != -1) { @@ -448,7 +448,7 @@ void w_clear() } } -void w_ready() +void w_ready(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); if (self.weaponentity) self.weaponentity.state = WS_READY; @@ -565,7 +565,7 @@ float weapon_prepareattack(float secondary, float attacktime) return false; } -void weapon_thinkf(float fr, float t, void() func) +void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func) {SELFPARAM(); vector a; vector of, or, ou; @@ -669,7 +669,8 @@ void W_WeaponFrame() if(forbidWeaponUse(self)) if(self.weaponentity.state != WS_CLEAR) { - w_ready(); + Weapon wpn = get_weaponinfo(self.weapon); + w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); return; } @@ -769,8 +770,8 @@ void W_WeaponFrame() { bool key_pressed = self.BUTTON_HOOK; - entity e = self.offhand; - if (e.offhand_think) e.offhand_think(e, self, key_pressed); + Weapon wpn = self.offhand; + if (wpn.offhand_think) wpn.offhand_think(wpn, self, key_pressed); } if (w) { @@ -787,7 +788,8 @@ void W_WeaponFrame() v_forward = fo; v_right = ri; v_up = up; - self.weapon_think(); + Weapon wpn = get_weaponinfo(self.weapon); + self.weapon_think(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); } else bprint("\{1}^1ERROR: undefined weapon think function for ", self.netname, "\n"); @@ -870,7 +872,7 @@ void W_DecreaseAmmo(Weapon wep, float ammo_use) .float reload_complain; .string reload_sound; -void W_ReloadedAndReady() +void W_ReloadedAndReady(Weapon thiswep, bool fire1, bool fire2) {SELFPARAM(); // finish the reloading process, and do the ammo transfer @@ -894,7 +896,8 @@ void W_ReloadedAndReady() //ATTACK_FINISHED(self) -= self.reload_time - 1; - w_ready(); + Weapon wpn = get_weaponinfo(self.weapon); + w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2); } void W_Reload(float sent_ammo_min, string sent_sound) diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index 8ee65bb26..6bb2d656e 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -40,6 +40,6 @@ float weapon_prepareattack_check(float secondary, float attacktime); float weapon_prepareattack_do(float secondary, float attacktime); -void weapon_thinkf(float fr, float t, void() func); +void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func); #endif -- 2.39.2