Capital ships: scatter debris when components destroyed. Run scripts upon certain events.

This commit is contained in:
Steve 2015-12-13 17:54:57 +00:00
parent 743786efb8
commit 260ada68c8
2 changed files with 20 additions and 3 deletions

View File

@ -214,8 +214,14 @@ static void componentDie(void)
self->alive = ALIVE_DEAD;
addSmallExplosion();
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
addDebris(self->x, self->y, rand() % 4);
self->owner->health--;
if (self->owner->health > 0)
{
runScriptFunction("CAP_HEALTH %s %d", self->owner->name, self->owner->health);
}
}
static void gunDie(void)
@ -223,6 +229,7 @@ static void gunDie(void)
self->alive = ALIVE_DEAD;
addSmallExplosion();
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
addDebris(self->x, self->y, rand() % 4);
}
static void engineThink(void)
@ -237,6 +244,7 @@ static void engineDie(void)
self->alive = ALIVE_DEAD;
addSmallExplosion();
playBattleSound(SND_EXPLOSION_1 + rand() % 4, self->x, self->y);
addDebris(self->x, self->y, 4 + rand() % 9);
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
@ -247,9 +255,14 @@ static void engineDie(void)
}
/* no more engines - stop moving */
if (self->owner->health > 0)
{
self->owner->speed = 0;
self->owner->action = NULL;
self->owner->dx = self->owner->dy = 0;
runScriptFunction("CAP_ENGINES_DESTROYED %s", self->owner->name);
}
}
static void die(void)
@ -258,6 +271,8 @@ static void die(void)
self->alive = ALIVE_DEAD;
addDebris(self->x, self->y, 50);
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{
if (e->owner == self)

View File

@ -41,6 +41,8 @@ extern void applyFighterThrust(void);
extern void addLargeEngineEffect(void);
extern int getDistance(int x1, int y1, int x2, int y2);
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
extern void addDebris(int x, int y, int amount);
extern void runScriptFunction(char *format, ...);
extern Battle battle;
extern Entity *self;