Raised This Month: $51 Target: $400
 12% 

How is revive from ledge health calculated?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
eyal282
Veteran Member
Join Date: Aug 2011
Old 06-21-2023 , 18:22   How is revive from ledge health calculated?
Reply With Quote #1

When you have 100 perma HP and 0 temp HP and hang onto a ledge and get revived on 1 hanging HP, you will not have 100 perma HP, you will get up injured. What calculates this? What's the formula?

I need to know because the method to ignore the 200 max temporary HP is extremely fragile and is wiped with a single ledge hang.
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-22-2023 , 20:53   Re: How is revive from ledge health calculated?
Reply With Quote #2

AFAIK, u suppose to lose 1 health per sec when u r ledge hanging

I don't know if there is a native to adjust the post hanged health

but you could store client pre health before ledge hanging and then restore it after being revived

something like this

PHP Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <left4dhooks>

int g_iPermHealth_Pre[MAXPLAYERS+1];
int g_iTempHealth_Pre[MAXPLAYERS+1];

int g_iPermHealth_Post[MAXPLAYERS+1];
int g_iTempHealth_Post[MAXPLAYERS+1];

public 
void OnPluginStart()
{
    
HookEvent("revive_success"Event_ReviveSuccessEventHookMode_Post);
}

public 
Action OnPlayerRunCmd(int clientint &buttonsint &impulsefloat vel[3], float angles[3], int &weapon)
{
    if (!
client || !IsClientInGame(client) || GetClientTeam(client) != || !IsPlayerAlive(client) || GetEntProp(clientProp_Send"m_isHangingFromLedge") == 0) return Plugin_Handled;
    
    
g_iPermHealth_Pre[client] = GetClientHealth(client);
    
g_iTempHealth_Pre[client] = RoundToFloor(L4D_GetTempHealth(client));
    return 
Plugin_Continue;
}

void Event_ReviveSuccess(Event event, const char[] namebool dontBroadcast)
{
    if (!
event.GetBool("ledge_hang")) return;
    
    
int client GetClientOfUserId (event.GetInt("subject"));
    if (!
client || !IsClientInGame(client)) return;
    
    
g_iPermHealth_Post[client] = g_iPermHealth_Pre[client];
    
g_iTempHealth_Post[client] = g_iTempHealth_Pre[client];
    
    
CreateTimer(0.1Timer_RestoreClientHealthGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

Action Timer_RestoreClientHealth(Handle timerint userid)
{
    
int client GetClientOfUserId(userid);
    if(
client == || !IsClientInGame(client)) return Plugin_Stop;
    
    
SetEntProp(clientProp_Send"m_iHealth"g_iPermHealth_Post[client], 1);
    
L4D_SetTempHealth(clientfloat(g_iTempHealth_Post[client]));
    return 
Plugin_Handled;

__________________

Last edited by alasfourom; 06-22-2023 at 21:04.
alasfourom is offline
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 06-24-2023 , 02:52   Re: How is revive from ledge health calculated?
Reply With Quote #3

Quote:
Originally Posted by alasfourom View Post
something like this
PHP Code:
// Gets the health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealth(int client);

// Gets the temporary health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealthBuffer(int client); 
__________________
Silvers is offline
alasfourom
Senior Member
Join Date: Feb 2022
Location: Saudi Arabia
Old 06-24-2023 , 10:17   Re: How is revive from ledge health calculated?
Reply With Quote #4

Quote:
Originally Posted by Silvers View Post
PHP Code:
// Gets the health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealth(int client);

// Gets the temporary health of the survivor from before they were incapacitated
native int L4D2Direct_GetPreIncapHealthBuffer(int client); 
Ahh, you are right, didn't check that, this should make it a lot easier now
__________________
alasfourom is offline
sorallll
Senior Member
Join Date: Oct 2018
Old 06-24-2023 , 10:29   Re: How is revive from ledge health calculated?
Reply With Quote #5

PHP Code:
int healthtempHealthbufferTime;
if (
GetEntProp(clientProp_Send"m_isIncapacitated")) {
    if (!
GetEntProp(clientProp_Send"m_isHangingFromLedge")) {
        static 
ConVar cSurvivorReviveH;
        if (!
cSurvivorReviveH)
            
cSurvivorReviveH FindConVar("survivor_revive_health");

        
health 1;
        
tempHealth cSurvivorReviveH.IntValue;
    }
    else {
        static 
ConVar cSurvivorIncapH;
        if (!
cSurvivorIncapH)
            
cSurvivorIncapH FindConVar("survivor_incap_health");

        
int m_preHangingHealth L4D2Direct_GetPreIncapHealth(client);                                                                        // 玩家挂边前的实血
        
int m_preHangingHealthBuffer L4D2Direct_GetPreIncapHealthBuffer(client);                                                            // 玩家挂边前的虚血
        
int preTotalHealth m_preHangingHealth m_preHangingHealthBuffer;                                                                    // 玩家挂边前的总血量
        
int revivedTotalHealth RoundToFloor(GetEntProp(clientProp_Data"m_iHealth") / cSurvivorIncapH.FloatValue preTotalHealth);    // 玩家挂边起身后的总血量

        
int deltaHealth preTotalHealth revivedTotalHealth;
        if (
m_preHangingHealthBuffer deltaHealth) {
            
health m_preHangingHealth;
            
tempHealth m_preHangingHealthBuffer deltaHealth;
        }
        else {
            
health m_preHangingHealth - (deltaHealth m_preHangingHealthBuffer);
            
tempHealth 0;
        }
    }
    
bufferTime 0;
}
else {
    
health GetEntProp(clientProp_Data"m_iHealth");
    
tempHealth RoundToNearest(GetEntPropFloat(clientProp_Send"m_healthBuffer"));
    
bufferTime RoundToNearest(GetGameTime() - GetEntPropFloat(clientProp_Send"m_healthBufferTime"));

what you need is this
PHP Code:
int healthtempHealth;
static 
ConVar cSurvivorIncapH;
if (!
cSurvivorIncapH)
    
cSurvivorIncapH FindConVar("survivor_incap_health");

int m_preHangingHealth L4D2Direct_GetPreIncapHealth(client);                                                                        // 玩家挂边前的实血
int m_preHangingHealthBuffer L4D2Direct_GetPreIncapHealthBuffer(client);                                                            // 玩家挂边前的虚血
int preTotalHealth m_preHangingHealth m_preHangingHealthBuffer;                                                                    // 玩家挂边前的总血量
int revivedTotalHealth RoundToFloor(GetEntProp(clientProp_Data"m_iHealth") / cSurvivorIncapH.FloatValue preTotalHealth);    // 玩家挂边起身后的总血量

int deltaHealth preTotalHealth revivedTotalHealth;
if (
m_preHangingHealthBuffer deltaHealth) {
    
health m_preHangingHealth;
    
tempHealth m_preHangingHealthBuffer deltaHealth;
}
else {
    
health m_preHangingHealth - (deltaHealth m_preHangingHealthBuffer);
    
tempHealth 0;


Last edited by sorallll; 06-24-2023 at 10:39.
sorallll is offline
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 02:36.


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