From f4360106d5c886dbe46fb22cc5e3b3ad5ad92cca Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 23 Aug 2019 12:46:12 +1000 Subject: [PATCH] Fix an issue with vortex secondary that prevented it from detecting zoom, also add a special edge case that allows the secondary to be used as a charged shot --- qcsrc/common/weapons/weapon/vortex.qc | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index af7fac624..46bf28262 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -161,7 +161,7 @@ void W_Vortex_Attack(Weapon thiswep, entity actor, .entity weaponentity, float i void W_Vortex_Charge(entity actor, .entity weaponentity, float dt) { - if(WEP_CVAR(vortex, charge) && actor.(weaponentity).vortex_charge < WEP_CVAR(vortex, charge_limit)) + if(WEP_CVAR(vortex, charge) && actor.(weaponentity).vortex_charge < WEP_CVAR(vortex, charge_limit) && !WEP_CVAR_SEC(vortex, chargepool)) actor.(weaponentity).vortex_charge = min(1, actor.(weaponentity).vortex_charge + WEP_CVAR(vortex, charge_rate) * dt / W_TICSPERFRAME); } @@ -180,7 +180,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity if(!WEP_CVAR(vortex, charge_always)) W_Vortex_Charge(actor, weaponentity, frametime); - if(WEP_CVAR_SEC(vortex, chargepool)) + if(WEP_CVAR_SEC(vortex, chargepool) && WEP_CVAR_SEC(vortex, ammo)) if(actor.(weaponentity).vortex_chargepool_ammo < 1) { if(actor.vortex_chargepool_pauseregen_finished < time) @@ -200,7 +200,7 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(vortex, animtime), w_ready); } } - if((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (PHYS_INPUT_BUTTON_ZOOM(actor) | PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2)) + if(((WEP_CVAR(vortex, charge) && !WEP_CVAR(vortex, secondary)) ? (CS(actor).zoomstate || PHYS_INPUT_BUTTON_ZOOM(actor) || PHYS_INPUT_BUTTON_ZOOMSCRIPT(actor)) : (fire & 2))) { if(WEP_CVAR(vortex, charge)) { @@ -215,14 +215,16 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity { // always deplete if secondary is held actor.(weaponentity).vortex_chargepool_ammo = max(0, actor.(weaponentity).vortex_chargepool_ammo - WEP_CVAR_SEC(vortex, ammo) * dt); - - dt = min(dt, (1 - actor.(weaponentity).vortex_charge) / WEP_CVAR(vortex, charge_rate)); + } + dt = min(dt, (1 - actor.(weaponentity).vortex_charge) / WEP_CVAR(vortex, charge_rate)); + if(WEP_CVAR_SEC(vortex, ammo)) + { actor.vortex_chargepool_pauseregen_finished = time + WEP_CVAR_SEC(vortex, chargepool_pause_regen); dt = min(dt, actor.(weaponentity).vortex_chargepool_ammo); - dt = max(0, dt); - - actor.(weaponentity).vortex_charge += dt * WEP_CVAR(vortex, charge_rate); } + dt = max(0, dt); + + actor.(weaponentity).vortex_charge += dt * WEP_CVAR(vortex, charge_rate); } else if(WEP_CVAR_SEC(vortex, ammo)) @@ -273,6 +275,13 @@ METHOD(Vortex, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } + else if(WEP_CVAR(vortex, charge) && WEP_CVAR_SEC(vortex, chargepool) && !WEP_CVAR_SEC(vortex, ammo) && !WEP_CVAR(vortex, secondary)) + { + float dt = frametime / W_TICSPERFRAME; + + // TODO: add a special cvar for this functionality (charge_rot_rate is taken!) + actor.(weaponentity).vortex_charge = max(0, actor.(weaponentity).vortex_charge - dt * (WEP_CVAR(vortex, charge_rate) * 2)); // rots twice as fast + } } } METHOD(Vortex, wr_setup, void(entity thiswep, entity actor, .entity weaponentity)) -- 2.39.2