Blockland Forums
Home
Help
Login
Register
Blockland Forums
»
Blockland Forums
»
Modification Help
»
[RESOURCE] Support_SpeedFactor.cs - Extremely simple interface to speed scaling
« previous
next »
Print
Pages: [
1
]
Author
Topic: [RESOURCE] Support_SpeedFactor.cs - Extremely simple interface to speed scaling (Read 1369 times)
portify
January 13, 2015, 03:57:26 PM
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.
«
Last Edit: January 13, 2015, 04:03:29 PM by portify
»
Ad Bot
Advertisement
Honorabl3
January 13, 2015, 04:16:17 PM
Awesome, thanks for sharing!
Print
Pages: [
1
]
« previous
next »
Blockland Forums
»
Blockland Forums
»
Modification Help
»
[RESOURCE] Support_SpeedFactor.cs - Extremely simple interface to speed scaling