[Lua] Event on_pre_entity_damaged
Posted: Wed Apr 17, 2019 8:09 pm
TL;DR;
Add an lua event before the entity damage is done, so it can be altered.
What:
On the moment an entity receives damage the on_entity_damaged is fired. This is after the damage is applied so no way to alter/modify it during this event. Also because there is no way to receive the health of the entity before the damage is applied it is hard to calculate the actual damage done or alter the amount of damage when it hits zero. Since the health property doesn't allow values below 0.
So if we can have an event that is fired before the damage is applied and we have the possibility to alter the damage amount (optional), we can alter the health or damage properly.
For example during the night you get a 50% bonus damage increase. Currently this is impossible because we cannot alter the actual damage done/received.
The name could be something like on_pre_entity_damaged, but that depends on your naming standards
One of the problems with the on_entity_damaged event is that original_damage_amount and final_damage_amount is always the same when having no research/armour. i would expect this to differ depending on the resistances and/or settings value. This might also be a bug.
p.s. this is al tested with throwing grenades on oneself
Edit: We also noticed these values are 0 as long as you have an active/charged shield. Is it possible to fire this event before the shield damage is done?
Why:
So mods can have more freedom in the amount of damage given/received on certain times or create temporary damage (de)buffs.
Add an lua event before the entity damage is done, so it can be altered.
What:
On the moment an entity receives damage the on_entity_damaged is fired. This is after the damage is applied so no way to alter/modify it during this event. Also because there is no way to receive the health of the entity before the damage is applied it is hard to calculate the actual damage done or alter the amount of damage when it hits zero. Since the health property doesn't allow values below 0.
So if we can have an event that is fired before the damage is applied and we have the possibility to alter the damage amount (optional), we can alter the health or damage properly.
For example during the night you get a 50% bonus damage increase. Currently this is impossible because we cannot alter the actual damage done/received.
The name could be something like on_pre_entity_damaged, but that depends on your naming standards
One of the problems with the on_entity_damaged event is that original_damage_amount and final_damage_amount is always the same when having no research/armour. i would expect this to differ depending on the resistances and/or settings value. This might also be a bug.
p.s. this is al tested with throwing grenades on oneself
Edit: We also noticed these values are 0 as long as you have an active/charged shield. Is it possible to fire this event before the shield damage is done?
Why:
So mods can have more freedom in the amount of damage given/received on certain times or create temporary damage (de)buffs.