2 Copyright © 2004 Parallel Realities
3 Copyright © 2007-2008 Kővágó Zoltán <DirtY.iCE.hu@gmail.com>
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 #include "CGameData.h"
25 #include "CGraphics.h"
28 #include "CObjective.h"
29 #include "gettext.hpp"
32 // This is for easy mode
33 void skipBossMission()
35 if (game
.stagesCleared
== 5)
37 gameData
.addCompletedObjective("BioMech Supply Depot", "Easy Mode Skip", 1, 1);
38 game
.stagesCleared
= 6;
41 if (game
.stagesCleared
== 10)
43 gameData
.addCompletedObjective("BioMech Communications", "Easy Mode Skip", 1, 1);
44 game
.hasAquaLung
= true;
45 game
.stagesCleared
= 11;
46 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
48 graphics
.drawString(_("You got the Aqua Lung!"), bx
+320, by
+420, TXT_CENTERED
, graphics
.screen
);
50 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
53 if (game
.stagesCleared
== 15)
55 gameData
.addCompletedObjective("BioMech Assimilator", "Easy Mode Skip", 1, 1);
56 game
.hasJetPack
= true;
57 game
.stagesCleared
= 16;
58 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
60 graphics
.drawString(_("You got the Jet Pack!"), bx
+320, by
+420, TXT_CENTERED
, graphics
.screen
);
62 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
65 if (game
.stagesCleared
== 21)
67 gameData
.addCompletedObjective("BioMech HQ", "Easy Mode Skip", 1, 1);
68 game
.stagesCleared
= 22;
72 void processPostMissionData()
76 if (!gameData
.stagePreviouslyCleared(game
.stageName
))
86 gameData
.setMIARescueCount(map
.name
, map
.foundMIAs
, map
.totalMIAs
);
88 Objective
*objective
= (Objective
*)map
.objectiveList
.getHead();
89 Entity
*mia
= (Entity
*)map
.miaList
.getHead();
91 while (objective
->next
!= NULL
)
93 objective
= (Objective
*)objective
->next
;
95 gameData
.addCompletedObjective(map
.name
, objective
->description
, objective
->currentValue
, objective
->targetValue
);
100 while (mia
->next
!= NULL
)
102 mia
= (Entity
*)mia
->next
;
109 sprintf(string
, "MIA_%s", mia
->name
);
113 gameData
.addCompletedObjective(map
.name
, string
, 1, 1);
117 gameData
.addCompletedObjective(map
.name
, string
, 0, 1);
124 void clearAllMissionData()
126 char levelMIAKey
[100];
128 sprintf(levelMIAKey
, "%s MIAs", game
.stageName
);
130 Data
*data
= (Data
*)gameData
.dataList
.getHead();
131 Data
*previous
= data
;
133 while (data
->next
!= NULL
)
135 data
= (Data
*)data
->next
;
137 if ((strcmp(data
->key
, game
.stageName
) == 0) || (strstr(data
->key
, levelMIAKey
)))
139 gameData
.dataList
.remove(previous
, data
);
148 map
.destroyPersistant(map
.name
);
151 void showMissionClear()
154 bool perfect
= perfectlyCompleted();
158 (perfect
) ? clear
= graphics
.loadImage("gfx/main/areaPerfect.png") : clear
= graphics
.loadImage("gfx/main/areaClear.png");
160 graphics
.loadBackground("gfx/main/areaClearBackGround.jpg", false);
162 SDL_Surface
*panel
= graphics
.alphaRect(550, 420, 0x00, 0x00, 0x00);
163 SDL_SetAlpha(panel
, SDL_SRCALPHA
|SDL_RLEACCEL
, 180);
164 graphics
.drawRect(1, 1, panel
->w
- 2, panel
->h
- 2 , graphics
.black
, graphics
.white
, panel
);
166 graphics
.blit(panel
, (640 - panel
->w
) / 2, (480 - panel
->h
) / 2, graphics
.background
, false);
168 audio
.loadSound(0, "sound/pop1.wav");
169 audio
.loadSound(1, "sound/cheer.wav");
171 SDL_FillRect(graphics
.screen
, NULL
, graphics
.black
);
172 graphics
.updateScreen();
177 Objective
*objective
= (Objective
*)map
.objectiveList
.getHead();
178 Entity
*mia
= (Entity
*)map
.miaList
.getHead();
179 Sprite
*teleportStar
= graphics
.getSprite("TeleportStar", true);
185 int nextStarBurst
= 10 * (rand() % 6);
187 float px
, py
, dx
, dy
;
190 while (mia
->next
!= NULL
)
192 mia
= (Entity
*)mia
->next
;
203 if (count
> colCount
)
212 if (count
> colCount
)
215 if (place
> (colCount
* 25))
216 place
= colCount
* 25;
218 place
= (640 - place
) / 2;
220 graphics
.setFontSize(1);
222 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
229 if (map
.totalMIAs
> 0)
231 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
232 sprintf(message
, "%s", _("Rescue %d MIAs").c_str());
233 sprintf(message
, message
, map
.requiredMIAs
);
234 graphics
.drawString(message
, col1
, y
, TXT_RIGHT
, graphics
.background
);
236 if (map
.foundMIAs
< map
.requiredMIAs
)
238 graphics
.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
239 sprintf(message
, "%d / %d", map
.foundMIAs
, map
.requiredMIAs
);
240 graphics
.drawString(message
, col2
, y
, TXT_LEFT
, graphics
.background
);
244 graphics
.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
245 graphics
.drawString(_("Completed"), col2
, y
, TXT_LEFT
, graphics
.background
);
249 objective
= (Objective
*)map
.objectiveList
.getHead();
251 //engine.setPlayerPosition(0, 0, -1, -1, -1, -1);
252 map
.offsetX
= - bx
; map
.offsetY
= - by
;
254 while (objective
->next
!= NULL
)
256 objective
= (Objective
*)objective
->next
;
260 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
262 if ((game
.skill
< 3) && (strstr(objective
->description
, "L.R.T.S.")) && (!gameData
.completedWorld
))
264 graphics
.drawString("???? ???????? ????", col1
, y
, TXT_RIGHT
, graphics
.background
);
268 graphics
.drawString(_(objective
->description
), col1
, y
, TXT_RIGHT
, graphics
.background
);
271 if (objective
->currentValue
< objective
->targetValue
)
273 if (objective
->targetValue
== 1)
275 graphics
.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
276 graphics
.drawString(_("Incomplete"), col2
, y
, TXT_LEFT
, graphics
.background
);
280 graphics
.setFontColor(0xff, 0x00, 0x00, 0x00, 0x00, 0x00);
281 sprintf(message
, "%d / %d", objective
->currentValue
, objective
->targetValue
);
282 graphics
.drawString(message
, col2
, y
, TXT_LEFT
, graphics
.background
);
287 graphics
.setFontColor(0x00, 0xff, 0x00, 0x00, 0x00, 0x00);
288 graphics
.drawString(_("Completed"), col2
, y
, TXT_LEFT
, graphics
.background
);
292 graphics
.setFontColor(0xff, 0xff, 0xff, 0x00, 0x00, 0x00);
294 unsigned int frameLimit
= SDL_GetTicks() + 16;
297 audio
.playSound(1, 1);
302 graphics
.updateScreen();
303 graphics
.animateSprites();
305 if (engine
.userAccepts())
308 graphics
.drawBackground();
310 graphics
.blit(clear
, bx
+ 320, by
+ clearY
, graphics
.screen
, true);
312 Math::limitInt(&(clearY
-= 5), 70, 520);
316 mia
= (Entity
*)map
.miaList
.getHead();
320 while (mia
->next
!= NULL
)
322 mia
= (Entity
*)mia
->next
;
327 if (count
> colCount
)
330 graphics
.blit(mia
->getFaceImage(), bx
+ (int)mia
->x
, by
+ (int)mia
->y
, graphics
.screen
, false);
333 audio
.playSound(0, 0);
335 if (mia
->x
> (place
+ (count
* 25)))
336 Math::limitFloat(&(mia
->x
-= 35), place
+ (count
* 25), 640);
338 if (mia
->x
> place
+ (count
* 25))
346 Math::limitInt(&(--nextStarBurst
), 0, 999);
348 if (nextStarBurst
== 0)
350 nextStarBurst
= 10 * (rand() % 6);
352 px
= Math::rrand(50, 585);
353 py
= Math::rrand(55, 85);
355 for (int i
= 0 ; i
< 50 ; i
++)
357 dx
= Math::rrand(-30, 30); dx
/= 20;
358 dy
= Math::rrand(-30, 30); dy
/= 20;
359 map
.addParticle(px
, py
, dx
, dy
, Math::rrand(30, 60), graphics
.red
, teleportStar
, PAR_WEIGHTLESS
);
367 sprintf(message
, "%s - %.2d:%.2d:%.2d", _("Mission Time").c_str(), game
.currentMissionHours
, game
.currentMissionMinutes
, game
.currentMissionSeconds
);
368 graphics
.drawString(message
, bx
+ 320, by
+ 420, true, graphics
.screen
);
370 while (SDL_GetTicks() < frameLimit
){}
371 frameLimit
= SDL_GetTicks() + 16;
377 processPostMissionData();
379 if (!engine
.practice
)