Skip to content

Commit b4d009d

Browse files
committed
1 parent f9354b8 commit b4d009d

8 files changed

Lines changed: 74 additions & 24 deletions

File tree

addons/sourcemod/gamedata/left4dhooks.l4d2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3040,7 +3040,7 @@
30403040
"CGrenadeLauncher_Projectile::Explode"
30413041
{
30423042
"library" "server"
3043-
"linux" "@_ZN27CGrenadeLauncher_Projectile12ExplodeTouchEP11CBaseEntity"
3043+
"linux" "@_ZN27CGrenadeLauncher_Projectile7ExplodeEP10CGameTracei"
30443044
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\x2A\x89\x2A\x2A\x8B\x2A\x2A\x53\x56\x8B\x2A\x8B\x2A\x2A\x2A\x2A\x2A\xC1\x2A\x2A\x57"
30453045
/* ? ? ? ? ? ? ? ? ? A1 ? ? ? ? 33 ? 89 ? ? 8B ? ? 53 56 8B ? 8B ? ? ? ? ? C1 ? ? 57 */
30463046
}
42 Bytes
Binary file not shown.

addons/sourcemod/scripting/include/left4dhooks.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,7 @@ forward void L4D_OnSpawnSpecial_PostHandled(int client, int zombieClass, const f
13601360
/**
13611361
* @brief Called whenever ZombieManager::SpawnTank(Vector&,QAngle&) is invoked
13621362
* @remarks Not invoked if z_spawn tank is used and it gives a ghosted/dead player tank
1363+
* @remarks This sometimes triggers every frame or so, in L4D2 "c7m3_port" map on Windows, after leaving the saferoom in Versus
13631364
*
13641365
* @param vecPos Vector coordinate where tank is spawned
13651366
* @param vecAng QAngle where tank will be facing
@@ -1372,6 +1373,7 @@ forward Action L4D_OnSpawnTank(const float vecPos[3], const float vecAng[3]);
13721373
* @brief Called whenever ZombieManager::SpawnTank(Vector&,QAngle&) is invoked
13731374
* @remarks Not invoked if z_spawn tank is used and it gives a ghosted/dead player tank
13741375
* @remarks This forward will not trigger if the relative pre-hook forward has been blocked with Plugin_Handled
1376+
* @remarks This sometimes triggers every frame or so, in L4D2 "c7m3_port" map on Windows, after leaving the saferoom in Versus, client index will be -1
13751377
*
13761378
* @param client The client index who spawned
13771379
* @param vecPos Vector coordinate where tank is spawned
@@ -2288,7 +2290,7 @@ forward void L4D_TankRock_BounceTouch_PostHandled(int tank, int rock, int entity
22882290
* @param tank_index Client index of the tank
22892291
* @param enterStasis Is the tank in stasis
22902292
*
2291-
* @return Plugin_Handled to block window from showing and to keep Tank Bot, Plugin_Changed to use overwritten values from plugin, Plugin_Continue otherwise
2293+
* @return Plugin_Handled to block window from showing and to keep Tank Bot, Plugin_Changed to use overwritten values from plugin, Plugin_Continue otherwise
22922294
*/
22932295
forward Action L4D_OnTryOfferingTankBot(int tank_index, bool &enterStasis);
22942296

addons/sourcemod/scripting/l4dd/l4dd_forwards.sp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -447,9 +447,9 @@ void SetupDetours(GameData hGameData = null)
447447

448448
if( g_bLeft4Dead2 )
449449
{
450-
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D_MolotovProjectile_Pre");
451-
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D_MolotovProjectile_Post", true);
452-
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D_MolotovProjectile_PostHandled", true);
450+
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D2_VomitJarProjectile_Pre");
451+
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D2_VomitJarProjectile_Post", true);
452+
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CVomitJarProjectile_Create_Pre, DTR_CVomitJarProjectile_Create_Post, "L4DD::CVomitJarProjectile::Create", "L4D2_VomitJarProjectile_PostHandled", true);
453453

454454
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CGrenadeLauncherProjectile_Create_Pre, DTR_CGrenadeLauncherProjectile_Create_Post, "L4DD::CGrenadeLauncher_Projectile::Create", "L4D2_GrenadeLauncherProjectile_Pre");
455455
CreateDetour(g_bLinuxOS ? hGameData : g_hTempGameData, DTR_CGrenadeLauncherProjectile_Create_Pre, DTR_CGrenadeLauncherProjectile_Create_Post, "L4DD::CGrenadeLauncher_Projectile::Create", "L4D2_GrenadeLauncherProjectile_Post", true);
@@ -1247,8 +1247,6 @@ MRESReturn Spawn_TankWitch_Post(Handle hForward, Handle hForward2, DHookReturn h
12471247
Call_PushArray(a2, sizeof(a2));
12481248
Call_Finish();
12491249

1250-
// g_bBlock_Spawn_TankWitch = false;
1251-
12521250
return MRES_Ignored;
12531251
}
12541252

