From 35120f73c3c6c21d01f62a3c0b4cce7d14f8db96 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 3 May 2016 11:28:17 +0100 Subject: [PATCH] Disable capital ship by destroying engines and guns. AI_IGNORE will apply only to main components. --- src/battle/capitalShips.c | 36 +++++++++++++++++++++++++++++------- src/system/lookup.c | 1 + 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/battle/capitalShips.c b/src/battle/capitalShips.c index 83ab485..d3cecb9 100644 --- a/src/battle/capitalShips.c +++ b/src/battle/capitalShips.c @@ -33,6 +33,7 @@ static void loadCapitalShipDef(char *filename); static void loadComponents(Entity *parent, cJSON *components); static void loadGuns(Entity *parent, cJSON *guns); static void loadEngines(Entity *parent, cJSON *engines); +static void disable(void); static Entity defHead, *defTail; @@ -275,7 +276,7 @@ static void gunDie(void) if (--self->owner->systemPower == 1) { - runScriptFunction("CAP_HELPLESS %s", self->owner->name); + disable(); } } @@ -315,7 +316,7 @@ static void engineDie(void) if (--self->owner->systemPower == 1) { - runScriptFunction("CAP_HELPLESS %s", self->owner->name); + disable(); } } @@ -356,6 +357,25 @@ static void handleDisabled(void) } } +static void disable(void) +{ + Entity *e; + + runScriptFunction("CAP_HELPLESS %s", self->owner->name); + + for (e = battle.entityHead.next ; e != NULL ; e = e->next) + { + if (e->owner == self->owner) + { + e->systemPower = 0; + e->flags |= EF_DISABLED; + } + } + + updateObjective(self->owner->name, TT_DISABLE); + updateObjective(self->owner->groupName, TT_DISABLE); +} + void loadCapitalShipDefs(void) { char **filenames; @@ -593,10 +613,16 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags) { if (e->owner == parent) { + if (flags != -1) + { + e->flags |= flags; + } + switch (e->type) { case ET_COMPONENT_ENGINE: sprintf(e->name, _("%s (Engine)"), parent->name); + e->flags &= ~EF_AI_IGNORE; break; case ET_COMPONENT: @@ -605,15 +631,11 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags) case ET_COMPONENT_GUN: sprintf(e->name, _("%s (Gun)"), parent->name); + e->flags &= ~EF_AI_IGNORE; break; } e->active = parent->active; - - if (flags != -1) - { - e->flags |= flags; - } } } } diff --git a/src/system/lookup.c b/src/system/lookup.c index 366eecc..b2d06f0 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -66,6 +66,7 @@ void initLookups(void) addLookup("EF_NO_KILL_INC", EF_NO_KILL_INC); addLookup("EF_NO_MT_BOX", EF_NO_MT_BOX); addLookup("EF_FRIENDLY_HEALTH_BAR", EF_FRIENDLY_HEALTH_BAR); + addLookup("EF_AI_IGNORE", EF_AI_IGNORE); addLookup("AIF_NONE", AIF_NONE); addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER);