Raised This Month: $32 Target: $400
 8% 

Fall Damage Formula


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2010 , 12:41   Fall Damage Formula
Reply With Quote #1

Useless stuff, but someone may be interested...

cstrike values (should be the sames for czero)
Code:
#define PLAYER_FATAL_FALL_SPEED 980.0
#define PLAYER_MAX_SAFE_FALL_SPEED 500.0
#define PLAYER_FALL_PUNCH_THRESHHOLD 250.0 // found by arkshine
player.h (those are half life default values)
Code:
#define PLAYER_FATAL_FALL_SPEED		1024// approx 60 feet
#define PLAYER_MAX_SAFE_FALL_SPEED	580// approx 20 feet
#define DAMAGE_FOR_FALL_SPEED		(float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second.
#define PLAYER_MIN_BOUNCE_SPEED		200
#define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast.
multiplay_gamerules.cpp
Code:
float CHalfLifeMultiplay :: FlPlayerFallDamage( CBasePlayer *pPlayer )
{
	int iFallDamage = (int)falldamage.value;

	switch ( iFallDamage )
	{
	case 1://progressive
		pPlayer->m_flFallVelocity -= PLAYER_MAX_SAFE_FALL_SPEED;
		return pPlayer->m_flFallVelocity * DAMAGE_FOR_FALL_SPEED;
		break;
	default:
	case 0:// fixed
		return 10;
		break;
	}
}
player.cpp
Code:
void CBasePlayer::PostThink()
{
// [...]

// check to see if player landed hard enough to make a sound
// falling farther than half of the maximum safe distance, but not as far a max safe distance will
// play a bootscrape sound, and no damage will be inflicted. Fallling a distance shorter than half
// of maximum safe distance will make no sound. Falling farther than max safe distance will play a 
// fallpain sound, and damage will be inflicted based on how far the player fell

	if ( (FBitSet(pev->flags, FL_ONGROUND)) && (pev->health > 0) && m_flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD )
	{
		// ALERT ( at_console, "%f\n", m_flFallVelocity );

		if (pev->watertype == CONTENT_WATER)
		{
			// Did he hit the world or a non-moving entity?
			// BUG - this happens all the time in water, especially when 
			// BUG - water has current force
			// if ( !pev->groundentity || VARS(pev->groundentity)->velocity.z == 0 )
				// EMIT_SOUND(ENT(pev), CHAN_BODY, "player/pl_wade1.wav", 1, ATTN_NORM);
		}
		else if ( m_flFallVelocity > PLAYER_MAX_SAFE_FALL_SPEED )
		{// after this point, we start doing damage
			
			float flFallDamage = g_pGameRules->FlPlayerFallDamage( this );

			if ( flFallDamage > pev->health )
			{//splat
				// note: play on item channel because we play footstep landing on body channel
				EMIT_SOUND(ENT(pev), CHAN_ITEM, "common/bodysplat.wav", 1, ATTN_NORM);
			}

			if ( flFallDamage > 0 )
			{
				TakeDamage(VARS(eoNullEntity), VARS(eoNullEntity), flFallDamage, DMG_FALL ); 
				pev->punchangle.x = 0;
			}
		}

		if ( IsAlive() )
		{
			SetAnimation( PLAYER_WALK );
		}
    }

	if (FBitSet(pev->flags, FL_ONGROUND))
	{		
		if (m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer())
		{
			CSoundEnt::InsertSound ( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 );
			// ALERT( at_console, "fall %f\n", m_flFallVelocity );
		}
		m_flFallVelocity = 0;
	}
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-25-2012 at 18:26.
ConnorMcLeod is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-04-2010 , 13:46   Re: Fall Damage Formula
Reply With Quote #2

Would be better to have some kind of stock, those codes can't help some people
__________________
xPaw is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-04-2010 , 15:14   Re: Fall Damage Formula
Reply With Quote #3

That is just to let you know cs values.
flDamage that is passed into TakeDamage is already the final damage taken, so make a stock would be even more useless than having created that thread.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 01-13-2010 , 13:34   Re: Fall Damage Formula
Reply With Quote #4

It's not the fall that kills ya, it's the sudden stop at the end. People have been jumping out of planes for years, while so do die jumping out of a plane, such as the case of an elderly gentlemen who had a heart attack secondary to the adrenaline flow caused by that said individual jumping out of the plane, most of the times it does not happen. People do die from multi vehicle collisions, jumper downs, and gun shot wounds every day. They them selfs did not die because of the first act, they died because of the injury(s) they received because of that act. It's the blood loss, the cardiac arrest secondary to the blood loss (hypovolemia) giving you a pulse less rhythm on the EKG known as PEA (Pulse-less Electrical Activity).

I'm going through paramedic school right now, so I find this all very intresting, injury mechanics in general is quite an intresting field but not simulated within the game engine.

That said tho, I would of taken terminal velocity as the max speed of any falling object and then found the velocity that f = t / v gives you a point where f is so great that the human system instantly collapses, or causes fatal injury's.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-16-2010 , 08:57   Re: Fall Damage Formula
Reply With Quote #5

Quote:
Originally Posted by Dygear View Post
It's not the fall that kills ya, it's the sudden stop at the end.
I gave up there.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 01-30-2010 , 08:46   Re: Fall Damage Formula
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
I gave up there.
LOL connor
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode