Skip to content

Commit d44cb66

Browse files
committed
1 parent b4d009d commit d44cb66

8 files changed

Lines changed: 102 additions & 6 deletions

File tree

addons/sourcemod/gamedata/left4dhooks.l4d2.txt

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2029,6 +2029,18 @@
20292029
}
20302030
}
20312031

2032+
"CTerrorPlayer::RoundRespawn::Address"
2033+
{
2034+
"windows"
2035+
{
2036+
"signature" "CTerrorPlayer::RoundRespawn"
2037+
}
2038+
"linux"
2039+
{
2040+
"signature" "CTerrorPlayer::RoundRespawn"
2041+
}
2042+
}
2043+
20322044
// Used for dynamic searching of memory address for SDKCall
20332045
"Molotov_StrFind"
20342046
{
@@ -2264,6 +2276,22 @@
22642276
"linux" "5"
22652277
}
22662278

2279+
"CTerrorPlayer::RoundRespawn::Offset"
2280+
{
2281+
"windows" "8"
2282+
"linux" "18"
2283+
}
2284+
"CTerrorPlayer::RoundRespawn::Bytes"
2285+
{
2286+
"windows" "232" // 0xE8
2287+
"linux" "232" // 0xE8
2288+
}
2289+
"CTerrorPlayer::RoundRespawn::Count"
2290+
{
2291+
"windows" "16"
2292+
"linux" "17"
2293+
}
2294+
22672295
"MobSpawnTimer"
22682296
{
22692297
"windows" "660"
@@ -5901,7 +5929,7 @@
59015929
"library" "server"
59025930
"linux" "@_ZN13CTerrorPlayer12RoundRespawnEv"
59035931
"windows" "\x56\x8B\xF1\xE8\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x84\xC0\x75"
5904-
/* 56 8B F1 E8 ? ? ? ? E8 ? ? ? ? 84 C0 75 */
5932+
/* 56 8B F1 E8 ? ? ? ? E8 ? ? ? ? 84 C0 75 */
59055933
}
59065934

59075935
/*
410 Bytes
Binary file not shown.

addons/sourcemod/scripting/include/left4dhooks.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5137,7 +5137,7 @@ native void L4D2_UseAdrenaline(int client, float fTime = 15.0, bool heal = true,
51375137
*
51385138
* @noreturn
51395139
*/
5140-
native void L4D_RespawnPlayer(int client);
5140+
native void L4D_RespawnPlayer(int client, bool resetStats = true);
51415141

