Use EF_DISABLED for jumpgates, rather than systemPower.

This commit is contained in:
Steve 2016-03-12 12:35:05 +00:00
parent 5d38abcbeb
commit 71b0a00689
9 changed files with 57 additions and 24 deletions

View File

@ -74,7 +74,7 @@
"type" : "ET_JUMPGATE",
"x" : 25,
"y" : 25,
"systemPower" : 0
"flags" : "+EF_DISABLED"
}
],
"script" : [
@ -99,7 +99,7 @@
"MSG_BOX Dodds;Estelle, we've got this. We can take them.",
"MSG_BOX de Winter;We're taking too many losses, Dodds. Fall back now, that's an order.",
"WAIT_MSG_BOX",
"ACTIVATE_JUMPGATE",
"ACTIVATE_JUMPGATE 1",
"RETREAT_ALLIES"
]
}

View File

@ -110,7 +110,7 @@
"type" : "ET_JUMPGATE",
"x" : 10,
"y" : 8,
"systemPower" : 0
"flags" : "+EF_DISABLED"
}
],
"items" : [
@ -159,7 +159,7 @@
"WAIT 2",
"MSG_BOX Tug;Tow cable attached. Ready to head home.",
"MSG_BOX Carr;We're done here. Let's bring our mystery guest in.",
"ACTIVATE_JUMPGATE",
"ACTIVATE_JUMPGATE 1",
"WAIT 20",
"ACTIVATE_ENTITIES Dart",
"ACTIVATE_OBJECTIVES Destroy intercepting Darts",

View File

@ -101,7 +101,7 @@
"type" : "ET_JUMPGATE",
"x" : 30,
"y" : 1,
"systemPower" : 0
"flags" : "+EF_DISABLED"
}
],
"script" : [
@ -146,7 +146,7 @@
"MSG_BOX Control;Commander, your current missions has been aborted. Return to the jumpgate. We need a full report as to what just happened out there.",
"MSG_BOX Spencer;Got it, coming home.",
"WAIT_MSG_BOX",
"ACTIVATE_JUMPGATE",
"ACTIVATE_JUMPGATE 1",
"ACTIVATE_OBJECTIVES Retreat to jumpgate",
"RETREAT_ALLIES"
]

View File

