Veteran Member
|
03-19-2019
, 04:23
Re: Passing a reference parameter to CreateVCall
|
#3
|
Quote:
Originally Posted by Fyren
Off the top of my head, you don't want to memcpy the contents of CTakeDamageInfo. You want to put its address there and bintools/SH will do the right thing.
But, to debug, you should probably set a breakpoint on the actual virtual function you want to be calling. You'll be able to verify it's being called because your breakpoint will get hit and then you can inspect the stack to make sure the right address of your CTakeDamageInfo is there. It's also possible the game itself doesn't use that function or it does nothing. A breakpoint will let you know that as well.
|
Thanks for the explication, I really appreciate that because I dont know infact how the Bintools work exactly, I just took of SDKTool's examples and modified them...
Now, that I've tried to call that function inside a sourcemod plugin instead of an extension I just found out that VALVe removed the very functionality I needed from it... (this is in CS:GO), this function used to tear the player apart into peaces with the SpawnRandomGibs function, now only SpawnRandomHeadGibs works, the others dont
EDIT: here's some randomness for anybody if they want to try it...
PHP Code:
#include <sourcemod> #include <sdktools> #include <dhooks> #pragma newdecls required
Handle hSpawnHeadGib, hSpawnRandomGibs, hCorpseGib, hInitGib, hSpawnGib;
Handle hHasHumanGibs, hHasAlienGibs;
public void OnPluginStart() { Handle config = LoadGameConfigFile("zitests.games"); if( config == null ) { SetFailState("Failed to load the config"); } bool prep_finished = false; StartPrepSDKCall(SDKCall_Player); prep_finished = PrepSDKCall_SetFromConf(config, SDKConf_Signature, "SpawnHeadGib"); if( prep_finished ) { PrintToServer("Preparation for the SpawnHeadGib SDK call is a success!"); } PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer); hSpawnHeadGib = EndPrepSDKCall(); if( hSpawnHeadGib == null ) { PrintToServer("Failed to start SpawnHeadGib call"); } StartPrepSDKCall(SDKCall_Player); prep_finished = PrepSDKCall_SetFromConf(config, SDKConf_Signature, "SpawnRandomGibs"); if( prep_finished ) { PrintToServer("Preparation for the SpawnRandomGibs SDK call is a success!"); } PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByValue); hSpawnRandomGibs = EndPrepSDKCall(); if( hSpawnRandomGibs == null ) { PrintToServer("Failed to start SpawnRandomGibs call"); } // StartPrepSDKCall(SDKCall_Player); prep_finished = PrepSDKCall_SetFromConf(config, SDKConf_Signature, "CorpseGib"); if( prep_finished ) { PrintToServer("Preparation for the CorpseGib SDK call is a success!"); } /* Vector m_vecDamageForce; Vector m_vecDamagePosition; Vector m_vecReportedPosition; // Position players are told damage is coming from EHANDLE m_hInflictor; EHANDLE m_hAttacker; EHANDLE m_hWeapon; float m_flDamage; float m_flMaxDamage; float m_flBaseDamage; // The damage amount before skill leve adjustments are made. Used to get uniform damage forces. int m_bitsDamageType; int m_iDamageCustom; int m_iDamageStats; int m_iAmmoType; // AmmoType of the weapon used to cause this damage, if any float m_flRadius; // CS:GO int m_iDamagedOtherPlayers; int m_iObjectsPenetrated; uint32 m_uiBulletID; uint8 m_uiRecoilIndex; */ PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKType_PlainOldData); PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_ByRef); hCorpseGib = EndPrepSDKCall(); if( hCorpseGib == null ) { PrintToServer("Failed to start CorpseGib call"); } StartPrepSDKCall(SDKCall_Entity); prep_finished = PrepSDKCall_SetFromConf(config, SDKConf_Signature, "SpawnGib"); if( prep_finished ) { PrintToServer("Preparation for the SpawnGib SDK call is a success!"); } PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer); hSpawnGib = EndPrepSDKCall(); if( hSpawnGib == null ) { PrintToServer("Failed to start SpawnGib call"); } StartPrepSDKCall(SDKCall_Entity); prep_finished = PrepSDKCall_SetFromConf(config, SDKConf_Signature, "InitGib"); if( prep_finished ) { PrintToServer("Preparation for the InitGib SDK call is a success!"); } PrepSDKCall_AddParameter(SDKType_CBasePlayer, SDKPass_Pointer); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByValue); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_ByValue); hInitGib = EndPrepSDKCall(); if( hInitGib == null ) { PrintToServer("Failed to start InitGib call"); } hHasHumanGibs = DHookCreate(312, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, PreHasHumanGibs); hHasAlienGibs = DHookCreate(313, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, PreHasAlienGibs); }
public void OnMapStart() { PrecacheModel("models/gibs/hgibs.mdl", true); AddFileToDownloadsTable("models/gibs/hgibs.mdl"); PrecacheModel("models/gibs/hgibs_rib.mdl", true); AddFileToDownloadsTable("models/gibs/hgibs_rib.mdl"); PrecacheModel("models/gibs/hgibs_scapula.mdl", true); AddFileToDownloadsTable("models/gibs/hgibs_scapula.mdl"); PrecacheModel("models/gibs/hgibs_spine.mdl", true); AddFileToDownloadsTable("models/gibs/hgibs_spine.mdl"); AddFileToDownloadsTable("materials/models/gibs/hgibs/rib.vmt"); AddFileToDownloadsTable("materials/models/gibs/hgibs/scapula.vmt"); AddFileToDownloadsTable("materials/models/gibs/hgibs/skull1.vmt"); AddFileToDownloadsTable("materials/models/gibs/hgibs/spine.vmt"); AddFileToDownloadsTable("materials/models/gibs/hgibs/skull1.vmt"); PrecacheModel("materials/models/gibs/hgibs/skull1.vmt", true); PrecacheGeneric("materials/models/gibs/hgibs/skull1.vmt", true); PrecacheModel("models/gibs/agibs.mdl", true); AddFileToDownloadsTable("models/gibs/agibs.mdl"); }
void ChangeBloodColor(int client, int bloodColor) { SetEntProp(client, Prop_Data, "m_bloodColor", bloodColor); } void SpawnHeadGib(int client) { SDKCall(hSpawnHeadGib, client, client); }
void SpawnRandomGibs(int client, int gibs, int gibsType) { SDKCall(hSpawnRandomGibs, client, client, gibs, gibsType); }
void SpawnGib(int gibEntity, const char[] gibModel) { SDKCall(hSpawnGib, gibEntity, gibModel); }
void InitGib(int gibEntity, int client, float minVelocity, float maxVelocity) { SDKCall(hInitGib, gibEntity, client, minVelocity, maxVelocity); }
#define HUMAN_GIB_COUNT 6 #define ALIEN_GIB_COUNT 4
void SpawnRandomGibs2(int client, int gibs, int gibType ) { int gibEntity = -1; for( int splat = 0; splat < gibs; splat++ ) { gibEntity = CreateEntityByName("gib"); if( gibEntity == -1 ) { PrintToChat(client, "Failed to create gib entity"); continue; }
if( gibType == 0 ) { // Human SpawnGib(gibEntity, "models/gibs/hgibs.mdl"); SetEntProp(gibEntity, Prop_Data, "m_nBody", GetRandomInt(1, HUMAN_GIB_COUNT - 1)); PrintToChat(client, "HUMAN GIBs!"); } else if( gibType == 1 ) { // Alien SpawnGib(gibEntity, "models/gibs/agibs.mdl"); SetEntProp(gibEntity, Prop_Data, "m_nBody", GetRandomInt(0, ALIEN_GIB_COUNT - 1));
PrintToChat(client, "ALIEN GIBs!"); } float origin[3]; GetClientAbsOrigin(client, origin); origin[2] += 1.0; float velocity[3]; GetEntPropVector(client, Prop_Data, "m_vecVelocity", velocity); velocity[0] += GetRandomFloat (-0.25, 0.25); velocity[1] += GetRandomFloat (-0.25, 0.25); velocity[2] += GetRandomFloat (-0.25, 0.25);
velocity[0] *= GetRandomFloat(300.0, 400.0) / 250.0; velocity[1] *= GetRandomFloat(300.0, 400.0) / 250.0; velocity[2] *= GetRandomFloat(300.0, 400.0) / 250.0; float angularVelocity[3]; // GetEntPropVector(gibEntity, Prop_Data, "m_vecAngularVelocity", angularVelocity); angularVelocity[0] = GetRandomFloat ( 100, 200 ); angularVelocity[1] = GetRandomFloat ( 100, 300 ); // SetEntPropVector(gibEntity, Prop_Data, "m_vecAngularVelocity", angularVelocity); SetEntProp(gibEntity, Prop_Data, "m_bloodColor", GetEntProp(client, Prop_Data, "m_bloodColor")); SetEntProp(gibEntity, Prop_Data, "m_nSolidType", 2); SetEntProp(gibEntity, Prop_Send, "m_CollisionGroup", 1); TeleportEntity(gibEntity, origin, NULL_VECTOR, velocity); // InitGib(gibEntity, client, 300.0, 400.0); } }
any CorpseGib(int client, float damageForce[3], float damagePos[3], float reportedPos[3], int inflictor, int attacker, int weapon, float damage, float maxDamage, float baseDamage, int damageType, int damageCustom, int damageStats, int ammoType, float radius, int damagedOtherPlayers, int objectsPenetrated, int bulletId, int recoilIndex) { return SDKCall(hCorpseGib, client, damageForce, damagePos, reportedPos, inflictor, attacker, weapon, damage, maxDamage, baseDamage, damageType, damageCustom, damageStats, ammoType, radius, damagedOtherPlayers, objectsPenetrated, bulletId, recoilIndex); }
public void OnClientPutInServer(int client) { DHookEntity(hHasHumanGibs, false, client); DHookEntity(hHasAlienGibs, false, client); }
public MRESReturn PreHasHumanGibs(int client, Handle hReturn) { DHookSetReturn(hReturn, true); return MRES_Supercede; }
public MRESReturn PreHasAlienGibs(int client, Handle hReturn) { DHookSetReturn(hReturn, false); return MRES_Supercede; }
public void OnClientSayCommand_Post(int client, const char[] command, const char[] sArgs) { if( !IsPlayerAlive(client) ) { return; } int i = 0; // int bloodColor = GetRandomInt(0, 5); // ChangeBloodColor(client, bloodColor); // PrintToChat(client, "Your blood color has been changed to %d", bloodColor); if( strcmp(sArgs, "corpse", false) == 0 && hCorpseGib ) { bool gibbed = true; gibbed = CorpseGib(client, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, 1, 1, 69, 0.0, 0.0, 0.0, 0, 0, 0, 0, 0.0, 0, 0, 0, 0); PrintToChat(client, "Corpse gibs should be spawned by now! [Gibbed: %s, Gib: Alien]", gibbed ? "True" : "False"); } else if( strcmp(sArgs, "head", false) == 0 && hSpawnHeadGib ) { for( i = 0; i < 10; i++ ) { SpawnHeadGib(client); } PrintToChat(client, "Head gibs should be spawned by now!"); } else if( strcmp(sArgs, "random", false) == 0 && hSpawnRandomGibs ) { for( i = 0; i < 5; i++ ) { SpawnRandomGibs(client, 4, 0); SpawnRandomGibs(client, 4, 1); } PrintToChat(client, "Random corpse gibs should be spawned by now!"); } else if( strcmp(sArgs, "random2", false) == 0 && hSpawnRandomGibs ) { for( i = 0; i < 5; i++ ) { SpawnRandomGibs2(client, 4, 0); SpawnRandomGibs2(client, 4, 1); } PrintToChat(client, "Random corpse gibs should be spawned by now!"); } }
Sigs:
PHP Code:
"Games" { "#default" { "Signatures" { "CorpseGib" { "library" "server" "windows" "\x53\x56\x51\x68\x2A\x2A\x2A\x2A\x8B\xF1" "linux" "" } "SpawnRandomGibs" { "library" "server" "windows" "\x55\x8B\xEC\x83\xEC\x08\x89\x55\xFC" "linux" "" } "SpawnHeadGib" { "library" "server" "windows" "\x55\x8B\xEC\x83\xEC\x24\x53\x56\x57\x8B\xD9" "linux" "" } "InitGib" { "library" "server" "windows" "\x55\x8B\xEC\x83\xEC\x0C\x56\x8B\xF1\x8B\x86\xD4\x00\x00\x00\xC1\xE8\x0C\xA8\x01\x74\x2A\xE8\x2A\x2A\x2A\x2A\xF3\x0F\x7E\x86\x7C\x01\x00\x00" "linux" "" } "SpawnGib" { "library" "server" "windows" "\x55\x8B\xEC\x83\xEC\x08\x53\x56\x57\x6A\x01\x6A\x05" "linux" "" } } } }
Last edited by TheDS1337; 03-19-2019 at 04:24.
|
|