From 48a4dbe422d3af0676cd78effe06cf9d85543f08 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 24 Nov 2015 00:12:05 +1000 Subject: [PATCH] Move the vortex charge thing into a mini mutator (why this can't be done in the weapon frame function is beyond me) --- qcsrc/common/physics.qc | 18 ------------------ qcsrc/common/weapons/weapon/vortex.qc | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 299a0570e..34f5663d5 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -912,22 +912,6 @@ void PM_check_blocked() #endif } -void PM_check_vortex() -{SELFPARAM(); -#ifdef SVQC - // WEAPONTODO - float xyspeed = vlen(vec2(self.velocity)); - if (self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) - { - // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed - xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); - float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); - // add the extra charge - self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); - } -#endif -} - void PM_fly(float maxspd_mod) {SELFPARAM(); // noclipping or flying @@ -1588,8 +1572,6 @@ void PM_Main(entity this) else PM_air(buttons_prev, maxspeed_mod); - PM_check_vortex(); - :end if (IS_ONGROUND(this)) this.lastground = time; diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 8a90679b8..dfb6354dd 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -104,6 +104,22 @@ NET_HANDLE(TE_CSQC_VORTEXBEAMPARTICLE, bool isNew) spawnfunc(weapon_vortex) { weapon_defaultspawnfunc(this, WEP_VORTEX); } spawnfunc(weapon_nex) { spawnfunc_weapon_vortex(this); } +REGISTER_MUTATOR(vortex_charge, true); + +MUTATOR_HOOKFUNCTION(vortex_charge, GetPressedKeys) +{SELFPARAM(); + // WEAPONTODO + float xyspeed = vlen(vec2(self.velocity)); + if (self.weapon == WEP_VORTEX.m_id && WEP_CVAR(vortex, charge) && WEP_CVAR(vortex, charge_velocity_rate) && xyspeed > WEP_CVAR(vortex, charge_minspeed)) + { + // add a maximum of charge_velocity_rate when going fast (f = 1), gradually increasing from minspeed (f = 0) to maxspeed + xyspeed = min(xyspeed, WEP_CVAR(vortex, charge_maxspeed)); + float f = (xyspeed - WEP_CVAR(vortex, charge_minspeed)) / (WEP_CVAR(vortex, charge_maxspeed) - WEP_CVAR(vortex, charge_minspeed)); + // add the extra charge + self.vortex_charge = min(1, self.vortex_charge + WEP_CVAR(vortex, charge_velocity_rate) * f * PHYS_INPUT_TIMELENGTH); + } +} + void W_Vortex_Attack(Weapon thiswep, float issecondary) {SELFPARAM(); float mydmg, myforce, mymindist, mymaxdist, myhalflife, myforcehalflife, myammo, charge; -- 2.39.2