Disable capital ship by destroying engines and guns. AI_IGNORE will apply only to main components.

This commit is contained in:
Steve 2016-05-03 11:28:17 +01:00
parent 12c5671da0
commit 35120f73c3
2 changed files with 30 additions and 7 deletions

View File

@ -33,6 +33,7 @@ static void loadCapitalShipDef(char *filename);
static void loadComponents(Entity *parent, cJSON *components); static void loadComponents(Entity *parent, cJSON *components);
static void loadGuns(Entity *parent, cJSON *guns); static void loadGuns(Entity *parent, cJSON *guns);
static void loadEngines(Entity *parent, cJSON *engines); static void loadEngines(Entity *parent, cJSON *engines);
static void disable(void);
static Entity defHead, *defTail; static Entity defHead, *defTail;
@ -275,7 +276,7 @@ static void gunDie(void)
if (--self->owner->systemPower == 1) 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) 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) void loadCapitalShipDefs(void)
{ {
char **filenames; char **filenames;
@ -593,10 +613,16 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags)
{ {
if (e->owner == parent) if (e->owner == parent)
{ {
if (flags != -1)
{
e->flags |= flags;
}
switch (e->type) switch (e->type)
{ {
case ET_COMPONENT_ENGINE: case ET_COMPONENT_ENGINE:
sprintf(e->name, _("%s (Engine)"), parent->name); sprintf(e->name, _("%s (Engine)"), parent->name);
e->flags &= ~EF_AI_IGNORE;
break; break;
case ET_COMPONENT: case ET_COMPONENT:
@ -605,15 +631,11 @@ void updateCapitalShipComponentProperties(Entity *parent, long flags)
case ET_COMPONENT_GUN: case ET_COMPONENT_GUN:
sprintf(e->name, _("%s (Gun)"), parent->name); sprintf(e->name, _("%s (Gun)"), parent->name);
e->flags &= ~EF_AI_IGNORE;
break; break;
} }
e->active = parent->active; e->active = parent->active;
if (flags != -1)
{
e->flags |= flags;
}
} }
} }
} }

View File

@ -66,6 +66,7 @@ void initLookups(void)
addLookup("EF_NO_KILL_INC", EF_NO_KILL_INC); addLookup("EF_NO_KILL_INC", EF_NO_KILL_INC);
addLookup("EF_NO_MT_BOX", EF_NO_MT_BOX); addLookup("EF_NO_MT_BOX", EF_NO_MT_BOX);
addLookup("EF_FRIENDLY_HEALTH_BAR", EF_FRIENDLY_HEALTH_BAR); addLookup("EF_FRIENDLY_HEALTH_BAR", EF_FRIENDLY_HEALTH_BAR);
addLookup("EF_AI_IGNORE", EF_AI_IGNORE);
addLookup("AIF_NONE", AIF_NONE); addLookup("AIF_NONE", AIF_NONE);
addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER); addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER);