Author Topic: Fall damage sensitivity  (Read 1170 times)

I've been working on a few player types lately for sooperseekret means, and have been wanting to make the player more sensitive to fall damage. Like, instead of falling  I was wondering if that's possible?
From in-game tests, the player seems to be able to fall about <60 bricks before reaching a lethal velocity.
Even more so, can I make the player, well, play a sound upon receiving fall damage?

So,
Can I make the player more sensitive to fall damage?
And can I make the player play a sound upon receiving fall damage?

As far as I can remember, falling damage is handled by Armor::onImpact. I haven't tested this, but simply having this method on your player datablock should work (and hopefully stop it from handling fall damage normally for that datablock). It's argument will be (%this, %obj). You would then check to see if the z coordinate of the object's velocity is smaller than the negative of the speed you want to kill the player, and if it was kill the player (and play your sound at the player's position). If you wanted to handle player's being killed when they jet into something as well, then you would instead get the length of the velocity (vectorLen) and compare that to the speed constant instead. Also, %obj.kill() will work fine normally but to polish it off you would make it apply the correct fall-damage damage type.

The minImpactSpeed on a player datablock specifies how fast (standard Torque unit velocity) a player must be moving when colliding with a solid object in order to take damage.

The damage applied is the player's current velocity (standard Torque unit velocity, again) multiplied by the speedDamageScale field on a player databock.

Change around these values until you're satisfied.
If you're curious, the single-value version of their velocity is calculated using vectorLen( %obj.getVelocity() );

This is fantastic, thank you very much!

Doesn't allow him to play a sound when fall damage is applied though. However, I had completely forgotten about those fields, so chances are that the impact sounds that vehicles have might be on players too. Then you could just set the hard impact sound to your player-fell sound. If they don't work, then you're either going to have to use my idea or listen for fall damage on the player via the armor::damage function.

I know there's water impact sounds for players, so I'll bet there's sounds for the other things.

I'm having a bit more trouble than I thought.

I'm trying out Destiny's method and am not trying to implement a sound effect just yet. Is it possible to have an example? If it isn't too much trouble s:

Wait, disregard that- looks like all I needed was one small line of code:

Code: [Select]
minImpactSpeed = "x";
-.-"

Now to work in a sound effect. Will I need to create an explosion upon impact damage?

serverPlay3d(Position, SoundDatablock);

Wait, disregard that- looks like all I needed was one small line of code:

Code: [Select]
minImpactSpeed = "x";
-.-"

Now to work in a sound effect. Will I need to create an explosion upon impact damage?
bonecrunch.wav

function PlayerType::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
     if(%damageType == $DamageType::Fall || %damageType == $DamageType::Impact)
     {
     //Sound stuff
     }
Parent::damage(%this, %obj, %sourceObject, %position, %damage, %damageType);
}