View Single Post
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 11-28-2021 , 05:51   Re: DHooks (Dynamic Hooks - Dev Preview)
Reply With Quote #869

Has there been some sort of breaking change with this transition?

An old plugin of mines that used to work seems to be causing crashes now.

I hooked CBaseEntity::IsDeflectable() and through some gameplay testing have found that it is quite just my own isolated plugin for this that crashes... with crash logs pointing at BaseCombatCharacter::IsHiddenByFog(CBaseEntit y*) for some reason.

Zero reference to IsDeflectable in my crash logs but I know for a fact it's this plugin causing them.

My offsets seem to be correct according to the vtable dumper.

Here is pretty much my full plugin for it. It seems to compile fine with sm1.11 too, which I am running. But it was also broken with sm1.10 and the version of DHooks before I upgraded to the sm1.11 one.

It's been ages since I tried DHook stuff and I forget how I figured any of this out <.<

Code:
"Games"
{
    "tf"
    {
        "Offsets"
        {
            "CBaseEntity::IsDeflectable()" // Works for CTFPlayer too, basically any entity.
            {
                "library" "server"
                "windows"   "152"
                "linux"     "153"
                "mac"       "153"
            }
        }
    }
}
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <dhooks>

#undef REQUIRE_PLUGIN
#include <saxtonhale>
#define REQUIRE_PLUGIN

#define FL_CROUCHWALKING (FL_ONGROUND|FL_DUCKING)

static Handle:g_fnIsDeflectable;
static 
bool:g_bIsVSHRunning;

public 
OnPluginStart()
{
    
OnPluginStart_RegisterIsDeflectable();
}

public 
OnClientPostAdminCheck(iClient)
{
    
DHookEntity(g_fnIsDeflectabletrueiClient);
}

public 
OnMapStart()
{
    for (new 
iClient 1iClient <= MaxClientsiClient++)
    {
        if (
IsClientInGame(iClient))
        {
            
OnClientPostAdminCheck(iClient);
        }
    }
}

stock OnPluginStart_RegisterIsDeflectable()
{
    new 
Handle:hGameData LoadGameConfigFile("airblast.data");
    if (
hGameData == INVALID_HANDLE)
    {
        
SetFailState("Unable to load required gamedata (airblast.data.txt)");
    }

    new 
iOffset GameConfGetOffset(hGameData"CBaseEntity::IsDeflectable()");
    if (
iOffset == -1)
    {
        
SetFailState("Failed To Get Offset For CBaseEntity::IsDeflectable()");
    }
    
    
g_fnIsDeflectable DHookCreate(iOffsetHookType_EntityReturnType_BoolThisPointer_CBaseEntityOnCheckIfDeflectable);

    
CloseHandle(hGameData);
}

public 
MRESReturn:OnCheckIfDeflectable(iVictimHandle:hReturnHandle:hParams)
{
    
//PrintToChatAll("IS DEFLECTABLE?!");

    
if (!g_bIsVSHRunning || VSH_GetRoundState() != VSHRState_Active || VSH_GetBossType(iVictim) != BossType_Main)
    {
        return 
MRES_Ignored;
    }

    if (
VSH_IsBossAnchored())
    {
        
//PrintToChatAll("Anchored!");
        
DHookSetReturn(hReturnfalse);
        return 
MRES_Override;
    }

    if (
VSH_IsBossSuperJumping())
    {
        
//PrintToChatAll("Anchored!");
        
DHookSetReturn(hReturnfalse);
        return 
MRES_Override;
    }

    return 
MRES_Ignored;
}

public 
OnAllPluginsLoaded()
{
    
g_bIsVSHRunning LibraryExists("saxtonhale");
}

public 
OnLibraryAdded(const String:name[])
{
    if (
StrEqual(name"saxtonhale"))
    {
        
g_bIsVSHRunning true;
    }
}

public 
OnLibraryRemoved(const String:name[])
{
    if (
StrEqual(name"saxtonhale"))
    {
        
g_bIsVSHRunning false;
    }

__________________

Last edited by Chdata; 11-28-2021 at 05:54.
Chdata is offline