View Single Post
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