Author Topic: Dynamic ImpulseForce for different players  (Read 810 times)

Is there a way to change the impulseForce dynamically per player?
Like, some players should get flung away less than others from the same explosion based on a player variable.

I was thinking of using functions like:
Code: [Select]
function Armor::Damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
function Armor::onCollision(%this, %obj, %col, %thing, %other, %other2)
But I don't find enough documentation to find out what every variable in there is suppose to represent or if any are useful to my problem.
The Appendix A doesn't list those kind of functions.


I could possibly slow down or speed up their velocity after they get damaged by an explosion.
But that would also incorporate the speed they were moving at, giving a distorted trajectory.
So I'll probably use that if no better ways are found.

You could use vectorScale(%velocityVector,%playerVariable) on the vector from the explosion I guess?

I found a solution thanks to Quartz and wanted to post it here.

What I basically did was add a schedule when a player got hit by the explosion that would increase his speed by a factor of his Energy level.
Code: [Select]
function LandmineFinalExplosionProjectile::onExplode(%dataBlock, %this)
    {
    parent::onExplode(%this,%obj);

initContainerRadiusSearch(%this.getPosition(), 20, $TypeMasks::PlayerObjectType); //look for players in the explosion radius
while(%player = containerSearchNext())
{
        %player.IncreaseVelocitySch = %player.schedule(100,"IncreaseVelocity", %player);
}
    }

    function Player::IncreaseVelocity(%player)
    {
        if(isObject(%player)){
    %player.setVelocity(vectorScale(%player.getVelocity(),(%player.getEnergyLevel() * 0.01))); //actually increase the speed
        }
    }

Since my playertype has a max energy of 200, it ranges from 0 (not getting knocked back at all) to 2 (getting knocked back 2 times as far as the original)

I found a solution thanks to Quartz and wanted to post it here.

What I basically did was add a schedule when a player got hit by the explosion that would increase his speed by a factor of his Energy level.

Since my playertype has a max energy of 200, it ranges from 0 (not getting knocked back at all) to 2 (getting knocked back 2 times as far as the original)