
damage an entity
LadyCailinBot opened this issue ยท 5 comments
CMDHELPER-2652 - Reported by Hekta
Would it be possible to add a function like damage(amount, entityID_of_victim, [entityID_of_damager]) to deal damage to an entity ?
Comment by PseudoKnight
This is what set_entity_health() does, except it doesn't trigger an entity_damage event. That would the trigger() domain, which is waiting to be fixed.
Comment by Hekta
Ok thanks.
For exemple, using trigger() will it provoke an attack by the victim to the damager or set the killer if damager is a player ?
Comment by PseudoKnight
You'd be able to trigger (almost?) any event with data you provide (cause, damager, etc). But it hasn't worked in a long while (if ever).
Comment by Tom.Gebbett
i've never seen trigger work, but the principle is that you define the event type and the event object, and then the binds pick that up as if the event had been triggered naturally.
You can of course build in a (health = (health - damage)) function for both any entity with health, there are various ways to do this. set/get_entity_health() uses a percentage, and you can work out what the maximum is with get_max_health().
You can combine this function with an entity_play_effect() call for 'hurt'.