]> git.lizzy.rs Git - dungeon_game.git/blobdiff - plugins/game/game.c
Only call on_death callback if entity was alive before
[dungeon_game.git] / plugins / game / game.c
index b2832147087e1d2ae0b53912bb62fe68de6e6e2b..74892c81f0c64f92166f6ae5a49e8d1b36896a70 100644 (file)
@@ -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);
 }