Skip to content

Commit

Permalink
Merge branch 'SirPlease:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
altair-sossai authored Dec 9, 2024
2 parents ae9a000 + 0eae66d commit 38d5035
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 55 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check_plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
#- "1.10"
- "1.11"
- "1.12"
- "1.13"

steps:
- uses: actions/checkout@v4
Expand Down
116 changes: 116 additions & 0 deletions addons/sourcemod/gamedata/l4d_fix_stagger_dir.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,51 @@

"left4dead"
{
"Functions"
{
"CTerrorPlayer::OnShovedBySurvivor"
{
"linux"
{
"signature" "CTerrorPlayer::OnShovedBySurvivor [clone]"
"callconv" "cdecl"
}
"windows"
{
"signature" "CTerrorPlayer::OnShovedBySurvivor"
"callconv" "stdcall"
}
"return" "void"
"arguments"
{
"this"
{
"type" "cbaseentity"
"linux"
{
"register" "eax"
}
"windows"
{
"register" "ecx"
}
}
"a2"
{
"type" "cbaseentity"
"linux"
{
"register" "edx"
}
}
"a3"
{
"type" "vectorptr"
}
}
}
}

"Offsets"
{
"CTerrorPlayer::m_PlayerAnimState"
Expand Down Expand Up @@ -56,11 +101,69 @@
/* 83 ? ? ? 8B ? E8 ? ? ? ? 84 ? 0F 85 ? ? ? ? 8B ? 8B */
/* Search: "Player.Shoved" */
}

// Stolen from left4dhooks thanks to Silvers
/*
* CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&)
*/
"CTerrorPlayer::OnShovedBySurvivor"
{
"library" "server"
"linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector"
"windows" "\x81\x2A\x2A\x2A\x2A\x2A\x56\x8B\x2A\xE8\x2A\x2A\x2A\x2A\x84\x2A\x0F\x85"
/* 81 ? ? ? ? ? 56 8B ? E8 ? ? ? ? 84 ? 0F 85 */
}

// Stolen from left4dhooks thanks to Silvers
/*
* CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&) [clone]
*/
"CTerrorPlayer::OnShovedBySurvivor [clone]"
{
"library" "server"
"linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector.part.591"
}
}
}

