Source of Support_SpeedFactor.cs (791 bytes)
This lets you easily scale the player's movement speed in all directions and states whilst remaining compatible with other scripts.
Here's an example of using it - making all players half as fast while holding your weapon image:
function MyWeaponImage::onMount(%this, %obj, %slot)
{
%obj.updateSpeedFactor();
}
function MyWeaponImage::onUnMount(%this, %obj, %slot)
{
// Unmount it after we're done here so `::getMountedImage` doesn't see this image
%obj.schedule(0, updateSpeedFactor);
}
package MyWeaponPackage
{
function Player::getSpeedFactor(%this)
{
if (%this.getMountedImage(0) == MyWeaponImage.getID())
return Parent::getSpeedFactor(%this) * 0.5; // Note how speed is halved here
return Parent::getSpeedFactor(%this);
}
};
activatePackage("MyWeaponPackage");
This can easily be used to do things like speed powerups and weapon reloading cycles that slow you down.