Raised This Month: $51 Target: $400
 12% 

Solved Passing CTakeDamageInfo to an SDKCall?


Post New Thread Reply   
 
Thread Tools Display Modes
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-10-2019 , 13:38   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #11

Yeah; that's what I figured -- DeathNotice does a lot.

Quote:
Originally Posted by Shadowysn View Post
I only made a bit of progress in the gamedata part because all the other things like CTFGameRules::DeathNotice still need CTakeDamageInfo.
And oddly enough, all of the DeathNotice function(s) weren't called in CTFPlayer's Event_Killed or FeignDeath function.
It does, actually: CTFPlayer::FeignDeath() calls g_pGameRules->DeathNotice right before the call to CTFPlayer::ShouldDropAmmoPack; g_pGameRules gets dereferenced then calls it virtually (listed as call dword ptr [edx+14Ch], or a call to vtable offset 83).

A virtual gamerules SDKCall should work, theoretically.
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 11-11-2019 , 06:24   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #12

Quote:
Originally Posted by nosoop View Post
Yeah; that's what I figured -- DeathNotice does a lot.



It does, actually: CTFPlayer::FeignDeath() calls g_pGameRules->DeathNotice right before the call to CTFPlayer::ShouldDropAmmoPack; g_pGameRules gets dereferenced then calls it virtually (listed as call dword ptr [edx+14Ch], or a call to vtable offset 83).

A virtual gamerules SDKCall should work, theoretically.
So, something like:
PHP Code:
// GAMEDATA
"CTFGameRules::DeathNotice"
{
    
"library"    "server"
    "linux"        "@_ZN12CTFGameRules11DeathNoticeEP11CBasePlayerRK15CTakeDamageInfoPKc"
    "windows"    "\x55\x8B\x2A\x81\x2A\x2A\x2A\x2A\x2A\x53\x56\x8B\x2A\x2A\x8B\x2A\xC7\x2A\x2A\x2A\x2A\x2A\x2A"
}

// PLUGIN
StartPrepSDKCall(SDKCall_Entity);
if (!
PrepSDKCall_SetFromConf(hConfSDKConf_Signature"CTFGameRules::DeathNotice"))
{
    
SetFailState("[SM] Failed to set AC-DR CTFGameRules::DeathNotice from config!");
}
PrepSDKCall_AddParameter(SDKType_CBasePlayerSDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_PlainOldDataSDKPass_Plain);
Handle hDeathNotice EndPrepSDKCall();

int tf_gamerules FindEntityByClassname(-1"tf_gamerules");
if (
IsValidEntity(tf_gamerules))
SDKCall(hDeathNoticetf_gamerulesclient); 
...or do I have to find something in the binary again?
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4
Shadowysn is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-11-2019 , 10:42   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #13

Your gamedata uses the DeathNotice call with a char* parameter, so you'll want to add that or use the one that isn't (which just calls the one you've declared with "player_death" as the last parameter, for other killfeed notices like the fish.).

There is a SDKCall_GameRules call type, so you don't need to pass in a gamerules instance.

Invoking the function would then be something like

Code:
SDKCall(hDeathNotice, victim, pTakeDamageInfo, "player_death");
Otherwise, I think that should be fine. I did make a mistake though; the size of CTakeDamageInfo should be 0x68 (last member is at 0x64).
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)

Last edited by nosoop; 11-11-2019 at 10:44.
nosoop is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 11-12-2019 , 00:12   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #14

Quote:
Originally Posted by nosoop View Post
Your gamedata uses the DeathNotice call with a char* parameter, so you'll want to add that or use the one that isn't (which just calls the one you've declared with "player_death" as the last parameter, for other killfeed notices like the fish.).

There is a SDKCall_GameRules call type, so you don't need to pass in a gamerules instance.

Invoking the function would then be something like

Code:
SDKCall(hDeathNotice, victim, pTakeDamageInfo, "player_death");
Otherwise, I think that should be fine. I did make a mistake though; the size of CTakeDamageInfo should be 0x68 (last member is at 0x64).
Okay. Understood most of what you were saying, but still no progress on that SDKCall.
Well, I've decided to try out Source Scramble.

Except I have no idea what to do to create the damage info object.
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4
Shadowysn is offline
nosoop
Veteran Member
Join Date: Aug 2014
Old 11-12-2019 , 06:27   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #15

Allocation is performed by instantiating a MemoryBlock instance, and deletion performed by freeing the handle. Let me know if there's anything unclear in the extension's documentation.

Attached is known working code that creates a killfeed notice whenever a player is attacked by another player. pls donate
Attached Files
File Type: sp Get Plugin or Get Source (fake_death_notice.sp - 119 views - 3.7 KB)
__________________
I do TF2, TF2 servers, and TF2 plugins.
I don't do DMs over Discord -- PM me on the forums regarding inquiries.
AlliedModders Releases / Github / TF2 Server / Donate (BTC / BCH / coffee)
nosoop is offline
Shadowysn
Senior Member
Join Date: Sep 2015
Location: Location:
Old 11-12-2019 , 07:28   Re: Passing CTakeDamageInfo to an SDKCall?
Reply With Quote #16

Quote:
Originally Posted by nosoop View Post
Allocation is performed by instantiating a MemoryBlock instance, and deletion performed by freeing the handle. Let me know if there's anything unclear in the extension's documentation.

Attached is known working code that creates a killfeed notice whenever a player is attacked by another player. pls donate
Oh wow, thank you so much!
I haven't got the time to test the code, but if it works I'll finally be able to focus more on the bugs and other things. (hitsounds, proper death screams, etc.)
After I sort the code of course, I think it looks like a mess right now.

EDIT: Yep, it works perfectly!

i iz no money of own
__________________
ragdoll spam, that is all

Steam profile, where I game, obviously.
Youtube channel, where I do Stick Death Maze animations and some other stuff.
no plugin requests, sorry


My Plugins:
-search list-
Modified Plugins:
1 | 2 | 3 | 4

Last edited by Shadowysn; 11-12-2019 at 09:37.
Shadowysn is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode