Author Topic: Decreasing opponents speed on contact  (Read 2711 times)

Sure, but you need to make one important modification.  It shouldn't hold people in the air, they should just fall down.  I'm using -5 as the vertical velocity, and I think that should be sufficient for the drop.  If you feel the player needs to drop more quickly, decrease the number, perhaps to -10.

Code: [Select]
$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)
{
%velX = getWord(%player.getVelocity(),0) * $impedepercentage;
%velY = getWord(%player.getVelocity(),1) * $impedepercentage;
%velZ = -5;
%player.setVelocity(%velX SPC %velY SPC %velZ);
schedule($impedecheckfrequency,0,"impedePlayer",%player);
}
}

function cancelImpede(%player)
{
if(isObject(%player))
{
%player.impeded = "";
}
}

Oops.  Too much copy pasta is a bad thing.  It's not a syntax error though, and it would have compiled just fine.
It is a syntax error, the SPC operator requires something before and afterwards.

Are you sure?  Hmm, interesting.  Well it was copy pasta, I don't feel too bad about it.  Plus, I'm at work and can't test any of this.

Is there anyway to make the effect like completely frozen for 10 seconds? I tried making it freeze 1000 times a second but its all laggy  :cookieMonster:

This configuration should work.
$impededuration = 10 * 1000;
$impedecheckfrequency = 1000 / 20;
$impedepercentage = 10 / 100;

I'm gonna code that in, but I can't test until after school... thank you :cookie:

Yeah, just remember that the variables are all declared at the top.  Just change their values there.

once again laggy...  What I want it to do is like keep them at that speed for the  not impede them to that speed for a number of times. Sorry to be difficult  :cookieMonster:

That shouldn't be laggy unless your computer is really slow.  It might feel laggy as you're controlling the player, but it shouldn't create any real game lag.  If you just want to make them completely stop, just clear the client's control object.

How do I clear the control object