AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Passing CTakeDamageInfo to an SDKCall? (https://forums.alliedmods.net/showthread.php?t=319516)

Shadowysn 11-04-2019 22:57

Passing CTakeDamageInfo to an SDKCall?
 
Yep, I have no idea what to do.

I attempted this a long time ago but I didn't really know what I was doing, and it all blew up in my face. :?
I learned a bit from my mistakes, but since then I kinda left it alone.
Until now.

EDITED-IN EXPLANATION: I'm trying to create a death notice in the kill feed in TF2 using actual values from a TakeDamage hook.
PHP Code:

SDKCall(hPlayerEventKilledvictimint[
float m_vecDamageForce[3]; m_vecDamageForce == damageForce
]); 

I am completely aware that this is wrong, but I have no other ideas how it's done other than individual values crammed into a datapack. :\

nosoop 11-05-2019 00:20

Re: Passing CTakeDamageInfo to an SDKCall?
 
If you don't already have an CTakeDamageInfo instance on hand, you'll probably need to use something like Source Scramble to allocate one, set up the desired values, then pass its address. Refer to game/shared/takedamageinfo.h in the Source SDK for how it's laid out.

However, it does seem like you're posting about an attempt to solve a different problem (the XY problem) -- what are you actually trying to solve, if anything?

Shadowysn 11-05-2019 00:57

Re: Passing CTakeDamageInfo to an SDKCall?
 
Quote:

Originally Posted by nosoop (Post 2672019)
If you don't already have an CTakeDamageInfo instance on hand, you'll probably need to use something like Source Scramble to allocate one, set up the desired values, then pass its address. Refer to game/shared/takedamageinfo.h in the Source SDK for how it's laid out.

However, it does seem like you're posting about an attempt to solve a different problem (the XY problem) -- what are you actually trying to solve, if anything?

Generally just trying to make an SDKCall that utilizes CTakeDamageInfo to work properly.
In that case, I'm trying to create a CTakeDamageInfo object or getting it to function some other way.

DJ Tsunami 11-05-2019 03:30

Re: Passing CTakeDamageInfo to an SDKCall?
 
Can't you just use SDKHooks_TakeDamage? It uses a custom CTakeDamageInfo object to inflict damage.

Shadowysn 11-05-2019 05:31

Re: Passing CTakeDamageInfo to an SDKCall?
 
Quote:

Originally Posted by DJ Tsunami (Post 2672028)
Can't you just use SDKHook_TakeDamage? It uses as custom CTakeDamageInfo object to inflict damage.

If you mean passing it to the SDKCall, does it actually work? And besides that, I don't want to damage the person for a second time, as I want to pass real values to the function I'm using.

If you mean taking a look in how it works, sure, but I'm getting the feeling it could just be from an inbuilt-extension and thus isn't applicable to normal Sourcemod plugins.

EDIT: Oh wait, you're the creator of SDKHooks, okay.
Um, my early outburst aside, SDKHook_TakeDamage is a void function which means it's not going to return anything.
But since you created that function, (I hope) can you tell how you made the CTakeDamageInfo object?

DJ Tsunami 11-05-2019 13:58

Re: Passing CTakeDamageInfo to an SDKCall?
 
It's unclear from your first post what you are actually trying to do. If you're trying to inflict damage, what are you expecting the call to return?

Either way, the custom CTakeDamageInfo object is here: https://github.com/alliedmodders/sou...geinfohack.cpp
And the TakeDamage call is here: https://github.com/alliedmodders/sou....cpp#L178-L179

This is of course C++, so I'm not sure if it can be done directly in SourcePawn with SDKCall.

Shadowysn 11-06-2019 03:56

Re: Passing CTakeDamageInfo to an SDKCall?
 
Quote:

Originally Posted by DJ Tsunami (Post 2672090)
It's unclear from your first post what you are actually trying to do. If you're trying to inflict damage, what are you expecting the call to return?

Either way, the custom CTakeDamageInfo object is here: https://github.com/alliedmodders/sou...geinfohack.cpp
And the TakeDamage call is here: https://github.com/alliedmodders/sou....cpp#L178-L179

This is of course C++, so I'm not sure if it can be done directly in SourcePawn with SDKCall.

Not trying to inflict damage, but passing down the TakeDamage values to CMultiplayRules::DeathNotice to create a fake kill in the killfeed.

Welp, looks like I'm slumped.

nosoop 11-06-2019 05:27

Re: Passing CTakeDamageInfo to an SDKCall?
 
There's the XY problem that should've been mentioned sooner.
Not that it improves the situation much since the killfeed does calls for getting weapon names, assisters and such, but those are things you can recreate.

For Source Scramble, you can allocate a MemoryBlock (size 0x64 in TF2, not sure about other games), then populate the members then SDKCall. This plugin reads / writes offsets in a CTakeDamageInfo struct retrieved via DHooks (I went this route because the extension's objectptr accessors have a few issues), but it should be the same principle with the manually-allocated one.

asherkin 11-09-2019 06:45

Re: Passing CTakeDamageInfo to an SDKCall?
 
If you only care about the killfeed, just fire the player_death event yourself, that can all be done with natives built in to SM.

Shadowysn 11-10-2019 00:07

Re: Passing CTakeDamageInfo to an SDKCall?
 
EDIT: Apologies for causing an XY problem, but damn it I did not realize whatever was causing it until it was too late. I really hate how my way of learning is to keep getting into problems I don't even realize completely.
Quote:

Originally Posted by asherkin (Post 2672438)
If you only care about the killfeed, just fire the player_death event yourself, that can all be done with natives built in to SM.

I'm already using that method, but I'd have to recreate all the code to pass onto the event in order to make a convincing feigned death. :bacon:

Weapons, deathflags, tauntkills, so much stuff needed to do.
At it's current state the event will only report unique weapons as stock, as well as other inconsistencies. (Like taunt kills using the normal weapon's killicon instead.)
Plus, crit glows on the killfeed don't work for some reason.

End result would most likely be a long mess of code that can become outdated with any updates to the killfeed system, even if major updates don't happen.
Better reuse than copy, I guess.


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.

Instead, they called a weird function in the Linux binary - EconEntity_OnOwnerKillEaterEvent - that didn't need a CTakeDamageInfo passed to it, but I was unable to find it on Windows.
(The fact I'm using IDA Free which has no decompiler isn't helping.)

Welp, if all else fails I guess I'm gonna have to give up and use Source Scramble for this.


All times are GMT -4. The time now is 16:18.

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