diff --git a/Makefile b/Makefile
index e329cf0..9c48232 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
CXXFLAGS ?= -O2 -Wall -g
CXXFLAGS += `pkg-config --cflags sdl2 SDL2_image SDL2_mixer`
LIBS = `pkg-config --libs sdl2 SDL2_image SDL2_mixer`
-OBJS = alien.o audio.o bullet.o cargo.o collectable.o colors.o cutscene.o engine.o event.o explosion.o game.o gfx.o info.o intermission.o missions.o player.o radio.o renderer.o resources.o save.o screen.o ship.o shop.o Starfighter.o title.o weapons.o window.o
+OBJS = alien.o audio.o bullet.o cargo.o collectable.o colors.o cutscene.o engine.o event.o explosion.o game.o gfx.o info.o intermission.o mission.o player.o radio.o renderer.o resources.o save.o screen.o ship.o shop.o Starfighter.o title.o weapons.o window.o
VERSION = 1.7-dev
PROG = starfighter
diff --git a/src/Starfighter.h b/src/Starfighter.h
index 5b6ce08..3e1a376 100644
--- a/src/Starfighter.h
+++ b/src/Starfighter.h
@@ -50,7 +50,7 @@ along with this program. If not, see .
#include "intermission.h"
#include "save.h"
#include "info.h"
-#include "missions.h"
+#include "mission.h"
#include "player.h"
#include "renderer.h"
#include "resources.h"
diff --git a/src/alien.cpp b/src/alien.cpp
index e696a0a..36dced2 100644
--- a/src/alien.cpp
+++ b/src/alien.cpp
@@ -1802,8 +1802,8 @@ void alien_destroy(object *alien, object *attacker)
}
}
- updateMissionRequirements(M_DESTROY_TARGET_TYPE, alien->classDef, 1);
- updateMissionRequirements(M_PROTECT_TARGET, alien->classDef, 1);
+ mission_updateRequirements(M_DESTROY_TARGET_TYPE, alien->classDef, 1);
+ mission_updateRequirements(M_PROTECT_TARGET, alien->classDef, 1);
if (rand() % 100 <= alien->collectChance)
{
@@ -1918,7 +1918,7 @@ void alien_hurt(object *alien, object *attacker, int damage, int ion)
if (!(alien->flags & FL_DISABLED))
{
alien->flags += FL_DISABLED;
- updateMissionRequirements(M_DISABLE_TARGET,
+ mission_updateRequirements(M_DISABLE_TARGET,
alien->classDef, 1);
}
diff --git a/src/defs.h b/src/defs.h
index 2dd46b2..d110353 100644
--- a/src/defs.h
+++ b/src/defs.h
@@ -98,6 +98,8 @@ along with this program. If not, see .
#define WF_DISABLE 1024
#define WF_TIMEDEXPLOSION 2048
+#define MT_NONE -2
+
#define MAX_CARGO 20
#define MAX_INFOLINES 3
#define MAX_EVENTS 20
diff --git a/src/game.cpp b/src/game.cpp
index 13ca9be..5ee2c0b 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -178,8 +178,8 @@ void game_init()
}
initWeapons();
- initMissions();
- initPlanetMissions(game.system);
+ mission_init();
+ intermission_initPlanets(game.system);
}
static void game_addDebris(int x, int y, int amount)
@@ -484,7 +484,7 @@ static void game_doCollectables()
break;
}
- updateMissionRequirements(M_COLLECT, collectable->type,
+ mission_updateRequirements(M_COLLECT, collectable->type,
collectable->value);
collectable->active = 0;
@@ -513,7 +513,7 @@ static void game_doCollectables()
if ((collectable->type == P_CARGO) ||
(collectable->type == P_ESCAPEPOD) ||
(collectable->type == P_SLAVES))
- updateMissionRequirements(M_PROTECT_PICKUP, collectable->type, 1);
+ mission_updateRequirements(M_PROTECT_PICKUP, collectable->type, 1);
}
if (collectable->active)
@@ -795,7 +795,7 @@ static void game_doBullets()
explosion_add(cargo[j].x + RANDRANGE(-15, 15),
cargo[j].y + RANDRANGE(-15, 15),
SP_BIG_EXPLOSION);
- updateMissionRequirements(M_PROTECT_PICKUP,
+ mission_updateRequirements(M_PROTECT_PICKUP,
P_CARGO, 1);
}
}
@@ -1020,11 +1020,11 @@ static void game_doAliens()
}
aliens[i].shield = 0;
- updateMissionRequirements(M_ESCAPE_TARGET,
+ mission_updateRequirements(M_ESCAPE_TARGET,
aliens[i].classDef, 1);
if (aliens[i].classDef != CD_CLOAKFIGHTER)
- updateMissionRequirements(M_DESTROY_TARGET_TYPE,
+ mission_updateRequirements(M_DESTROY_TARGET_TYPE,
aliens[i].classDef, 1);
}
}
@@ -1802,7 +1802,7 @@ static void game_doHud()
}
}
- if ((!allMissionsCompleted()) && (SDL_GetTicks() >= engine.counter2))
+ if ((!mission_checkCompleted()) && (SDL_GetTicks() >= engine.counter2))
{
engine.timeTaken++;
engine.counter2 = SDL_GetTicks() + 1000;
@@ -1836,7 +1836,7 @@ static void game_doHud()
if (currentMission.timeLimit2[i] > -1)
currentMission.timeLimit2[i]--;
}
- checkTimer();
+ mission_checkTimer();
events_check();
}
@@ -1849,7 +1849,7 @@ static void game_doHud()
if (currentMission.timeLimit2[i] > -1)
currentMission.timeLimit2[i]--;
}
- checkTimer();
+ mission_checkTimer();
events_check();
engine.counter = (SDL_GetTicks() + 1000);
}
@@ -2072,8 +2072,8 @@ int game_mainLoop()
{
engine_resetLists();
- setMission(game.area);
- missionBriefScreen();
+ mission_set(game.area);
+ mission_showStartScreen();
cargo_init();
initPlayer();
@@ -2249,12 +2249,12 @@ int game_mainLoop()
{
renderer_update();
- if ((allMissionsCompleted()) && (engine.missionCompleteTimer == 0))
+ if ((mission_checkCompleted()) && (engine.missionCompleteTimer == 0))
{
engine.missionCompleteTimer = SDL_GetTicks() + 4000;
}
- if ((missionFailed()) && (engine.missionCompleteTimer == 0))
+ if ((mission_checkFailed()) && (engine.missionCompleteTimer == 0))
{
if (game.area != MISN_MOEBO)
engine.missionCompleteTimer = SDL_GetTicks() + 4000;
@@ -2267,7 +2267,7 @@ int game_mainLoop()
{
if (SDL_GetTicks() >= engine.missionCompleteTimer)
{
- if ((!missionFailed()) && (game.area != MISN_VENUS))
+ if ((!mission_checkFailed()) && (game.area != MISN_VENUS))
{
leaveSector();
if ((engine.done == 2) &&
@@ -2413,10 +2413,10 @@ int game_mainLoop()
screen_flushBuffer();
- if ((player.shield > 0) && (!missionFailed()))
+ if ((player.shield > 0) && (!mission_checkFailed()))
{
if (game.area < MISN_VENUS)
- missionFinishedScreen();
+ mission_showFinishedScreen();
switch (game.area)
{
@@ -2443,7 +2443,7 @@ int game_mainLoop()
if (game.area < MISN_VENUS)
{
- updateSystemStatus();
+ intermission_updateSystemStatus();
save(0);
}
diff --git a/src/intermission.cpp b/src/intermission.cpp
index 18cc0b5..58ff4ac 100644
--- a/src/intermission.cpp
+++ b/src/intermission.cpp
@@ -19,6 +19,185 @@ along with this program. If not, see .
#include "Starfighter.h"
+// XXX: Magic number
+Planet intermission_planets[10];
+
+void intermission_initPlanets(int system)
+{
+ // XXX: Magic number
+ for (int i = 0 ; i < 10 ; i++)
+ {
+ intermission_planets[i].missionNumber = -1; // no mission for this planet
+ intermission_planets[i].missionCompleted = 1;
+ }
+
+ switch(system)
+ {
+ // Spirit
+ case SYSTEM_SPIRIT:
+ intermission_planets[PLANET_HAIL].missionNumber = MISN_HAIL;
+ intermission_planets[PLANET_HAIL].missionCompleted = 0;
+
+ intermission_planets[PLANET_CERADSE].missionNumber = MISN_CERADSE;
+ intermission_planets[PLANET_CERADSE].missionCompleted = 0;
+
+ intermission_planets[PLANET_HINSTAG].missionNumber = MISN_HINSTAG;
+ intermission_planets[PLANET_HINSTAG].missionCompleted = 0;
+
+ intermission_planets[PLANET_JOLDAR].missionNumber = MISN_JOLDAR;
+ intermission_planets[PLANET_JOLDAR].missionCompleted = 0;
+
+ intermission_planets[PLANET_MOEBO].missionNumber = MISN_MOEBO;
+ intermission_planets[PLANET_MOEBO].missionCompleted = -1;
+
+ break;
+
+ // Eyananth
+ case SYSTEM_EYANANTH:
+ intermission_planets[PLANET_NEROD].missionNumber = MISN_NEROD;
+ intermission_planets[PLANET_NEROD].missionCompleted = 0;
+
+ intermission_planets[PLANET_ALLEZ].missionNumber = MISN_ALLEZ;
+ intermission_planets[PLANET_ALLEZ].missionCompleted = 0;
+
+ intermission_planets[PLANET_URUSOR].missionNumber = MISN_URUSOR;
+ intermission_planets[PLANET_URUSOR].missionCompleted = -1;
+
+ intermission_planets[PLANET_DORIM].missionNumber = MISN_DORIM;
+ intermission_planets[PLANET_DORIM].missionCompleted = -1;
+
+ intermission_planets[PLANET_ELAMALE].missionNumber = MISN_ELAMALE;
+ intermission_planets[PLANET_ELAMALE].missionCompleted = -2;
+
+ // This one is for the slaves
+ intermission_planets[PLANET_RESCUESLAVES].missionNumber = MISN_RESCUESLAVES;
+ intermission_planets[PLANET_RESCUESLAVES].missionCompleted = 0;
+
+ break;
+
+ // Mordor
+ case SYSTEM_MORDOR:
+ intermission_planets[PLANET_ODEON].missionNumber = MISN_ODEON;
+ intermission_planets[PLANET_ODEON].missionCompleted = 0;
+
+ intermission_planets[PLANET_FELLON].missionNumber = MISN_FELLON;
+ intermission_planets[PLANET_FELLON].missionCompleted = 0;
+
+ intermission_planets[PLANET_SIVEDI].missionNumber = MISN_SIVEDI;
+ intermission_planets[PLANET_SIVEDI].missionCompleted = -1;
+
+ intermission_planets[PLANET_ALMARTHA].missionNumber = MISN_ALMARTHA;
+ intermission_planets[PLANET_ALMARTHA].missionCompleted = -1;
+
+ intermission_planets[PLANET_POSWIC].missionNumber = MISN_POSWIC;
+ intermission_planets[PLANET_POSWIC].missionCompleted = -2;
+
+ intermission_planets[PLANET_ELLESH].missionNumber = MISN_ELLESH;
+ intermission_planets[PLANET_ELLESH].missionCompleted = -3;
+
+ // This one is for the experimental fighter
+ intermission_planets[PLANET_CLOAKFIGHTER].missionNumber = MISN_CLOAKFIGHTER;
+ intermission_planets[PLANET_CLOAKFIGHTER].missionCompleted = 0;
+
+ break;
+
+ // Sol
+ case SYSTEM_SOL:
+ intermission_planets[PLANET_PLUTO].missionNumber = MISN_PLUTO;
+ intermission_planets[PLANET_PLUTO].missionCompleted = 0;
+
+ intermission_planets[PLANET_NEPTUNE].missionNumber = MISN_NEPTUNE;
+ intermission_planets[PLANET_NEPTUNE].missionCompleted = 0;
+
+ intermission_planets[PLANET_URANUS].missionNumber = MISN_URANUS;
+ intermission_planets[PLANET_URANUS].missionCompleted = 0;
+
+ intermission_planets[PLANET_SATURN].missionNumber = MISN_SATURN;
+ intermission_planets[PLANET_SATURN].missionCompleted = -1;
+
+ intermission_planets[PLANET_JUPITER].missionNumber = MISN_JUPITER;
+ intermission_planets[PLANET_JUPITER].missionCompleted = -2;
+
+ intermission_planets[PLANET_MARS].missionNumber = MISN_MARS;
+ intermission_planets[PLANET_MARS].missionCompleted = -3;
+
+ intermission_planets[PLANET_EARTH].missionNumber = MISN_EARTH;
+ intermission_planets[PLANET_EARTH].missionCompleted = -4;
+
+ intermission_planets[PLANET_VENUS].missionNumber = MISN_VENUS;
+ intermission_planets[PLANET_VENUS].missionCompleted = -5;
+
+ break;
+ }
+}
+
+void intermission_unlockPlanets()
+{
+ // XXX: Magic number
+ for (int i = 0 ; i < 10 ; i++)
+ {
+ if ((intermission_planets[i].missionCompleted == 0) && (intermission_planets[i].missionNumber != -1))
+ return;
+ }
+
+ for (int i = 0 ; i < 10 ; i++)
+ {
+ if (intermission_planets[i].missionCompleted < 0)
+ intermission_planets[i].missionCompleted++;
+ }
+}
+
+void intermission_updateSystemStatus()
+{
+ if (game.area == MISN_START)
+ {
+ game.stationedPlanet = 0;
+ game.area = 1;
+ strcpy(game.stationedName, "Hail");
+ intermission_initPlanets(game.system);
+ }
+ else if (game.area == MISN_MOEBO)
+ {
+ game.stationedPlanet = 0;
+ game.system = 1;
+ game.area = MISN_RESCUESLAVES;
+ strcpy(game.stationedName, "Nerod");
+ intermission_initPlanets(game.system);
+
+ if (game.difficulty == DIFFICULTY_ORIGINAL)
+ player.maxShield = 50;
+ }
+ else if (game.area == MISN_ELAMALE)
+ {
+ game.stationedPlanet = 0;
+ game.system = 2;
+ game.area = MISN_CLOAKFIGHTER;
+ strcpy(game.stationedName, "Odeon");
+ intermission_initPlanets(game.system);
+
+ if (game.difficulty == DIFFICULTY_ORIGINAL)
+ player.maxShield = 75;
+ }
+ else if (game.area == MISN_ELLESH)
+ {
+ game.stationedPlanet = 8;
+ game.system = 3;
+ game.area = MISN_PLUTO;
+ strcpy(game.stationedName, "Pluto");
+ intermission_initPlanets(game.system);
+
+ if (game.difficulty == DIFFICULTY_ORIGINAL)
+ player.maxShield = 100;
+ }
+ else // Update the mission for the planet
+ {
+ intermission_planets[game.stationedPlanet].missionCompleted = 1;
+ }
+
+ strcpy(game.destinationName, "None");
+ game.destinationPlanet = game.stationedPlanet;
+}
+
/*
Drives the cursor. Is used by some other screens too
*/
@@ -135,264 +314,264 @@ static void intermission_setStatusLines()
/*
Sets the names and stats of the planets within the current system.
*/
-static void intermission_setSystemPlanets()
+static void intermission_setPlanets()
{
for (int i = 0 ; i < 10 ; i++)
{
- systemPlanet[i].y = -1;
- strcpy(systemPlanet[i].name, "");
- systemPlanet[i].image = NULL;
- systemPlanet[i].messageMission = -1;
- systemPlanet[i].messageSlot = -1;
- systemPlanet[i].faceImage = -1;
- strcpy(systemPlanet[i].subject, "ERROR");
+ intermission_planets[i].y = -1;
+ strcpy(intermission_planets[i].name, "");
+ intermission_planets[i].image = NULL;
+ intermission_planets[i].messageMission = -1;
+ intermission_planets[i].messageSlot = -1;
+ intermission_planets[i].faceImage = -1;
+ strcpy(intermission_planets[i].subject, "ERROR");
}
switch (game.system)
{
case SYSTEM_SPIRIT:
- systemPlanet[PLANET_HAIL].y = 15;
- strcpy(systemPlanet[PLANET_HAIL].name, "Hail");
- systemPlanet[PLANET_HAIL].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_HAIL].y = 15;
+ strcpy(intermission_planets[PLANET_HAIL].name, "Hail");
+ intermission_planets[PLANET_HAIL].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_CERADSE].y = 30;
- strcpy(systemPlanet[PLANET_CERADSE].name, "Ceradse");
- systemPlanet[PLANET_CERADSE].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_CERADSE].y = 30;
+ strcpy(intermission_planets[PLANET_CERADSE].name, "Ceradse");
+ intermission_planets[PLANET_CERADSE].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_HINSTAG].y = 30;
- strcpy(systemPlanet[PLANET_HINSTAG].name, "Hinstag");
- systemPlanet[PLANET_HINSTAG].image = gfx_sprites[SP_PLANET_RED];
+ intermission_planets[PLANET_HINSTAG].y = 30;
+ strcpy(intermission_planets[PLANET_HINSTAG].name, "Hinstag");
+ intermission_planets[PLANET_HINSTAG].image = gfx_sprites[SP_PLANET_RED];
- systemPlanet[PLANET_JOLDAR].y = 20;
- strcpy(systemPlanet[PLANET_JOLDAR].name, "Joldar");
- systemPlanet[PLANET_JOLDAR].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_JOLDAR].y = 20;
+ strcpy(intermission_planets[PLANET_JOLDAR].name, "Joldar");
+ intermission_planets[PLANET_JOLDAR].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_MOEBO].y = 40;
- strcpy(systemPlanet[PLANET_MOEBO].name, "Moebo");
- systemPlanet[PLANET_MOEBO].image = gfx_sprites[SP_PLANET_ORANGE];
+ intermission_planets[PLANET_MOEBO].y = 40;
+ strcpy(intermission_planets[PLANET_MOEBO].name, "Moebo");
+ intermission_planets[PLANET_MOEBO].image = gfx_sprites[SP_PLANET_ORANGE];
- systemPlanet[PLANET_HAIL].messageMission = MISN_HAIL;
- systemPlanet[PLANET_HAIL].messageSlot = 0;
- systemPlanet[PLANET_HAIL].faceImage = FS_KRASS;
- strcpy(systemPlanet[PLANET_HAIL].subject, "Destroy WEAPCO training ground");
+ intermission_planets[PLANET_HAIL].messageMission = MISN_HAIL;
+ intermission_planets[PLANET_HAIL].messageSlot = 0;
+ intermission_planets[PLANET_HAIL].faceImage = FS_KRASS;
+ strcpy(intermission_planets[PLANET_HAIL].subject, "Destroy WEAPCO training ground");
- systemPlanet[PLANET_CERADSE].messageMission = MISN_CERADSE;
- systemPlanet[PLANET_CERADSE].messageSlot = 1;
- systemPlanet[PLANET_CERADSE].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_CERADSE].subject, "Collect 6 cargo pods");
+ intermission_planets[PLANET_CERADSE].messageMission = MISN_CERADSE;
+ intermission_planets[PLANET_CERADSE].messageSlot = 1;
+ intermission_planets[PLANET_CERADSE].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_CERADSE].subject, "Collect 6 cargo pods");
- systemPlanet[PLANET_HINSTAG].messageMission = MISN_HINSTAG;
- systemPlanet[PLANET_HINSTAG].messageSlot = 2;
- systemPlanet[PLANET_HINSTAG].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_HINSTAG].subject, "Destroy 5 WEAPCO missile boats");
+ intermission_planets[PLANET_HINSTAG].messageMission = MISN_HINSTAG;
+ intermission_planets[PLANET_HINSTAG].messageSlot = 2;
+ intermission_planets[PLANET_HINSTAG].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_HINSTAG].subject, "Destroy 5 WEAPCO missile boats");
- systemPlanet[PLANET_JOLDAR].messageMission = MISN_JOLDAR;
- systemPlanet[PLANET_JOLDAR].messageSlot = 3;
- systemPlanet[PLANET_JOLDAR].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_JOLDAR].subject, "Clear the mine field around Joldar");
+ intermission_planets[PLANET_JOLDAR].messageMission = MISN_JOLDAR;
+ intermission_planets[PLANET_JOLDAR].messageSlot = 3;
+ intermission_planets[PLANET_JOLDAR].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_JOLDAR].subject, "Clear the mine field around Joldar");
- systemPlanet[PLANET_MOEBO].messageMission = MISN_MOEBO;
- systemPlanet[PLANET_MOEBO].messageSlot = 0;
- systemPlanet[PLANET_MOEBO].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_MOEBO].subject, "Destroy WEAPCO frigate");
+ intermission_planets[PLANET_MOEBO].messageMission = MISN_MOEBO;
+ intermission_planets[PLANET_MOEBO].messageSlot = 0;
+ intermission_planets[PLANET_MOEBO].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_MOEBO].subject, "Destroy WEAPCO frigate");
break;
case SYSTEM_EYANANTH:
- strcpy(systemPlanet[PLANET_RESCUESLAVES].name, "WEAPCO interceptions");
+ strcpy(intermission_planets[PLANET_RESCUESLAVES].name, "WEAPCO interceptions");
- systemPlanet[PLANET_NEROD].y = 15;
- strcpy(systemPlanet[PLANET_NEROD].name, "Nerod");
- systemPlanet[PLANET_NEROD].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_NEROD].y = 15;
+ strcpy(intermission_planets[PLANET_NEROD].name, "Nerod");
+ intermission_planets[PLANET_NEROD].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_ALLEZ].y = 30;
- strcpy(systemPlanet[PLANET_ALLEZ].name, "Allez");
- systemPlanet[PLANET_ALLEZ].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_ALLEZ].y = 30;
+ strcpy(intermission_planets[PLANET_ALLEZ].name, "Allez");
+ intermission_planets[PLANET_ALLEZ].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_URUSOR].y = 30;
- strcpy(systemPlanet[PLANET_URUSOR].name, "Urusor");
- systemPlanet[PLANET_URUSOR].image = gfx_sprites[SP_PLANET_RED];
+ intermission_planets[PLANET_URUSOR].y = 30;
+ strcpy(intermission_planets[PLANET_URUSOR].name, "Urusor");
+ intermission_planets[PLANET_URUSOR].image = gfx_sprites[SP_PLANET_RED];
- systemPlanet[PLANET_DORIM].y = 20;
- strcpy(systemPlanet[PLANET_DORIM].name, "Dorim");
- systemPlanet[PLANET_DORIM].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_DORIM].y = 20;
+ strcpy(intermission_planets[PLANET_DORIM].name, "Dorim");
+ intermission_planets[PLANET_DORIM].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_ELAMALE].y = 40;
- strcpy(systemPlanet[PLANET_ELAMALE].name, "Elamale");
- systemPlanet[PLANET_ELAMALE].image = gfx_sprites[SP_PLANET_ORANGE];
+ intermission_planets[PLANET_ELAMALE].y = 40;
+ strcpy(intermission_planets[PLANET_ELAMALE].name, "Elamale");
+ intermission_planets[PLANET_ELAMALE].image = gfx_sprites[SP_PLANET_ORANGE];
- systemPlanet[PLANET_RESCUESLAVES].messageMission = MISN_RESCUESLAVES;
- systemPlanet[PLANET_RESCUESLAVES].messageSlot = 0;
- systemPlanet[PLANET_RESCUESLAVES].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_RESCUESLAVES].subject, "Rescue slaves");
+ intermission_planets[PLANET_RESCUESLAVES].messageMission = MISN_RESCUESLAVES;
+ intermission_planets[PLANET_RESCUESLAVES].messageSlot = 0;
+ intermission_planets[PLANET_RESCUESLAVES].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_RESCUESLAVES].subject, "Rescue slaves");
- systemPlanet[PLANET_NEROD].messageMission = MISN_NEROD;
- systemPlanet[PLANET_NEROD].messageSlot = 1;
- systemPlanet[PLANET_NEROD].faceImage = FS_PHOEBE;
- strcpy(systemPlanet[PLANET_NEROD].subject, "SOS");
+ intermission_planets[PLANET_NEROD].messageMission = MISN_NEROD;
+ intermission_planets[PLANET_NEROD].messageSlot = 1;
+ intermission_planets[PLANET_NEROD].faceImage = FS_PHOEBE;
+ strcpy(intermission_planets[PLANET_NEROD].subject, "SOS");
- systemPlanet[PLANET_ALLEZ].messageMission = MISN_ALLEZ;
- systemPlanet[PLANET_ALLEZ].messageSlot = 2;
- systemPlanet[PLANET_ALLEZ].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_ALLEZ].subject, "Assist medical supply craft");
+ intermission_planets[PLANET_ALLEZ].messageMission = MISN_ALLEZ;
+ intermission_planets[PLANET_ALLEZ].messageSlot = 2;
+ intermission_planets[PLANET_ALLEZ].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_ALLEZ].subject, "Assist medical supply craft");
- systemPlanet[PLANET_URUSOR].messageMission = MISN_URUSOR;
- systemPlanet[PLANET_URUSOR].messageSlot = 0;
- systemPlanet[PLANET_URUSOR].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_URUSOR].subject, "Capture five WEAPCO supply craft");
+ intermission_planets[PLANET_URUSOR].messageMission = MISN_URUSOR;
+ intermission_planets[PLANET_URUSOR].messageSlot = 0;
+ intermission_planets[PLANET_URUSOR].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_URUSOR].subject, "Capture five WEAPCO supply craft");
- systemPlanet[PLANET_DORIM].messageMission = MISN_DORIM;
- systemPlanet[PLANET_DORIM].messageSlot = 1;
- systemPlanet[PLANET_DORIM].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_DORIM].subject, "Find WEAPCO scientist");
+ intermission_planets[PLANET_DORIM].messageMission = MISN_DORIM;
+ intermission_planets[PLANET_DORIM].messageSlot = 1;
+ intermission_planets[PLANET_DORIM].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_DORIM].subject, "Find WEAPCO scientist");
- systemPlanet[PLANET_ELAMALE].messageMission = MISN_ELAMALE;
- systemPlanet[PLANET_ELAMALE].messageSlot = 0;
- systemPlanet[PLANET_ELAMALE].faceImage = FS_PHOEBE;
- strcpy(systemPlanet[PLANET_ELAMALE].subject, "Destroy WEAPCO Ore Mining craft");
+ intermission_planets[PLANET_ELAMALE].messageMission = MISN_ELAMALE;
+ intermission_planets[PLANET_ELAMALE].messageSlot = 0;
+ intermission_planets[PLANET_ELAMALE].faceImage = FS_PHOEBE;
+ strcpy(intermission_planets[PLANET_ELAMALE].subject, "Destroy WEAPCO Ore Mining craft");
break;
case SYSTEM_MORDOR:
- strcpy(systemPlanet[PLANET_CLOAKFIGHTER].name, "WEAPCO interceptions");
+ strcpy(intermission_planets[PLANET_CLOAKFIGHTER].name, "WEAPCO interceptions");
- systemPlanet[PLANET_ODEON].y = 15;
- strcpy(systemPlanet[PLANET_ODEON].name, "Odeon");
- systemPlanet[PLANET_ODEON].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_ODEON].y = 15;
+ strcpy(intermission_planets[PLANET_ODEON].name, "Odeon");
+ intermission_planets[PLANET_ODEON].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_FELLON].y = 30;
- strcpy(systemPlanet[PLANET_FELLON].name, "Fellon");
- systemPlanet[PLANET_FELLON].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_FELLON].y = 30;
+ strcpy(intermission_planets[PLANET_FELLON].name, "Fellon");
+ intermission_planets[PLANET_FELLON].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_SIVEDI].y = 30;
- strcpy(systemPlanet[PLANET_SIVEDI].name, "Sivedi");
- systemPlanet[PLANET_SIVEDI].image = gfx_sprites[SP_PLANET_RED];
+ intermission_planets[PLANET_SIVEDI].y = 30;
+ strcpy(intermission_planets[PLANET_SIVEDI].name, "Sivedi");
+ intermission_planets[PLANET_SIVEDI].image = gfx_sprites[SP_PLANET_RED];
- systemPlanet[PLANET_ALMARTHA].y = 20;
- strcpy(systemPlanet[PLANET_ALMARTHA].name, "Almartha");
- systemPlanet[PLANET_ALMARTHA].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_ALMARTHA].y = 20;
+ strcpy(intermission_planets[PLANET_ALMARTHA].name, "Almartha");
+ intermission_planets[PLANET_ALMARTHA].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_POSWIC].y = 20;
- strcpy(systemPlanet[PLANET_POSWIC].name, "Poswic");
- systemPlanet[PLANET_POSWIC].image = gfx_sprites[SP_PLANET_ORANGE];
+ intermission_planets[PLANET_POSWIC].y = 20;
+ strcpy(intermission_planets[PLANET_POSWIC].name, "Poswic");
+ intermission_planets[PLANET_POSWIC].image = gfx_sprites[SP_PLANET_ORANGE];
- systemPlanet[PLANET_ELLESH].y = 40;
- strcpy(systemPlanet[PLANET_ELLESH].name, "Ellesh");
- systemPlanet[PLANET_ELLESH].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_ELLESH].y = 40;
+ strcpy(intermission_planets[PLANET_ELLESH].name, "Ellesh");
+ intermission_planets[PLANET_ELLESH].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_CLOAKFIGHTER].messageMission = MISN_CLOAKFIGHTER;
- systemPlanet[PLANET_CLOAKFIGHTER].messageSlot = 0;
- systemPlanet[PLANET_CLOAKFIGHTER].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_CLOAKFIGHTER].subject, "Destroy experimental fighter");
+ intermission_planets[PLANET_CLOAKFIGHTER].messageMission = MISN_CLOAKFIGHTER;
+ intermission_planets[PLANET_CLOAKFIGHTER].messageSlot = 0;
+ intermission_planets[PLANET_CLOAKFIGHTER].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_CLOAKFIGHTER].subject, "Destroy experimental fighter");
- systemPlanet[PLANET_ODEON].messageMission = MISN_ODEON;
- systemPlanet[PLANET_ODEON].messageSlot = 1;
- systemPlanet[PLANET_ODEON].faceImage = FS_PHOEBE;
- strcpy(systemPlanet[PLANET_ODEON].subject, "Rescue Ursula");
+ intermission_planets[PLANET_ODEON].messageMission = MISN_ODEON;
+ intermission_planets[PLANET_ODEON].messageSlot = 1;
+ intermission_planets[PLANET_ODEON].faceImage = FS_PHOEBE;
+ strcpy(intermission_planets[PLANET_ODEON].subject, "Rescue Ursula");
- systemPlanet[PLANET_FELLON].messageMission = MISN_FELLON;
- systemPlanet[PLANET_FELLON].messageSlot = 2;
- systemPlanet[PLANET_FELLON].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_FELLON].subject, "Assist rebel forces");
+ intermission_planets[PLANET_FELLON].messageMission = MISN_FELLON;
+ intermission_planets[PLANET_FELLON].messageSlot = 2;
+ intermission_planets[PLANET_FELLON].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_FELLON].subject, "Assist rebel forces");
- systemPlanet[PLANET_SIVEDI].messageMission = MISN_SIVEDI;
- systemPlanet[PLANET_SIVEDI].messageSlot = 0;
- systemPlanet[PLANET_SIVEDI].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_SIVEDI].subject, "Mine ore from asteroid belt");
+ intermission_planets[PLANET_SIVEDI].messageMission = MISN_SIVEDI;
+ intermission_planets[PLANET_SIVEDI].messageSlot = 0;
+ intermission_planets[PLANET_SIVEDI].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_SIVEDI].subject, "Mine ore from asteroid belt");
- systemPlanet[PLANET_ALMARTHA].messageMission = MISN_ALMARTHA;
- systemPlanet[PLANET_ALMARTHA].messageSlot = 1;
- systemPlanet[PLANET_ALMARTHA].faceImage = FS_KRASS;
- strcpy(systemPlanet[PLANET_ALMARTHA].subject, "Create a diversion");
+ intermission_planets[PLANET_ALMARTHA].messageMission = MISN_ALMARTHA;
+ intermission_planets[PLANET_ALMARTHA].messageSlot = 1;
+ intermission_planets[PLANET_ALMARTHA].faceImage = FS_KRASS;
+ strcpy(intermission_planets[PLANET_ALMARTHA].subject, "Create a diversion");
- systemPlanet[PLANET_POSWIC].messageMission = MISN_POSWIC;
- systemPlanet[PLANET_POSWIC].messageSlot = 0;
- systemPlanet[PLANET_POSWIC].faceImage = FS_URSULA;
- strcpy(systemPlanet[PLANET_POSWIC].subject, "Capture WEAPCO executive transport");
+ intermission_planets[PLANET_POSWIC].messageMission = MISN_POSWIC;
+ intermission_planets[PLANET_POSWIC].messageSlot = 0;
+ intermission_planets[PLANET_POSWIC].faceImage = FS_URSULA;
+ strcpy(intermission_planets[PLANET_POSWIC].subject, "Capture WEAPCO executive transport");
- systemPlanet[PLANET_ELLESH].messageMission = MISN_ELLESH;
- systemPlanet[PLANET_ELLESH].messageSlot = 0;
- systemPlanet[PLANET_ELLESH].faceImage = FS_PHOEBE;
- strcpy(systemPlanet[PLANET_ELLESH].subject, "Destroy WEAPCO executive transport");
+ intermission_planets[PLANET_ELLESH].messageMission = MISN_ELLESH;
+ intermission_planets[PLANET_ELLESH].messageSlot = 0;
+ intermission_planets[PLANET_ELLESH].faceImage = FS_PHOEBE;
+ strcpy(intermission_planets[PLANET_ELLESH].subject, "Destroy WEAPCO executive transport");
break;
case SYSTEM_SOL:
- systemPlanet[PLANET_MERCURY].y = 15;
- strcpy(systemPlanet[PLANET_MERCURY].name, "Mercury");
- systemPlanet[PLANET_MERCURY].image = gfx_sprites[SP_PLANET_RED];
+ intermission_planets[PLANET_MERCURY].y = 15;
+ strcpy(intermission_planets[PLANET_MERCURY].name, "Mercury");
+ intermission_planets[PLANET_MERCURY].image = gfx_sprites[SP_PLANET_RED];
- systemPlanet[PLANET_VENUS].y = 20;
- strcpy(systemPlanet[PLANET_VENUS].name, "Venus");
- systemPlanet[PLANET_VENUS].image = gfx_sprites[SP_PLANET_ORANGE];
+ intermission_planets[PLANET_VENUS].y = 20;
+ strcpy(intermission_planets[PLANET_VENUS].name, "Venus");
+ intermission_planets[PLANET_VENUS].image = gfx_sprites[SP_PLANET_ORANGE];
- systemPlanet[PLANET_EARTH].y = 20;
- strcpy(systemPlanet[PLANET_EARTH].name, "Earth");
- systemPlanet[PLANET_EARTH].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_EARTH].y = 20;
+ strcpy(intermission_planets[PLANET_EARTH].name, "Earth");
+ intermission_planets[PLANET_EARTH].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_MARS].y = 20;
- strcpy(systemPlanet[PLANET_MARS].name, "Mars");
- systemPlanet[PLANET_MARS].image = gfx_sprites[SP_PLANET_RED];
+ intermission_planets[PLANET_MARS].y = 20;
+ strcpy(intermission_planets[PLANET_MARS].name, "Mars");
+ intermission_planets[PLANET_MARS].image = gfx_sprites[SP_PLANET_RED];
- systemPlanet[PLANET_JUPITER].y = 30;
- strcpy(systemPlanet[PLANET_JUPITER].name, "Jupiter");
- systemPlanet[PLANET_JUPITER].image = gfx_sprites[SP_PLANET_ORANGE];
+ intermission_planets[PLANET_JUPITER].y = 30;
+ strcpy(intermission_planets[PLANET_JUPITER].name, "Jupiter");
+ intermission_planets[PLANET_JUPITER].image = gfx_sprites[SP_PLANET_ORANGE];
- systemPlanet[PLANET_SATURN].y = 20;
- strcpy(systemPlanet[PLANET_SATURN].name, "Saturn");
- systemPlanet[PLANET_SATURN].image = gfx_sprites[SP_PLANET_GREEN];
+ intermission_planets[PLANET_SATURN].y = 20;
+ strcpy(intermission_planets[PLANET_SATURN].name, "Saturn");
+ intermission_planets[PLANET_SATURN].image = gfx_sprites[SP_PLANET_GREEN];
- systemPlanet[PLANET_URANUS].y = 20;
- strcpy(systemPlanet[PLANET_URANUS].name, "Uranus");
- systemPlanet[PLANET_URANUS].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_URANUS].y = 20;
+ strcpy(intermission_planets[PLANET_URANUS].name, "Uranus");
+ intermission_planets[PLANET_URANUS].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_NEPTUNE].y = 20;
- strcpy(systemPlanet[PLANET_NEPTUNE].name, "Neptune");
- systemPlanet[PLANET_NEPTUNE].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_NEPTUNE].y = 20;
+ strcpy(intermission_planets[PLANET_NEPTUNE].name, "Neptune");
+ intermission_planets[PLANET_NEPTUNE].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_PLUTO].y = 20;
- strcpy(systemPlanet[PLANET_PLUTO].name, "Pluto");
- systemPlanet[PLANET_PLUTO].image = gfx_sprites[SP_PLANET_BLUE];
+ intermission_planets[PLANET_PLUTO].y = 20;
+ strcpy(intermission_planets[PLANET_PLUTO].name, "Pluto");
+ intermission_planets[PLANET_PLUTO].image = gfx_sprites[SP_PLANET_BLUE];
- systemPlanet[PLANET_PLUTO].messageMission = MISN_PLUTO;
- systemPlanet[PLANET_PLUTO].messageSlot = 0;
- systemPlanet[PLANET_PLUTO].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_PLUTO].subject, "Secure Pluto");
+ intermission_planets[PLANET_PLUTO].messageMission = MISN_PLUTO;
+ intermission_planets[PLANET_PLUTO].messageSlot = 0;
+ intermission_planets[PLANET_PLUTO].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_PLUTO].subject, "Secure Pluto");
- systemPlanet[PLANET_NEPTUNE].messageMission = MISN_NEPTUNE;
- systemPlanet[PLANET_NEPTUNE].messageSlot = 1;
- systemPlanet[PLANET_NEPTUNE].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_NEPTUNE].subject, "Secure Neptune");
+ intermission_planets[PLANET_NEPTUNE].messageMission = MISN_NEPTUNE;
+ intermission_planets[PLANET_NEPTUNE].messageSlot = 1;
+ intermission_planets[PLANET_NEPTUNE].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_NEPTUNE].subject, "Secure Neptune");
- systemPlanet[PLANET_URANUS].messageMission = MISN_URANUS;
- systemPlanet[PLANET_URANUS].messageSlot = 2;
- systemPlanet[PLANET_URANUS].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_URANUS].subject, "Secure Uranus");
+ intermission_planets[PLANET_URANUS].messageMission = MISN_URANUS;
+ intermission_planets[PLANET_URANUS].messageSlot = 2;
+ intermission_planets[PLANET_URANUS].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_URANUS].subject, "Secure Uranus");
- systemPlanet[PLANET_SATURN].messageMission = MISN_SATURN;
- systemPlanet[PLANET_SATURN].messageSlot = 0;
- systemPlanet[PLANET_SATURN].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_SATURN].subject, "Destroy outer defense system");
+ intermission_planets[PLANET_SATURN].messageMission = MISN_SATURN;
+ intermission_planets[PLANET_SATURN].messageSlot = 0;
+ intermission_planets[PLANET_SATURN].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_SATURN].subject, "Destroy outer defense system");
- systemPlanet[PLANET_JUPITER].messageMission = MISN_JUPITER;
- systemPlanet[PLANET_JUPITER].messageSlot = 0;
- systemPlanet[PLANET_JUPITER].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_JUPITER].subject, "Investigate distress call");
+ intermission_planets[PLANET_JUPITER].messageMission = MISN_JUPITER;
+ intermission_planets[PLANET_JUPITER].messageSlot = 0;
+ intermission_planets[PLANET_JUPITER].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_JUPITER].subject, "Investigate distress call");
- systemPlanet[PLANET_MARS].messageMission = MISN_MARS;
- systemPlanet[PLANET_MARS].messageSlot = 0;
- systemPlanet[PLANET_MARS].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_MARS].subject, "Navigate asteroid belt");
+ intermission_planets[PLANET_MARS].messageMission = MISN_MARS;
+ intermission_planets[PLANET_MARS].messageSlot = 0;
+ intermission_planets[PLANET_MARS].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_MARS].subject, "Navigate asteroid belt");
- systemPlanet[PLANET_EARTH].messageMission = MISN_EARTH;
- systemPlanet[PLANET_EARTH].messageSlot = 0;
- systemPlanet[PLANET_EARTH].faceImage = FS_CHRIS;
- strcpy(systemPlanet[PLANET_EARTH].subject, "Take back Earth");
+ intermission_planets[PLANET_EARTH].messageMission = MISN_EARTH;
+ intermission_planets[PLANET_EARTH].messageSlot = 0;
+ intermission_planets[PLANET_EARTH].faceImage = FS_CHRIS;
+ strcpy(intermission_planets[PLANET_EARTH].subject, "Take back Earth");
- systemPlanet[PLANET_VENUS].messageMission = MISN_VENUS;
- systemPlanet[PLANET_VENUS].messageSlot = 0;
- systemPlanet[PLANET_VENUS].faceImage = FS_SID;
- strcpy(systemPlanet[PLANET_VENUS].subject, "Defeat Kline");
+ intermission_planets[PLANET_VENUS].messageMission = MISN_VENUS;
+ intermission_planets[PLANET_VENUS].messageSlot = 0;
+ intermission_planets[PLANET_VENUS].faceImage = FS_SID;
+ strcpy(intermission_planets[PLANET_VENUS].subject, "Defeat Kline");
break;
}
@@ -400,14 +579,14 @@ static void intermission_setSystemPlanets()
/*
Spins the planets around the sun, spaced according to their Y value
-as defined in intermission_setSystemPlanets(). Moving the cursor over the planet
+as defined in intermission_setPlanets(). Moving the cursor over the planet
will show their name and their current status
*/
static int intermission_showSystem(float x, float y, int selectable)
{
SDL_Rect r;
int planet = 0;
- int planetSpace = systemPlanet[planet].y;
+ int planetSpace = intermission_planets[planet].y;
int rtn = 0;
// Blit the sun
@@ -425,29 +604,29 @@ static int intermission_showSystem(float x, float y, int selectable)
r.w = 10;
r.h = 10;
- r.x -= (systemPlanet[planet].image->w / 2);
- r.y -= (systemPlanet[planet].image->h / 2);
- screen_blit(systemPlanet[planet].image, r.x, r.y);
+ r.x -= (intermission_planets[planet].image->w / 2);
+ r.y -= (intermission_planets[planet].image->h / 2);
+ screen_blit(intermission_planets[planet].image, r.x, r.y);
if (selectable &&
game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6,
- r.x, r.y, systemPlanet[planet].image->w,
- systemPlanet[planet].image->h))
+ r.x, r.y, intermission_planets[planet].image->w,
+ intermission_planets[planet].image->h))
{
- screen_renderString(systemPlanet[planet].name, -1, 545, FONT_WHITE);
+ screen_renderString(intermission_planets[planet].name, -1, 545, FONT_WHITE);
if ((engine.keyState[KEY_FIRE]))
{
game.destinationPlanet = planet;
- strcpy(game.destinationName, systemPlanet[game.destinationPlanet].name);
+ strcpy(game.destinationName, intermission_planets[game.destinationPlanet].name);
rtn = 1;
engine.keyState[KEY_FIRE] = 0;
}
}
planet++;
- if (systemPlanet[planet].y == -1)
+ if (intermission_planets[planet].y == -1)
break;
- planetSpace = systemPlanet[planet].y;
+ planetSpace = intermission_planets[planet].y;
}
return rtn;
@@ -510,7 +689,7 @@ static void intermission_updateCommsSurface(SDL_Surface *comms)
gfx_drawRect(comms, 0, 10, comms->w - 1, 55, 0x00, 0x22, 0x00);
gfx_blit(gfx_faceSprites[FS_CHRIS], 20, 15, comms);
gfx_renderString("Chris Bainfield", 80, 15, FONT_WHITE, 0, comms);
- sprintf(string, "Current Location: %s", systemPlanet[game.stationedPlanet].name);
+ sprintf(string, "Current Location: %s", intermission_planets[game.stationedPlanet].name);
gfx_renderString(string, 80, 35, FONT_WHITE, 0, comms);
}
@@ -527,13 +706,13 @@ static void intermission_createCommsSurface(SDL_Surface *comms)
// XXX: Magic number
for (int i = 0 ; i < 10 ; i++)
{
- if ((systemPlanet[i].messageSlot != -1) && (systemPlanet[i].missionCompleted == 0))
+ if ((intermission_planets[i].messageSlot != -1) && (intermission_planets[i].missionCompleted == 0))
{
- yOffset = systemPlanet[i].messageSlot * 60;
+ yOffset = intermission_planets[i].messageSlot * 60;
gfx_drawRect(comms, 0, 105 + yOffset, comms->w - 1, 55, 0x00, 0x00, 0x77);
- gfx_blit(gfx_faceSprites[systemPlanet[i].faceImage], 20, 110 + yOffset, comms);
- gfx_renderString(systemPlanet[i].name, 80, 110 + yOffset, FONT_WHITE, 0, comms);
- gfx_renderString(systemPlanet[i].subject, 80, 130 + yOffset, FONT_CYAN, 0, comms);
+ gfx_blit(gfx_faceSprites[intermission_planets[i].faceImage], 20, 110 + yOffset, comms);
+ gfx_renderString(intermission_planets[i].name, 80, 110 + yOffset, FONT_WHITE, 0, comms);
+ gfx_renderString(intermission_planets[i].subject, 80, 130 + yOffset, FONT_CYAN, 0, comms);
}
}
@@ -555,18 +734,18 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
char name[50];
char string[2000];
int y = 50;
- int mission = -1;
+ int misn = -1;
// XXX: Magic number
for (int i = 0 ; i < 10 ; i++)
{
- if ((systemPlanet[i].messageSlot == missionSlot) && (systemPlanet[i].missionCompleted == 0))
+ if ((intermission_planets[i].messageSlot == missionSlot) && (intermission_planets[i].missionCompleted == 0))
{
- mission = systemPlanet[i].messageMission;
+ misn = intermission_planets[i].messageMission;
}
}
- if (mission == -1)
+ if (misn == -1)
return;
gfx_drawRect(comms, 0, 0, comms->w - 1, comms->h - 1, 0x00, 0x00, 0x25);
@@ -575,7 +754,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
// the screen listing all of the comms. For some reason, this has always
// been defined twice, which is redundant and has led to inconsistencies in
// the past.
- switch (mission)
+ switch (misn)
{
case MISN_HAIL:
strcpy(name, "Krass Tyler");
@@ -941,7 +1120,7 @@ static void intermission_createMissionDetailSurface(SDL_Surface *comms, int miss
strcpy(string, "Hey, why am I talking to myself? This shouldn't happen! Clearly, this must be a bug.");
y = intermission_renderDialog(comms, y, FS_CHRIS, string);
- sprintf(string, "I should go to starfighter.nongnu.org and report this bug there. In that report, I should mention that the mission number is %d.", mission);
+ sprintf(string, "I should go to starfighter.nongnu.org and report this bug there. In that report, I should mention that the mission number is %d.", misn);
y = intermission_renderDialog(comms, y, FS_CHRIS, string);
strcpy(string, "Wait, what am I still talking into empty space for? It's not like anyone can hear me...");
@@ -1100,7 +1279,7 @@ int intermission()
gfx_free();
- checkForBossMission(); // double check just to make sure!
+ intermission_unlockPlanets(); // double check just to make sure!
// Tell the game we are not in a mission so
// do not perform certain keyboard actions
@@ -1172,7 +1351,7 @@ int intermission()
intermission_setStatusLines();
initShop();
- intermission_setSystemPlanets();
+ intermission_setPlanets();
SDL_Surface *statsSurface = gfx_createAlphaRect(600, 330, 0x00, 0x00, 0x99);
SDL_Surface *savesSurface = gfx_createSurface(350, 300);
@@ -1212,7 +1391,7 @@ int intermission()
break;
case SYSTEM_SOL:
// There is no chance of being interceptted after the final attack on Earth
- if ((game.system == SYSTEM_SOL) && (systemPlanet[2].missionCompleted))
+ if ((game.system == SYSTEM_SOL) && (intermission_planets[2].missionCompleted))
interceptionChance = 0;
else
interceptionChance = 1. / 100.;
@@ -1239,11 +1418,11 @@ int intermission()
gfx_createTextObject(TS_INFO_OPTIONS, "Options", -1, iconInfoY, FONT_WHITE);
gfx_createTextObject(TS_INFO_EXIT, "Exit to Title Screen", -1, iconInfoY, FONT_WHITE);
- sprintf(string, "Stationed At: %s", systemPlanet[game.stationedPlanet].name);
+ sprintf(string, "Stationed At: %s", intermission_planets[game.stationedPlanet].name);
gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 450, FONT_WHITE);
if (game.destinationPlanet > -1)
- sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name);
+ sprintf(string, "Destination: %s", intermission_planets[game.destinationPlanet].name);
else
strcpy(string, "Destination: None");
gfx_createTextObject(TS_DEST_PLANET, string, 550, 450, FONT_WHITE);
@@ -1309,7 +1488,7 @@ int intermission()
case 0:
if (game.stationedPlanet == game.destinationPlanet)
{
- game.area = systemPlanet[game.stationedPlanet].missionNumber;
+ game.area = intermission_planets[game.stationedPlanet].missionNumber;
rtn = 2;
engine.done = 1;
}
@@ -1323,9 +1502,9 @@ int intermission()
if (distance < 1)
distance = 1;
- gfx_createTextObject(TS_CURRENT_PLANET, systemPlanet[game.stationedPlanet].name,
+ gfx_createTextObject(TS_CURRENT_PLANET, intermission_planets[game.stationedPlanet].name,
135, 480, FONT_WHITE);
- gfx_createTextObject(TS_DEST_PLANET, systemPlanet[game.destinationPlanet].name,
+ gfx_createTextObject(TS_DEST_PLANET, intermission_planets[game.destinationPlanet].name,
635, 480, FONT_WHITE);
section = 8;
@@ -1354,7 +1533,7 @@ int intermission()
if (intermission_showSystem(sinX, cosY, 1))
{
- sprintf(string, "Destination: %s", systemPlanet[game.destinationPlanet].name);
+ sprintf(string, "Destination: %s", intermission_planets[game.destinationPlanet].name);
gfx_createTextObject(TS_DEST_PLANET, string, 550, 450, FONT_WHITE);
}
@@ -1394,9 +1573,9 @@ int intermission()
case 8:
intermission_showSystem(sinX, cosY, 0);
- screen_blit(systemPlanet[game.stationedPlanet].image, 150, 450);
+ screen_blit(intermission_planets[game.stationedPlanet].image, 150, 450);
screen_blitText(TS_CURRENT_PLANET);
- screen_blit(systemPlanet[game.destinationPlanet].image, 650, 450);
+ screen_blit(intermission_planets[game.destinationPlanet].image, 650, 450);
screen_blitText(TS_DEST_PLANET);
destRect.w += distance;
@@ -1408,9 +1587,9 @@ int intermission()
game.distanceCovered = 0;
player.shield = player.maxShield;
sprintf(string, "Stationed At: %s",
- systemPlanet[game.stationedPlanet].name);
+ intermission_planets[game.stationedPlanet].name);
strcpy(game.stationedName,
- systemPlanet[game.stationedPlanet].name);
+ intermission_planets[game.stationedPlanet].name);
gfx_createTextObject(TS_CURRENT_PLANET, string, 90, 450, FONT_WHITE);
intermission_updateCommsSurface(commsSurface);
section = 1;
@@ -1436,7 +1615,7 @@ int intermission()
if (section != 8)
{
if ((game.stationedPlanet == game.destinationPlanet) &&
- (!systemPlanet[game.stationedPlanet].missionCompleted))
+ (!intermission_planets[game.stationedPlanet].missionCompleted))
screen_blit(gfx_sprites[SP_START_MISSION], 80, 500);
else if (game.stationedPlanet != game.destinationPlanet)
screen_blit(gfx_sprites[SP_GOTO], 80, 500);
@@ -1451,7 +1630,7 @@ int intermission()
if (game_collision(engine.cursor_x + 13, engine.cursor_y + 13, 6, 6, 80, 500, 32, 32) &&
((game.stationedPlanet != game.destinationPlanet) ||
- (!systemPlanet[game.stationedPlanet].missionCompleted)))
+ (!intermission_planets[game.stationedPlanet].missionCompleted)))
{
if (game.stationedPlanet == game.destinationPlanet)
screen_blitText(TS_INFO_START_MISSION);
diff --git a/src/intermission.h b/src/intermission.h
index 67833c6..e4b2825 100644
--- a/src/intermission.h
+++ b/src/intermission.h
@@ -20,6 +20,11 @@ along with this program. If not, see .
#ifndef INTERMISSION_H
#define INTERMISSION_H
+extern Planet intermission_planets[10];
+
+void intermission_initPlanets(int system);
+void intermission_unlockPlanets();
+void intermission_updateSystemStatus();
int intermission();
#endif
diff --git a/src/missions.cpp b/src/mission.cpp
similarity index 84%
rename from src/missions.cpp
rename to src/mission.cpp
index fe5b350..37a0aa6 100644
--- a/src/missions.cpp
+++ b/src/mission.cpp
@@ -20,203 +20,17 @@ along with this program. If not, see .
#include "Starfighter.h"
#include "radio.h"
-// XXX: Magic number
-Planet systemPlanet[10];
-mission currentMission;
-static mission missions[MISN_MAX];
+Mission currentMission;
-void initPlanetMissions(int system)
-{
- // XXX: Magic number
- for (int i = 0 ; i < 10 ; i++)
- {
- systemPlanet[i].missionNumber = -1; // no mission for this planet
- systemPlanet[i].missionCompleted = 1;
- }
-
- switch(system)
- {
- // Spirit
- case SYSTEM_SPIRIT:
- systemPlanet[PLANET_HAIL].missionNumber = MISN_HAIL;
- systemPlanet[PLANET_HAIL].missionCompleted = 0;
-
- systemPlanet[PLANET_CERADSE].missionNumber = MISN_CERADSE;
- systemPlanet[PLANET_CERADSE].missionCompleted = 0;
-
- systemPlanet[PLANET_HINSTAG].missionNumber = MISN_HINSTAG;
- systemPlanet[PLANET_HINSTAG].missionCompleted = 0;
-
- systemPlanet[PLANET_JOLDAR].missionNumber = MISN_JOLDAR;
- systemPlanet[PLANET_JOLDAR].missionCompleted = 0;
-
- systemPlanet[PLANET_MOEBO].missionNumber = MISN_MOEBO;
- systemPlanet[PLANET_MOEBO].missionCompleted = -1;
-
- break;
-
- // Eyananth
- case SYSTEM_EYANANTH:
- systemPlanet[PLANET_NEROD].missionNumber = MISN_NEROD;
- systemPlanet[PLANET_NEROD].missionCompleted = 0;
-
- systemPlanet[PLANET_ALLEZ].missionNumber = MISN_ALLEZ;
- systemPlanet[PLANET_ALLEZ].missionCompleted = 0;
-
- systemPlanet[PLANET_URUSOR].missionNumber = MISN_URUSOR;
- systemPlanet[PLANET_URUSOR].missionCompleted = -1;
-
- systemPlanet[PLANET_DORIM].missionNumber = MISN_DORIM;
- systemPlanet[PLANET_DORIM].missionCompleted = -1;
-
- systemPlanet[PLANET_ELAMALE].missionNumber = MISN_ELAMALE;
- systemPlanet[PLANET_ELAMALE].missionCompleted = -2;
-
- // This one is for the slaves
- systemPlanet[PLANET_RESCUESLAVES].missionNumber = MISN_RESCUESLAVES;
- systemPlanet[PLANET_RESCUESLAVES].missionCompleted = 0;
-
- break;
-
- // Mordor
- case SYSTEM_MORDOR:
- systemPlanet[PLANET_ODEON].missionNumber = MISN_ODEON;
- systemPlanet[PLANET_ODEON].missionCompleted = 0;
-
- systemPlanet[PLANET_FELLON].missionNumber = MISN_FELLON;
- systemPlanet[PLANET_FELLON].missionCompleted = 0;
-
- systemPlanet[PLANET_SIVEDI].missionNumber = MISN_SIVEDI;
- systemPlanet[PLANET_SIVEDI].missionCompleted = -1;
-
- systemPlanet[PLANET_ALMARTHA].missionNumber = MISN_ALMARTHA;
- systemPlanet[PLANET_ALMARTHA].missionCompleted = -1;
-
- systemPlanet[PLANET_POSWIC].missionNumber = MISN_POSWIC;
- systemPlanet[PLANET_POSWIC].missionCompleted = -2;
-
- systemPlanet[PLANET_ELLESH].missionNumber = MISN_ELLESH;
- systemPlanet[PLANET_ELLESH].missionCompleted = -3;
-
- // This one is for the experimental fighter
- systemPlanet[PLANET_CLOAKFIGHTER].missionNumber = MISN_CLOAKFIGHTER;
- systemPlanet[PLANET_CLOAKFIGHTER].missionCompleted = 0;
-
- break;
-
- // Sol
- case SYSTEM_SOL:
- systemPlanet[PLANET_PLUTO].missionNumber = MISN_PLUTO;
- systemPlanet[PLANET_PLUTO].missionCompleted = 0;
-
- systemPlanet[PLANET_NEPTUNE].missionNumber = MISN_NEPTUNE;
- systemPlanet[PLANET_NEPTUNE].missionCompleted = 0;
-
- systemPlanet[PLANET_URANUS].missionNumber = MISN_URANUS;
- systemPlanet[PLANET_URANUS].missionCompleted = 0;
-
- systemPlanet[PLANET_SATURN].missionNumber = MISN_SATURN;
- systemPlanet[PLANET_SATURN].missionCompleted = -1;
-
- systemPlanet[PLANET_JUPITER].missionNumber = MISN_JUPITER;
- systemPlanet[PLANET_JUPITER].missionCompleted = -2;
-
- systemPlanet[PLANET_MARS].missionNumber = MISN_MARS;
- systemPlanet[PLANET_MARS].missionCompleted = -3;
-
- systemPlanet[PLANET_EARTH].missionNumber = MISN_EARTH;
- systemPlanet[PLANET_EARTH].missionCompleted = -4;
-
- systemPlanet[PLANET_VENUS].missionNumber = MISN_VENUS;
- systemPlanet[PLANET_VENUS].missionCompleted = -5;
-
- break;
- }
-}
-
-void checkForBossMission()
-{
- // XXX: Magic number
- for (int i = 0 ; i < 10 ; i++)
- {
- if ((systemPlanet[i].missionCompleted == 0) && (systemPlanet[i].missionNumber != -1))
- return;
- }
-
- for (int i = 0 ; i < 10 ; i++)
- {
- if (systemPlanet[i].missionCompleted < 0)
- systemPlanet[i].missionCompleted++;
- }
-}
-
-void updateSystemStatus()
-{
- if (game.area == MISN_START)
- {
- game.stationedPlanet = 0;
- game.area = 1;
- strcpy(game.stationedName, "Hail");
- initPlanetMissions(game.system);
- }
- else if (game.area == MISN_MOEBO)
- {
- game.stationedPlanet = 0;
- game.system = 1;
- game.area = MISN_RESCUESLAVES;
- strcpy(game.stationedName, "Nerod");
- initPlanetMissions(game.system);
-
- if (game.difficulty == DIFFICULTY_ORIGINAL)
- player.maxShield = 50;
- }
- else if (game.area == MISN_ELAMALE)
- {
- game.stationedPlanet = 0;
- game.system = 2;
- game.area = MISN_CLOAKFIGHTER;
- strcpy(game.stationedName, "Odeon");
- initPlanetMissions(game.system);
-
- if (game.difficulty == DIFFICULTY_ORIGINAL)
- player.maxShield = 75;
- }
- else if (game.area == MISN_ELLESH)
- {
- game.stationedPlanet = 8;
- game.system = 3;
- game.area = MISN_PLUTO;
- strcpy(game.stationedName, "Pluto");
- initPlanetMissions(game.system);
-
- if (game.difficulty == DIFFICULTY_ORIGINAL)
- player.maxShield = 100;
- }
- else // Update the mission for the planet
- {
- systemPlanet[game.stationedPlanet].missionCompleted = 1;
- }
-
- strcpy(game.destinationName, "None");
- game.destinationPlanet = game.stationedPlanet;
-}
+static Mission missions[MISN_MAX];
/*
-Mission Completed Variables:
-
-0 : Not Completed
-1 : Completed
-2 : Just Completed
-3 : Constraint
--1 : Mission Failed
--2 : Just Failed
-
Timer Variable:
1+ : Time in minutes
-1 : Time up
-2 : No timer
*/
-static void clearAllMissions()
+static void mission_clearAll()
{
for (int m = 0 ; m < MISN_MAX ; m++)
{
@@ -226,8 +40,8 @@ static void clearAllMissions()
missions[m].primaryType[i] = M_NONE;
missions[m].target1[i] = -1;
missions[m].targetValue1[i] = -1;
- missions[m].timeLimit1[i] = -2;
- missions[m].completed1[i] = 1;
+ missions[m].timeLimit1[i] = MT_NONE;
+ missions[m].completed1[i] = OB_COMPLETED;
}
for (int i = 0 ; i < 3 ; i++)
@@ -236,740 +50,27 @@ static void clearAllMissions()
missions[m].secondaryType[i] = M_NONE;
missions[m].target2[i] = -1;
missions[m].targetValue2[i] = -1;
- missions[m].timeLimit2[i] = -2;
- missions[m].completed2[i] = 1;
+ missions[m].timeLimit2[i] = MT_NONE;
+ missions[m].completed2[i] = OB_COMPLETED;
}
missions[m].addAliens = -1;
}
}
-/*
-Sets the currentMission object to the mission number the player
-is currently on. Timing is assigned if it is required. The rate
-at which to add enemies in this mission is also set.
-*/
-void setMission(int mission)
-{
- currentMission = missions[mission];
- engine.minutes = currentMission.timeLimit1[0];
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.timeLimit1[i] > engine.minutes)
- engine.minutes = currentMission.timeLimit1[i];
- if (currentMission.timeLimit2[i] > engine.minutes)
- engine.minutes = currentMission.timeLimit2[i];
-
- if (currentMission.completed1[i] == OB_INCOMPLETE)
- currentMission.remainingObjectives1++;
- if (currentMission.completed2[i] == OB_INCOMPLETE)
- currentMission.remainingObjectives1++;
- }
-
- engine.addAliens = currentMission.addAliens;
-
- if (engine.minutes > -1)
- {
- engine.timeMission = 1;
- engine.seconds = 0;
- }
-
- engine.counter2 = 0;
- engine.timeTaken = 0;
-}
-
-/*
-Call this whenever a mission requires all the remaining aliens to
-automatically die
-*/
-static void mission_killAllEnemies()
-{
- for (int i = 0 ; i < ALIEN_MAX ; i++)
- {
- if ((aliens[i].flags & FL_WEAPCO) && (aliens[i].active) &&
- (aliens[i].shield > 0))
- aliens[i].shield = 0;
- }
-}
-
-void checkTimer()
-{
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.timeLimit1[i] == -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
- currentMission.completed1[i] = OB_JUST_FAILED;
- }
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.timeLimit2[i] == -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
- currentMission.completed2[i] = OB_JUST_FAILED;
- }
-
- // Find out if there are any uncompleted missions that require the timer
- engine.timeMission = 0;
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.timeLimit1[i] > -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
- engine.timeMission = 1;
- if ((currentMission.timeLimit2[i] > -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
- engine.timeMission = 1;
- }
-
- // specific to Spirit Boss
- if ((game.area == MISN_MOEBO) &&
- (currentMission.completed1[0] < OB_INCOMPLETE))
- engine.timeMission = 1;
-
- // specific to the Asteroid belt
- if ((game.area == MISN_MARS) &&
- (currentMission.completed1[0] < OB_INCOMPLETE))
- {
- currentMission.completed1[0] = OB_COMPLETED;
- mission_killAllEnemies();
- engine.addAliens = -1;
- info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
- }
-}
-
-static void evaluateRequirement(int type, int id, int *completed, int *targetValue, int fontColor)
-{
- char message[25];
-
- if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) &&
- (type != M_PROTECT_PICKUP))
- {
- *completed = OB_JUST_COMPLETED;
- checkTimer();
- if ((game.area == MISN_URUSOR) && (type == M_DISABLE_TARGET))
- radio_setMessage(FS_SID, "All vessels disabled!", 1);
- }
- else
- {
- strcpy(message, "");
- switch(type)
- {
- case M_COLLECT:
- switch(id)
- {
- case P_CASH:
- sprintf(message, "Collect $%d more...", *targetValue);
- if ((rand() % 2) == 0)
- sprintf(message, "$%d more to go...", *targetValue);
- break;
- case P_CARGO:
- sprintf(message, "Collect %d more...", *targetValue);
- if ((rand() % 2) == 0)
- sprintf(message, "%d more to go...", *targetValue);
- break;
- case P_ORE:
- sprintf(message, "Collect %d more...", *targetValue);
- if ((rand() % 2) == 0)
- sprintf(message, "%d more to go...", *targetValue);
- break;
- }
- break;
- case M_PROTECT_PICKUP:
- *completed = OB_JUST_FAILED;
- switch(id)
- {
- case P_CARGO:
- sprintf(message, "Cargo pod destroyed!");
- if (game.area == MISN_CERADSE) // Get lectured by Sid
- radio_setMessage(FS_SID, "Chris, we needed that pod! I told you that we couldn't afford to lose a single one!", 1);
- break;
- case P_ESCAPEPOD:
- sprintf(message, "Escape Pod lost!");
- if (game.area == MISN_ODEON) // Get lectured by Phoebe
- radio_setMessage(FS_PHOEBE, "No... Ursula...", 1);
- break;
- }
- break;
- case M_PROTECT_TARGET:
- if (*targetValue <= 0)
- {
- *completed = OB_JUST_FAILED;
- switch (game.area)
- {
- case MISN_NEROD:
- radio_setMessage(FS_SID, "Dammit, Chris! We just lost her!", 1);
- break;
- case MISN_ALLEZ:
- radio_setMessage(FS_CREW, "Noooo! Hull bre...", 1);
- break;
- case MISN_URUSOR:
- radio_setMessage(FS_SID, "Chris, we've got to disable them, not destroy them!!", 1);
- break;
- }
- }
- break;
- case M_DESTROY_TARGET_TYPE:
- if ((*targetValue <= 10) || (*targetValue % 10 == 0))
- {
- if (CHANCE(0.5))
- sprintf(message, "%d more to go...", *targetValue);
- else
- sprintf(message, "Destroy %d more...", *targetValue);
- }
- break;
- case M_DISABLE_TARGET:
- sprintf(message, "Disable %d more...", *targetValue);
- break;
- }
-
- if (strcmp(message, "") != 0)
- info_setLine(message, fontColor);
- }
-}
-
-void updateMissionRequirements(int type, int id, int value)
-{
- // Can't complete missions if you're dead!
- if (player.shield <= 0)
- return;
-
- char message[25];
- char matched = 0;
-
- // We don't need to worry here since if Sid dies,
- // you will automatically fail the mission(!)
- if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID))
- {
- info_setLine("Sid has been killed!", FONT_RED);
- currentMission.completed1[0] = OB_JUST_FAILED;
- }
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.completed1[i] == OB_INCOMPLETE) || (currentMission.completed1[i] == OB_CONDITION))
- {
- if ((currentMission.primaryType[i] == type) &&
- ((currentMission.target1[i] == id) ||
- (currentMission.target1[i] == CD_ANY)))
- {
- matched = 1;
- currentMission.targetValue1[i] -= value;
- evaluateRequirement(type, id, ¤tMission.completed1[i], ¤tMission.targetValue1[i], FONT_CYAN);
- }
- }
- }
-
- // Don't evaluate secondary objectives at the same time!
- if (matched)
- return;
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.completed2[i] == OB_INCOMPLETE) || (currentMission.completed2[i] == OB_CONDITION))
- {
- if ((currentMission.secondaryType[i] == type) &&
- ((currentMission.target2[i] == id) ||
- (currentMission.target2[i] == CD_ANY)))
- {
- currentMission.targetValue2[i] -= value;
- evaluateRequirement(type, id, ¤tMission.completed2[i], ¤tMission.targetValue2[i], FONT_YELLOW);
- return;
- }
- }
- }
-
- // Special Case - Interceptions
- if (game.area == MISN_INTERCEPTION)
- {
- if ((type == M_COLLECT) && (id == P_SLAVES))
- {
- if (systemPlanet[9].missionCompleted == 0)
- {
- if (game.slavesRescued >= 250)
- {
- info_setLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN);
- systemPlanet[9].missionCompleted = 1;
- }
- else
- {
- sprintf(message, "Rescue %d more...", 250 - game.slavesRescued);
- info_setLine(message, FONT_CYAN);
- }
- }
- }
-
- if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER))
- {
- info_setLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN);
- systemPlanet[9].missionCompleted = 1;
- radio_setMessage(FS_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1);
- game.experimentalShield = 0;
- }
- }
-}
-
-/*
-This is only used as few times in the game.
-Missions 11 and 23 to be exact!
-*/
-static int revealHiddenObjectives()
-{
- int allDone = 1;
- char string[255] = "";
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.completed1[i] == OB_HIDDEN)
- {
- currentMission.completed1[i] = OB_INCOMPLETE;
- sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]);
- info_setLine(string, FONT_CYAN);
- allDone = 0;
- }
- }
-
- if (!allDone)
- {
- // Activate Kline!! :)
- if (game.area == MISN_ELAMALE)
- {
- mission_killAllEnemies();
- events_sync();
- aliens[ALIEN_KLINE].active = 1;
- aliens[ALIEN_KLINE].x = player.x + 1000;
- aliens[ALIEN_KLINE].y = player.y;
- aliens[ALIEN_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE;
- player_setTarget(ALIEN_KLINE);
- audio_playMusic("music/last_cyber_dance.ogg", -1);
- }
- }
-
- return allDone;
-}
-
-int allMissionsCompleted()
-{
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.completed1[i] == OB_INCOMPLETE)
- {
- if ((currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
- {
- currentMission.completed1[i] = OB_JUST_COMPLETED;
- checkTimer();
- }
- }
- }
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.completed2[i] == OB_INCOMPLETE)
- {
- if ((currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
- {
- currentMission.completed2[i] = OB_JUST_COMPLETED;
- checkTimer();
- }
- }
- }
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.completed1[i] == OB_JUST_COMPLETED)
- {
- if (currentMission.remainingObjectives1 > 1)
- {
- if ((game.area != MISN_POSWIC) || (i != 1))
- info_setLine("*** Primary Objective Completed ***", FONT_GREEN);
- else
- info_setLine(">>> Primary Objective Failed <<<", FONT_RED);
- currentMission.completed1[i] = OB_COMPLETED;
- }
- else
- {
- if (currentMission.remainingObjectives2 > 0)
- {
- info_setLine("Emergency warp drive activated. Press button to engage.", FONT_CYAN);
- }
-
- if (game.area != MISN_INTERCEPTION)
- info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
- else
- info_setLine("*** Interception Destroyed ***", FONT_GREEN);
- currentMission.completed1[i] = OB_COMPLETED;
-
- // do some area specific things
- if ((game.area == MISN_MOEBO) ||
- (game.area == MISN_DORIM) ||
- (game.area == MISN_ELLESH) ||
- (game.area == MISN_MARS))
- {
- if (currentMission.remainingObjectives2 == 0)
- {
- mission_killAllEnemies();
- engine.addAliens = -1;
- }
- }
-
- if (game.area == MISN_EARTH)
- radio_setMessage(FS_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1);
- }
- }
-
- if (currentMission.completed2[i] == OB_JUST_COMPLETED)
- {
- if (currentMission.remainingObjectives2 > 1)
- {
- info_setLine("*** Secondary Objective Completed ***", FONT_GREEN);
- currentMission.completed2[i] = OB_COMPLETED;
- }
- else
- {
- info_setLine("*** All Secondary Objectives Completed ***", FONT_GREEN);
- currentMission.completed2[i] = OB_COMPLETED;
-
- // do some area specific things
- if ((game.area == MISN_DORIM) &&
- (currentMission.remainingObjectives1 == 0))
- {
- mission_killAllEnemies();
- engine.addAliens = -1;
- }
- }
- }
-
- if (currentMission.completed1[i] == OB_JUST_FAILED)
- {
- info_setLine(">>> MISSION FAILED <<<", FONT_RED);
- currentMission.completed1[i] = OB_FAILED;
- }
-
- if (currentMission.completed2[i] == OB_JUST_FAILED)
- {
- info_setLine(">>> Secondary Objective Failed <<<", FONT_RED);
- currentMission.completed2[i] = OB_FAILED;
- }
- }
-
- int remaining;
- int add = 0;
- int allDone = 1;
-
- // Zero objective list for a recount
- currentMission.remainingObjectives1 = currentMission.remainingObjectives2 = 0;
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.primaryType[i] != M_NONE)
- {
- if (currentMission.completed1[i] == OB_INCOMPLETE)
- {
- currentMission.remainingObjectives1++;
- if (currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS)
- add = 1;
- allDone = 0;
- }
-
- if (currentMission.completed1[i] < OB_INCOMPLETE)
- return 0;
- }
- if (currentMission.secondaryType[i] != M_NONE)
- {
- if (currentMission.completed2[i] == OB_INCOMPLETE)
- {
- currentMission.remainingObjectives2++;
- if (currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS)
- add = 1;
- allDone = 0;
- }
- }
- }
-
- if (allDone)
- allDone = revealHiddenObjectives();
-
- remaining = currentMission.remainingObjectives1 + currentMission.remainingObjectives2;
-
- // We've only got one objective left and it's destroy all targets,
- // so stop adding aliens (otherwise it might be impossible to finish!)
- if ((add) && (remaining == 1))
- engine.addAliens = -1;
-
- return allDone;
-}
-
-int missionFailed()
-{
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.completed1[i] < OB_INCOMPLETE)
- {
- return 1;
- }
- }
-
- return 0;
-}
-
-static void drawBriefScreen()
-{
- SDL_Rect r = {0, 0, (uint16_t)screen->w, 2};
-
- for (int i = 0 ; i < (int)(screen->h / 4) - 30 ; i++)
- {
- r.y = (i * 2) + 62; // Not a typo; a black gap is left in the middle if it's 60.
- SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
- r.y = (screen->h - (i * 2) - 60);
- SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
- }
-
- screen_drawRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
- screen_drawRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
- screen_renderString("Primary Objectives", 150, 74, FONT_WHITE);
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if ((currentMission.primaryType[i] != M_NONE) && (currentMission.completed1[i] != OB_HIDDEN))
- {
- screen_renderString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);
- }
- }
-
- if (currentMission.secondaryType[0] != M_NONE)
- {
- screen_drawRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
- screen_drawRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
- screen_renderString("Secondary Objectives", 150, 234, FONT_WHITE);
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.secondaryType[i] != M_NONE)
- {
- screen_renderString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);
- game.secondaryMissions++;
- }
- }
- }
-
- screen_drawRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
- screen_drawRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
- screen_renderString("Additional Information", 150, 394, FONT_WHITE);
-}
-
-/*
-Simply displays a screen with all the mission information on it, pulled
-back from the data stored in the currentMission object. The music for the
-mission begins playing here.
-*/
-void missionBriefScreen()
-{
- screen_clear(black);
- renderer_update();
-
- if (game.area != MISN_INTERCEPTION)
- {
- screen_clear(black);
- drawBriefScreen();
-
- if (currentMission.timeLimit1[0] > 0)
- {
- char temp[50];
- if (game.area != MISN_MARS)
- sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);
- else
- sprintf(temp, "SURVIVAL FOR %d minutes", currentMission.timeLimit1[0]);
- screen_renderString(temp, -1, 500, FONT_RED);
- }
-
- switch (game.area)
- {
- case MISN_URUSOR:
- case MISN_DORIM:
- case MISN_SIVEDI:
- case MISN_ALMARTHA:
- case MISN_ELLESH:
- case MISN_MARS:
- case MISN_VENUS:
- screen_renderString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);
- if (game.hasWingMate2)
- screen_renderString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);
- break;
- }
-
- if ((game.area == MISN_URUSOR) ||
- (game.area == MISN_POSWIC) ||
- (game.area == MISN_EARTH))
- screen_renderString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);
-
- renderer_update();
- }
-
- loadGameGraphics();
- gfx_createTextObject(TS_SHIELD, "Shield", screen->w / 32, screen->h - 50, FONT_WHITE);
- gfx_createTextObject(TS_PLASMA_T, "Plasma:", screen->w * 5 / 16, screen->h - 50, FONT_WHITE);
-
- if (player.weaponType[1] == W_CHARGER)
- gfx_createTextObject(TS_AMMO_T, "Charge", screen->w / 2, screen->h - 50, FONT_WHITE);
- else if (player.weaponType[1] == W_LASER)
- gfx_createTextObject(TS_AMMO_T, "Heat", screen->w / 2 + 20, screen->h - 50, FONT_WHITE);
- else
- gfx_createTextObject(TS_AMMO_T, "Rockets:", screen->w / 2, screen->h - 50, FONT_WHITE);
-
- gfx_createTextObject(TS_TARGET, "Target", screen->w * 11 / 16, screen->h - 50, FONT_WHITE);
- gfx_createTextObject(TS_TARGET_SID, "Sid", screen->w * 11 / 16 + 27, screen->h - 50, FONT_WHITE);
- gfx_createTextObject(TS_TARGET_PHOEBE, "Phoebe", screen->w * 11 / 16, screen->h - 50, FONT_WHITE);
- gfx_createTextObject(TS_TARGET_KLINE, "Kline", screen->w * 11 / 16 + 9, screen->h - 50, FONT_WHITE);
- gfx_createTextObject(TS_CASH_T, "Cash: $", 25, 20, FONT_WHITE);
- gfx_createTextObject(TS_OBJECTIVES_T, "Objectives Remaining:", screen->w - 250, 20, FONT_WHITE);
- gfx_createTextObject(TS_TIME_T, "Time Remaining - ", screen->w / 2 - 140, 20, FONT_WHITE);
- gfx_createTextObject(TS_POWER, "Power", screen->w / 32, screen->h - 30, FONT_WHITE);
- gfx_createTextObject(TS_OUTPUT, "Output", screen->w * 5 / 16, screen->h - 30, FONT_WHITE);
- gfx_createTextObject(TS_COOLER, "Cooler", screen->w * 97 / 160, screen->h - 30, FONT_WHITE);
- audio_playRandomTrack();
-
- if (game.area != MISN_INTERCEPTION)
- {
- screen_renderString("PRESS ENTER TO CONTINUE...", -1, 550, FONT_WHITE);
-
- renderer_update();
-
- flushInput();
- engine.done = 0;
- engine.keyState[KEY_FIRE] = 0;
- engine.keyState[KEY_ALTFIRE] = 0;
- engine.keyState[KEY_ESCAPE] = 0;
-
- while (1)
- {
- game_delayFrame();
- getPlayerInput();
- if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) ||
- (engine.keyState[KEY_ESCAPE]))
- break;
- }
-
- screen_clear(black);
- renderer_update();
- screen_clear(black);
- }
-
- engine.gameSection = SECTION_GAME;
-}
-
-/*
-Display a screen showing all the information from the mission
-the player has just done. This includes objectives that have been
-completed and failed. A mission timer is also displayed at the bottom
-of the screen.
-*/
-void missionFinishedScreen()
-{
- int shield_bonus;
- char temp[100];
-
- if (game.area != MISN_INTERCEPTION)
- {
- screen_clear(black);
- renderer_update();
-
- if (game.shots > 0)
- game.accuracy = (game.hits * 100) / game.shots;
-
- screen_clear(black);
- drawBriefScreen();
-
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.primaryType[i] != M_NONE)
- {
- if ((game.area != MISN_POSWIC) || (i != 1))
- screen_renderString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);
- else
- screen_renderString("FAILED", 550, 114 + (i * 30), FONT_RED);
- }
- }
-
- if (currentMission.secondaryType[0] != M_NONE)
- {
- for (int i = 0 ; i < 3 ; i++)
- {
- if (currentMission.secondaryType[i] != M_NONE)
- {
- strcpy(temp, currentMission.secondaryObjective[i]);
- if (currentMission.completed2[i] >= OB_COMPLETED)
- {
- screen_renderString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);
- game.secondaryMissionsCompleted++;
- }
- else
- {
- screen_renderString("FAILED", 550, 274 + (i * 30), FONT_RED);
- }
- }
- }
- }
-
- if (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 0)
- {
- if (game.difficulty == DIFFICULTY_NIGHTMARE)
- shield_bonus = 100;
- else
- shield_bonus = player.shield * 10;
- sprintf(temp, "Shield Bonus: $%.3d", shield_bonus);
- screen_renderString(temp, -1, 430, FONT_WHITE);
- game.cash += shield_bonus;
- game.cashEarned += shield_bonus;
- }
-
- game.timeTaken += engine.timeTaken;
-
- snprintf(temp, sizeof temp, "Mission Time: %2ld:%02ld:%02ld",
- engine.timeTaken / 3600, (engine.timeTaken / 60) % 60,
- engine.timeTaken % 60);
-
- screen_renderString(temp, -1, 500, FONT_WHITE);
-
- // Do some mission specific stuff here...
- if (game.area == MISN_HAIL)
- game.cash -= 500;
- else if (game.area == MISN_ODEON)
- game.hasWingMate2 = 1;
- else if (game.area == MISN_ALMARTHA)
- game.cash -= 2000;
-
- checkForBossMission();
-
- renderer_update();
-
- flushInput();
- engine.done = 0;
- engine.keyState[KEY_FIRE] = 0;
-
- while (1)
- {
- game_delayFrame();
- getPlayerInput();
- if ((engine.keyState[KEY_FIRE]))
- break;
- }
- }
-
- // Stop people from "selling" Laser ammo as rockets.
- if (player.weaponType[1] == W_LASER)
- player.ammo[1] = 1;
-
- audio_haltMusic();
-}
-
/*
This is where all the missions are defined.
*/
-void initMissions()
+void mission_init()
{
- clearAllMissions();
+ mission_clearAll();
// Seconds to wait between attempting to add an enemy
- int SOMETIMES = 40 * 60;
- int NORMAL = 15 * 60;
- int FREQUENT = 5 * 60;
- int ALWAYS = 1 * 60;
- int NEVER = -1;
+ static const int SOMETIMES = 40 * 60;
+ static const int NORMAL = 15 * 60;
+ static const int FREQUENT = 5 * 60;
+ static const int ALWAYS = 1 * 60;
+ static const int NEVER = -1;
sprintf(missions[MISN_START].primaryObjective[0],
@@ -1405,3 +506,716 @@ void initMissions()
missions[MISN_INTERCEPTION].primaryType[0] = M_DESTROY_ALL_TARGETS;
missions[MISN_INTERCEPTION].completed1[0] = OB_INCOMPLETE;
}
+
+/*
+Sets the currentMission object to the mission number the player
+is currently on. Timing is assigned if it is required. The rate
+at which to add enemies in this mission is also set.
+*/
+void mission_set(int misn)
+{
+ currentMission = missions[misn];
+ engine.minutes = currentMission.timeLimit1[0];
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.timeLimit1[i] > engine.minutes)
+ engine.minutes = currentMission.timeLimit1[i];
+ if (currentMission.timeLimit2[i] > engine.minutes)
+ engine.minutes = currentMission.timeLimit2[i];
+
+ if (currentMission.completed1[i] == OB_INCOMPLETE)
+ currentMission.remainingObjectives1++;
+ if (currentMission.completed2[i] == OB_INCOMPLETE)
+ currentMission.remainingObjectives1++;
+ }
+
+ engine.addAliens = currentMission.addAliens;
+
+ if (engine.minutes > -1)
+ {
+ engine.timeMission = 1;
+ engine.seconds = 0;
+ }
+
+ engine.counter2 = 0;
+ engine.timeTaken = 0;
+}
+
+/*
+Call this whenever a mission requires all the remaining aliens to
+automatically die
+*/
+static void mission_killAllEnemies()
+{
+ for (int i = 0 ; i < ALIEN_MAX ; i++)
+ {
+ if ((aliens[i].flags & FL_WEAPCO) && (aliens[i].active) &&
+ (aliens[i].shield > 0))
+ aliens[i].shield = 0;
+ }
+}
+
+void mission_checkTimer()
+{
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.timeLimit1[i] == -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
+ currentMission.completed1[i] = OB_JUST_FAILED;
+ }
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.timeLimit2[i] == -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
+ currentMission.completed2[i] = OB_JUST_FAILED;
+ }
+
+ // Find out if there are any uncompleted missions that require the timer
+ engine.timeMission = 0;
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.timeLimit1[i] > -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
+ engine.timeMission = 1;
+ if ((currentMission.timeLimit2[i] > -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
+ engine.timeMission = 1;
+ }
+
+ // specific to Spirit Boss
+ if ((game.area == MISN_MOEBO) &&
+ (currentMission.completed1[0] < OB_INCOMPLETE))
+ engine.timeMission = 1;
+
+ // specific to the Asteroid belt
+ if ((game.area == MISN_MARS) &&
+ (currentMission.completed1[0] < OB_INCOMPLETE))
+ {
+ currentMission.completed1[0] = OB_COMPLETED;
+ mission_killAllEnemies();
+ engine.addAliens = -1;
+ info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
+ }
+}
+
+static void mission_evaluate(int type, int id, int *completed, int *targetValue, int fontColor)
+{
+ char message[25];
+
+ if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) &&
+ (type != M_PROTECT_PICKUP))
+ {
+ *completed = OB_JUST_COMPLETED;
+ mission_checkTimer();
+ if ((game.area == MISN_URUSOR) && (type == M_DISABLE_TARGET))
+ radio_setMessage(FS_SID, "All vessels disabled!", 1);
+ }
+ else
+ {
+ strcpy(message, "");
+ switch(type)
+ {
+ case M_COLLECT:
+ switch(id)
+ {
+ case P_CASH:
+ sprintf(message, "Collect $%d more...", *targetValue);
+ if ((rand() % 2) == 0)
+ sprintf(message, "$%d more to go...", *targetValue);
+ break;
+ case P_CARGO:
+ sprintf(message, "Collect %d more...", *targetValue);
+ if ((rand() % 2) == 0)
+ sprintf(message, "%d more to go...", *targetValue);
+ break;
+ case P_ORE:
+ sprintf(message, "Collect %d more...", *targetValue);
+ if ((rand() % 2) == 0)
+ sprintf(message, "%d more to go...", *targetValue);
+ break;
+ }
+ break;
+ case M_PROTECT_PICKUP:
+ *completed = OB_JUST_FAILED;
+ switch(id)
+ {
+ case P_CARGO:
+ sprintf(message, "Cargo pod destroyed!");
+ if (game.area == MISN_CERADSE) // Get lectured by Sid
+ radio_setMessage(FS_SID, "Chris, we needed that pod! I told you that we couldn't afford to lose a single one!", 1);
+ break;
+ case P_ESCAPEPOD:
+ sprintf(message, "Escape Pod lost!");
+ if (game.area == MISN_ODEON) // Get lectured by Phoebe
+ radio_setMessage(FS_PHOEBE, "No... Ursula...", 1);
+ break;
+ }
+ break;
+ case M_PROTECT_TARGET:
+ if (*targetValue <= 0)
+ {
+ *completed = OB_JUST_FAILED;
+ switch (game.area)
+ {
+ case MISN_NEROD:
+ radio_setMessage(FS_SID, "Dammit, Chris! We just lost her!", 1);
+ break;
+ case MISN_ALLEZ:
+ radio_setMessage(FS_CREW, "Noooo! Hull bre...", 1);
+ break;
+ case MISN_URUSOR:
+ radio_setMessage(FS_SID, "Chris, we've got to disable them, not destroy them!!", 1);
+ break;
+ }
+ }
+ break;
+ case M_DESTROY_TARGET_TYPE:
+ if ((*targetValue <= 10) || (*targetValue % 10 == 0))
+ {
+ if (CHANCE(0.5))
+ sprintf(message, "%d more to go...", *targetValue);
+ else
+ sprintf(message, "Destroy %d more...", *targetValue);
+ }
+ break;
+ case M_DISABLE_TARGET:
+ sprintf(message, "Disable %d more...", *targetValue);
+ break;
+ }
+
+ if (strcmp(message, "") != 0)
+ info_setLine(message, fontColor);
+ }
+}
+
+void mission_updateRequirements(int type, int id, int value)
+{
+ // Can't complete missions if you're dead!
+ if (player.shield <= 0)
+ return;
+
+ char message[25];
+ char matched = 0;
+
+ // We don't need to worry here since if Sid dies,
+ // you will automatically fail the mission(!)
+ if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID))
+ {
+ info_setLine("Sid has been killed!", FONT_RED);
+ currentMission.completed1[0] = OB_JUST_FAILED;
+ }
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.completed1[i] == OB_INCOMPLETE) || (currentMission.completed1[i] == OB_CONDITION))
+ {
+ if ((currentMission.primaryType[i] == type) &&
+ ((currentMission.target1[i] == id) ||
+ (currentMission.target1[i] == CD_ANY)))
+ {
+ matched = 1;
+ currentMission.targetValue1[i] -= value;
+ mission_evaluate(type, id, ¤tMission.completed1[i], ¤tMission.targetValue1[i], FONT_CYAN);
+ }
+ }
+ }
+
+ // Don't evaluate secondary objectives at the same time!
+ if (matched)
+ return;
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.completed2[i] == OB_INCOMPLETE) || (currentMission.completed2[i] == OB_CONDITION))
+ {
+ if ((currentMission.secondaryType[i] == type) &&
+ ((currentMission.target2[i] == id) ||
+ (currentMission.target2[i] == CD_ANY)))
+ {
+ currentMission.targetValue2[i] -= value;
+ mission_evaluate(type, id, ¤tMission.completed2[i], ¤tMission.targetValue2[i], FONT_YELLOW);
+ return;
+ }
+ }
+ }
+
+ // Special Case - Interceptions
+ if (game.area == MISN_INTERCEPTION)
+ {
+ if ((type == M_COLLECT) && (id == P_SLAVES))
+ {
+ if (intermission_planets[9].missionCompleted == 0)
+ {
+ if (game.slavesRescued >= 250)
+ {
+ info_setLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN);
+ intermission_planets[9].missionCompleted = 1;
+ }
+ else
+ {
+ sprintf(message, "Rescue %d more...", 250 - game.slavesRescued);
+ info_setLine(message, FONT_CYAN);
+ }
+ }
+ }
+
+ if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER))
+ {
+ info_setLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN);
+ intermission_planets[9].missionCompleted = 1;
+ radio_setMessage(FS_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1);
+ game.experimentalShield = 0;
+ }
+ }
+}
+
+/*
+This is only used a few times in the game.
+Missions 11 and 23 to be exact!
+*/
+static int mission_revealObjectives()
+{
+ int allDone = 1;
+ char string[255] = "";
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.completed1[i] == OB_HIDDEN)
+ {
+ currentMission.completed1[i] = OB_INCOMPLETE;
+ sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]);
+ info_setLine(string, FONT_CYAN);
+ allDone = 0;
+ }
+ }
+
+ if (!allDone)
+ {
+ // Activate Kline!! :)
+ if (game.area == MISN_ELAMALE)
+ {
+ mission_killAllEnemies();
+ events_sync();
+ aliens[ALIEN_KLINE].active = 1;
+ aliens[ALIEN_KLINE].x = player.x + 1000;
+ aliens[ALIEN_KLINE].y = player.y;
+ aliens[ALIEN_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE;
+ player_setTarget(ALIEN_KLINE);
+ audio_playMusic("music/last_cyber_dance.ogg", -1);
+ }
+ }
+
+ return allDone;
+}
+
+int mission_checkCompleted()
+{
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.completed1[i] == OB_INCOMPLETE)
+ {
+ if ((currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
+ {
+ currentMission.completed1[i] = OB_JUST_COMPLETED;
+ mission_checkTimer();
+ }
+ }
+ }
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.completed2[i] == OB_INCOMPLETE)
+ {
+ if ((currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
+ {
+ currentMission.completed2[i] = OB_JUST_COMPLETED;
+ mission_checkTimer();
+ }
+ }
+ }
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.completed1[i] == OB_JUST_COMPLETED)
+ {
+ if (currentMission.remainingObjectives1 > 1)
+ {
+ if ((game.area != MISN_POSWIC) || (i != 1))
+ info_setLine("*** Primary Objective Completed ***", FONT_GREEN);
+ else
+ info_setLine(">>> Primary Objective Failed <<<", FONT_RED);
+ currentMission.completed1[i] = OB_COMPLETED;
+ }
+ else
+ {
+ if (currentMission.remainingObjectives2 > 0)
+ {
+ info_setLine("Emergency warp drive activated. Press button to engage.", FONT_CYAN);
+ }
+
+ if (game.area != MISN_INTERCEPTION)
+ info_setLine("*** All Primary Objectives Completed ***", FONT_GREEN);
+ else
+ info_setLine("*** Interception Destroyed ***", FONT_GREEN);
+ currentMission.completed1[i] = OB_COMPLETED;
+
+ // do some area specific things
+ if ((game.area == MISN_MOEBO) ||
+ (game.area == MISN_DORIM) ||
+ (game.area == MISN_ELLESH) ||
+ (game.area == MISN_MARS))
+ {
+ if (currentMission.remainingObjectives2 == 0)
+ {
+ mission_killAllEnemies();
+ engine.addAliens = -1;
+ }
+ }
+
+ if (game.area == MISN_EARTH)
+ radio_setMessage(FS_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1);
+ }
+ }
+
+ if (currentMission.completed2[i] == OB_JUST_COMPLETED)
+ {
+ if (currentMission.remainingObjectives2 > 1)
+ {
+ info_setLine("*** Secondary Objective Completed ***", FONT_GREEN);
+ currentMission.completed2[i] = OB_COMPLETED;
+ }
+ else
+ {
+ info_setLine("*** All Secondary Objectives Completed ***", FONT_GREEN);
+ currentMission.completed2[i] = OB_COMPLETED;
+
+ // do some area specific things
+ if ((game.area == MISN_DORIM) &&
+ (currentMission.remainingObjectives1 == 0))
+ {
+ mission_killAllEnemies();
+ engine.addAliens = -1;
+ }
+ }
+ }
+
+ if (currentMission.completed1[i] == OB_JUST_FAILED)
+ {
+ info_setLine(">>> MISSION FAILED <<<", FONT_RED);
+ currentMission.completed1[i] = OB_FAILED;
+ }
+
+ if (currentMission.completed2[i] == OB_JUST_FAILED)
+ {
+ info_setLine(">>> Secondary Objective Failed <<<", FONT_RED);
+ currentMission.completed2[i] = OB_FAILED;
+ }
+ }
+
+ int remaining;
+ int add = 0;
+ int allDone = 1;
+
+ // Zero objective list for a recount
+ currentMission.remainingObjectives1 = currentMission.remainingObjectives2 = 0;
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.primaryType[i] != M_NONE)
+ {
+ if (currentMission.completed1[i] == OB_INCOMPLETE)
+ {
+ currentMission.remainingObjectives1++;
+ if (currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS)
+ add = 1;
+ allDone = 0;
+ }
+
+ if (currentMission.completed1[i] < OB_INCOMPLETE)
+ return 0;
+ }
+ if (currentMission.secondaryType[i] != M_NONE)
+ {
+ if (currentMission.completed2[i] == OB_INCOMPLETE)
+ {
+ currentMission.remainingObjectives2++;
+ if (currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS)
+ add = 1;
+ allDone = 0;
+ }
+ }
+ }
+
+ if (allDone)
+ allDone = mission_revealObjectives();
+
+ remaining = currentMission.remainingObjectives1 + currentMission.remainingObjectives2;
+
+ // We've only got one objective left and it's destroy all targets,
+ // so stop adding aliens (otherwise it might be impossible to finish!)
+ if ((add) && (remaining == 1))
+ engine.addAliens = -1;
+
+ return allDone;
+}
+
+int mission_checkFailed()
+{
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.completed1[i] < OB_INCOMPLETE)
+ {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static void mission_drawScreen()
+{
+ SDL_Rect r = {0, 0, (int)screen->w, 2};
+
+ for (int i = 0 ; i < (int)(screen->h / 4) - 30 ; i++)
+ {
+ r.y = (i * 2) + 62; // Not a typo; a black gap is left in the middle if it's 60.
+ SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
+ r.y = (screen->h - (i * 2) - 60);
+ SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
+ }
+
+ screen_drawRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
+ screen_drawRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
+ screen_renderString("Primary Objectives", 150, 74, FONT_WHITE);
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if ((currentMission.primaryType[i] != M_NONE) && (currentMission.completed1[i] != OB_HIDDEN))
+ {
+ screen_renderString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);
+ }
+ }
+
+ if (currentMission.secondaryType[0] != M_NONE)
+ {
+ screen_drawRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
+ screen_drawRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
+ screen_renderString("Secondary Objectives", 150, 234, FONT_WHITE);
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.secondaryType[i] != M_NONE)
+ {
+ screen_renderString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);
+ game.secondaryMissions++;
+ }
+ }
+ }
+
+ screen_drawRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
+ screen_drawRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
+ screen_renderString("Additional Information", 150, 394, FONT_WHITE);
+}
+
+/*
+Simply displays a screen with all the mission information on it, pulled
+back from the data stored in the currentMission object. The music for the
+mission begins playing here.
+*/
+void mission_showStartScreen()
+{
+ screen_clear(black);
+ renderer_update();
+
+ if (game.area != MISN_INTERCEPTION)
+ {
+ screen_clear(black);
+ mission_drawScreen();
+
+ if (currentMission.timeLimit1[0] > 0)
+ {
+ char temp[50];
+ if (game.area != MISN_MARS)
+ sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);
+ else
+ sprintf(temp, "SURVIVAL FOR %d minutes", currentMission.timeLimit1[0]);
+ screen_renderString(temp, -1, 500, FONT_RED);
+ }
+
+ switch (game.area)
+ {
+ case MISN_URUSOR:
+ case MISN_DORIM:
+ case MISN_SIVEDI:
+ case MISN_ALMARTHA:
+ case MISN_ELLESH:
+ case MISN_MARS:
+ case MISN_VENUS:
+ screen_renderString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);
+ if (game.hasWingMate2)
+ screen_renderString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);
+ break;
+ }
+
+ if ((game.area == MISN_URUSOR) ||
+ (game.area == MISN_POSWIC) ||
+ (game.area == MISN_EARTH))
+ screen_renderString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);
+
+ renderer_update();
+ }
+
+ loadGameGraphics();
+ gfx_createTextObject(TS_SHIELD, "Shield", screen->w / 32, screen->h - 50, FONT_WHITE);
+ gfx_createTextObject(TS_PLASMA_T, "Plasma:", screen->w * 5 / 16, screen->h - 50, FONT_WHITE);
+
+ if (player.weaponType[1] == W_CHARGER)
+ gfx_createTextObject(TS_AMMO_T, "Charge", screen->w / 2, screen->h - 50, FONT_WHITE);
+ else if (player.weaponType[1] == W_LASER)
+ gfx_createTextObject(TS_AMMO_T, "Heat", screen->w / 2 + 20, screen->h - 50, FONT_WHITE);
+ else
+ gfx_createTextObject(TS_AMMO_T, "Rockets:", screen->w / 2, screen->h - 50, FONT_WHITE);
+
+ gfx_createTextObject(TS_TARGET, "Target", screen->w * 11 / 16, screen->h - 50, FONT_WHITE);
+ gfx_createTextObject(TS_TARGET_SID, "Sid", screen->w * 11 / 16 + 27, screen->h - 50, FONT_WHITE);
+ gfx_createTextObject(TS_TARGET_PHOEBE, "Phoebe", screen->w * 11 / 16, screen->h - 50, FONT_WHITE);
+ gfx_createTextObject(TS_TARGET_KLINE, "Kline", screen->w * 11 / 16 + 9, screen->h - 50, FONT_WHITE);
+ gfx_createTextObject(TS_CASH_T, "Cash: $", 25, 20, FONT_WHITE);
+ gfx_createTextObject(TS_OBJECTIVES_T, "Objectives Remaining:", screen->w - 250, 20, FONT_WHITE);
+ gfx_createTextObject(TS_TIME_T, "Time Remaining - ", screen->w / 2 - 140, 20, FONT_WHITE);
+ gfx_createTextObject(TS_POWER, "Power", screen->w / 32, screen->h - 30, FONT_WHITE);
+ gfx_createTextObject(TS_OUTPUT, "Output", screen->w * 5 / 16, screen->h - 30, FONT_WHITE);
+ gfx_createTextObject(TS_COOLER, "Cooler", screen->w * 97 / 160, screen->h - 30, FONT_WHITE);
+ audio_playRandomTrack();
+
+ if (game.area != MISN_INTERCEPTION)
+ {
+ screen_renderString("PRESS ENTER TO CONTINUE...", -1, 550, FONT_WHITE);
+
+ renderer_update();
+
+ flushInput();
+ engine.done = 0;
+ engine.keyState[KEY_FIRE] = 0;
+ engine.keyState[KEY_ALTFIRE] = 0;
+ engine.keyState[KEY_ESCAPE] = 0;
+
+ while (1)
+ {
+ game_delayFrame();
+ getPlayerInput();
+ if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) ||
+ (engine.keyState[KEY_ESCAPE]))
+ break;
+ }
+
+ screen_clear(black);
+ renderer_update();
+ screen_clear(black);
+ }
+
+ engine.gameSection = SECTION_GAME;
+}
+
+/*
+Display a screen showing all the information from the mission
+the player has just done. This includes objectives that have been
+completed and failed. A mission timer is also displayed at the bottom
+of the screen.
+*/
+void mission_showFinishedScreen()
+{
+ int shield_bonus;
+ char temp[100];
+
+ if (game.area != MISN_INTERCEPTION)
+ {
+ screen_clear(black);
+ renderer_update();
+
+ if (game.shots > 0)
+ game.accuracy = (game.hits * 100) / game.shots;
+
+ screen_clear(black);
+ mission_drawScreen();
+
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.primaryType[i] != M_NONE)
+ {
+ if ((game.area != MISN_POSWIC) || (i != 1))
+ screen_renderString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);
+ else
+ screen_renderString("FAILED", 550, 114 + (i * 30), FONT_RED);
+ }
+ }
+
+ if (currentMission.secondaryType[0] != M_NONE)
+ {
+ for (int i = 0 ; i < 3 ; i++)
+ {
+ if (currentMission.secondaryType[i] != M_NONE)
+ {
+ strcpy(temp, currentMission.secondaryObjective[i]);
+ if (currentMission.completed2[i] >= OB_COMPLETED)
+ {
+ screen_renderString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);
+ game.secondaryMissionsCompleted++;
+ }
+ else
+ {
+ screen_renderString("FAILED", 550, 274 + (i * 30), FONT_RED);
+ }
+ }
+ }
+ }
+
+ if (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 0)
+ {
+ if (game.difficulty == DIFFICULTY_NIGHTMARE)
+ shield_bonus = 100;
+ else
+ shield_bonus = player.shield * 10;
+ sprintf(temp, "Shield Bonus: $%.3d", shield_bonus);
+ screen_renderString(temp, -1, 430, FONT_WHITE);
+ game.cash += shield_bonus;
+ game.cashEarned += shield_bonus;
+ }
+
+ game.timeTaken += engine.timeTaken;
+
+ snprintf(temp, sizeof temp, "Mission Time: %2ld:%02ld:%02ld",
+ engine.timeTaken / 3600, (engine.timeTaken / 60) % 60,
+ engine.timeTaken % 60);
+
+ screen_renderString(temp, -1, 500, FONT_WHITE);
+
+ // Do some mission specific stuff here...
+ if (game.area == MISN_HAIL)
+ game.cash -= 500;
+ else if (game.area == MISN_ODEON)
+ game.hasWingMate2 = 1;
+ else if (game.area == MISN_ALMARTHA)
+ game.cash -= 2000;
+
+ intermission_unlockPlanets();
+
+ renderer_update();
+
+ flushInput();
+ engine.done = 0;
+ engine.keyState[KEY_FIRE] = 0;
+
+ while (1)
+ {
+ game_delayFrame();
+ getPlayerInput();
+ if ((engine.keyState[KEY_FIRE]))
+ break;
+ }
+ }
+
+ // Stop people from "selling" Laser ammo as rockets.
+ if (player.weaponType[1] == W_LASER)
+ player.ammo[1] = 1;
+
+ audio_haltMusic();
+}
diff --git a/src/missions.h b/src/mission.h
similarity index 59%
rename from src/missions.h
rename to src/mission.h
index c806232..a7c83cd 100644
--- a/src/missions.h
+++ b/src/mission.h
@@ -17,22 +17,18 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-#ifndef MISSIONS_H
-#define MISSIONS_H
+#ifndef MISSION_H
+#define MISSION_H
-extern Planet systemPlanet[10];
-extern mission currentMission;
+extern Mission currentMission;
-extern void initPlanetMissions(int system);
-extern void checkForBossMission();
-extern void updateSystemStatus();
-extern void setMission(int mission);
-extern void checkTimer();
-extern void updateMissionRequirements(int type, int id, int value);
-extern int allMissionsCompleted();
-extern int missionFailed();
-extern void missionBriefScreen();
-extern void missionFinishedScreen();
-extern void initMissions();
+void mission_set(int mission);
+void mission_checkTimer();
+void mission_updateRequirements(int type, int id, int value);
+int mission_checkCompleted();
+int mission_checkFailed();
+void mission_showStartScreen();
+void mission_showFinishedScreen();
+void mission_init();
#endif
diff --git a/src/save.cpp b/src/save.cpp
index f29989f..72624fa 100644
--- a/src/save.cpp
+++ b/src/save.cpp
@@ -241,12 +241,12 @@ int save_load(int slot)
}
// Re-init all the planets in this system...
- initPlanetMissions(game.system);
+ intermission_initPlanets(game.system);
// ... and then override with completition status
// XXX: Magic number
for (int i = 0 ; i < 10 ; i++)
- systemPlanet[i].missionCompleted = game.missionCompleted[i];
+ intermission_planets[i].missionCompleted = game.missionCompleted[i];
return 1;
}
@@ -269,7 +269,7 @@ void save(int slot)
game.saveFormat = 4;
// XXX: Magic number
for (int i = 0 ; i < 10 ; i++)
- game.missionCompleted[i] = systemPlanet[i].missionCompleted;
+ game.missionCompleted[i] = intermission_planets[i].missionCompleted;
if (fp != NULL)
{
diff --git a/src/structs.h b/src/structs.h
index e34c55b..4f0ce27 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -68,7 +68,7 @@ typedef struct object_ {
} object;
-typedef struct mission_ {
+typedef struct Mission_ {
char primaryObjective[3][50]; // Description
int primaryType[3]; // The type of mission this is
@@ -88,7 +88,7 @@ typedef struct mission_ {
int remainingObjectives2;
int addAliens; // How often to add new enemies
-} mission;
+} Mission;
typedef struct Star_ {