Raised This Month: $32 Target: $400
 8% 

Solved [L4D] How accurately calculate tank damage with SDKHook?


Post New Thread Reply   
 
Thread Tools Display Modes
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 05-09-2021 , 11:29   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #11

He means that if another plugin changes the damage received by the tank through hooking OnTakeDamage too, you may output the wrong results,
cause SM may execute your plugin first, and the one that changes the damage next.

I usually use the "OnTakeDamagePost"/"OnTakeDamageAlivePost" hook, but I'm not sure if this solves these cases

I already had a lot of problems trying to calculate things on Post hooks (not triggering functions or outputting different values like attacker)

I don't know if for the player entity you could deal with these situations, but with prop_physics I know this happens.

Still is a good code snippet (as always) and may work in most scenarios.
__________________
Marttt is offline
fdxx
Member
Join Date: Oct 2020
Location: 0xdeadbeef
Old 07-15-2021 , 02:22   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #12

Hi, Dragokas, I want to ask an unrelated question:

Do we need SDKUnhook in the "tank_killed" event?

I searched the forum and most people just said "SDKHooks automatically handles unhooking on disconnect".

But, will "automatically unhooking" be after Tank death?
fdxx is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 07-15-2021 , 05:57   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #13

Quote:
Originally Posted by fdxx View Post
Do we need SDKUnhook in the "tank_killed" event?
It depends on your needs.

Quote:
Originally Posted by fdxx View Post
I searched the forum and most people just said "SDKHooks automatically handles unhooking on disconnect".
Yes, when disconnected and when the entity is destroyed (no more valid).

Quote:
Originally Posted by fdxx View Post
But, will "automatically unhooking" be after Tank death?
No, not instantly.
Firstly, incap event occurs, than death event, and than disconnect & auto-unhook.
Each stage has a duration of about 3-5 seconds.

So, as you can see in 1st example, to measure damage accurately I manually set g_bDied flag when it should be really considered so, which is when the damage > health elapsed.
Surely, instead of flag I could use SDKUnhook.

You must understand that the problem with tank starting on more earlier stage than death: it is an incap event (the animation when the tank is falling on the ground),
when you can still shoot the tank and that damage still coming to OnTankDamage callback, and that's why I used above logic.
I can't tell you whether damage still coming to OnTankDamage after tank death occurs (I didn't check), but SDK hook is still valid at the moment.

There is an alternative type of hook, called SDKHook_OnTakeDamageAlive, which prevents callback from catching damage when the client is died.
But it is not applicable for this case due to described "incap" specific, where SDKHook_OnTakeDamageAlive still catching the damage because the client is still alive.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 07-15-2021 at 06:16.
Dragokas is offline
fdxx
Member
Join Date: Oct 2020
Location: 0xdeadbeef
Old 07-15-2021 , 08:09   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #14

Quote:
Originally Posted by Dragokas View Post
It depends on your needs.


Yes, when disconnected and when the entity is destroyed (no more valid).


No, not instantly.
Firstly, incap event occurs, than death event, and than disconnect & auto-unhook.
Each stage has a duration of about 3-5 seconds.

So, as you can see in 1st example, to measure damage accurately I manually set g_bDied flag when it should be really considered so, which is when the damage > health elapsed.
Surely, instead of flag I could use SDKUnhook.

You must understand that the problem with tank starting on more earlier stage than death: it is an incap event (the animation when the tank is falling on the ground),
when you can still shoot the tank and that damage still coming to OnTankDamage callback, and that's why I used above logic.
I can't tell you whether damage still coming to OnTankDamage after tank death occurs (I didn't check), but SDK hook is still valid at the moment.

There is an alternative type of hook, called SDKHook_OnTakeDamageAlive, which prevents callback from catching damage when the client is died.
But it is not applicable for this case due to described "incap" specific, where SDKHook_OnTakeDamageAlive still catching the damage because the client is still alive.
Thank you so much for your detailed answer!
fdxx is offline
3ipKa
Member
Join Date: Jul 2013
Old 09-21-2022 , 02:58   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #15

Hi, Dragokas! What about witch? IDK, maybe i missed something, but I am faced with the fact that i can correctly catch gunfire damage, but not fire damage to witch.
3ipKa is offline
Marttt
Veteran Member
Join Date: Jan 2019
Location: Brazil
Old 09-21-2022 , 07:27   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #16

Probably the same method for the witch should work, why do you think the damage is not calculated correctly?

The witch dies after a while in fire, so sometimes the damage won't be the same as her HP.
__________________

Last edited by Marttt; 09-21-2022 at 07:46.
Marttt is offline
3ipKa
Member
Join Date: Jul 2013
Old 09-21-2022 , 12:37   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #17

I tried event hurt and OnTakeDamagePost, and all in all i got only 75 HP of damage from fire to witch, made tests on almost clean server. I noticed, fire makes 1.0 point of damage each time, is it ok?
3ipKa is offline
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 09-21-2022 , 13:23   Re: [L4D] How accurately calculate tank damage with SDKHook?
Reply With Quote #18

I think, you'll better create a separate topic.
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]
Dragokas is offline
Reply


Thread Tools
Display Modes

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 00:18.


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