Skip to content

Commit

Permalink
l4d_unrestrict_panic_battlefield
Browse files Browse the repository at this point in the history
增加
  • Loading branch information
fantasylidong committed Feb 27, 2024
1 parent 91ebcda commit 820fa94
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 0 deletions.
93 changes: 93 additions & 0 deletions addons/sourcemod/gamedata/l4d_unrestrict_panic_battlefield.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
"Games"
{
"left4dead2"
{
"MemPatches"
{
"ZombieManager::GetRandomPZSpawnPosition__skip_PanicEventActive"
{
"signature" "ZombieManager::GetRandomPZSpawnPosition"
"linux"
{
"offset" "26Ch"
"verify" "\x0F\x85"
"patch" "\x90\x90\x90\x90\x90\x90"
}
"windows"
{
"offset" "4Bh"
"verify" "\x74"
"patch" "\xEB"
}
}

"ZombieManager::CollectSpawnAreas__skip_PanicEventActive"
{
"signature" "ZombieManager::CollectSpawnAreas"
"linux"
{
"offset" "562h"
"verify" "\x74"
"patch" "\xEB"
}
"windows"
{
"offset" "442h"
"verify" "\x74"
"patch" "\xEB"
}
}

"ZombieManager::AccumulateSpawnAreaCollection__skip_PanicEventActive"
{
"signature" "ZombieManager::AccumulateSpawnAreaCollection"
"linux"
{
"offset" "6D9h"
"verify" "\x0F\x85"
"patch" "\x90\x90\x90\x90\x90\x90"
}
"windows"
{
"offset" "19Bh"
"verify" "\x74"
"patch" "\xEB"
}
}
}

"Signatures"
{
// stolen from left4dhooks thanks to Silvers
/*
* ZombieManager::GetRandomPZSpawnPosition(ZombieManager *_ZombieManager, int zombieClass, int attempts, int a4, int a5)
*/
"ZombieManager::GetRandomPZSpawnPosition"
{
"library" "server"
"linux" "@_ZNK13ZombieManager24GetRandomPZSpawnPositionE15ZombieClassTypeiP13CTerrorPlayerP6Vector"
"windows" "\x55\x8B\x2A\x83\x2A\x2A\x53\x57\x8B\x2A\x2A\x8B\x2A\x89\x2A\x2A\x85\x2A\x75\x2A\x5F\x32"
/* 55 8B ? 83 ? ? 53 57 8B ? ? 8B ? 89 ? ? 85 ? 75 ? 5F 32 */
/* Search "ZombieManager::GetRandomPZSpawnPosition" */
}

// Search string "ZombieManager::CollectSpawnAreas"
"ZombieManager::CollectSpawnAreas"
{
"library" "server"
"linux" "@_ZNK13ZombieManager17CollectSpawnAreasENS_15MobLocationTypeE15ZombieClassType"
"windows" "\x55\x8B\xEC\x83\xEC\x48\xA1\x2A\x2A\x2A\x2A\x53\x56\x57\x33\xFF\x89\x7D\xEC\x89\x7D\xF0\x8B\xF1\x39\x78\x08\x74\x2A\x8B\x40\x08\x68\x2A\x2A\x2A\x2A\x8B\x50\x50\x68\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\x68\x2A\x2A\x2A\x2A\x68\x1A\x07\x00\x00"
/* 55 8B EC 83 EC 48 A1 ? ? ? ? 53 56 57 33 FF 89 7D EC 89 7D F0 8B F1 39 78 08 74 ? 8B 40 08 68 ? ? ? ? 8B 50 50 68 ? ? ? ? 68 ? ? ? ? 68 ? ? ? ? 68 1A 07 00 00 */
}

// Search string "ZombieManager::AccumulateSpawnAreaCollection"
"ZombieManager::AccumulateSpawnAreaCollection"
{
"library" "server"
"linux" "@_ZNK13ZombieManager29AccumulateSpawnAreaCollectionERK10CUtlVectorIP8CNavArea10CUtlMemoryIS2_iEENS_15MobLocationTypeE15ZombieClassTypefPS5_bb"
"windows" "\x55\x8B\xEC\x83\xEC\x48\xA1\x2A\x2A\x2A\x2A\x53\x56\x33\xF6\x89\x75\xDC"
/* 55 8B EC 83 EC 48 A1 ? ? ? ? 53 56 33 F6 89 75 DC */
}
}
}
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sourcescramble>

methodmap GameDataWrapper < GameData {
public GameDataWrapper(const char[] file) {
GameData gd = new GameData(file);
if (!gd) SetFailState("Missing gamedata \"%s\"", file);
return view_as<GameDataWrapper>(gd);
}
public MemoryPatch CreatePatchOrFail(const char[] name, bool enable = false) {
MemoryPatch hPatch = MemoryPatch.CreateFromConf(this, name);
if (!(enable ? hPatch.Enable() : hPatch.Validate()))
SetFailState("Failed to patch \"%s\"", name);
return hPatch;
}
}

enum struct BattleFieldPatch
{
// "SPAWN_SPECIALS_ANYWHERE" is preferred over "SPAWN_SPECIALS_IN_FRONT_OF_SURVIVORS"
MemoryPatch GetRandomPZSpawnPosition;

// Only collects spawn areas with "BATTLEFIELD" flag
// Enabling this lets ZombieManager turn to "SurvivorActiveSet" for collecting spawn areas.
MemoryPatch CollectSpawnAreas;

// Never spawn Common Infected on spawning-disallowed areas
// Enabling this may cause Common Infected spawning much closer.
MemoryPatch AccumulateSpawnAreaCollection;

void Enable()
{
this.GetRandomPZSpawnPosition.Enable();
this.CollectSpawnAreas.Enable();
this.AccumulateSpawnAreaCollection.Enable();
}

void Disable()
{
this.GetRandomPZSpawnPosition.Disable();
this.CollectSpawnAreas.Disable();
this.AccumulateSpawnAreaCollection.Disable();
}
}
BattleFieldPatch g_BattleFieldPatch;

public void OnPluginStart()
{
GameDataWrapper gd = new GameDataWrapper("l4d_unrestrict_panic_battlefield");

g_BattleFieldPatch.GetRandomPZSpawnPosition = gd.CreatePatchOrFail("ZombieManager::GetRandomPZSpawnPosition__skip_PanicEventActive", false);
g_BattleFieldPatch.CollectSpawnAreas = gd.CreatePatchOrFail("ZombieManager::CollectSpawnAreas__skip_PanicEventActive", false);
g_BattleFieldPatch.AccumulateSpawnAreaCollection = gd.CreatePatchOrFail("ZombieManager::AccumulateSpawnAreaCollection__skip_PanicEventActive", false);

delete gd;
}

stock void TogglePatch(bool toggle)
{
toggle ? g_BattleFieldPatch.Enable() : g_BattleFieldPatch.Disable();
}
1 change: 1 addition & 0 deletions cfg/cfgogl/annehappy/shared_plugins.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ sm plugins unload fixes/l4d_fix_common_shove.smx
sm plugins load fixes/l4d2_blackscreen_fix.smx
sm plugins load fixes/l4d2_ladder_patch.smx
sm plugins load fixes/lfd_both_fixSG552.smx
sm plugins load fixes/l4d_unrestrict_panic_battlefield.smx
//sm plugins load fixes/l4d2_jockey_unteleport.smx

//---------------------------
Expand Down

0 comments on commit 820fa94

Please sign in to comment.