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

How do divide points?

vectorScale(%vector,-number);?
lol idiot Pickle.
« Last Edit: January 08, 2008, 02:04:45 PM by MrPickle »

Actually, you need to multiply it by the reciprocal of %number:
Code: [Select]
VectorScale(%vector, 1 / %number);
Multiplying it by a negative number will only reverse the direction and scale it normally.

Multiplying it by a negative number will only reverse the direction and scale it normally.

That why I crossed it out and said stupid pickle.

With a high frequency and a low percentage, won't that bring the player to a complete stop (0.001 bricks per second) rather than 'slow down'?

Well, that's why it's configurable.  I don't really care whether it gets done or not, I just thought it might be better than going to the trouble of a new datablock.

Now that I think about it, it might not be a good idea to modify Z axis velocity.  Here's the corrected version:

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)
{
%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC 1));
schedule($impedecheckfrequency,0,"impedePlayer",%player);
}
}

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

I also modified the configuration a bit to make it a more natural slowing.
« Last Edit: January 08, 2008, 02:59:05 PM by Trader »

Holy  :iceCream: All I have to say is I suck at modding and thank you  :cookieMonster:

Np.  Lemme know how it works in-game.

Hmm, one more correction.  The Z velocity still needs to be adjusted if it is greater than zero.

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)
{
%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 = "";
}
}
« Last Edit: January 08, 2008, 03:56:44 PM by Trader »

%player.setVelocity(vectorScale(%player.getVelocity(),$impedepercentage SPC $impedepercentage SPC $impedepercentage SPC));

Oops.  Too much copy pasta is a bad thing.  It's not a syntax error though, and it would have compiled just fine.

Do I still have to change anything based on my weapon name? (not working)

If you notice, I changed the projectile name to impedeProjectile.  Either change my code or change yours to correct the difference in projectile names.

I thought so  :cookieMonster:
gonna try right now

OMG Trader is epic win. Not only does it work :cookieMonster: But it can freeze people to about a foot of move room IN MID AIR

EDIT: Trader, Do I have permission to use this in PPT's Magic Mod?