Anyone have a "hacky" mp_falldamage script?

I am sure this has been asked 100 times before, someone might even have made a script…

I am asking if anyone has a script, or if they can make one. At least till Garry fixes what he broke.

Why is this so important? Because its one of the best features of realism in gmod and I would like it back.

Thanks :slight_smile:

mp_falldamage 1

I found this on the wiki:

[lua]function GM:GetFallDamage( ply, fspeed )

return ( fspeed / 8 )

end[/lua]

Garry didn’t break anything. He just added a new function.

Thanks man! Much need, many thanks for helping out.

You’re welcome.

Sorry to bump the thread, but what do I do with that code snippet?

I just added it into:

gamemodes\sandbox\shared.lua

If you are using sandbox as your default gamemode then it will enable fall damage. The one posted above is not really similar to the one garry had before so I changed the variables.

Try this one instead:
[lua]function GM:GetFallDamage( ply, fspeed )

return ( fspeed / 14 )

end[/lua]

[lua]
FALL_DAMAGE_SCALE=0.25 --adjust as necessary, Lower=less damage
function GM:GetFallDamage( ply, flFallSpeed )
return (flFallSpeed-580)*FALL_DAMAGE_SCALE
end
[/lua]

[editline]10:02AM[/editline]

and if you wana be realy cool put this in with your player think (if you have made one yet)
[lua]if(pl:Health()<(0-pl:GetVelocity().z-580)/FALL_DAMAGE_SCALE && !(pl:GetMoveType()==MOVETYPE_NOCLIP)) then pl:Kill() end[/lua]
I use this in my gamemodes

I use this

[lua]function MPFallDamage( ply, vel )
if GetConVarNumber( “mp_falldamage” ) == 1 then
vel = vel - 580
return vel*(100/(1024-580))
end
end
hook.Add( “GetFallDamage”, “MPFallDamage”, MPFallDamage )[/lua]

Credit to someone who I have forgotten the name of. It works a treat. All you do with the code is put it into a serverside file in your gamemode.

very similar to mine only mine is adjustabls

Mines better though.

His is better. You shouldn’t override gamemode hooks unless it’s a gamemode you are making yourself (As soon as scrds updates, you will lose your function, while his will still work)

I will agree that the method is better.
I dont necessarily agree that his code is better.

[editline]10:25AM[/editline]

I’ll create an addon later.
[lua]
–Scaled Dynamic Fall Damage, Used when mp_falldamage==1
CreateConVar( “mp_falldamage_scale”, “0.25”, { FCVAR_REPLICATED, FCVAR_ARCHIVE } )

–Static Fall Damage, Used when mp_falldamage==0
CreateConVar( “mp_falldamage_static”, “10”, { FCVAR_REPLICATED, FCVAR_ARCHIVE } )

function AwateFallDamage( pl, vel )
if GetConVarNumber( “mp_falldamage” ) == 1 then
return (flFallSpeed-580)*GetConVarNumber( “mp_falldamage_scale” )
else
return GetConVarNumber( “mp_falldamage_static” )
end
end

hook.Add( “GetFallDamage”, “AwateFallDamage”, AwateFallDamage)
[/lua]

This is what the SDK uses, gravity is also factored in:



local function CalcFallDamage( ply, velocity )

	if ( server_settings.Bool( "mp_falldamage" ) ) then

		local gravity = server_settings.Int( "sv_gravity", 600 )
		
		local fatal = math.sqrt( 2 * gravity * 60 * 12 )
		local safe = math.sqrt( 2 * gravity * 20 * 12 )
		
		local damage = 100 / ( fatal - safe )
		
		velocity = velocity - safe
		return velocity * damage
	
	end
	
end
hook.Add( "GetFallDamage", "CalcFallDamage", CalcFallDamage )

very nice.
/me holds head in shame and walks away.

I perfer having a set number, rather having people able to type in a number of their choice, and mess with it and ruin it.

how would anyone ruin it? it can only be changed by the server admin.

The admin would ruin it -

“Oh, look! I can change the falldamage!”

Changes the falldamage to 1

“Haha, now I can mess around with my mates!”

I think that only the gamemode creator should have authority over what the falldamage is.

but we are not talking about a gamemode. we are talking about an addon that re-mplements mp_falldamage. Mine does that and more. frustrated