Due to api doesn't support modifying resistance or max_health parameters(locked in prototypes),
I'm relying on on_entity_damaged event. But I can't get accurate last HP before an entity die.
I have read these articles,
Add on_pre_entity_damaged event [2018] - Won't implement
viewtopic.php?f=221&t=63529
[Lua] Event on_pre_entity_damaged [2019] - Won't implement
viewtopic.php?f=221&t=69648
Access to original health/current lifetime [2020] -
viewtopic.php?p=484320#p484320
I think they are saying about similar function.
But I guess developers want to preserve current state due to performance reason.
Then how about to remove negative detection?
I think health related values have 'float' types so it can have negative values, unless you made it as some custom 'ufloat' type.
I found that event.final_health is definetly useless because it always same to event.entity.health.
I think both are always accessible. So event.final_health is useless.
But it will get meaning if it can have negative value, allowing such simple calculation always accurate :
Code: Select all
(LastHP just before damaged) = event.final_health + event.final_damage_amount
because both event.entity.health and event.final_health are 0
but event.final_damage_amount have pure damage calculated from original damage w/o health bottom limit(zero).
Which means there is no way to get entity's last health before damaged in this case.