damage an entity
LadyCailin opened this issue ยท 5 comments
CMDHELPER-2652 - Reported by Hekta on 2013-04-17 13:58:13 UTC
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 on 2013-04-17 22:56:33 UTC
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 PseudoKnight on 2014-07-18 21:30:31 UTC
damage_entity() has been added for a while and the source parameter was added in build 2709. Can be closed.
Comment by Hekta on 2013-04-22 01:29:42 UTC
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 on 2013-04-22 04:02:06 UTC
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 on 2013-04-23 10:35:10 UTC
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'.