@ -330,7 +330,7 @@ static void drawPlayerTargeter(void)
float angle;
int x, y;
if (player->target || battle.missionTarget || (battle.jumpgate && battle.jumpgate->systemPower))
if (player->target || battle.missionTarget || jumpgateEnabled())
{
if (player->target)
{
@ -376,7 +376,7 @@ static void drawPlayerTargeter(void)
blitRotated(targetPointer, x - battle.camera.x, y - battle.camera.y, angle);
}
if (battle.jumpgate && battle.jumpgate->systemPower)
if (jumpgateEnabled())
{
angle = getAngle(player->x, player->y, battle.jumpgate->x, battle.jumpgate->y);
x = player->x;
@ -478,7 +478,7 @@ static void drawDistancesInfo(void)
y += 25;
}
if (battle.jumpgate && battle.jumpgate->systemPower)
if (jumpgateEnabled())
{
distance = distanceToKM(player->x, player->y, battle.jumpgate->x, battle.jumpgate->y);

View File

@ -34,6 +34,7 @@ extern int getPercent(float current, float total);
extern int playerHasGun(int type);
extern char *getTranslatedString(char *string);
extern char *timeToString(long millis, int showHours);
extern int jumpgateEnabled(void);
extern App app;
extern Battle battle;

View File

@ -45,6 +45,26 @@ Entity *spawnJumpgate(void)
return jumpgate;
}
int jumpgateEnabled(void)
{
return (battle.jumpgate && (!(battle.jumpgate->flags & EF_DISABLED)));
}
void activateJumpgate(int activate)
{
if (battle.jumpgate)
{
if (activate)
{
battle.jumpgate->flags &= ~EF_DISABLED;
}
else
{
battle.jumpgate->flags |= EF_DISABLED;
}
}
}
static void think(void)
{
self->thinkTime = 4;
@ -55,7 +75,7 @@ static void think(void)
self->angle -= 360;
}
if (self->systemPower)
if (jumpgateEnabled())
{
handleFleeingEntities();
}
@ -128,7 +148,7 @@ static void addEscapeEffect(Entity *ent)
static void draw(void)
{
if (self->systemPower)
if (jumpgateEnabled())
{
blitRotated(portal, self->x - battle.camera.x, self->y - battle.camera.y, portalAngle);
}

View File

@ -211,7 +211,8 @@ static void executeNextLine(ScriptRunner *runner)
}
else if (strcmp(command, "ACTIVATE_JUMPGATE") == 0)
{
battle.jumpgate->systemPower = MAX_SYSTEM_POWER;
sscanf(line, "%*s %d", &intParam[0]);
activateJumpgate(intParam[0]);
}
else if (strcmp(command, "ACTIVATE_NEXT_WAYPOINT") == 0)
{

View File

@ -36,6 +36,7 @@ extern int showingMessageBoxes(void);
extern char *getTranslatedString(char *string);
extern void spawnScriptFighter(char *fighters, char *side, int num, char *location);
extern void activateNextWaypoint(int id);
extern void activateJumpgate(int activate);
extern Battle battle;
extern Colors colors;

View File

@ -374,7 +374,7 @@ static void loadFighters(cJSON *node)
Entity *e;
char **types, *name, *groupName, *type;
int side, scatter, number, active;
int i, numTypes, addFlags, addAIFlags, systemPower;
int i, numTypes, addFlags, addAIFlags;
long flags, aiFlags;
float x, y;
@ -398,7 +398,6 @@ static void loadFighters(cJSON *node)
number = getJSONValue(node, "number", 1);
scatter = getJSONValue(node, "scatter", 1);
active = getJSONValue(node, "active", 1);
systemPower = getJSONValue(node, "systemPower", MAX_SYSTEM_POWER);
if (cJSON_GetObjectItem(node, "flags"))
{
@ -461,12 +460,6 @@ static void loadFighters(cJSON *node)
{
STRNCPY(e->groupName, groupName, MAX_NAME_LENGTH);
}
e->systemPower = systemPower;
if (!e->systemPower)
{
e->flags |= EF_DISABLED;
}
}
node = node->next;
@ -572,8 +565,9 @@ static void loadEntities(cJSON *node)
{
Entity *e;
char *name, *groupName;
int i, type, scatter, number, active, systemPower;
int i, type, scatter, number, active, addFlags;
float x, y;
long flags;
if (node)
{
@ -593,7 +587,11 @@ static void loadEntities(cJSON *node)
number = getJSONValue(node, "number", 1);
active = getJSONValue(node, "active", 1);
scatter = getJSONValue(node, "scatter", 1);
systemPower = getJSONValue(node, "systemPower", MAX_SYSTEM_POWER);
if (cJSON_GetObjectItem(node, "flags"))
{
flags = flagsToLong(cJSON_GetObjectItem(node, "flags")->valuestring, &addFlags);
}
for (i = 0 ; i < number ; i++)
{
@ -622,6 +620,20 @@ static void loadEntities(cJSON *node)
{
STRNCPY(e->groupName, groupName, MAX_NAME_LENGTH);
}
if (flags != -1)
{
if (addFlags)
{
e->flags |= flags;
}
else
{
e->flags = flags;
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_WARN, "Flags for '%s' (%s) replaced", e->name, e->defName);
}
}
e->x = x;
e->y = y;
@ -634,8 +646,6 @@ static void loadEntities(cJSON *node)
e->active = active;
e->systemPower = systemPower;
SDL_QueryTexture(e->texture, NULL, NULL, &e->w, &e->h);
}