Update dhooks

This commit is contained in:
Jackzie 2024-02-15 09:03:07 -06:00
parent 897c5681ad
commit f5e0662e58
5 changed files with 1281 additions and 134 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
/* /*
* Left 4 DHooks Direct * Left 4 DHooks Direct
* Copyright (C) 2023 Silvers * Copyright (C) 2024 Silvers
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,6 +21,8 @@
#endif #endif
#define _l4d_anim_included #define _l4d_anim_included
#pragma newdecls required
#include <sdktools> #include <sdktools>
#include <sdkhooks> #include <sdkhooks>

View file

@ -1,5 +1,5 @@
/** /**
* Copyright (C) 2023 LuxLuma * Copyright (C) 2024 LuxLuma
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -20,6 +20,8 @@
#endif #endif
#define _lux_library_included #define _lux_library_included
#pragma newdecls required
#include <sourcemod> #include <sourcemod>
#include <sdktools> #include <sdktools>
@ -27,7 +29,7 @@
#tryinclude <left4dhooks_silver> #tryinclude <left4dhooks_silver>
#tryinclude <left4dhooks_stocks> #tryinclude <left4dhooks_stocks>
#define LUX_LIBRARY_VERSION "0.5.7" #define LUX_LIBRARY_VERSION "0.5.8"
#define GIMMEDATA "lux_library" #define GIMMEDATA "lux_library"
@ -385,6 +387,9 @@ stock float Terror_GetAdrenalineTime(int iClient)
timerAddress = FindSendPropInfo("CTerrorPlayer", "m_bAdrenalineActive") - 12; timerAddress = FindSendPropInfo("CTerrorPlayer", "m_bAdrenalineActive") - 12;
} }
if(GetEntProp(iClient, Prop_Send, "m_bAdrenalineActive", 1) < 1)
return -1.0;
//timerAddress + 8 = TimeStamp //timerAddress + 8 = TimeStamp
float flGameTime = GetGameTime(); float flGameTime = GetGameTime();
float flTime = GetEntDataFloat(iClient, timerAddress + 8); float flTime = GetEntDataFloat(iClient, timerAddress + 8);
@ -1431,10 +1436,10 @@ stock void EmitMixedAmbientSound(int client, const char[] sample,
if(flDistMulti > 1.0) if(flDistMulti > 1.0)
{ {
newPitch = FloatToInt(newPitch / (flDistMulti > 2.0 ? 2.0 : flDistMulti)); newPitch = RoundToNearest(newPitch / (flDistMulti > 2.0 ? 2.0 : flDistMulti));
} }
DistLevelBoost = FloatToInt((flDistPercent * exponent) * levelBoost); DistLevelBoost = RoundToNearest((flDistPercent * exponent) * levelBoost);
if(DistLevelBoost > levelBoost) if(DistLevelBoost > levelBoost)
DistLevelBoost = levelBoost; DistLevelBoost = levelBoost;
@ -1515,21 +1520,16 @@ stock void EmitMixedAmbientSound_FallBack(int client, const char[] sample,
newPitch = pitch; newPitch = pitch;
if(flDistMulti > 1.0) if(flDistMulti > 1.0)
{ {
newPitch = FloatToInt(newPitch / (flDistMulti > 2.0 ? 2.0 : flDistMulti)); newPitch = RoundToNearest(newPitch / (flDistMulti > 2.0 ? 2.0 : flDistMulti));
} }
DistLevelBoost = FloatToInt((flDistPercent * exponent) * levelBoost); DistLevelBoost = RoundToNearest((flDistPercent * exponent) * levelBoost);
if(DistLevelBoost > levelBoost) if(DistLevelBoost > levelBoost)
DistLevelBoost = levelBoost; DistLevelBoost = levelBoost;
EmitSoundToClient(client, sample, entity, sndChannel, level + DistLevelBoost, _, _, newPitch, _, origin); EmitSoundToClient(client, sample, entity, sndChannel, level + DistLevelBoost, _, _, newPitch, _, origin);
} }
int FloatToInt(float val)
{
return RoundFloat(val);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////Legacy Particle Stock/////////////////////////////////////////////////////////////// ////////////////////////////////////Legacy Particle Stock///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

View file

@ -1,6 +1,6 @@
/* /*
* Left 4 DHooks Direct - Stock Functions * Left 4 DHooks Direct - Stock Functions
* Copyright (C) 2023 Silvers * Copyright (C) 2024 Silvers
* *
* This program is free software: you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -21,6 +21,8 @@
#endif #endif
#define _l4d_silver_included #define _l4d_silver_included
#pragma newdecls required
#include <sdktools> #include <sdktools>
#include <sdkhooks> #include <sdkhooks>
@ -949,6 +951,72 @@ stock void L4D_LedgeHangDisable(int client)
* *
* @return Returns true if player is staggering, false otherwise * @return Returns true if player is staggering, false otherwise
*/ */
// Updated more accurate version thanks to "HarryPotter" for providing.
stock bool L4D_IsPlayerStaggering(int client)
{
static int Activity = -1;
if( L4D_IsEngineLeft4Dead2() )
{
Activity = PlayerAnimState.FromPlayer(client).GetMainActivity();
switch( Activity )
{
case L4D2_ACT_TERROR_SHOVED_FORWARD_MELEE, // 633, 634, 635, 636: stumble
L4D2_ACT_TERROR_SHOVED_BACKWARD_MELEE,
L4D2_ACT_TERROR_SHOVED_LEFTWARD_MELEE,
L4D2_ACT_TERROR_SHOVED_RIGHTWARD_MELEE:
return true;
}
}
else
{
Activity = L4D1_GetMainActivity(client);
switch( Activity )
{
case L4D1_ACT_TERROR_SHOVED_FORWARD, // 1145, 1146, 1147, 1148: stumble
L4D1_ACT_TERROR_SHOVED_BACKWARD,
L4D1_ACT_TERROR_SHOVED_LEFTWARD,
L4D1_ACT_TERROR_SHOVED_RIGHTWARD:
return true;
}
}
static int m_iQueuedStaggerType = -1;
if( m_iQueuedStaggerType == -1 )
m_iQueuedStaggerType = FindSendPropInfo("CTerrorPlayer", "m_staggerDist") + 4;
if( GetEntData(client, m_iQueuedStaggerType, 4) == -1 )
{
if( GetGameTime() >= GetEntPropFloat(client, Prop_Send, "m_staggerTimer", 1) )
{
return false;
}
static float vStgDist[3], vOrigin[3];
GetEntPropVector(client, Prop_Send, "m_staggerStart", vStgDist);
GetEntPropVector(client, Prop_Send, "m_vecOrigin", vOrigin);
static float fStgDist2;
fStgDist2 = GetEntPropFloat(client, Prop_Send, "m_staggerDist");
return GetVectorDistance(vStgDist, vOrigin) <= fStgDist2;
}
return true;
}
stock int L4D1_GetMainActivity(int client)
{
static int s_iOffs_m_eCurrentMainSequenceActivity = -1;
if( s_iOffs_m_eCurrentMainSequenceActivity == -1 )
s_iOffs_m_eCurrentMainSequenceActivity = FindSendPropInfo("CTerrorPlayer", "m_iProgressBarDuration") + 476;
return LoadFromAddress(GetEntityAddress(client) + view_as<Address>(s_iOffs_m_eCurrentMainSequenceActivity), NumberType_Int32);
}
/* OLD VERSION (Before being updated by "HarryPotter")
stock bool L4D_IsPlayerStaggering(int client) stock bool L4D_IsPlayerStaggering(int client)
{ {
static int m_iQueuedStaggerType = -1; static int m_iQueuedStaggerType = -1;
@ -974,6 +1042,7 @@ stock bool L4D_IsPlayerStaggering(int client)
return true; return true;
} }
*/

