From 22afef45c7fb42ddb09e07ef05fddac5c593bb7d Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 8 Dec 2015 06:43:03 +0000 Subject: [PATCH] Reduce cap ship health when component is destroyed. --- src/battle/capitalShips.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/battle/capitalShips.c b/src/battle/capitalShips.c index 13a544d..9de5047 100644 --- a/src/battle/capitalShips.c +++ b/src/battle/capitalShips.c @@ -65,10 +65,13 @@ static void componentDie(void) self->alive = ALIVE_DEAD; addSmallExplosion(); playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y); + + self->owner->health--; } static void die(void) { + self->alive = ALIVE_DEAD; } void loadCapitalShipDefs(void) @@ -135,6 +138,8 @@ static void loadComponents(Entity *parent, cJSON *components) Entity *e; cJSON *component; + parent->health = 0; + if (components) { component = components->child; @@ -166,6 +171,8 @@ static void loadComponents(Entity *parent, cJSON *components) e->die = componentDie; component = component->next; + + parent->health++; } } }