Page 1 of 1
[0.17.31] Lua events.on_entity_damaged does not trigger when energy shield takes damage
Posted: Sun Apr 14, 2019 12:43 pm
by Ultros
As per the documentation
https://lua-api.factorio.com/latest/events.html ,it does not trigger when health is directly set as opposed to being damaged, however no event appears to fire when the player is shielded and damaged normally.
It would be better for the event to fire (with the entity being damaged counting as the player's shields) instead.
The mod used to generate the damage text (and which relies on that call) is
viewtopic.php?p=367915#p367915, which I updated for 0.17 and posted here
viewtopic.php?p=422035#p422035
Re: [0.17.31] Lua events.on_entity_damaged does not trigger when energy shield takes damage
Posted: Sun Apr 14, 2019 6:02 pm
by Rseding91
Thanks for the report. That's working as intended: if the entity doesn't take damage (because the shield absorbed it) then it didn't take damage.
Re: [0.17.31] Lua events.on_entity_damaged does not trigger when energy shield takes damage
Posted: Sun Apr 14, 2019 11:24 pm
by Ultros
Rseding91 wrote: Sun Apr 14, 2019 6:02 pm
Thanks for the report. That's working as intended: if the entity doesn't take damage (because the shield absorbed it) then it didn't take damage.
While it is true that the player entity did not take damage to its own hitpoints, the damage still occurred to an entity, in this case, the shield. It would significantly impair the usefulness of the event if damage to the shield does not trigger the event, as it will prevent the player from seeing the data even though the damage data is calculated as per normal.
Re: [0.17.31] Lua events.on_entity_damaged does not trigger when energy shield takes damage
Posted: Sun Apr 14, 2019 11:29 pm
by Bilka
Ultros wrote: Sun Apr 14, 2019 11:24 pm
the damage still occurred to an entity, in this case, the shield.
The shield is not an entity.
It would significantly impair the usefulness of the event if damage to the shield does not trigger the event, as it will prevent the player from seeing the data even though the damage data is calculated as per normal.
No entity got damaged, the on entity damaged event should not fire. Perhaps it would be useful for another event to be raised and you are free to suggest that in the modding interface requests - but on entity damaged will not cover something unrelated.
Re: [0.17.31] Lua events.on_entity_damaged does not trigger when energy shield takes damage
Posted: Sun Apr 14, 2019 11:39 pm
by Ultros
Bilka wrote: Sun Apr 14, 2019 11:29 pm
The shield is not an entity.
This actually explains a lot, if the shield was implemented as a check on damage of the player and not as an independent entity, then that would explain why the shield does not trigger the event.
Thanks for the clarification.