From 70374f3ca40208261ae728c12cdf91e8506ff578 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Wed, 9 Jun 2021 17:32:40 +0200 Subject: [PATCH] Only call on_death callback if entity was alive before --- plugins/game/game.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.44.0