"left4dead2"
{
"Functions"
{
"CTerrorPlayer::OnShovedBySurvivor"
{
"signature" "CTerrorPlayer::OnShovedBySurvivor"
"linux"
{
"callconv" "cdecl"
}
"windows"
{
"callconv" "stdcall"
}
"return" "void"
"arguments"
{
"this"
{
"type" "cbaseentity"
"windows"
{
"register" "ecx"
}
}
"a2"
{
"type" "cbaseentity"
}
"a3"
{
"type" "vectorptr"
}
}
}
}

"Offsets"
{
/* Windows offset:
Expand Down Expand Up @@ -104,6 +207,19 @@
* Using a long local jump as the unique portion (last few bytes of sig)
*/
}

// Stolen from left4dhooks thanks to Silvers
/*
* CTerrorPlayer::OnShovedBySurvivor(CTerrorPlayer*, Vector const&) - used by L4D2 on Special Infected (got melee'd)
* unique string "jockey_ride" in CTerrorPlayer::OnLeptOnSurvivor(), look up for "JockeyZombie.Ride", look up for var_14, CTerrorPlayer::OnShovedBySurvivor is call after that
*/
"CTerrorPlayer::OnShovedBySurvivor"
{
"library" "server"
"linux" "@_ZN13CTerrorPlayer18OnShovedBySurvivorEPS_RK6Vector"
"windows" "\x55\x8B\xEC\x81\xEC\x2A\x2A\x2A\x2A\xA1\x2A\x2A\x2A\x2A\x33\xC5\x89\x45\xFC\x53\x8B\x5D\x2A\x56\x57\x8B\x7D\x2A\x8B\xF1"
/* 55 8B EC 81 EC ? ? ? ? A1 ? ? ? ? 33 C5 89 45 FC 53 8B 5D ? 56 57 8B 7D ? 8B F1 */
}
}
}
}
Binary file modified addons/sourcemod/plugins/fixes/l4d_fix_stagger_dir.smx
Binary file not shown.
23 changes: 10 additions & 13 deletions addons/sourcemod/scripting/holdout_bonus.sp
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public HoldOutStarts ( const String:output[], caller, activator, Float:delay )
{
if ( g_bHoldoutActive ) { return; }

PrintDebug( 1, "Holdout Starts (hooked)." );
PrintDebug( "Holdout Starts (hooked)." );

g_bHoldoutActive = true;
g_iHoldoutStartTime = GetTime();
Expand Down Expand Up @@ -401,7 +401,7 @@ public HoldOutEnds_Hook ( const String:output[], caller, activator, Float:delay
// hooked on map logic
// only use as safeguard / check for time

PrintDebug( 1, "Holdout Ends (hooked): abs: %i / prg %i / defined %i.", GetTime() - g_iHoldoutStartTime, g_iProgress, g_iHoldoutTime );
PrintDebug( "Holdout Ends (hooked): abs: %i / prg %i / defined %i.", GetTime() - g_iHoldoutStartTime, g_iProgress, g_iHoldoutTime );

if ( g_bHoldoutActive )
{
Expand All @@ -417,7 +417,7 @@ stock HoldOutEnds( bool:bByRequest = false )
{
g_bHoldoutActive = false;

PrintDebug( 1, "Holdout over, awarding bonus: prg %i / defined %i.", g_iProgress, g_iHoldoutTime );
PrintDebug( "Holdout over, awarding bonus: prg %i / defined %i.", g_iProgress, g_iHoldoutTime );

g_iActualBonus = CalculateHoldOutBonus();

Expand Down Expand Up @@ -638,7 +638,7 @@ KV_Load()
return;
}

PrintDebug( 1, "Holdout data loaded from file: %s.", sNameBuff );
PrintDebug( "Holdout data loaded from file: %s.", sNameBuff );
}

bool: KV_UpdateHoldoutMapInfo()
Expand Down Expand Up @@ -680,7 +680,7 @@ bool: KV_UpdateHoldoutMapInfo()
KvGetString( g_kHIData, "t_e_hook", g_sHoldoutEndHook, MAXSTR, "" );
}

PrintDebug( 1, "Read holdout mapinfo for '%s': %i / (factor: %.2f; abs: %i).",
PrintDebug( "Read holdout mapinfo for '%s': %i / (factor: %.2f; abs: %i).",
mapname, g_bHoldoutThisRound,
g_fHoldoutPointFactor, g_iHoldoutPointAbsolute
);
Expand Down Expand Up @@ -734,13 +734,10 @@ stock GetPlayerCharacter ( client )
return tmpChr;
}

stock PrintDebug( debugLevel, const String:Message[], any:... )
stock PrintDebug( const String:Message[], any:... )
{
//if (debugLevel <= GetConVarInt(g_hCvarDebug))
//{
decl String:DebugBuff[256];
VFormat(DebugBuff, sizeof(DebugBuff), Message, 3);
LogMessage(DebugBuff);
//PrintToServer(DebugBuff);
//}
decl String:DebugBuff[256];
VFormat(DebugBuff, sizeof(DebugBuff), Message, 3);
LogMessage(DebugBuff);
//PrintToServer(DebugBuff);
}
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,11 @@ stock void TE_SetupPhysicsProp(float vecModelOrigin[3],
TE_WriteNum("r", RGB[0]);
TE_WriteNum("g", RGB[1]);
TE_WriteNum("b", RGB[2]);

// Garbage code to prevent warning, symbol 'iSkin' is not used
if (iSkin == -1) {
LogError("TE_SetupPhysicsProp %d", iSkin);
}
}

/**
Expand Down
89 changes: 65 additions & 24 deletions addons/sourcemod/scripting/l4d_fix_stagger_dir.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#pragma newdecls required

#include <sourcemod>
#include <dhooks>
// #include <dhooks>
#include <left4dhooks>

#define PLUGIN_VERSION "1.0"
#define PLUGIN_VERSION "1.2"

public Plugin myinfo =
{
Expand All @@ -29,28 +30,29 @@ methodmap GameDataWrapper < GameData {
if (offset == -1) SetFailState("Missing offset \"%s\"", key);
return offset;
}
public DynamicDetour CreateDetourOrFail(
const char[] name,
DHookCallback preHook = INVALID_FUNCTION,
DHookCallback postHook = INVALID_FUNCTION) {
DynamicDetour hSetup = DynamicDetour.FromConf(this, name);
if (!hSetup)
SetFailState("Missing detour setup \"%s\"", name);
if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook))
SetFailState("Failed to pre-detour \"%s\"", name);
if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook))
SetFailState("Failed to post-detour \"%s\"", name);
return hSetup;
}
// public DynamicDetour CreateDetourOrFail(
// const char[] name,
// DHookCallback preHook = INVALID_FUNCTION,
// DHookCallback postHook = INVALID_FUNCTION) {
// DynamicDetour hSetup = DynamicDetour.FromConf(this, name);
// if (!hSetup)
// SetFailState("Missing detour setup \"%s\"", name);
// if (preHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Pre, preHook))
// SetFailState("Failed to pre-detour \"%s\"", name);
// if (postHook != INVALID_FUNCTION && !hSetup.Enable(Hook_Post, postHook))
// SetFailState("Failed to post-detour \"%s\"", name);
// return hSetup;
// }
}

int g_iOffs_m_PlayerAnimState;
int g_iOffs_m_flEyeYaw;

methodmap Address {}
methodmap PlayerAnimState < Address {
public static PlayerAnimState FromPlayer(int client) {
return view_as<PlayerAnimState>(GetEntData(client, g_iOffs_m_PlayerAnimState));
methodmap PlayerAnimStateEx < Address
{
public static PlayerAnimStateEx FromPlayer(int client) {
return view_as<PlayerAnimStateEx>(GetEntData(client, g_iOffs_m_PlayerAnimState));
}

property float m_flEyeYaw {
Expand All @@ -64,18 +66,57 @@ public void OnPluginStart()
g_iOffs_m_PlayerAnimState = gd.GetOffset("CTerrorPlayer::m_PlayerAnimState");
g_iOffs_m_flEyeYaw = gd.GetOffset("m_flEyeYaw");

delete gd.CreateDetourOrFail("CTerrorPlayer::OnStaggered", DTR_OnStaggered);
// https://github.com/Target5150/MoYu_Server_Stupid_Plugins/issues/70
// delete gd.CreateDetourOrFail("CTerrorPlayer::OnShovedBySurvivor", DTR_OnShovedBySurvivor);
// delete gd.CreateDetourOrFail("CTerrorPlayer::OnStaggered", DTR_OnStaggered);
delete gd;
}

MRESReturn DTR_OnStaggered(int client, DHookParam hParams)
public Action L4D_OnShovedBySurvivor(int client, int victim, const float vecDir[3])
{
if (IsClientInGame(victim))
{
float ang[3];
GetClientAbsAngles(victim, ang);
PlayerAnimStateEx.FromPlayer(victim).m_flEyeYaw = ang[1];
}

return Plugin_Continue;
}

public Action L4D2_OnStagger(int client, int source)
{
if (IsClientInGame(client) && GetClientTeam(client) == 2)
if (IsClientInGame(client))
{
float ang[3];
GetClientAbsAngles(client, ang);
PlayerAnimState.FromPlayer(client).m_flEyeYaw = ang[1];
PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1];
}

return MRES_Ignored;
}
return Plugin_Continue;
}

// MRESReturn DTR_OnShovedBySurvivor(DHookParam hParams)
// {
// int client = hParams.Get(1);
// if (IsClientInGame(client))
// {
// float ang[3];
// GetClientAbsAngles(client, ang);
// PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1];
// }

// return MRES_Ignored;
// }

// MRESReturn DTR_OnStaggered(int client, DHookParam hParams)
// {
// if (IsClientInGame(client))
// {
// float ang[3];
// GetClientAbsAngles(client, ang);
// PlayerAnimStateEx.FromPlayer(client).m_flEyeYaw = ang[1];
// }

// return MRES_Ignored;
// }
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/l4dd/l4dd_forwards.sp
Original file line number Diff line number Diff line change
Expand Up @@ -5517,7 +5517,7 @@ MRESReturn DTR_CSquirrelVM_GetValue(DHookReturn hReturn, DHookParam hParams) //
bool StringToVector(const char[] str, const char[] spilt, float vec[3])
{
char buffers[3][20];
if( 3 > ExplodeString(str, spilt, buffers, sizeof(buffers[]), sizeof(buffers[][]), true) )
if( 3 > ExplodeString(str, spilt, buffers, sizeof(buffers), sizeof(buffers[]), true) )
return false;

for( int i = 0; i < 3; ++i )
Expand Down
Loading

0 comments on commit 38d5035

Please sign in to comment.