View file

@ -1,7 +1,7 @@
/** /**
* ============================================================================= * =============================================================================
* Left 4 Dead Stocks Library (C)2011-2012 Buster "Mr. Zero" Nielsen * Left 4 Dead Stocks Library (C)2011-2012 Buster "Mr. Zero" Nielsen
* Syntax Update and merge into "Left 4 DHooks Direct" (C) 2023 "SilverShot" * Syntax Update and merge into "Left 4 DHooks Direct" (C) 2024 "SilverShot"
* ============================================================================= * =============================================================================
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@ -32,6 +32,8 @@
#endif #endif
#define _l4d_stocks_included #define _l4d_stocks_included
#pragma newdecls required
#tryinclude <left4dhooks_anim> #tryinclude <left4dhooks_anim>
#tryinclude <left4dhooks_silver> #tryinclude <left4dhooks_silver>
#tryinclude <left4dhooks_lux_library> #tryinclude <left4dhooks_lux_library>
@ -665,7 +667,7 @@ stock int L4D_GetPendingTankPlayer()
* @return True if glow was set, false if entity does not support glow. * @return True if glow was set, false if entity does not support glow.
*/ */
// L4D2 only. // L4D2 only.
stock bool L4D2_SetEntityGlow(int entity, L4D2GlowType type, int range, int minRange, colorOverride[3], bool flashing) stock bool L4D2_SetEntityGlow(int entity, L4D2GlowType type, int range, int minRange, int colorOverride[3], bool flashing)
{ {
if (!IsValidEntity(entity)) if (!IsValidEntity(entity))
{ {
@ -1321,6 +1323,30 @@ stock void L4D_SetPlayerTempHealth(int client, int tempHealth)
SetEntPropFloat(client, Prop_Send, "m_healthBufferTime", GetGameTime()); SetEntPropFloat(client, Prop_Send, "m_healthBufferTime", GetGameTime());
} }
/**
* Set players temporarily health. Allows for setting above 200 HP.
*
* @param client Client index.
* @param tempHealth Temporarily health.
* @noreturn
* @error Invalid client index.
*/
stock void L4D_SetPlayerTempHealthFloat(int client, float tempHealth)
{
static ConVar painPillsDecayCvar;
if (painPillsDecayCvar == null)
{
painPillsDecayCvar = FindConVar("pain_pills_decay_rate");
if (painPillsDecayCvar == null)
{
return;
}
}
SetEntPropFloat(client, Prop_Send, "m_healthBuffer", tempHealth);
SetEntPropFloat(client, Prop_Send, "m_healthBufferTime", GetGameTime() + ((tempHealth - 200) / painPillsDecayCvar.FloatValue + 1 / painPillsDecayCvar.FloatValue));
}
/** /**
* Returns player use action. * Returns player use action.
* *