AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Detecting falling without damage (https://forums.alliedmods.net/showthread.php?t=171390)

nikhilgupta345 11-05-2011 11:45

Detecting falling without damage
 
Is there any way to detect if a player landed on another player without taking damage from the fall?

ConnorMcLeod 11-05-2011 11:48

Re: Detecting falling without damage
 
you mean "even when he doesn't take damage" or "only when he doesn't take damage" ?

Bugsy 11-05-2011 12:02

Re: Detecting falling without damage
 
Probably a better way but could be accomplished with this, though not perfectly. Check health when player first off ground and again when landing, you would need checking if injured while in air by weapon. Can also take a look at jim_yangs post under mine.

http://forums.alliedmods.net/showpos...73&postcount=7

bibu 11-05-2011 14:12

Re: Detecting falling without damage
 
Don't know if this can help:

http://forums.alliedmods.net/showthread.php?p=915157

or this

http://forums.alliedmods.net/showthread.php?p=722032

ConnorMcLeod 11-05-2011 15:34

Re: Detecting falling without damage
 
Dunno if this can work :

Reference : http://forums.alliedmods.net/showthread.php?t=114407

PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

const Float:PLAYER_FATAL_FALL_SPEED 980.0 // approx 60 feet
const Float:PLAYER_MAX_SAFE_FALL_SPEED 500.0 // approx 20 feet
#define DAMAGE_FOR_FALL_SPEED        100.0 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED ) // damage per unit per second.
const Float:PLAYER_MIN_BOUNCE_SPEED        200.0
const Float:PLAYER_FALL_PUNCH_THRESHHOLD 350.0 // won't punch player's screen/make scrape noise unless player falling at least this fast.

const XO_PLAYER 5
const m_flFallVelocity 251

public plugin_init()
{
    
register_plugin("Landing check damage""0.1""ConnorMcLeod")
    
RegisterHam(Ham_Player_PostThink"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
public CBasePlayer_PostThinkid )
{
    if( 
is_user_alive(id) && pev(idpev_flags) & FL_ONGROUND )
    {
        new 
Float:flFallVelocity get_pdata_float(idm_flFallVelocityXO_PLAYER)
        if( 
flFallVelocity )
        {
            new 
iGroundEntity pev(idpev_groundentity)
            new 
Float:flFallDamage
            
if ( flFallVelocity >= PLAYER_FALL_PUNCH_THRESHHOLD && pev(idpev_watertype) != CONTENTS_WATER  && flFallVelocity PLAYER_MAX_SAFE_FALL_SPEED )
            {
                
flFallDamage DAMAGE_FOR_FALL_SPEED * ( flFallVelocity PLAYER_MAX_SAFE_FALL_SPEED )
            }
            if( 
flFallDamage )
            {
                
// player has landed on entity %d (iGroundEntity) (can be 0, lets check if it is a player) and is gonna take %f damage (set m_flFallVelocity to 0 if you want to remove fall damage)
            
}
            else
            {
                
// player has landed on entity %d (iGroundEntity) (can be 0, lets check if it is a player) and is not gonna take any damage (raise m_flFallVelocity if you want to add damage)
            
}
        }
    }




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

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