misc lib updates

This commit is contained in:
Jackzie 2022-01-07 07:52:52 -06:00
parent 509c6a1b21
commit fa583fdee9
No known key found for this signature in database
GPG key ID: 1E834FE36520537A
6 changed files with 4161 additions and 7 deletions

View file

@ -212,6 +212,15 @@ bool IsAnyPlayerNear(int source, float range) {
return false;
}
void ThrowItemToPlayer(int victim, int target, int slot) {
int wpn = GetPlayerWeaponSlot(victim, slot);
if(wpn > 0 && (slot != 1 || DoesClientHaveMelee(victim))) {
static float pos[3];
GetClientAbsOrigin(target, pos);
SDKHooks_DropWeapon(victim, wpn, pos);
}
}
void ThrowItemToClosestPlayer(int victim, int slot) {
int wpn = GetPlayerWeaponSlot(victim, slot);
if(wpn > 0 && (slot != 1 || DoesClientHaveMelee(victim))) {

View file

@ -17,8 +17,8 @@
* Left 4 Downtown 2 Extension updates
* Copyright (C) 2017 "Accelerator74"
*
* Left 4 DHooks SourceMod plugin
* Copyright (C) 2020 "SilverShot" / "Silvers"
* Left 4 DHooks Direct SourceMod plugin
* Copyright (C) 2021 "SilverShot" / "Silvers"
*
* =============================================================================
*
@ -52,6 +52,26 @@
#define _l4dh_included
#include <left4dhooks_anim>
#include <left4dhooks_silver>
#include <left4dhooks_lux_library>
#include <left4dhooks_stocks>
// Natives:
// L4D1 = 24 [left4downtown] + 47 [l4d_direct] + 15 [l4d2addresses] + 44 [silvers - mine!] + 4 [anim] = 126
// L4D2 = 53 [left4downtown] + 61 [l4d_direct] + 26 [l4d2addresses] + 79 [silvers - mine!] + 4 [anim] = 212
// Forwards:
// L4D1 = 61;
// L4D2 = 78;
// Stocks: (L4D1 = 106. L4D2 = 149)
// left4dhooks_silver 37 stocks (L4D2 = 4, L4D1 = 0)
// left4dhooks_stocks 82 stocks (L4D2 = 39, L4D1 = 4)
// left4dhooks_lux_library 34 stocks (L4D2 = 4, L4D1 = 0)
@ -105,6 +125,11 @@ public void __pl_l4dh_SetNTVOptional()
MarkNativeAsOptional("L4D2_VomitJarPrj");
MarkNativeAsOptional("L4D2_GrenadeLauncherPrj");
MarkNativeAsOptional("L4D_GetPointer");
MarkNativeAsOptional("L4D_GetClientFromAddress");
MarkNativeAsOptional("L4D_GetEntityFromAddress");
MarkNativeAsOptional("L4D_ReadMemoryString");
MarkNativeAsOptional("L4D_GetServerOS");
MarkNativeAsOptional("L4D2_ExecVScriptCode");
MarkNativeAsOptional("L4D2_GetVScriptOutput");
MarkNativeAsOptional("L4D2_SpitterPrj");
@ -335,6 +360,21 @@ enum
GAMEMODE_SCAVENGE = 8
}
// For the "L4D_GetPointer" native
enum PointerType
{
POINTER_DIRECTOR = 1, // @TheDirector
POINTER_SERVER = 2, // @sv
POINTER_GAMERULES = 3, // @g_pGameRules
POINTER_NAVMESH = 4, // @TheNavMesh
POINTER_ZOMBIEMANAGER = 5, // @TheZombieManager
POINTER_WEAPONINFO = 6, // @_ZL20m_WeaponInfoDatabase
POINTER_MELEEINFO = 7, // @g_MeleeWeaponInfoStore (L4D2 Only)
POINTER_EVENTMANAGER = 8, // pScriptedEventManager (L4D2 Only)
POINTER_SCAVENGEMODE = 9, // pScavengeMode (L4D2 Only)
POINTER_VERSUSMODE = 10 // pVersusMode
}
// Provided by "BHaType":
// For the "L4D_State_Transition" native.
// X -> Y (means X state will become Y state on next frame or some seconds later)
@ -466,6 +506,20 @@ native int AnimGetFromActivity(char[] activity);
*/
forward Action L4D_OnSpawnSpecial(int &zombieClass, const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnSpecial(ZombieClassType,Vector&,QAngle&) is invoked
* @remarks Only used for bot special spawns (not players)
* @remarks zombieClass: 1=Smoker, 2=Boomer, 3=Hunter, 4=Spitter, 5=Jockey, 6=Charger
*
* @param client The client index who spawned
* @param zombieClass Zombie class that will be spawned.
* @param vecPos Vector coordinate where special will be spawned
* @param vecAng QAngle where spcial will be facing
*
* @noreturn
*/
forward void L4D_OnSpawnSpecial_Post(int client, int zombieClass, const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnTank(Vector&,QAngle&) is invoked
* @remarks Not invoked if z_spawn tank is used and it gives a ghosted/dead player tank
@ -477,6 +531,18 @@ forward Action L4D_OnSpawnSpecial(int &zombieClass, const float vecPos[3], const
*/
forward Action L4D_OnSpawnTank(const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnTank(Vector&,QAngle&) is invoked
* @remarks Not invoked if z_spawn tank is used and it gives a ghosted/dead player tank
*
* @param client The client index who spawned
* @param vecPos Vector coordinate where tank is spawned
* @param vecAng QAngle where tank will be facing
*
* @noreturn
*/
forward void L4D_OnSpawnTank_Post(int client, const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnWitch(Vector&,QAngle&) is invoked
* @brief Called when a Witch spawns
@ -488,6 +554,18 @@ forward Action L4D_OnSpawnTank(const float vecPos[3], const float vecAng[3]);
*/
forward Action L4D_OnSpawnWitch(const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnWitch(Vector&,QAngle&) is invoked
* @brief Called when a Witch spawns
*
* @param entity Entity index that spawned
* @param vecPos Vector coordinate where witch is spawned
* @param vecAng QAngle where witch will be facing
*
* @noreturn
*/
forward void L4D_OnSpawnWitch_Post(int entity, const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnWitchBride(Vector&,QAngle&) is invoked
* @brief Called when a Witch Bride spawns
@ -500,6 +578,19 @@ forward Action L4D_OnSpawnWitch(const float vecPos[3], const float vecAng[3]);
// L4D2 only.
forward Action L4D2_OnSpawnWitchBride(const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever ZombieManager::SpawnWitchBride(Vector&,QAngle&) is invoked
* @brief Called when a Witch Bride spawns
*
* @param entity Entity index that spawned
* @param vecPos Vector coordinate where witch is spawned
* @param vecAng QAngle where witch will be facing
*
* @noreturn
*/
// L4D2 only.
forward void L4D2_OnSpawnWitchBride_Post(int entity, const float vecPos[3], const float vecAng[3]);
/**
* @brief Called whenever CDirector::OnMobRushStart(void) is invoked
* @remarks called on random hordes, mini and finale hordes, and boomer hordes, causes Zombies to attack
@ -1242,7 +1333,7 @@ forward Action L4D2_OnStartCarryingVictim(int victim, int attacker);
* @remarks Called when a Survivor player is covered in Boomer bile, or when using "Bile the World" plugin by "AtomicStryker"
*
* @param victim the client who's now it
* @param attacker the attacker who caused the vomit
* @param attacker the attacker who caused the vomit (can be 0)
*
* @return Plugin_Handled to block, Plugin_Changed to use overwritten values from plugin, Plugin_Continue otherwise
*/
@ -1253,7 +1344,7 @@ forward Action L4D_OnVomitedUpon(int victim, int &attacker, bool &boomerExplosio
* @remarks Called when a Special Infected is hit from a Bilejar explosion
*
* @param victim the client who's now it
* @param attacker the attacker who caused the vomit
* @param attacker the attacker who caused the vomit (can be 0)
* @param boomerExplosion true if triggered by a boommer explosion
*
* @return Plugin_Handled to block, Plugin_Changed to use overwritten values from plugin, Plugin_Continue otherwise
@ -1377,6 +1468,49 @@ forward Action L4D_OnGetRandomPZSpawnPosition(int &client, int &zombieClass, int
// ====================================================================================================
// NATIVES - Silvers
// ====================================================================================================
/**
* @brief Returns the address pointer to various internal game objects
*
* @param ptr_type Using the PointerType enum to select which pointer to return
*
* @return Address pointer or 0 on failure.
*/
native Address L4D_GetPointer(PointerType ptr_type);
/**
* @brief Returns a client index from a memory address
*
* @param addy Address to check
*
* @return Client index or 0 on failure.
*/
native int L4D_GetClientFromAddress(Address addy);
/**
* @brief Returns an entity index from a memory address
*
* @param addy Address to check
*
* @return Entity index or -1 on failure.
*/
native int L4D_GetEntityFromAddress(Address addy);
/**
* @brief Returns an entity index from a memory address
*
* @param addy Address to check
*
* @return Entity index or -1 on failure.
*/
native int L4D_ReadMemoryString(Address addy, char[] buffer, int maxlength);
/**
* @brief Returns the servers operating system.
*
* @return 0=Windows. 1=Linux.
*/
native int L4D_GetServerOS();
/**
* @brief Runs a specified VScript code.
* @remarks Saves having to create an entity. The entity can remain alive and used again...
@ -2529,9 +2663,9 @@ native float L4D2_ITimerGetElapsedTime(L4D2IntervalTimer timer);
* 2020 Update2: Now works in Left4DHooks. Glitchy animation bug when reloading an already full weapon.
* 2021 Update3: Fix plugin for modified ammo clips found here: https://forums.alliedmods.net/showthread.php?t=327105
A note regarding Clipsize: Any non-standard value will NOT be in effect at weapon pickup, which means the client
has to reload once to achieve the modified value. To fix this, add a weapon pickup hook in your plugin (eg "player_use")
and use something like this with a small timer delay of 0.1 seconds or more (dont you love this engine).
A note regarding Clipsize: Any non-standard value will NOT be in effect at weapon pickup, which means the client
has to reload once to achieve the modified value. To fix this, add a weapon pickup hook in your plugin (eg "player_use")
and use something like this with a small timer delay of 0.1 seconds or more (dont you love this engine).
int weapon = GetPlayerWeaponSlot(client, 0);
if( weapon == INVALID_ENT_REFERENCE ) return;
@ -2544,6 +2678,8 @@ enum L4D2IntWeaponAttributes
L4D2IWA_Damage,
L4D2IWA_Bullets,
L4D2IWA_ClipSize,
L4D2IWA_Bucket,
L4D2IWA_Tier, // L4D2 only
MAX_SIZE_L4D2IntWeaponAttributes
};
@ -2566,15 +2702,19 @@ enum L4D2FloatWeaponAttributes
L4D2FWA_CycleTime,
L4D2FWA_PelletScatterPitch,
L4D2FWA_PelletScatterYaw,
L4D2FWA_VerticalPunch,
L4D2FWA_HorizontalPunch, // Requires "z_gun_horiz_punch" cvar changed to "1".
MAX_SIZE_L4D2FloatWeaponAttributes
};
// L4D2 only
enum L4D2BoolMeleeWeaponAttributes
{
L4D2BMWA_Decapitates,
MAX_SIZE_L4D2BoolMeleeWeaponAttributes
};
// L4D2 only
enum L4D2IntMeleeWeaponAttributes
{
L4D2IMWA_DamageFlags,
@ -2582,6 +2722,7 @@ enum L4D2IntMeleeWeaponAttributes
MAX_SIZE_L4D2IntMeleeWeaponAttributes
};
// L4D2 only
enum L4D2FloatMeleeWeaponAttributes
{
L4D2FMWA_Damage,

View file

@ -1,3 +1,37 @@
/*
* Left 4 DHooks Direct
* Copyright (C) 2021 Silvers
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if defined _l4d_anim_included
#endinput
#endif
#define _l4d_anim_included
#include <sdktools>
#include <sdkhooks>
#tryinclude <left4dhooks_silver>
#tryinclude <left4dhooks_stocks>
#tryinclude <left4dhooks_lux_library>
// ====================================================================================================
// ACT_* ANIMATION VALUES
// ====================================================================================================

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,883 @@
/*
* Left 4 DHooks Direct - Stock Functions
* Copyright (C) 2021 Silvers
*
* 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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#if defined _l4d_silver_included
#endinput
#endif
#define _l4d_silver_included
#include <sdktools>
#include <sdkhooks>
#tryinclude <left4dhooks_anim>
#tryinclude <left4dhooks_stocks>
#tryinclude <left4dhooks_lux_library>
// ====================================================================================================
// ENUMS
// ====================================================================================================
enum
{
L4D_TEAM_UNASSIGNED = 0,
L4D_TEAM_SPECTATOR = 1,
L4D_TEAM_SURVIVOR = 2,
L4D_TEAM_INFECTED = 3,
L4D_TEAM_FOUR = 4
}
enum
{
L4D_WEAPON_SLOT_PRIMARY = 0,
L4D_WEAPON_SLOT_SECONDARY = 1,
L4D_WEAPON_SLOT_GRENADE = 2,
L4D_WEAPON_SLOT_MEDKIT = 3, // L4D2: Also upgrade ammo packs and defibrillator
L4D_WEAPON_SLOT_PILLS = 4, // L4D2: Also Adrenaline
L4D_WEAPON_SLOT_CARRIED = 5 // Physics props such as GasCan etc.
}
enum
{
L4D1_ZOMBIE_CLASS_SMOKER = 1,
L4D1_ZOMBIE_CLASS_BOOMER = 2,
L4D1_ZOMBIE_CLASS_HUNTER = 3,
L4D1_ZOMBIE_CLASS_WITCH = 4,
L4D1_ZOMBIE_CLASS_TANK = 5
}
enum
{
L4D2_ZOMBIE_CLASS_SMOKER = 1,
L4D2_ZOMBIE_CLASS_BOOMER = 2,
L4D2_ZOMBIE_CLASS_HUNTER = 3,
L4D2_ZOMBIE_CLASS_SPITTER = 4,
L4D2_ZOMBIE_CLASS_JOCKEY = 5,
L4D2_ZOMBIE_CLASS_CHARGER = 6,
L4D2_ZOMBIE_CLASS_WITCH = 7,
L4D2_ZOMBIE_CLASS_TANK = 8
}
enum
{
SERVER_OS_WINDOWS = 0,
SERVER_OS_LINUX = 1,
}
// Thanks to "Dragokas":
enum // m_eDoorState
{
DOOR_STATE_CLOSED,
DOOR_STATE_OPENING_IN_PROGRESS,
DOOR_STATE_OPENED,
DOOR_STATE_CLOSING_IN_PROGRESS
}
// Thanks to "Dragokas":
enum // m_spawnflags
{
DOOR_FLAG_STARTS_OPEN = 1,
DOOR_FLAG_STARTS_LOCKED = 2048,
DOOR_FLAG_SILENT = 4096,
DOOR_FLAG_USE_CLOSES = 8192,
DOOR_FLAG_SILENT_NPC = 16384,
DOOR_FLAG_IGNORE_USE = 32768,
DOOR_FLAG_UNBREAKABLE = 524288
}
// ====================================================================================================
// STOCKS
// ====================================================================================================
// ENGINE STOCKS
// ==================================================
static EngineVersion g_iEngine;
/**
* @brief Returns if the server is running on the Left 4 Dead series engine
*
* @return True if the server is running on the Left 4 Dead series
*/
stock bool L4D_IsEngineLeft4Dead()
{
if( g_iEngine == Engine_Unknown )
{
g_iEngine = GetEngineVersion();
}
return (g_iEngine == Engine_Left4Dead || g_iEngine == Engine_Left4Dead2);
}
/**
* @brief Returns if the server is running on Left 4 Dead 1
*
* @return True if server is running on Left 4 Dead 1
*/
stock bool L4D_IsEngineLeft4Dead1()
{
if( g_iEngine == Engine_Unknown )
{
g_iEngine = GetEngineVersion();
}
return g_iEngine == Engine_Left4Dead;
}
/**
* @brief Returns if the server is running on Left 4 Dead 2
*
* @return True if server is running on Left 4 Dead 2
*/
stock bool L4D_IsEngineLeft4Dead2()
{
if( g_iEngine == Engine_Unknown )
{
g_iEngine = GetEngineVersion();
}
return g_iEngine == Engine_Left4Dead2;
}
// ==================================================
// DOOR STOCKS
// ==================================================
/**
* @brief Returns the specified door state. Uses the "DOOR_STATE_*" enum
*
* @param entity The "prop_door*" entity to check
*
* @return the "DOOR_STATE_*" value
*/
stock int L4D_GetDoorState(int entity)
{
return GetEntProp(entity, Prop_Data, "m_eDoorState");
}
/**
* @brief Returns the specified door flags. Uses the "DOOR_FLAG_*" enum
*
* @param entity The "prop_door*" entity to check
*
* @return the "DOOR_FLAG_*" value
*/
stock int L4D_GetDoorFlag(int entity)
{
return GetEntProp(entity, Prop_Data, "m_spawnflags");
}
// ==================================================
// ENTITY STOCKS
// ==================================================
/**
* @brief Returns a players current weapon, or -1 if none.
*
* @param client Client ID of the player to check
*
* @return weapon entity index or -1 if none
*/
stock int L4D_GetPlayerCurrentWeapon(int client)
{
return GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
}
/**
* @brief Returns the Custom Ability entity of a Special Infected
* @remarks Returns the entity of "ability_vomit" (Boomer), "ability_lunge" (Hunter), "ability_tongue" (Smoker), "ability_charge" (Charger), "ability_ride" (Jockey), "ability_spit" (Spitter), "ability_throw" (Tank)
*
* @param client Client ID of the player to check
*
* @return entity index or -1 if none
*/
stock int L4D_GetPlayerCustomAbility(int client)
{
return GetEntPropEnt(client, Prop_Send, "m_customAbility");
}
/**
* @brief Returns the players Use Action Target
*
* @param client Client ID of the player to check
*
* @return entity index or -1 if none
*/
stock int L4D_GetPlayerUseTarget(int client)
{
return GetEntPropEnt(client, Prop_Send, "m_useActionTarget");
}
/**
* @brief Returns the parent of an entity
*
* @param client Entity index to check
*
* @return entity index or -1 if none
*/
stock int L4D_EntityParent(int entity)
{
return GetEntPropEnt(entity, Prop_Data, "m_pParent");
}
// ==================================================
// COMMON INFECTED STOCKS
// ==================================================
/**
* @brief Creates a panic event mob horde
* @remarks Subject to horde cooldown timer
* @remarks Can probably reset the timer with either "L4D_ResetMobTimer();" native or using "L4D2CT_MobSpawnTimer" with the timer natives.
*
* @noreturn
*/
stock void L4D_ForcePanicEvent()
{
ServerCommand("director_force_panic_event");
}
/**
* @brief Returns the current number of common infected
*
* @return entity index or -1 if none
*/
stock int L4D_GetCommonsCount()
{
int entity = -1;
int count;
while( (entity = FindEntityByClassname(entity, "infected")) != INVALID_ENT_REFERENCE )
{
count++;
}
return count;
}
/**
* @brief Spawns a Common Infected at the given position
*
* @param vPos Origin vector to spawn at
* @param vAng Angles vector to spawn at (optional)
*
* @return entity index or -1 on failure
*/
stock int L4D_SpawnCommonInfected(float vPos[3], float vAng[3] = { 0.0, 0.0, 0.0 })
{
int entity = CreateEntityByName("infected");
if( entity != -1 )
{
DispatchSpawn(entity);
TeleportEntity(entity, vPos, vAng, NULL_VECTOR);
}
return entity;
}
// ==================================================
// INFECTED: GET VICTIM
// ==================================================
/**
* @brief Returns the Survivor victim when pinned by a Hunter
*
* @param client Client ID of the Special Infected player to check
*
* @return Victim client index, or 0 if none
*/
stock int L4D_GetVictimHunter(int client)
{
int attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pounceVictim")) > 0 )
return attacker;
return 0;
}
/**
* @brief Returns the Survivor victim when pinned by a Smoker
*
* @param client Client ID of the Special Infected player to check
*
* @return Victim client index, or 0 if none
*/
stock int L4D_GetVictimSmoker(int client)
{
int attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_tongueVictim")) > 0 )
return attacker;
return 0;
}
/**
* @brief Returns the Survivor victim when pinned by a Charger
*
* @param client Client ID of the Special Infected player to check
*
* @return Victim client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetVictimCharger(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pummelVictim")) > 0 )
return attacker;
}
return 0;
}
/**
* @brief Returns the Survivor victim when carried by a Charger
*
* @param client Client ID of the Special Infected player to check
*
* @return Victim client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetVictimCarry(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_carryVictim")) > 0 )
return attacker;
}
return 0;
}
/**
* @brief Returns the Survivor victim when pinned by a Jockey
*
* @param client Client ID of the Special Infected player to check
*
* @return Victim client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetVictimJockey(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyVictim")) > 0 )
return attacker;
}
return 0;
}
// ==================================================
// SURVIVOR: GET ATTACKER
// ==================================================
/**
* @brief Returns a Survivors attacker when pinned by a Hunter
*
* @param client Client ID of the Survivor player to check
*
* @return Attacker client index, or 0 if none
*/
stock int L4D_GetAttackerHunter(int client)
{
int attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker")) > 0 )
return attacker;
return 0;
}
/**
* @brief Returns a Survivors attacker when pinned by a Smoker
*
* @param client Client ID of the Survivor player to check
*
* @return Attacker client index, or 0 if none
*/
stock int L4D_GetAttackerSmoker(int client)
{
int attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner")) > 0 )
return attacker;
return 0;
}
/**
* @brief Returns a Survivors attacker when pummelled by a Charger
*
* @param client Client ID of the Survivor player to check
*
* @return Attacker client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetAttackerCharger(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker")) > 0 )
return attacker;
}
return 0;
}
/**
* @brief Returns a Survivors attacker when carried by a Charger
*
* @param client Client ID of the Survivor player to check
*
* @return Attacker client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetAttackerCarry(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_carryAttacker")) > 0 )
return attacker;
}
return 0;
}
/**
* @brief Returns a Survivors attacker when pinned by a Jockey
*
* @param client Client ID of the Survivor player to check
*
* @return Attacker client index, or 0 if none
*/
// L4D2 only.
stock int L4D_GetAttackerJockey(int client)
{
int attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker")) > 0 )
return attacker;
}
return 0;
}
// ==================================================
// PINNED CHECKS
// ==================================================
/**
* @brief Returns the attacker when a Survivor is pinned by a Special Infected
*
* @param client Client ID of the player to check
*
* @return Attacker client index, or 0 if none
*/
stock int L4D_GetPinnedInfected(int client)
{
int attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker")) > 0 )
return attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner")) > 0 )
return attacker;
if( L4D_IsEngineLeft4Dead2() )
{
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker")) > 0 )
return attacker;
if( (attacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker")) > 0 )
return attacker;
}
return 0;
}
/**
* @brief Returns if a Survivor is pinned by a Special Infected
*
* @param client Client ID of the player to check
*
* @return True if pinned, false otherwise
*/
stock bool L4D_IsPlayerPinned(int client)
{
return L4D_GetPinnedInfected(client) != 0;
}
// ==================================================
// LEDGE HANG STOCKS
// ==================================================
/**
* @brief Returns if a Survivor is hanging from a ledge
*
* @param client Client ID of the player to check
*
* @return True if hanging, false otherwise
*/
stock bool L4D_IsPlayerHangingFromLedge(int client)
{
return GetEntProp(client, Prop_Send, "m_isHangingFromLedge", 1) == 1;
}
/**
* @brief Returns if a Survivor can ledge hang
*
* @param client Client ID of the player to check
*
* @return True if can hang, false otherwise
*/
stock bool L4D_CanPlayerLedgeHang(int client)
{
// Get address
static int addy = -1;
if( addy == -1 )
{
/*
See the function "CTerrorPlayer::InputDisableLedgeHang"
On Windows: this[16417] = 0;
m_bWasPresentAtSurvivalStart offset == 16388
16388 + 29 = 16417
Offset unlikely to change unless netprops are added/removed/changed - which is very unlikely
*/
addy = FindSendPropInfo("CTerrorPlayer", "m_bWasPresentAtSurvivalStart") + 29;
}
return GetEntData(client, addy, 1) == 1;
}
/**
* @brief Allow a Survivor to ledge hang
*
* @param client Client ID of the player to affect
*
* @noreturn
*/
stock void L4D_LedgeHangEnable(int client)
{
AcceptEntityInput(client, "EnableLedgeHang");
}
/**
* @brief Disallow a Survivor to ledge hang
*
* @param client Client ID of the player to affect
*
* @noreturn
*/
stock void L4D_LedgeHangDisable(int client)
{
AcceptEntityInput(client, "DisableLedgeHang");
}
// ==================================================
// INCAP and REVIVE STOCKS
// ==================================================
/**
* @brief Set a Survivors incapacitated netprop
* @remarks When setting to false can make a Survivor have 300 health (the incapped health value)
*
* @param client Client ID of the player to affect
* @param incap True to incap, false to remove incap (not the proper way of reviving from incap, probably bypasses revive event)
*
* @noreturn
*/
stock void L4D_SetPlayerIncapped(int client, bool incap)
{
SetEntProp(client, Prop_Send, "m_isIncapacitated", incap ? 1 : 0);
}
/**
* @brief Incap a Survivor by giving them 100.0 damage
*
* @param client Client ID of the player to affect
* @param attacker Optionally set the attacker to credit them for the incap
*
* @noreturn
*/
stock void L4D_SetPlayerIncappedDamage(int client, int attacker = 0)
{
SDKHooks_TakeDamage(client, attacker, attacker, 100.0);
}
/**
* @brief Returns a Survivors revive target
*
* @param client Client ID of the player to check
*
* @return Target client index, or 0 if none
*/
stock int L4D_GetPlayerReviveTarget(int client)
{
int target = GetEntPropEnt(client, Prop_Send, "m_reviveTarget");
if( target > 0 )
return target;
return 0;
}
/**
* @brief Returns an incapacitated Survivor's reviver
*
* @param client Client ID of the player to check
*
* @return Reviver client index, or 0 if none
*/
stock int L4D_GetPlayerReviveOwner(int client)
{
int target = GetEntPropEnt(client, Prop_Send, "m_reviveOwner");
if( target > 0 )
return target;
return 0;
}
/**
* @brief Stops a Survivor reviving someone
* @remarks Prevents accidental freezing of player who tried to revive you
* @remarks Thanks to "Dragokas" for the stock
*
* @param client Client ID of the player to affect
*
* @noreturn
*/
stock void L4D_StopReviveAction(int client)
{
int owner_save = -1;
int target_save = -1;
int owner = GetEntPropEnt(client, Prop_Send, "m_reviveOwner"); // when you reviving somebody, this is -1. When somebody revive you, this is somebody's id
int target = GetEntPropEnt(client, Prop_Send, "m_reviveTarget"); // when you reviving somebody, this is somebody's id. When somebody revive you, this is -1
SetEntPropEnt(client, Prop_Send, "m_reviveOwner", -1);
SetEntPropEnt(client, Prop_Send, "m_reviveTarget", -1);
if( owner != -1 ) // we must reset flag for both - for you, and who you revive
{
SetEntPropEnt(owner, Prop_Send, "m_reviveOwner", -1);
SetEntPropEnt(owner, Prop_Send, "m_reviveTarget", -1);
owner_save = owner;
}
if( target != -1 )
{
SetEntPropEnt(target, Prop_Send, "m_reviveOwner", -1);
SetEntPropEnt(target, Prop_Send, "m_reviveTarget", -1);
target_save = target;
}
if( L4D_IsEngineLeft4Dead2() )
{
owner = GetEntPropEnt(client, Prop_Send, "m_useActionOwner"); // used when healing e.t.c.
target = GetEntPropEnt(client, Prop_Send, "m_useActionTarget");
SetEntPropEnt(client, Prop_Send, "m_useActionOwner", -1);
SetEntPropEnt(client, Prop_Send, "m_useActionTarget", -1);
if( owner != -1 )
{
SetEntPropEnt(owner, Prop_Send, "m_useActionOwner", -1);
SetEntPropEnt(owner, Prop_Send, "m_useActionTarget", -1);
owner_save = owner;
}
if( target != -1 )
{
SetEntPropEnt(target, Prop_Send, "m_useActionOwner", -1);
SetEntPropEnt(target, Prop_Send, "m_useActionTarget", -1);
target_save = target;
}
SetEntProp(client, Prop_Send, "m_iCurrentUseAction", 0);
SetEntPropFloat(client, Prop_Send, "m_flProgressBarDuration", 0.0);
if( owner_save != -1 )
{
SetEntProp(owner_save, Prop_Send, "m_iCurrentUseAction", 0);
SetEntPropFloat(owner_save, Prop_Send, "m_flProgressBarDuration", 0.0);
}
if( target_save != -1 )
{
SetEntProp(target_save, Prop_Send, "m_iCurrentUseAction", 0);
SetEntPropFloat(target_save, Prop_Send, "m_flProgressBarDuration", 0.0);
}
}
else
{
owner = GetEntPropEnt(client, Prop_Send, "m_healOwner"); // used when healing
target = GetEntPropEnt(client, Prop_Send, "m_healTarget");
SetEntPropEnt(client, Prop_Send, "m_healOwner", -1);
SetEntPropEnt(client, Prop_Send, "m_healTarget", -1);
if( owner != -1 )
{
SetEntPropEnt(owner, Prop_Send, "m_healOwner", -1);
SetEntPropEnt(owner, Prop_Send, "m_healTarget", -1);
owner_save = owner;
}
if( target != -1 )
{
SetEntPropEnt(target, Prop_Send, "m_healOwner", -1);
SetEntPropEnt(target, Prop_Send, "m_healTarget", -1);
target_save = target;
}
SetEntProp(client, Prop_Send, "m_iProgressBarDuration", 0);
if( owner_save != -1 )
{
SetEntProp(owner_save, Prop_Send, "m_iProgressBarDuration", 0);
}
if( target_save != -1 )
{
SetEntProp(target_save, Prop_Send, "m_iProgressBarDuration", 0);
}
}
}
/**
* @brief Returns if a Survivor is incapacitated
*
* @param client Client ID of the player to check
*
* @return True if incapacitated, false otherwise
*/
#pragma deprecated Use L4D_IsPlayerIncapacitated instead
stock bool L4D_IsPlayerIncapped(int client)
{
return GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) != 0;
}
// ==================================================
// GET CLIENT STOCKS
// ==================================================
/**
* @brief Returns a random client in-game
*
* @return Client index or 0 if none
*/
stock int GetAnyRandomClient()
{
int client;
ArrayList aClients = new ArrayList();
for( int i = 1; i <= MaxClients; i++ )
{
if( IsClientInGame(i) )
{
aClients.Push(i);
}
}
if( aClients.Length > 0 )
client = aClients.Get(GetRandomInt(0, aClients.Length - 1));
delete aClients;
return client;
}
/**
* @brief Returns a random Survivor
*
* @param alive -1 = Any. 0 = Only dead players. 1 = Only alive players
* @param bots -1 = Any. 0 - Only real players. 1 = Only fake players
*
* @return Client index or 0 if none
*/
stock int GetRandomSurvivor(int alive = -1, int bots = -1)
{
return Local_GetRandomClient(2, alive, bots);
}
/**
* @brief Returns a random Special Infected
*
* @param alive -1 = Any. 0 = Only dead players. 1 = Only alive players
* @param bots -1 = Any. 0 - Only real players. 1 = Only fake players
*
* @return Client index or 0 if none
*/
stock int GetRandomInfected(int alive = -1, int bots = -1)
{
return Local_GetRandomClient(3, alive, bots);
}
stock int Local_GetRandomClient(int team, int alive = -1, int bots = -1)
{
ArrayList aClients = new ArrayList();
for( int i = 1; i <= MaxClients; i++ )
{
if( IsClientInGame(i) && GetClientTeam(i) == team && (alive == -1 || IsPlayerAlive(i) == view_as<bool>(alive)) && (bots == -1 || IsFakeClient(i) == view_as<bool>(alive)) )
{
aClients.Push(i);
}
}
int client;
if( aClients.Length > 0 )
client = aClients.Get(GetRandomInt(0, aClients.Length - 1));
delete aClients;
return client;
}

File diff suppressed because it is too large Load diff