View Single Post
Spirit_12
Veteran Member
Join Date: Dec 2012
Location: Toronto, CA
Old 08-12-2018 , 23:38   Re: [L4D2]RandomWitch/LMC_RandomWitch +12 Models(Updated 01/03/2017)
Reply With Quote #7

What sort of panic event does it start? Can it not be blocked? If it is SpawnITMob function, which is used for Boomer horde and Car alarms then I can block it. Run the following plugin and check the messages, alter the cvars to see, if they block the event.

PHP Code:

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>
#include <dhooks>

#define GAMEDATA            "left4downtown.l4d2"
#define PLUGIN_VERSION         "1.0"

ConVar cvar_mob_count;
ConVar cvar_mobit_count;

public 
Plugin myinfo =
{
    
name "Spawn mob and Spawn IT mob",
    
author "$atanic $pirit",
    
description "Adds a hook for mob spawns",
    
version PLUGIN_VERSION,
    
url ""
}

public 
void OnPluginStart()
{
    
CreateConVar("mob_spawn_version"PLUGIN_VERSION""FCVAR_NOTIFY|FCVAR_DONTRECORD);
    
cvar_mob_count        =    CreateConVar"count_mob""0",        "Mob count to spawn!");
    
cvar_mobit_count    =    CreateConVar"count_mobit""0",    "MobIT count to spawn!");

    
Handle hGamedata LoadGameConfigFile(GAMEDATA);
    if( 
hGamedata == null 
        
SetFailState("Failed to load \"%s.txt\" gamedata."GAMEDATA);
        
    
// ====================================================================================================
    // Detour    -    ZombieManager::SpawnMob
    // ====================================================================================================
    
    
Handle hDetour_SpawnMob DHookCreateDetour(Address_NullCallConv_THISCALLReturnType_VoidThisPointer_Ignore);
    if( !
hDetour_SpawnMob )
        
SetFailState("Failed to setup detour for hDetour_SpawnMob");
    
    
// Load the address of the function from gamedata file.
    
if (!DHookSetFromConf(hDetour_SpawnMobhGamedataSDKConf_Signature"Zombiemanager_SpawnMob"))
        
SetFailState("Failed to find \"ZombieManager::SpawnMob\" signature.");

    
// Add all parameters.
    
DHookAddParam(hDetour_SpawnMobHookParamType_Int);


    
// Add a pre hook on the function.
    
if (!DHookEnableDetour(hDetour_SpawnMobfalseDetour_OnSpawnMob))
        
SetFailState("Failed to detour OnSpawnMob.");
        
    
// And a post hook.
    
if (!DHookEnableDetour(hDetour_SpawnMobtrueDetour_OnSpawnMob_Post))
        
SetFailState("Failed to detour OnSpawnMob post.");
        
    
// ====================================================================================================
    // Detour    -    ZombieManager::SpawnITMob
    // ====================================================================================================
    
    
Handle hDetour_SpawnITMob DHookCreateDetour(Address_NullCallConv_THISCALLReturnType_VoidThisPointer_Ignore);
    if( !
hDetour_SpawnITMob )
        
SetFailState("Failed to setup detour for hDetour_SpawnITMob");
    
    
// Load the address of the function from gamedata file.
    
if (!DHookSetFromConf(hDetour_SpawnITMobhGamedataSDKConf_Signature"Zombiemanager_SpawnITMob"))
        
SetFailState("Failed to find \"ZombieManager::SpawnITMob\" signature.");

    
// Add all parameters.
    
DHookAddParam(hDetour_SpawnITMobHookParamType_Int);


    
// Add a pre hook on the function.
    
if (!DHookEnableDetour(hDetour_SpawnITMobfalseDetour_OnSpawnITMob))
        
SetFailState("Failed to detour OnSpawnITMob.");
        
    
// And a post hook.
    
if (!DHookEnableDetour(hDetour_SpawnITMobtrueDetour_OnSpawnITMob_Post))
        
SetFailState("Failed to detour OnSpawnITMob post.");
}


// ====================================================================================================
// Function    -    ZombieManager::SpawnMob
// ====================================================================================================

public MRESReturn Detour_OnSpawnMob(Handle hParam)
{
    
int param1 DHookGetParam(hParam1);
    
//int client = SDKCall(hGetPlayerSlot, pThis) + 1; 
    
PrintToChatAll("Detour_OnSpawnMob_pre called on %d"param1);
    
    if(
cvar_mob_count.IntValue)
    {
        
DHookSetParam(hParam1cvar_mob_count.IntValue);
        return 
MRES_ChangedOverride;
    }
    return 
MRES_Ignored;
}

public 
MRESReturn Detour_OnSpawnMob_Post(Handle hParam)
{
    
int param1 DHookGetParam(hParam1);
    
PrintToChatAll("Detour_OnSpawnMob_Post called on %d"param1);
    return 
MRES_Ignored;
}

// ====================================================================================================
// Function    -    ZombieManager::SpawnITMob
// ====================================================================================================
    
public MRESReturn Detour_OnSpawnITMob(Handle hParam)
{
    
int param1 DHookGetParam(hParam1);
    
PrintToChatAll("Detour_OnSpawnITMob_pre called on %d"param1);
    
    if(
cvar_mobit_count.IntValue)
    {
        
DHookSetParam(hParam1cvar_mobit_count.IntValue);
        return 
MRES_ChangedOverride;
    }
    return 
MRES_Ignored;
}

public 
MRESReturn Detour_OnSpawnITMob_Post(Handle hParam)
{
    
int param1 DHookGetParam(hParam1);
    
PrintToChatAll("Detour_OnSpawnITMob_Post called on %d"param1);
    return 
MRES_Ignored;

Attached Files
File Type: sp Get Plugin or Get Source (Spawn_IT.sp - 364 views - 4.5 KB)
__________________

Last edited by Spirit_12; 08-12-2018 at 23:42.
Spirit_12 is offline