AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   [CS:GO] Determining if a player dies from a damage event (https://forums.alliedmods.net/showthread.php?t=307358)

popey456963 05-06-2018 18:09

[CS:GO] Determining if a player dies from a damage event
 
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?

Fyren 05-06-2018 20:03

Re: [CS:GO] Determining if a player dies from a damage event
 
You could use SDKHooks to modify the damage and find out.

Papero 05-07-2018 17:00

Re: [CS:GO] Determining if a player dies from a damage event
 
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?

Fyren 05-07-2018 20:00

Re: [CS:GO] Determining if a player dies from a damage event
 
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.


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

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