51425142
/**
51435143
* @brief To takeover a Survivor bot. First use "ChangeClientTeam" and change them to 0. Then call "L4D_SetHumanSpec" then call "L4D_TakeOverBot"

addons/sourcemod/scripting/l4dd/l4dd_gamedata.sp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2458,12 +2458,30 @@ void LoadGameData()
24582458
}
24592459
else if( byte != 0x90 )
24602460
{
2461-
LogError("CTerrorPlayer::CanBecomeGhost patch: byte mismatch. %X", LoadFromAddress(g_pCTerrorPlayer_CanBecomeGhost + view_as<Address>(g_iCanBecomeGhostOffset), NumberType_Int8));
2461+
LogError("CTerrorPlayer::CanBecomeGhost patch: byte mismatch. %X (%s)", LoadFromAddress(g_pCTerrorPlayer_CanBecomeGhost + view_as<Address>(g_iCanBecomeGhostOffset), NumberType_Int8), g_sSystem);
24622462
}
24632463
// ====================
24642464

24652465

24662466

2467+
// ====================
2468+
// Patch to allow "L4D_RespawnPlayer" to not reset stats
2469+
// ====================
2470+
// Address to function
2471+
g_pCTerrorPlayer_RoundRespawn = hGameData.GetAddress("CTerrorPlayer::RoundRespawn::Address");
2472+
ValidateAddress(g_pCTerrorPlayer_RoundRespawn, "CTerrorPlayer::RoundRespawn::Address", true);
2473+
2474+
// Offset to patch
2475+
g_iOff_RespawnPlayer = hGameData.GetOffset("CTerrorPlayer::RoundRespawn::Offset");
2476+
ValidateOffset(g_iOff_RespawnPlayer, "CTerrorPlayer::RoundRespawn::Offset");
2477+
2478+
// Patch count and byte match
2479+
g_iByte_RespawnPlayer = hGameData.GetOffset("CTerrorPlayer::RoundRespawn::Bytes");
2480+
g_iSize_RespawnPlayer = hGameData.GetOffset("CTerrorPlayer::RoundRespawn::Count");
2481+
// ====================
2482+
2483+
2484+
24672485
if( g_bLeft4Dead2 )
24682486
{
24692487
g_iOff_AddonEclipse1 = hGameData.GetOffset("AddonEclipse1");

addons/sourcemod/scripting/l4dd/l4dd_natives.sp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5288,10 +5288,40 @@ int Native_CTerrorPlayer_RespawnPlayer(Handle plugin, int numParams) // Native "
52885288
ValidateNatives(g_hSDK_CTerrorPlayer_RoundRespawn, "CTerrorPlayer::RoundRespawn");
52895289

52905290
int client = GetNativeCell(1);
5291+
bool reset = true;
5292+
if( numParams == 2 )
5293+
reset = GetNativeCell(2);
5294+
5295+
ArrayList aList = new ArrayList();
5296+
if( !reset )
5297+
{
5298+
int byte = LoadFromAddress(g_pCTerrorPlayer_RoundRespawn + view_as<Address>(g_iOff_RespawnPlayer), NumberType_Int8);
5299+
if( byte != g_iByte_RespawnPlayer )
5300+
{
5301+
reset = true;
5302+
LogError("CTerrorPlayer::RoundRespawn patch: byte mismatch. %X (%s).", byte, g_sSystem);
5303+
}
5304+
5305+
for( int i = 0; i < g_iSize_RespawnPlayer; i++ )
5306+
{
5307+
aList.Push(LoadFromAddress(g_pCTerrorPlayer_RoundRespawn + view_as<Address>(g_iOff_RespawnPlayer + i), NumberType_Int8));
5308+
StoreToAddress(g_pCTerrorPlayer_RoundRespawn + view_as<Address>(g_iOff_RespawnPlayer + i), 0x90, NumberType_Int8);
5309+
}
5310+
}
52915311

52925312
//PrintToServer("#### CALL g_hSDK_CTerrorPlayer_RoundRespawn");
52935313
SDKCall(g_hSDK_CTerrorPlayer_RoundRespawn, client);
52945314

5315+
if( !reset )
5316+
{
5317+
for( int i = 0; i < g_iSize_RespawnPlayer; i++ )
5318+
{
5319+
StoreToAddress(g_pCTerrorPlayer_RoundRespawn + view_as<Address>(g_iOff_RespawnPlayer + i), aList.Get(i), NumberType_Int8);
5320+
}
5321+
}
5322+
5323+
delete aList;
5324+
52955325
return 0;
52965326
}
52975327

addons/sourcemod/scripting/l4dd/left4dhooks_changelog.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
1.160 (15-Jul-2025)
2+
- Changed native "L4D_RespawnPlayer" to specify resetting player stats or not. Requested by "ball2hi".
3+
4+
- Updated: Plugin and test plugin.
5+
- Updated: "/gamedata/left4dhooks.l4d1.txt" GameData file.
6+
- Updated: "/gamedata/left4dhooks.l4d2.txt" GameData file.
7+
- Updated: "/scripting/l4dd/l4dd_gamedata.sp" project file.
8+
- Updated: "/scripting/l4dd/l4dd_natives.sp" project file.
9+
- Updated: "/scripting/include/left4dhooks.inc" include file.
10+
111
1.159 (01-Jul-2025)
212
- Fixed forward "L4D_OnDeathDroppedWeapons" from throwing client not in game errors. Thanks to "Mystik Spiral" for reporting.
313
- Fixed forwards "L4D2_VomitJarProjectile_*" not working due to incorrect initialization. Thanks to "Drgon" and "ProjectSky" for reporting.

addons/sourcemod/scripting/left4dhooks.sp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818

1919

2020

21-
#define PLUGIN_VERSION "1.159"
22-
#define PLUGIN_VERLONG 1159
21+
#define PLUGIN_VERSION "1.160"
22+
#define PLUGIN_VERLONG 1160
2323

2424
#define DEBUG 0
2525
// #define DEBUG 1 // Prints addresses + detour info (only use for debugging, slows server down).
@@ -304,6 +304,11 @@ int g_iOff_m_bInIntro;
304304
int g_iOff_m_attributeFlags;
305305
int g_iOff_m_spawnAttributes;
306306
int g_iOff_NavAreaID;
307+
308+
Address g_pCTerrorPlayer_RoundRespawn;
309+
int g_iOff_RespawnPlayer;
310+
int g_iSize_RespawnPlayer;
311+
int g_iByte_RespawnPlayer;
307312
// int g_iOff_m_iClrRender; // NULL PTR - METHOD (kept for demonstration)
308313
// int ClearTeamScore_A;
309314
// int ClearTeamScore_B;

addons/sourcemod/scripting/left4dhooks_test.sp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919

2020

21-
#define PLUGIN_VERSION "1.159"
21+
#define PLUGIN_VERSION "1.160"
2222

2323
/*=======================================================================================
2424
Plugin Info:
@@ -362,6 +362,11 @@ Action sm_l4dd(int client, int args)
362362

363363

364364

365+
L4D_RespawnPlayer(client, false);
366+
PrintToServer("L4D_RespawnPlayer %N", client);
367+
368+
369+
365370
/*
366371
L4D_SetPlayerIntensity(client, 0.9);
367372
ReplyToCommand(client, "A m_clientIntensity %d", GetEntProp(client, Prop_Send, "m_clientIntensity"));

0 commit comments

Comments
 (0)