on_entity_healed event

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
Svip
Long Handed Inserter
Long Handed Inserter
Posts: 88
Joined: Sun Apr 29, 2018 6:19 am
Contact:

on_entity_healed event

Post by Svip »

This is a request follow up to this thread.

Essentially, there is no way to hook in properly to when an entity is healed. The events that might appear related are "on_entity_damaged", "on_player_used_capsule" and "on_player_repaired_entity", but they are all imperfect to be used here.

Healing is not the same as repairing (although you could make that argument), but since modders do not expect that event to happen when the character is healed, it might break some mods. The same goes for "on_entity_damaged" which might confuse some mods, if it is called for negative damage. "on_player_used_capsule" feels more like a hack than a proper solution, besides, it doesn't inform one what the character was healed by.

Therefore I propose a new event, "on_entity_healed" that is otherwise identical to "on_entity_damaged" and occurs when there is negative damage. Indeed, I'd argue that it should contain the exact same parameters, and that "original_damage_amount" and "final_damage_amount" should remain, but negative, so it would be essentially a drop-in replacement for code already dealing with the "on_entity_damaged" scenario.

Of course, regardless of how it may be implemented, there is currently no way to hook into when the character gets healed, and that would be lovely to have. As an aside, I think the note for "on_entity_damaged" should mention that it doesn't fire when negative damage occurs (i.e. healing).

Edit: I'd like it to fire for each instance of healing, so if you have the following implementation:

Code: Select all

action_delivery =
{
	type = "instant",
	target_effects =
	{
		type = "damage",
		damage = {type = "natural", amount = -10}
	},
	{
		type = "damage",
		damage = {type = "fire", amount = -20}
	}
}
There should be two events, once for "natural" and once for "fire".

Post Reply

Return to “Modding interface requests”