Reduce cap ship health when component is destroyed.
This commit is contained in:
parent
6441f926e2
commit
22afef45c7
|
@ -65,10 +65,13 @@ static void componentDie(void)
|
||||||
self->alive = ALIVE_DEAD;
|
self->alive = ALIVE_DEAD;
|
||||||
addSmallExplosion();
|
addSmallExplosion();
|
||||||
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
|
||||||
|
|
||||||
|
self->owner->health--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void die(void)
|
static void die(void)
|
||||||
{
|
{
|
||||||
|
self->alive = ALIVE_DEAD;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadCapitalShipDefs(void)
|
void loadCapitalShipDefs(void)
|
||||||
|
@ -135,6 +138,8 @@ static void loadComponents(Entity *parent, cJSON *components)
|
||||||
Entity *e;
|
Entity *e;
|
||||||
cJSON *component;
|
cJSON *component;
|
||||||
|
|
||||||
|
parent->health = 0;
|
||||||
|
|
||||||
if (components)
|
if (components)
|
||||||
{
|
{
|
||||||
component = components->child;
|
component = components->child;
|
||||||
|
@ -166,6 +171,8 @@ static void loadComponents(Entity *parent, cJSON *components)
|
||||||
e->die = componentDie;
|
e->die = componentDie;
|
||||||
|
|
||||||
component = component->next;
|
component = component->next;
|
||||||
|
|
||||||
|
parent->health++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue