diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-09 17:32:40 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2021-06-09 17:32:40 +0200 |
commit | 70374f3ca40208261ae728c12cdf91e8506ff578 (patch) | |
tree | a18db863d8b0405811aab1c17b8cb68b0123a500 | |
parent | 7c11cb66608d5e335a19820e3392d6a7016cf7ce (diff) | |
download | dungeon_game-70374f3ca40208261ae728c12cdf91e8506ff578.tar.xz |
Only call on_death callback if entity was alive before
-rw-r--r-- | plugins/game/game.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/plugins/game/game.c b/plugins/game/game.c index b283214..74892c8 100644 --- a/plugins/game/game.c +++ b/plugins/game/game.c @@ -111,11 +111,13 @@ void spawn(struct entity def, int x, int y) void add_health(struct entity *entity, int health) { + bool was_alive = entity->health > 0; + entity->health += health; if (entity->health > entity->max_health) entity->health = entity->max_health; - else if (entity->health <= 0 && entity->on_death) + else if (entity->health <= 0 && was_alive && entity->on_death) entity->on_death(entity); } |