Access to original health/current lifetime
Posted: Fri Mar 13, 2020 12:57 pm
I realize something similar has already been asked before, and has been rejected because the requested event would be triggered too often. Perhaps it could get implemented with a small modification to an existing event, instead of an entirely new event?
The problem is that it's currently not possible to get the health of an entity before damage was applied. If you want to prevent an entity from damage by friendly fire, the naive way of doing it is to add final_damage_amount back to entity.health in on_entity_damaged. This won't work as expected because at the moment, entity.health can not be smaller than 0:
Having an additional property like "lifetime" or "remaining_lifetime" would help a lot! Is there any chance we could get access to current health/lifetime of an entity, please?
The problem is that it's currently not possible to get the health of an entity before damage was applied. If you want to prevent an entity from damage by friendly fire, the naive way of doing it is to add final_damage_amount back to entity.health in on_entity_damaged. This won't work as expected because at the moment, entity.health can not be smaller than 0:
It would be great if something like "entity.health_before_damage" or "entity.original_health" could be added to on_entity_damaged. Alternatively, it would help if health could be less than 0 in general -- which would imply changinghealth :: float [Read-Write]
Health of the entity. Setting health to less than 0 will set health to 0, entities with 0 health can not be attacked. Setting health to higher than max health will set health to max health.
toentities with 0 health can not be attacked
I'd also like to have something similar for entities that have lifetime/time_to_live instead of health. My particular use case for this is the issue with invisible fires. I want to create a dummy if a fire is detected. This dummy should be removed again when the fire has expired. Fire detection runs in regular intervals, so it may happen that a fire has been created just after a search for fire is completed. On the next check, part of the fire's lifetime will already have passed, but currently there is no way to know on which tick the fire has been created or how much of its lifetime is left (so if my dummy's TTL is set to fire.maximum_lifetime, it will be removed only some time after the fire has expired). All the prototype provides are these properties:entities with health < 0 can not be attacked
Code: Select all
initial_lifetime :: uint32 (optional)
lifetime_increase_by :: uint32 (optional)
lifetime_increase_cooldown :: uint32 (optional)
maximum_lifetime :: uint32 (optional)