Page 1 of 1

[1.1.80] Incorrect number of shots needed to destroy entities

Posted: Mon Jul 03, 2023 4:18 am
by xfret
This is such a small thing but I thought I'd report it anyways. I shot a wooden chest (exactly 100 health) with a pistol shooting firearm magazines (exactly 5 damage). It took 21 shots to destroy. Setting the chest to 10 health in editor mode takes 3 shots to destroy, but setting it to 5 health takes only 1. I would expect more consistency (either allowing entities to be at zero health or not) if this is possible.

Re: [1.1.80] Incorrect number of shots needed to destroy entities

Posted: Mon Jul 03, 2023 10:59 am
by boskid
I am really not sure how important is this to be fixed, i could add an epsilon on the health condition to make entity die if the health drops below 0.01 or some other small number. Right now entity only dies when the health drops exactly to a value of 0 while being damaged and the behavior you see is caused by the floating point math imprecision: in the game state, EntityWithHealth does not hold a health value, but a health ratio which changes between 0.0f and 1.0f. Whenever a health value is requested a healthRatio is multiplied by a maxHealth from the prototype. In this case when a wooden chest is being damaged from 65 HP down to 60 HP, the health ratio becomes equal to 0.600000024 which causes entity to have 60.0000038 HP. From this point you need to shoot one extra time to make its health drop to 0.

Re: [1.1.80] Incorrect number of shots needed to destroy entities

Posted: Tue Jul 04, 2023 7:41 pm
by xfret
Probably not important yeah. But do I get to at least say I found a bug? :D