@@ -3518,7 +3516,8 @@ MRESReturn DTR_CTerrorPlayer_OnIncapacitatedAsSurvivor_Post(int pThis, DHookRetu
35183516
MRESReturn DTR_CTerrorPlayer_DropWeapons(int pThis, DHookReturn hReturn) // Forward "L4D_OnDeathDroppedWeapons"
35193517
{
35203518
//PrintToServer("##### DTR_CTerrorPlayer_DropWeapons");
3521-
3519+
if( pThis < 1 || pThis > MaxClients ) return MRES_Ignored;
3520+
if( !IsClientInGame(pThis) ) return MRES_Ignored;
35223521
if( !IsPlayerAlive(pThis) ) return MRES_Ignored; // Triggered before round_start or so but players are dead at this point, should only trigger when still alive
35233522

35243523
// Get held object if non-weapon
@@ -4816,11 +4815,11 @@ MRESReturn DTR_InfoChangelevel_SaveEntities_Post_L4D2(int pThis) // Forward "L4D
48164815
return MRES_Ignored;
48174816
}
48184817

4819-
bool g_hBlock_CTerrorPlayer_TransitionRestore;
4818+
bool g_bBlock_CTerrorPlayer_TransitionRestore;
48204819
MRESReturn DTR_CTerrorPlayer_TransitionRestore(int pThis, DHookReturn hReturn)
48214820
{
48224821
//PrintToServer("##### DTR_CTerrorPlayer_TransitionRestore");
4823-
g_hBlock_CTerrorPlayer_TransitionRestore = false;
4822+
g_bBlock_CTerrorPlayer_TransitionRestore = false;
48244823

48254824
Action aResult = Plugin_Continue;
48264825
Call_StartForward(g_hFWD_CTerrorPlayer_TransitionRestore);
@@ -4829,7 +4828,7 @@ MRESReturn DTR_CTerrorPlayer_TransitionRestore(int pThis, DHookReturn hReturn)
48294828

48304829
if( aResult == Plugin_Handled )
48314830
{
4832-
g_hBlock_CTerrorPlayer_TransitionRestore = true;
4831+
g_bBlock_CTerrorPlayer_TransitionRestore = true;
48334832

48344833
hReturn.Value = 0;
48354834
return MRES_Supercede;
@@ -4843,7 +4842,7 @@ MRESReturn DTR_CTerrorPlayer_TransitionRestore_Post(int pThis, DHookReturn hRetu
48434842
//PrintToServer("##### DTR_CTerrorPlayer_TransitionRestore_Post");
48444843
Address iReturn = hReturn.Value;
48454844

4846-
Call_StartForward(g_hBlock_CTerrorPlayer_TransitionRestore ? g_hFWD_CTerrorPlayer_TransitionRestore_PostHandled : g_hFWD_CTerrorPlayer_TransitionRestore_Post);
4845+
Call_StartForward(g_bBlock_CTerrorPlayer_TransitionRestore ? g_hFWD_CTerrorPlayer_TransitionRestore_PostHandled : g_hFWD_CTerrorPlayer_TransitionRestore_Post);
48474846
Call_PushCell(pThis);
48484847
Call_PushCell(iReturn);
48494848
Call_Finish();

addons/sourcemod/scripting/l4dd/l4dd_setup.sp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,17 +215,16 @@ void SetupForwardsNatives()
215215
g_hFWD_InfoChangelevel_SaveEntities = new GlobalForward("L4D1_OnSavingEntities", ET_Event, Param_Cell, Param_Cell);
216216
g_hFWD_InfoChangelevel_SaveEntities_Post = new GlobalForward("L4D1_OnSavingEntities_Post", ET_Event, Param_Cell, Param_Cell);
217217
g_hFWD_InfoChangelevel_SaveEntities_PostHandled = new GlobalForward("L4D1_OnSavingEntities_PostHandled", ET_Event, Param_Cell, Param_Cell);
218+
}
218219

220+
if( g_bLeft4Dead2 )
221+
{
219222
g_hFWD_CTerrorPlayer_TransitionRestore = new GlobalForward("L4D2_OnTransitionRestore", ET_Event, Param_Cell);
220223
g_hFWD_CTerrorPlayer_TransitionRestore_Post = new GlobalForward("L4D2_OnTransitionRestore_Post", ET_Event, Param_Cell, Param_Cell);
221224
g_hFWD_CTerrorPlayer_TransitionRestore_PostHandled = new GlobalForward("L4D2_OnTransitionRestore_PostHandled", ET_Event, Param_Cell, Param_Cell);
222225
g_hFWD_RestoreTransitionedSurvivorBots = new GlobalForward("L4D2_OnRestoreTransitionedSurvivorBots", ET_Event);
223226
g_hFWD_RestoreTransitionedSurvivorBots_Post = new GlobalForward("L4D2_OnRestoreTransitionedSurvivorBots_Post", ET_Event);
224227
g_hFWD_RestoreTransitionedSurvivorBots_PostHandled = new GlobalForward("L4D2_OnRestoreTransitionedSurvivorBots_PostHandled", ET_Event);
225-
}
226-
227-
if( g_bLeft4Dead2 )
228-
{
229228
g_hFWD_CVomitJarProjectile_Create_Pre = new GlobalForward("L4D2_VomitJarProjectile_Pre", ET_Event, Param_Cell, Param_Array, Param_Array, Param_Array, Param_Array);
230229
g_hFWD_CVomitJarProjectile_Create_Post = new GlobalForward("L4D2_VomitJarProjectile_Post", ET_Event, Param_Cell, Param_Cell, Param_Array, Param_Array, Param_Array, Param_Array);
231230
g_hFWD_CVomitJarProjectile_Create_PostHandled = new GlobalForward("L4D2_VomitJarProjectile_PostHandled", ET_Event, Param_Cell, Param_Cell, Param_Array, Param_Array, Param_Array, Param_Array);

addons/sourcemod/scripting/l4dd/left4dhooks_changelog.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
1.158 (21-Mar-2025)
2-
- Added forwards "L4D2_OnTransitionRestore*" and "L4D2_OnRestoreTransitionedSurvivorBots*" to trigger on clients and bots transitioning data restore. Thanks to "blueblur0730" for adding.
3-
- Fixed native "L4D2Direct_SetVSCampaignScore" not updating the scores fully. Thanks to "nikita1824" for reporting.
1+
1.159 (01-Jul-2025)
2+
- Fixed forward "L4D_OnDeathDroppedWeapons" from throwing client not in game errors. Thanks to "Mystik Spiral" for reporting.
3+
- Fixed forwards "L4D2_VomitJarProjectile_*" not working due to incorrect initialization. Thanks to "Drgon" and "ProjectSky" for reporting.
4+
- Fixed gamedata signature for "CGrenadeLauncher_Projectile::Explode" forward on L4D2 Linux. Thanks to "xiaolinRM" for reporting.
5+
- Clarification in the include file on how often the "L4D_OnSpawnTank*" forwards trigger. Thanks to "Marttt" for reporting.
46

57
- Updated: Plugin and test plugin.
68
- Updated: "/gamedata/left4dhooks.l4d2.txt" GameData file.
79
- Updated: "/scripting/l4dd/l4dd_forwards.sp" project file.
8-
- Updated: "/scripting/l4dd/l4dd_natives.sp" project file.
910
- Updated: "/scripting/l4dd/l4dd_setup.sp" project file.
1011
- Updated: "/scripting/include/left4dhooks.inc" include file.
1112

13+
1.158 (21-Mar-2025)
14+
- Added forwards "L4D2_OnTransitionRestore*" and "L4D2_OnRestoreTransitionedSurvivorBots*" to trigger on clients and bots transitioning data restore. Thanks to "blueblur0730" for adding.
15+
- Fixed native "L4D2Direct_SetVSCampaignScore" not updating the scores fully. Thanks to "nikita1824" for reporting.
16+
1217
1.157 (04-Jan-2025)
1318
- Plugin is now compiled with SourceMod version 1.11 again.
1419
- Changed the "L4D_SetPlayerIntensity" stock to a native, fixing the function from not working. Thanks to "Neburai" for providing the method.

addons/sourcemod/scripting/left4dhooks.sp

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

1919

2020

21-
#define PLUGIN_VERSION "1.158"
22-
#define PLUGIN_VERLONG 1158
21+
#define PLUGIN_VERSION "1.159"
22+
#define PLUGIN_VERLONG 1159
2323

2424
#define DEBUG 0
2525
// #define DEBUG 1 // Prints addresses + detour info (only use for debugging, slows server down).
@@ -29,6 +29,8 @@
2929

3030
#define KILL_VSCRIPT 0 // 0=Keep VScript entity after using for "GetVScriptOutput". 1=Kill the entity after use (more resourceful to keep recreating, use if you're maxing out entities and reaching the limit regularly).
3131

32+
#define ALLOW_UPDATER 0 // 0=Off. 1=Allow the plugin to auto-update using the "Updater" plugin by "GoD-Tony". 2=Allow updating and reloading after update.
33+
3234

3335

3436
/*======================================================================================
@@ -111,6 +113,15 @@
111113
#include <dhooks>
112114
#include <left4dhooks>
113115

116+
// ====================================================================================================
117+
// UPDATER
118+
#define UPDATE_URL "https://raw.githubusercontent.com/SilvDev/Left4DHooks/main/sourcemod/updater.txt"
119+
120+
native void Updater_AddPlugin(const char[] url);
121+
// ====================================================================================================
122+
123+
124+
114125
// PROFILER
115126
#if DEBUG
116127
#include <profiler>
@@ -433,6 +444,14 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
433444
g_hThisPlugin = myself;
434445

435446

447+
448+
// =================
449+
// UPDATER
450+
// =================
451+
MarkNativeAsOptional("Updater_AddPlugin");
452+
453+
454+
436455
// =================
437456
// DUPLICATE PLUGIN RUNNING
438457
// =================
@@ -472,6 +491,32 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
472491
return APLRes_Success;
473492
}
474493

494+
495+
496+
// ====================================================================================================
497+
// UPDATER
498+
// ====================================================================================================
499+
#if ALLOW_UPDATER
500+
public void OnLibraryAdded(const char[] name)
501+
{
502+
if( strcmp(name, "updater") == 0 )
503+
{
504+
Updater_AddPlugin(UPDATE_URL);
505+
}
506+
}
507+
#endif
508+
509+
#if ALLOW_UPDATER == 2
510+
public void Updater_OnPluginUpdated()
511+
{
512+
char filename[64];
513+
GetPluginFilename(null, filename, sizeof(filename));
514+
ServerCommand("sm plugins reload %s", filename);
515+
}
516+
#endif
517+
518+
519+
475520
// ====================================================================================================
476521
// SETUP
477522
// ====================================================================================================

addons/sourcemod/scripting/left4dhooks_test.sp

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

1919

2020

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

2323
/*=======================================================================================
2424
Plugin Info:
@@ -5648,7 +5648,7 @@ public Action L4D2_OnTransitionRestore(int client)
56485648
if( called == 0 ) g_iForwards++;
56495649
called++;
56505650

5651-
ForwardCalled("\"L4D2_OnChangeFinaleStage\" client: %d (%N)", client, client);
5651+
ForwardCalled("\"L4D2_OnTransitionRestore\" client: %d (%N)", client, client);
56525652
}
56535653

56545654
// return Plugin_Handled;

0 commit comments

Comments
 (0)