Add previous_health attribute to on_entity_damaged

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
User avatar
Muppet9010
Long Handed Inserter
Long Handed Inserter
Posts: 66
Joined: Sat Dec 09, 2017 6:01 pm

Add previous_health attribute to on_entity_damaged

Post by Muppet9010 » Thu Nov 08, 2018 7:18 pm

Could a previous_health attribute be added to the on_entity_damaged event. It would have the entities health prior to the damage that the event is reporting.

The reason I ask is I have made a mod to avoid train deaths. While in low damage cases I can react to the damage and return the character's health to be equal to post damage health + damage done. In high damage cases, this leads to the player being returned to full health regardless of their previous health.


Low Damage Example:
  1. character health = 50
  2. character damaged for 20 damage
  3. character health = 30
  4. damage event is triggered with: final_damage_amount = 20
  5. mod reacts to event with: character health = current health + final damage done (30 + 20)
  6. character health restored back to 50 - all fine

High Damage Example:
  1. character health = 50
  2. character damaged for 1000 damage
  3. character health = 0
  4. damage event is triggered with: final_damage_amount = 1000
  5. mod reacts to event with: current health + final damage done (0 + 1000)
  6. character health restored to above pre-damage - this is what I hope the attribute will allow me to avoid

Post Reply

Return to “Modding interface requests”