Capital ships: scatter debris when components destroyed. Run scripts upon certain events.
This commit is contained in:
parent
743786efb8
commit
260ada68c8
|
@ -214,8 +214,14 @@ 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);
|
||||||
|
addDebris(self->x, self->y, rand() % 4);
|
||||||
|
|
||||||
self->owner->health--;
|
self->owner->health--;
|
||||||
|
|
||||||
|
if (self->owner->health > 0)
|
||||||
|
{
|
||||||
|
runScriptFunction("CAP_HEALTH %s %d", self->owner->name, self->owner->health);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gunDie(void)
|
static void gunDie(void)
|
||||||
|
@ -223,6 +229,7 @@ static void gunDie(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);
|
||||||
|
addDebris(self->x, self->y, rand() % 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void engineThink(void)
|
static void engineThink(void)
|
||||||
|
@ -237,6 +244,7 @@ static void engineDie(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);
|
||||||
|
addDebris(self->x, self->y, 4 + rand() % 9);
|
||||||
|
|
||||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
{
|
{
|
||||||
|
@ -247,9 +255,14 @@ static void engineDie(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* no more engines - stop moving */
|
/* no more engines - stop moving */
|
||||||
|
if (self->owner->health > 0)
|
||||||
|
{
|
||||||
self->owner->speed = 0;
|
self->owner->speed = 0;
|
||||||
self->owner->action = NULL;
|
self->owner->action = NULL;
|
||||||
self->owner->dx = self->owner->dy = 0;
|
self->owner->dx = self->owner->dy = 0;
|
||||||
|
|
||||||
|
runScriptFunction("CAP_ENGINES_DESTROYED %s", self->owner->name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void die(void)
|
static void die(void)
|
||||||
|
@ -258,6 +271,8 @@ static void die(void)
|
||||||
|
|
||||||
self->alive = ALIVE_DEAD;
|
self->alive = ALIVE_DEAD;
|
||||||
|
|
||||||
|
addDebris(self->x, self->y, 50);
|
||||||
|
|
||||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
{
|
{
|
||||||
if (e->owner == self)
|
if (e->owner == self)
|
||||||
|
|
|
@ -41,6 +41,8 @@ extern void applyFighterThrust(void);
|
||||||
extern void addLargeEngineEffect(void);
|
extern void addLargeEngineEffect(void);
|
||||||
extern int getDistance(int x1, int y1, int x2, int y2);
|
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 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 Battle battle;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
|
|
Loading…
Reference in New Issue