]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Move the vortex charge thing into a mini mutator (why this can't be done in the weapo...
authorMario <mario@smbclan.net>
Mon, 23 Nov 2015 14:12:05 +0000 (00:12 +1000)
committerMario <mario@smbclan.net>
Mon, 23 Nov 2015 14:12:05 +0000 (00:12 +1000)
qcsrc/common/physics.qc
qcsrc/common/weapons/weapon/vortex.qc

index 299a0570e273526e2de5792155f35b8788c9730f..34f5663d57478b5d3df05469da3df5d78a019ee9 100644 (file)
@@ -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;
index 8a90679b81a2690428328e79dd4598ccf40ce183..dfb6354dd2dcb7c225539c159acd5e1e35749736 100644 (file)
@@ -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;