Raised This Month: $ Target: $400
 0% 

[CS:GO] Determining if a player dies from a damage event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
popey456963
Member
Join Date: Mar 2016
Old 05-06-2018 , 18:09   [CS:GO] Determining if a player dies from a damage event
Reply With Quote #1

Using SDKHook it appears like you get damage as a float, but health is stored as an int. Wondering how death is calculated, if you have 19 health and take 19.1 damage, I assume you do, but I'm less sure of 18.9 / 18.1.

Basically, should I be using RoundToZero / RoundToCeil / RoundToFloor / RoundFloat before the check?
popey456963 is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 05-06-2018 , 20:03   Re: [CS:GO] Determining if a player dies from a damage event
Reply With Quote #2

You could use SDKHooks to modify the damage and find out.
Fyren is offline
Papero
Veteran Member
Join Date: Aug 2016
Location: Italy
Old 05-07-2018 , 17:00   Re: [CS:GO] Determining if a player dies from a damage event
Reply With Quote #3

I've tested a bit and using SDKHooks_TakeDamage (without armour) and these I've seen that:
if dam= X.99999999(8 nines or more) -> dam = x + 1
if dam= X.9999999(7 nines or less) -> dam = x

Examples:
I take 5.99999999 HPs Damage, then I lose 6 HPs.
I take 5.9999999 HPs Damage, then I lose 5 HPs.
I take 5.5 HPs Damage, then I lose 5 HPs.


Someone might know the reason?
__________________
My Plugins
SPCode


Steam: hexer504
Telegram: Hexah
Discord: Hexah#6903

If you like my work you can donate here!

Last edited by Papero; 05-07-2018 at 17:03.
Papero is offline
Fyren
FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren FyrenFyrenFyrenFyrenFyren
Join Date: Feb 2106
Old 05-07-2018 , 20:00   Re: [CS:GO] Determining if a player dies from a damage event
Reply With Quote #4

Floats don't have infinite space, so it's always going to have to pick the nearest representable value. If you keep adding 9s like that, eventually that value is going to be the next whole number. For the game you tested on, it looks like it's just truncating the damage. But not every game is necessarily going to act the same.
Fyren 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 04:55.


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