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

How can I do it

What I have so far is below


function ImpedimentaProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
   if(%col.getClassName() $="Player")
{
   %col.setVelocity(VectorMul(%player.getvelocity(),0.5));
}

What went wrong (it doesn't work) Help is appreciated

Code: [Select]
function ImpedimentaProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal){
   if(%col.getClassName() $="Player"){
   %col.setVelocity(VectorMul(%player.getvelocity(),0.5));
   }
}

Hope it works (THANK YOU)

Doesn't work =( any ideas?

EDIT: It does work I found out but not for long. I changed speed to .1 so I could more easily see the difference... My opponent sped down alot (almost stand still) for about half a second. How do i set a duration to it?
« Last Edit: January 06, 2008, 07:18:08 PM by Dr Bling »

If you want to permentally slow them down I'd make a custom player datablock with slow speeds then set their datablock to that datablock.

You'd have to make a custom player datablock.

vectorMul doesn't exist, you're probably thinking of vectorScale.

In this case, as recommended, using an alternate datablock would be better. Make it check whether your datablock has jets and use a jet/nojet "slowed" player.

EDIT: Also, that would work outside of a minigame...

Ah, but that sets the players damage back to 0.

Player::getDamageLevel()
Player::getEnergyLevel()
Player::setDamageLevel()
Player::setEnergyLevel()

Now I am really confused  :cookieMonster:

I'll explain later, the PS3 keyboard is a pain.

Then why did you bother posting, Jervan?

Code: [Select]
%damage = %player.getDamageLevel();
%energy = %player.getEnergyLevel();

%player.setDatablock(DrBlingPlayerDatablock); //Change the datablock to the one you're using.

%player.setDamageLevel(%damage);
%player.setEnergyLevel(%energy);

Code: [Select]
function ImpedimentaProjectile::onCollision(%this, %obj, %col, %fade, %pos, %normal){
if(%col.getClassName() $= "Player" && miniGameCanDamage(%obj, %col)){
%damage = %col.getDamageLevel();
%energy = %col.getEnergyLevel();
%col.setDatablock(DrBlingPlayerDatablock); //Change the datablock to the one you're using.
%col.setDamageLevel(%damage);
%col.setEnergyLevel(%energy);
%col.client.ApplyBodyParts();
%col.client.ApplyBodyColors();
}
}
Added minigame check and reset appearance after datablock change.

Or you could do it this way.

Code: [Select]
$impededuration = 3 * 1000; //Change "3" to the number of seconds it should last.
$impedecheckfrequency = 1000 / 5; //Change "5" to the number of times per second it should impede throughout the impede duration.
$impedepercentage = 10 / 100; //Change "10" 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)
{
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC $impedepercentage));
schedule($impedecheckfrequency,0,"impedePlayer",%player);
}
}

function cancelImpede(%player)
{
if(isObject(%player))
{
%player.impeded = "";
}
}
« Last Edit: January 08, 2008, 12:26:09 PM by Trader »

VectorScale multiplies all points in the given vector by the value in the second argument, so:

Code: [Select]
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC $impedepercentage));

need only be:

Code: [Select]
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage));
.. not that it will actually make any difference.