View Single Post
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 11-08-2018 , 07:21   Re: [TF2] Medigun healing enemy players help
Reply With Quote #4

Quote:
Originally Posted by Phil25 View Post
That is pretty insane. Care to post the full solution?
I forgot to respond

Gamedata(ghostbuster_defs.txt):
Code:
"Games"
{
	"#default"
	{
		"Signatures"
		{
			"CWeaponMedigun::AllowedToHealTarget" // "weapon_blocks_healing" and 4th function or debug and set breakpoints
			{
				"library"		"server"
				"windows"		"\x55\x8B\xEC\x53\x8B\xD9\x56\x57\x8B\xB3\xE8"
				"linux"			"_ZN14CWeaponMedigun19AllowedToHealTargetEP11CBaseEntity"
			}
		}
	}
}
Some code from my ff2 ghostbuster ability...(Requires DHooks with detours!)
PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <tf2>
#include <tf2_stocks>
#include <dhooks>

#pragma newdecls required

#define PLUGIN_NAME     "Example all-heal plugin"
#define PLUGIN_AUTHOR   "Naydef"
#define PLUGIN_VERSION  "1.0"

public Plugin myinfo =
{
    
name PLUGIN_NAME,
    
author PLUGIN_AUTHOR,
    
version PLUGIN_VERSION,
};

Handle hDetourAllowedToHealTarget;

public 
void OnPluginStart()
{
    
Handle gamedatafile=LoadGameConfigFile("ghostbuster_defs.games");
    if(
gamedatafile==null)
    {
        
SetFailState("Cannot find file ghostbuster_defs.games!");
    }
    
hDetourAllowedToHealTarget=DHookCreateDetour(Address_NullCallConv_THISCALLReturnType_BoolThisPointer_CBaseEntity);
    if(
hDetourAllowedToHealTarget==null)
    {
        
SetFailState("Failed to create CWeaponMedigun::AllowedToHealTarget detour!");
    }
    
// Load the address of the function from PTaH's signature gamedata file.
    
if(!DHookSetFromConf(hDetourAllowedToHealTargetgamedatafileSDKConf_Signature"CWeaponMedigun::AllowedToHealTarget"))
    {
        
SetFailState("Failed to load CWeaponMedigun::AllowedToHealTarget signature from gamedata");
    }
    
// Load the address of the function from PTaH's signature gamedata file.
    
delete gamedatafile;
    
    
//CWeaponMedigun::AllowedToHealTarget
    
DHookAddParam(hDetourAllowedToHealTargetHookParamType_CBaseEntity);
    
    
// Add a post hook on the function.
    
if(!DHookEnableDetour(hDetourAllowedToHealTargetfalseDetour_AllowedToHealTargetPost))
    {
        
SetFailState("Failed to detour CWeaponMedigun::AllowedToHealTarget!");
    }
}

public 
MRESReturn Detour_AllowedToHealTargetPost(int pThisHandle hReturnHandle hParams)
{
    if(
pThis==-|| DHookIsNullParam(hParams1))
    {
        return 
MRES_Ignored;
    }
    
//int targettoheal=DHookGetParam(hParams, 1);
    
DHookSetReturn(hReturntrue); // Just try the medigun in the game :)
    
return MRES_ChangedOverride;

__________________
My plugins:
*None for now*


Steam:
naydef

Last edited by Naydef; 11-08-2018 at 07:21.
Naydef is offline