Hmm, one more correction. The Z velocity still needs to be adjusted if it is greater than zero.
$impededuration = 3 * 1000; //Change "3" to the number of seconds it should last.
$impedecheckfrequency = 1000 / 2; //Change "2" to the number of times per second it should impede throughout the impede duration.
$impedepercentage = 50 / 100; //Change "50" to the percentage of normal speed you want them to be.
function impedeProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal)
{
if(%col.getClassName() $= "Player" && miniGameCanDamage(%obj, %col) && !%col.impeded)
{
%col.impeded = 1;
impedePlayer(%col);
schedule($impededuration,0,"cancelImpede",%col);
}
}
function impedePlayer(%player)
{
if(isObject(%player) && %player.impeded)
{
%zVelocity = getWord(%player.getVelocity(),2);
if(%zVelocity > 0)
{
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC $impedepercentage));
}
else
{
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC 1));
}
schedule($impedecheckfrequency,0,"impedePlayer",%player);
}
}
function cancelImpede(%player)
{
if(isObject(%player))
{
%player.impeded = "";
}
}