diff --git a/data/missions/coyote/03 - coyote assault #3.json b/data/missions/coyote/03 - coyote assault #3.json index 1d71700..74e6198 100644 --- a/data/missions/coyote/03 - coyote assault #3.json +++ b/data/missions/coyote/03 - coyote assault #3.json @@ -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" ] } diff --git a/data/missions/granada/02 - suspect packages #2.json b/data/missions/granada/02 - suspect packages #2.json index 8c83f4e..2f76c94 100644 --- a/data/missions/granada/02 - suspect packages #2.json +++ b/data/missions/granada/02 - suspect packages #2.json @@ -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", diff --git a/data/missions/rothan/02 - rothan defence #2.json b/data/missions/rothan/02 - rothan defence #2.json index 2960b49..42b580d 100644 --- a/data/missions/rothan/02 - rothan defence #2.json +++ b/data/missions/rothan/02 - rothan defence #2.json @@ -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" ] diff --git a/src/battle/hud.c b/src/battle/hud.c index 85eda92..eca800b 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -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); diff --git a/src/battle/hud.h b/src/battle/hud.h index 832fc6e..b67c9b8 100644 --- a/src/battle/hud.h +++ b/src/battle/hud.h @@ -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; diff --git a/src/battle/jumpgate.c b/src/battle/jumpgate.c index 5dec983..64c6365 100644 --- a/src/battle/jumpgate.c +++ b/src/battle/jumpgate.c @@ -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); } diff --git a/src/battle/script.c b/src/battle/script.c index 73e195c..91b58c4 100644 --- a/src/battle/script.c +++ b/src/battle/script.c @@ -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) { diff --git a/src/battle/script.h b/src/battle/script.h index 2f05ea9..b2c98c1 100644 --- a/src/battle/script.h +++ b/src/battle/script.h @@ -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; diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 6529aaa..1f5150c 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -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); }