Reduce cap ship health when component is destroyed.

This commit is contained in:
Steve 2015-12-08 06:43:03 +00:00
parent 6441f926e2
commit 22afef45c7
1 changed files with 7 additions and 0 deletions

View File

@ -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++;
}
}
}