2 Copyright (C) 2004-2011 Parallel Realities
3 Copyright (C) 2011-2015 Perpendicular Dimensions
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 // This is for easy mode
25 void skipBossMission()
27 if (game.stagesCleared == 5)
29 gameData.addCompletedObjective("BioMech Supply Depot", "Easy Mode Skip", 1, 1);
30 game.stagesCleared = 6;
33 if (game.stagesCleared == 10)
35 gameData.addCompletedObjective("BioMech Communications", "Easy Mode Skip", 1, 1);
36 game.hasAquaLung = true;
37 game.stagesCleared = 11;
38 SDL_FillRect(graphics.screen, NULL, graphics.black);
40 graphics.drawString(_("You got the Aqua Lung!"), 320, 420, TXT_CENTERED, graphics.screen);
42 SDL_FillRect(graphics.screen, NULL, graphics.black);
45 if (game.stagesCleared == 15)
47 gameData.addCompletedObjective("BioMech Assimilator", "Easy Mode Skip", 1, 1);
48 game.hasJetPack = true;
49 game.stagesCleared = 16;
50 SDL_FillRect(graphics.screen, NULL, graphics.black);
52 graphics.drawString(_("You got the Jet Pack!"), 320, 420, TXT_CENTERED, graphics.screen);
54 SDL_FillRect(graphics.screen, NULL, graphics.black);
57 if (game.stagesCleared == 21)
59 gameData.addCompletedObjective("BioMech HQ", "Easy Mode Skip", 1, 1);
60 game.stagesCleared = 22;
64 void processPostMissionData()
68 if (!gameData.stagePreviouslyCleared(game.stageName))
70 presentPlayerMedal(game.stageName);
79 gameData.setMIARescueCount(map.name, map.foundMIAs, map.totalMIAs);
81 Objective *objective = (Objective*)map.objectiveList.getHead();
82 Entity *mia = (Entity*)map.miaList.getHead();
84 while (objective->next != NULL)
86 objective = (Objective*)objective->next;
88 gameData.addCompletedObjective(map.name, objective->description, objective->currentValue, objective->targetValue);
93 while (mia->next != NULL)
95 mia = (Entity*)mia->next;
102 snprintf(string, sizeof string, "MIA_%s", mia->name);
106 gameData.addCompletedObjective(map.name, string, 1, 1);
110 gameData.addCompletedObjective(map.name, string, 0, 1);
116 if (game.totalEnemiesDefeated >= 1000)
118 presentPlayerMedal("1000_Enemies");
121 if (game.totalEnemiesDefeated >= 2500)
123 presentPlayerMedal("2500_Enemies");
127 void clearAllMissionData()
129 char levelMIAKey[100];
131 snprintf(levelMIAKey, sizeof levelMIAKey, "%s MIAs", game.stageName);
133 Data *data = (Data*)gameData.dataList.getHead();
134 Data *previous = data;
136 while (data->next != NULL)
138 data = (Data*)data->next;
140 if ((strcmp(data->key, game.stageName) == 0) || (strstr(data->key, levelMIAKey)))
142 gameData.dataList.remove(previous, data);
151 map.destroyPersistant(map.name);
154 void showMissionClear()
157 bool perfect = perfectlyCompleted();
161 (perfect) ? clear = graphics.loadImage("gfx/main/areaPerfect.png") : clear = graphics.loadImage("gfx/main/areaClear.png");
163 graphics.loadBackground("gfx/main/areaClearBackGround.jpg");
165 SDL_Surface *panel = graphics.alphaRect(550, 420, 0x00, 0x00, 0x00);
166 SDL_SetAlpha(panel, 180);
167 graphics.drawRect(1, 1, panel->w - 2, panel->h - 2 , graphics.black, graphics.white, panel);
169 graphics.blit(panel, (640 - panel->w) / 2, (480 - panel->h) / 2, graphics.background, false);
171 audio.loadSound(0, "sound/pop1");
172 audio.loadSound(1, "sound/cheer");
174 SDL_FillRect(graphics.screen, NULL, graphics.black);
175 graphics.updateScreen();
180 Objective *objective = (Objective*)map.objectiveList.getHead();
181 Entity *mia = (Entity*)map.miaList.getHead();
182 Sprite *teleportStar = graphics.getSprite("TeleportStar", true);
188 int nextStarBurst = 10 * (Math::prand() % 6);
190 float px, py, dx, dy;
193 while (mia->next != NULL)
195 mia = (Entity*)mia->next;
206 if (count > colCount)
215 if (count > colCount)
218 if (place > (colCount * 25))
219 place = colCount * 25;
221 place = (640 - place) / 2;
223 graphics.setFontSize(1);
225 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
232 if (map.totalMIAs > 0)
234 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
235 snprintf(message, sizeof message, _("Rescue %d MIAs"), map.requiredMIAs);
236 graphics.drawString(message, col1, y, TXT_RIGHT, graphics.background);
238 if (map.foundMIAs < map.requiredMIAs)
240 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
241 snprintf(message, sizeof message, "%d / %d", map.foundMIAs, map.requiredMIAs);
242 graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
246 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
247 graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.background);
251 objective = (Objective*)map.objectiveList.getHead();
253 engine.setPlayerPosition(0, 0, -1, -1, -1, -1);
255 while (objective->next != NULL)
257 objective = (Objective*)objective->next;
261 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
263 if ((game.skill < 3) && (strstr(objective->description, "L.R.T.S.")) && (!gameData.completedWorld))
265 graphics.drawString(_("???? ???????? ????"), col1, y, TXT_RIGHT, graphics.background);
269 graphics.drawString(_(objective->description), col1, y, TXT_RIGHT, graphics.background);
272 if (objective->currentValue < objective->targetValue)
274 if (objective->targetValue == 1)
276 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
277 graphics.drawString(_("Incomplete"), col2, y, TXT_LEFT, graphics.background);
281 graphics.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
282 snprintf(message, sizeof message, "%d / %d", objective->currentValue, objective->targetValue);
283 graphics.drawString(message, col2, y, TXT_LEFT, graphics.background);
288 graphics.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
289 graphics.drawString(_("Completed"), col2, y, TXT_LEFT, graphics.background);
293 graphics.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
295 unsigned int frameLimit = SDL_GetTicks() + 16;
298 audio.playSound(1, 1);
304 graphics.updateScreen();
305 graphics.animateSprites();
307 if (engine.userAccepts())
310 graphics.drawBackground();
312 graphics.blit(clear, 320, clearY, graphics.screen, true);
314 Math::limitInt(&(clearY -= 5), 70, 520);
318 mia = (Entity*)map.miaList.getHead();
322 while (mia->next != NULL)
324 mia = (Entity*)mia->next;
329 if (count > colCount)
332 graphics.blit(mia->getFaceImage(), (int)mia->x, (int)mia->y, graphics.screen, false);
335 audio.playSound(0, 0);
337 if (mia->x > (place + (count * 25)))
338 Math::limitFloat(&(mia->x -= 35), place + (count * 25), 640);
340 if (mia->x > place + (count * 25))
348 Math::limitInt(&(--nextStarBurst), 0, 999);
350 if (nextStarBurst == 0)
352 nextStarBurst = 10 * (Math::prand() % 6);
354 px = Math::rrand(50, 585);
355 py = Math::rrand(55, 85);
357 for (int i = 0 ; i < 50 ; i++)
359 dx = Math::rrand(-30, 30); dx /= 20;
360 dy = Math::rrand(-30, 30); dy /= 20;
361 map.addParticle(px, py, dx, dy, Math::rrand(30, 60), graphics.red, teleportStar, PAR_WEIGHTLESS);
369 static Graphics::SurfaceCache cache;
370 snprintf(message, sizeof message, "%s - %.2d:%.2d:%.2d", _("Mission Time"), game.currentMissionHours, game.currentMissionMinutes, game.currentMissionSeconds);
371 graphics.drawString(message, 320, 420, true, graphics.screen, cache);
373 engine.delay(frameLimit);
374 frameLimit = SDL_GetTicks() + 16;
379 processPostMissionData();
381 if (!engine.practice)