OSDN Git Service

Project: Starfighter 1.4 オリジナル
[starfighter-jp/starfighter-jp.git] / src / missions.cpp
1 /*
2 Copyright (C) 2003 Parallel Realities
3 Copyright (C) 2011, 2012, 2013 Guus Sliepen
4 Copyright (C) 2012, 2015 Julian Marchant
5
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 3
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "Starfighter.h"
21
22 // God, I hate this file! :((
23
24 Planet systemPlanet[10];
25 mission currentMission;
26 static mission missions[MISN_MAX];
27
28 void initPlanetMissions(signed char system)
29 {
30         for (int i = 0 ; i < 10 ; i++)
31         {
32                 systemPlanet[i].missionNumber = -1; // no mission for this planet
33                 systemPlanet[i].missionCompleted = 1;
34         }
35
36         switch(system)
37         {
38                 // Spirit
39                 case 0:
40                         systemPlanet[0].missionNumber = MISN_HAIL;
41                         systemPlanet[0].missionCompleted = 0;
42
43                         systemPlanet[1].missionNumber = MISN_CERADSE;
44                         systemPlanet[1].missionCompleted = 0;
45
46                         systemPlanet[2].missionNumber = MISN_HINSTAG;
47                         systemPlanet[2].missionCompleted = 0;
48
49                         systemPlanet[3].missionNumber = MISN_JOLDAR;
50                         systemPlanet[3].missionCompleted = 0;
51
52                         systemPlanet[4].missionNumber = MISN_MOEBO;
53                         systemPlanet[4].missionCompleted = -1;
54
55                         break;
56
57                 // Eyananth
58                 case 1:
59                         systemPlanet[0].missionNumber = MISN_NEROD;
60                         systemPlanet[0].missionCompleted = 0;
61
62                         systemPlanet[1].missionNumber = MISN_ALLEZ;
63                         systemPlanet[1].missionCompleted = 0;
64
65                         systemPlanet[2].missionNumber = MISN_URUSOR;
66                         systemPlanet[2].missionCompleted = -1;
67
68                         systemPlanet[3].missionNumber = MISN_DORIM;
69                         systemPlanet[3].missionCompleted = -1;
70
71                         systemPlanet[4].missionNumber = MISN_ELAMALE;
72                         systemPlanet[4].missionCompleted = -2;
73
74                         // This one is for the slaves
75                         systemPlanet[9].missionNumber = MISN_RESCUESLAVES;
76                         systemPlanet[9].missionCompleted = 0;
77
78                         break;
79
80                 // Mordor
81                 case 2:
82                         systemPlanet[0].missionNumber = MISN_ODEON;
83                         systemPlanet[0].missionCompleted = 0;
84
85                         systemPlanet[1].missionNumber = MISN_FELLON;
86                         systemPlanet[1].missionCompleted = 0;
87
88                         systemPlanet[2].missionNumber = MISN_SIVEDI;
89                         systemPlanet[2].missionCompleted = -1;
90
91                         systemPlanet[3].missionNumber = MISN_ALMARTHA;
92                         systemPlanet[3].missionCompleted = -1;
93
94                         systemPlanet[4].missionNumber = MISN_POSWIC;
95                         systemPlanet[4].missionCompleted = -2;
96
97                         systemPlanet[5].missionNumber = MISN_ELLESH;
98                         systemPlanet[5].missionCompleted = -3;
99
100                         // This one is for the experimental fighter
101                         systemPlanet[9].missionNumber = MISN_CLOAKFIGHTER;
102                         systemPlanet[9].missionCompleted = 0;
103
104                         break;
105
106                 // Sol
107                 case 3:
108                         systemPlanet[8].missionNumber = MISN_PLUTO;
109                         systemPlanet[8].missionCompleted = 0;
110
111                         systemPlanet[7].missionNumber = MISN_NEPTUNE;
112                         systemPlanet[7].missionCompleted = 0;
113
114                         systemPlanet[6].missionNumber = MISN_URANUS;
115                         systemPlanet[6].missionCompleted = 0;
116
117                         systemPlanet[5].missionNumber = MISN_SATURN;
118                         systemPlanet[5].missionCompleted = -1;
119
120                         systemPlanet[4].missionNumber = MISN_JUPITER;
121                         systemPlanet[4].missionCompleted = -2;
122
123                         systemPlanet[3].missionNumber = MISN_MARS;
124                         systemPlanet[3].missionCompleted = -3;
125
126                         systemPlanet[2].missionNumber = MISN_EARTH;
127                         systemPlanet[2].missionCompleted = -4;
128
129                         systemPlanet[1].missionNumber = MISN_VENUS;
130                         systemPlanet[1].missionCompleted = -5;
131
132                         break;
133         }
134 }
135
136 void checkForBossMission()
137 {
138         for (int i = 0 ; i < 10 ; i++)
139         {
140                 if ((systemPlanet[i].missionCompleted == 0) && (systemPlanet[i].missionNumber != -1))
141                         return;
142         }
143
144         for (int i = 0 ; i < 10 ; i++)
145         {
146                 if (systemPlanet[i].missionCompleted < 0)
147                         systemPlanet[i].missionCompleted++;
148         }
149 }
150
151 void updateSystemStatus()
152 {
153         if (game.area == MISN_START)
154         {
155                 game.stationedPlanet = 0;
156                 game.area = 1;
157                 strcpy(game.stationedName, "Hail");
158                 initPlanetMissions(game.system);
159         }
160         else if (game.area == MISN_MOEBO)
161         {
162                 game.stationedPlanet = 0;
163                 game.system = 1;
164                 game.area = MISN_RESCUESLAVES;
165                 strcpy(game.stationedName, "Nerod");
166                 initPlanetMissions(game.system);
167
168                 if (game.difficulty == DIFFICULTY_ORIGINAL)
169                         player.maxShield = 50;
170         }
171         else if (game.area == MISN_ELAMALE)
172         {
173                 game.stationedPlanet = 0;
174                 game.system = 2;
175                 game.area = MISN_CLOAKFIGHTER;
176                 strcpy(game.stationedName, "Odeon");
177                 initPlanetMissions(game.system);
178
179                 if (game.difficulty == DIFFICULTY_ORIGINAL)
180                         player.maxShield = 75;
181         }
182         else if (game.area == MISN_ELLESH)
183         {
184                 game.stationedPlanet = 8;
185                 game.system = 3;
186                 game.area = MISN_PLUTO;
187                 strcpy(game.stationedName, "Pluto");
188                 initPlanetMissions(game.system);
189
190                 if (game.difficulty == DIFFICULTY_ORIGINAL)
191                         player.maxShield = 100;
192         }
193         else // Update the mission for the planet
194         {
195                 systemPlanet[game.stationedPlanet].missionCompleted = 1;
196         }
197
198         strcpy(game.destinationName, "None");
199         game.destinationPlanet = game.stationedPlanet;
200 }
201
202 /*
203 Mission Completed Variables:
204
205 0  : Not Completed
206 1  : Completed
207 2  : Just Completed
208 3  : Constraint
209 -1 : Mission Failed
210 -2 : Just Failed
211
212 Timer Variable:
213 1+ : Time in minutes
214 -1 : Time up
215 -2 : No timer
216 */
217 static void clearAllMissions()
218 {
219         for (int m = 0 ; m < MISN_MAX ; m++)
220         {
221                 for (int i = 0 ; i < 3 ; i++)
222                 {
223                         strcpy(missions[m].primaryObjective[i], "");
224                         missions[m].primaryType[i] = NONE;
225                         missions[m].target1[i] = -1;
226                         missions[m].targetValue1[i] = -1;
227                         missions[m].timeLimit1[i] = -2;
228                         missions[m].completed1[i] = 1;
229                 }
230
231                 for (int i = 0 ; i < 3 ; i++)
232                 {
233                         strcpy(missions[m].secondaryObjective[i], "");
234                         missions[m].secondaryType[i] = NONE;
235                         missions[m].target2[i] = -1;
236                         missions[m].targetValue2[i] = -1;
237                         missions[m].timeLimit2[i] = -2;
238                         missions[m].completed2[i] = 1;
239                 }
240
241                 missions[m].addAliens = -1;
242         }
243 }
244
245 /*
246 Sets the currentMission object to the mission number the player
247 is currently on. Timing is assigned if it is required. The rate
248 at which to add enemies in this mission is also set.
249 */
250 void setMission(int mission)
251 {
252         currentMission = missions[mission];
253         engine.minutes = currentMission.timeLimit1[0];
254
255         for (int i = 0 ; i < 3 ; i++)
256         {
257                 if (currentMission.timeLimit1[i] > engine.minutes)
258                         engine.minutes = currentMission.timeLimit1[i];
259                 if (currentMission.timeLimit2[i] > engine.minutes)
260                         engine.minutes = currentMission.timeLimit2[i];
261
262                 if (currentMission.completed1[i] == 0)
263                         currentMission.remainingObjectives1++;
264                 if (currentMission.completed2[i] == 0)
265                         currentMission.remainingObjectives1++;
266         }
267
268         engine.addAliens = currentMission.addAliens;
269
270         if (engine.minutes > -1)
271         {
272                 engine.timeMission = 1;
273                 engine.seconds = 0;
274         }
275
276         engine.counter2 = 0;
277         engine.timeTaken = 0;
278 }
279
280 /*
281 Call this whenever a mission requires all the remaining aliens to
282 automatically die
283 */
284 static void mission_killAllEnemies()
285 {
286         for (int i = 0 ; i < ALIEN_MAX ; i++)
287         {
288                 if ((aliens[i].flags & FL_WEAPCO) && (aliens[i].active) &&
289                                 (aliens[i].shield > 0))
290                         aliens[i].shield = 0;
291         }
292 }
293
294 void checkTimer()
295 {
296         for (int i = 0 ; i < 3 ; i++)
297         {
298                 if ((currentMission.timeLimit1[i] == -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
299                         currentMission.completed1[i] = -2;
300         }
301
302         for (int i = 0 ; i < 3 ; i++)
303         {
304                 if ((currentMission.timeLimit2[i] == -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
305                         currentMission.completed2[i] = -2;
306         }
307
308         // Find out if there are any uncompleted missions that require the timer
309         engine.timeMission = 0;
310         for (int i = 0 ; i < 3 ; i++)
311         {
312                 if ((currentMission.timeLimit1[i] > -1) && (currentMission.completed1[i] == OB_INCOMPLETE))
313                         engine.timeMission = 1;
314                 if ((currentMission.timeLimit2[i] > -1) && (currentMission.completed2[i] == OB_INCOMPLETE))
315                         engine.timeMission = 1;
316         }
317
318         // specific to Spirit Boss
319         if ((game.area == MISN_MOEBO) &&
320                         (currentMission.completed1[0] < OB_INCOMPLETE))
321                 engine.timeMission = 1;
322
323         // specific to the Asteroid belt
324         if ((game.area == MISN_MARS) &&
325                 (currentMission.completed1[0] < OB_INCOMPLETE))
326         {
327                 currentMission.completed1[0] = OB_COMPLETED;
328                 mission_killAllEnemies();
329                 engine.addAliens = -1;
330                 setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN);
331         }
332 }
333
334 static void evaluateRequirement(int type, int id, int *completed, int *targetValue, int fontColor)
335 {
336         char message[25];
337
338         if ((*targetValue <= 0) && (type != M_PROTECT_TARGET) &&
339                 (type != M_PROTECT_PICKUP))
340         {
341                 *completed = 2;
342                 checkTimer();
343                 if ((game.area == MISN_URUSOR) && (type == M_DISABLE_TARGET))
344                         setRadioMessage(FACE_SID, "All vessels disabled!", 1);
345         }
346         else
347         {
348                 strcpy(message, "");
349                 switch(type)
350                 {
351                         case M_COLLECT:
352                                 switch(id)
353                                 {
354                                         case P_CASH:
355                                                 sprintf(message, "Collect $%d more...", *targetValue);
356                                                 if ((rand() % 2) == 0)
357                                                         sprintf(message, "$%d more to go...", *targetValue);
358                                                 break;
359                                         case P_CARGO:
360                                                 sprintf(message, "Collect %d more...", *targetValue);
361                                                 if ((rand() % 2) == 0)
362                                                         sprintf(message, "%d more to go...", *targetValue);
363                                                 break;
364                                         case P_ORE:
365                                                 sprintf(message, "Collect %d more...", *targetValue);
366                                                 if ((rand() % 2) == 0)
367                                                         sprintf(message, "%d more to go...", *targetValue);
368                                                 break;
369                                 }
370                                 break;
371                         case M_PROTECT_PICKUP:
372                                 *completed = -2;
373                                 switch(id)
374                                 {
375                                         case P_CARGO:
376                                                 sprintf(message, "Cargo pod destroyed!");
377                                                 if (game.area == MISN_CERADSE) // Get lectured by Sid
378                                                         setRadioMessage(FACE_SID, "Chris, we needed that pod!! I warned you that we couldn't afford to lose a single one!!", 1);
379                                                 break;
380                                         case P_ESCAPEPOD:
381                                                 sprintf(message, "Escape Pod lost!");
382                                                 if (game.area == MISN_ODEON) // Get lectured by Phoebe
383                                                         setRadioMessage(FACE_PHOEBE, "No... Ursula...", 1);
384                                                 break;
385                                 }
386                                 break;
387                         case M_PROTECT_TARGET:
388                                 if (*targetValue <= 0)
389                                 {
390                                         *completed = -2;
391                                         switch (game.area)
392                                         {
393                                                 case MISN_NEROD:
394                                                         setRadioMessage(FACE_SID, "Dammit, Chris! We just lost her!", 1);
395                                                         break;
396                                                 case MISN_ALLEZ:
397                                                         setRadioMessage(FACE_CREW, "Noooo!! Hull bre...", 1);
398                                                         break;
399                                                 case MISN_URUSOR:
400                                                         setRadioMessage(FACE_SID, "Chris, we've got to disable them, not destroy them!!", 1);
401                                                         break;
402                                         }
403                                 }
404                                 break;
405                         case M_DESTROY_TARGET_TYPE:
406                                 if ((*targetValue <= 10) || (*targetValue % 10 == 0))
407                                 {
408                                         if ((rand() % 2) == 0)
409                                                 sprintf(message, "%d more to go...", *targetValue);
410                                         else
411                                                 sprintf(message, "Destroy %d more...", *targetValue);
412                                 }
413                                 break;
414                         case M_DISABLE_TARGET:
415                                 sprintf(message, "Disable %d more...", *targetValue);
416                                 break;
417                 }
418
419                 if (strcmp(message, "") != 0)
420                         setInfoLine(message, fontColor);
421         }
422 }
423
424 void updateMissionRequirements(int type, int id, int value)
425 {
426         // Can't complete missions if you're dead!
427         if (player.shield <= 0)
428                 return;
429
430         char message[25];
431         char matched = 0;
432
433         // We don't need to worry here since if Sid dies,
434         // you will automatically fail the mission(!)
435         if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_SID))
436         {
437                 setInfoLine("Sid has been killed!!", FONT_RED);
438                 setRadioMessage(FACE_CHRIS, "Sid... I... I'm sorry...", 1);
439                 currentMission.completed1[0] = -2;
440         }
441
442         for (int i = 0 ; i < 3 ; i++)
443         {
444                 if ((currentMission.completed1[i] == OB_INCOMPLETE) || (currentMission.completed1[i] == OB_CONDITION))
445                 {
446                         if ((currentMission.primaryType[i] == type) &&
447                                 ((currentMission.target1[i] == id) ||
448                                         (currentMission.target1[i] == CD_ANY)))
449                         {
450                                 matched = 1;
451                                 currentMission.targetValue1[i] -= value;
452                                 evaluateRequirement(type, id, &currentMission.completed1[i], &currentMission.targetValue1[i], FONT_CYAN);
453                         }
454                 }
455         }
456
457         // Don't evaluate secondary objectives at the same time!
458         if (matched)
459                 return;
460
461         for (int i = 0 ; i < 3 ; i++)
462         {
463                 if ((currentMission.completed2[i] == OB_INCOMPLETE) || (currentMission.completed2[i] == OB_CONDITION))
464                 {
465                         if ((currentMission.secondaryType[i] == type) &&
466                                 ((currentMission.target2[i] == id) ||
467                                         (currentMission.target2[i] == CD_ANY)))
468                         {
469                                 currentMission.targetValue2[i] -= value;
470                                 evaluateRequirement(type, id, &currentMission.completed2[i], &currentMission.targetValue2[i], FONT_YELLOW);
471                                 return;
472                         }
473                 }
474         }
475
476         // Special Case - Interceptions
477         if (game.area == MISN_INTERCEPTION)
478         {
479                 if ((type == M_COLLECT) && (id == P_SLAVES))
480                 {
481                         if (systemPlanet[9].missionCompleted == 0)
482                         {
483                                 if (game.slavesRescued >= 250)
484                                 {
485                                         setInfoLine("*** Slaves Rescued - Mission Completed ***", FONT_GREEN);
486                                         systemPlanet[9].missionCompleted = 1;
487                                 }
488                                 else
489                                 {
490                                         sprintf(message, "Rescue %d more...", 250 - game.slavesRescued);
491                                         setInfoLine(message, FONT_CYAN);
492                                 }
493                         }
494                 }
495
496                 if ((type == M_DESTROY_TARGET_TYPE) && (id == CD_CLOAKFIGHTER))
497                 {
498                         setInfoLine("*** Experimental Fighter Destroyed - Mission Completed ***", FONT_GREEN);
499                         systemPlanet[9].missionCompleted = 1;
500                         setRadioMessage(FACE_CHRIS, "That's one less suprise that WEAPCO can spring on us!", 1);
501                         game.experimentalShield = 0;
502                 }
503         }
504 }
505
506 /*
507 This is only used as few times in the game.
508 Missions 11 and 23 to be exact!
509 */
510 static char revealHiddenObjectives()
511 {
512         char allDone = 1;
513         char string[255] = "";
514
515         for (int i = 0 ; i < 3 ; i++)
516         {
517                 if (currentMission.completed1[i] == OB_HIDDEN)
518                 {
519                         currentMission.completed1[i] = OB_INCOMPLETE;
520                         sprintf(string, "New Objective - %s", currentMission.primaryObjective[i]);
521                         setInfoLine(string, FONT_CYAN);
522                         allDone = 0;
523                 }
524         }
525
526         if (!allDone)
527         {
528                 // Activate Kline!! :)
529                 if (game.area == MISN_ELAMALE)
530                 {
531                         mission_killAllEnemies();
532                         syncScriptEvents();
533                         aliens[ALIEN_KLINE].active = true;
534                         aliens[ALIEN_KLINE].x = player.x + 1000;
535                         aliens[ALIEN_KLINE].y = player.y;
536                         aliens[ALIEN_KLINE].flags |= FL_IMMORTAL | FL_NOFIRE;
537                         player_setTarget(ALIEN_KLINE);
538                         audio_playMusic("music/last_cyber_dance.ogg", -1);
539                 }
540         }
541
542         return allDone;
543 }
544
545 bool allMissionsCompleted()
546 {
547         for (int i = 0 ; i < 3 ; i++)
548         {
549                 if (currentMission.completed1[i] == OB_INCOMPLETE)
550                 {
551                         if ((currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
552                         {
553                                 currentMission.completed1[i] = 2;
554                                 checkTimer();
555                         }
556                 }
557         }
558
559         for (int i = 0 ; i < 3 ; i++)
560         {
561                 if (currentMission.completed2[i] == OB_INCOMPLETE)
562                 {
563                         if ((currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS) && (engine.allAliensDead) && (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 1))
564                         {
565                                 currentMission.completed2[i] = 2;
566                                 checkTimer();
567                         }
568                 }
569         }
570
571         for (int i = 0 ; i < 3 ; i++)
572         {
573                 if (currentMission.completed1[i] == 2)
574                 {
575                         if (currentMission.remainingObjectives1 > 1)
576                         {
577                                 if ((game.area != MISN_POSWIC) || (i != 1))
578                                         setInfoLine("*** Primary Objective Completed ***", FONT_GREEN);
579                                 else
580                                         setInfoLine(">>> Primary Objective Failed <<<", FONT_RED);
581                                 currentMission.completed1[i] = OB_COMPLETED;
582                         }
583                         else
584                         {
585                                 if (game.area != MISN_INTERCEPTION)
586                                         setInfoLine("*** All Primary Objectives Completed ***", FONT_GREEN);
587                                 else
588                                         setInfoLine("*** Interception Destroyed ***", FONT_GREEN);
589                                 currentMission.completed1[i] = OB_COMPLETED;
590
591                                 // do some area specific things
592                                 if ((game.area == MISN_MOEBO) ||
593                                         (game.area == MISN_DORIM) ||
594                                         (game.area == MISN_ELLESH) ||
595                                         (game.area == MISN_MARS))
596                                 {
597                                         if (currentMission.remainingObjectives2 == 0)
598                                         {
599                                                 mission_killAllEnemies();
600                                                 engine.addAliens = -1;
601                                         }
602                                 }
603
604                                 if (game.area == MISN_EARTH)
605                                         setRadioMessage(FACE_CHRIS, "You guys stay here and keep things under control. I'm going after Kethlan!", 1);
606                         }
607                 }
608
609                 if (currentMission.completed2[i] == 2)
610                 {
611                         if (currentMission.remainingObjectives2 > 1)
612                         {
613                                 setInfoLine("*** Secondary Objective Completed ***", FONT_GREEN);
614                                 currentMission.completed2[i] = OB_COMPLETED;
615                         }
616                         else
617                         {
618                                 setInfoLine("*** All Secondary Objectives Completed ***", FONT_GREEN);
619                                 currentMission.completed2[i] = OB_COMPLETED;
620
621                                 // do some area specific things
622                                 if ((game.area == MISN_DORIM) &&
623                                         (currentMission.remainingObjectives1 == 0))
624                                 {
625                                         mission_killAllEnemies();
626                                         engine.addAliens = -1;
627                                 }
628                         }
629                 }
630
631                 if (currentMission.completed1[i] == -2)
632                 {
633                         setInfoLine(">>> MISSION FAILED <<<", FONT_RED);
634                         currentMission.completed1[i] = OB_FAILED;
635                 }
636
637                 if (currentMission.completed2[i] == -2)
638                 {
639                         setInfoLine(">>> Secondary Objective Failed <<<", FONT_RED);
640                         currentMission.completed2[i] = OB_FAILED;
641                 }
642         }
643
644         signed char remaining;
645         bool add = false;
646         bool allDone = true;
647
648         // Zero objective list for a recount
649         currentMission.remainingObjectives1 = currentMission.remainingObjectives2 = 0;
650
651         for (int i = 0 ; i < 3 ; i++)
652         {
653                 if (currentMission.primaryType[i] != NONE)
654                 {
655                         if (currentMission.completed1[i] == 0)
656                         {
657                                 currentMission.remainingObjectives1++;
658                                 if (currentMission.primaryType[i] == M_DESTROY_ALL_TARGETS)
659                                         add = true;
660                                 allDone = false;
661                         }
662
663                         if (currentMission.completed1[i] < 0)
664                                 return false;
665                 }
666                 if (currentMission.secondaryType[i] != NONE)
667                 {
668                         if (currentMission.completed2[i] == 0)
669                         {
670                                 currentMission.remainingObjectives2++;
671                                 if (currentMission.secondaryType[i] == M_DESTROY_ALL_TARGETS)
672                                         add = true;
673                                 allDone = false;
674                         }
675                 }
676         }
677
678         if (allDone)
679                 allDone = revealHiddenObjectives();
680
681         remaining = currentMission.remainingObjectives1 + currentMission.remainingObjectives2;
682
683         // We've only got one objective left and it's destroy all targets,
684         // so stop adding aliens (otherwise it might be impossible to finish!)
685         if ((add) && (remaining == 1))
686                 engine.addAliens = -1;
687
688         return allDone;
689 }
690
691 bool missionFailed()
692 {
693         for (int i = 0 ; i < 3 ; i++)
694         {
695                 if (currentMission.completed1[i] < 0)
696                 {
697                         return true;
698                 }
699         }
700
701         return false;
702 }
703
704 static void drawBriefScreen()
705 {
706         SDL_Rect r = {0, 0, (uint16_t)screen->w, 2};
707
708         for (int i = 0 ; i < (int)(screen->h / 4) - 30 ; i++)
709         {
710                 r.y = (i * 2) + 62; // Not a typo; a black gap is left in the middle if it's 60.
711                 SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
712                 r.y = (screen->h - (i * 2) - 60);
713                 SDL_FillRect(screen, &r, SDL_MapRGB(screen->format, 0, i, 0));
714         }
715
716         blevelRect(140, 70, 500, 20, 0x00, 0x77, 0x00);
717         blevelRect(140, 90, 500, 130, 0x00, 0x33, 0x00);
718         drawString("Primary Objectives", 150, 74, FONT_WHITE);
719
720         for (int i = 0 ; i < 3 ; i++)
721         {
722                 if ((currentMission.primaryType[i] != NONE) && (currentMission.completed1[i] != OB_HIDDEN))
723                 {
724                         drawString(currentMission.primaryObjective[i], 160, 114 + (i * 30), FONT_WHITE);
725                 }
726         }
727
728         if (currentMission.secondaryType[0] != NONE)
729         {
730                 blevelRect(140, 230, 500, 20, 0x00, 0x77, 0x77);
731                 blevelRect(140, 250, 500, 130, 0x00, 0x33, 0x33);
732                 drawString("Secondary Objectives", 150, 234, FONT_WHITE);
733
734                 for (int i = 0 ; i < 3 ; i++)
735                 {
736                         if (currentMission.secondaryType[i] != NONE)
737                         {
738                                 drawString(currentMission.secondaryObjective[i], 160, 274 + (i * 30), FONT_WHITE);
739                                 game.secondaryMissions++;
740                         }
741                 }
742         }
743
744         blevelRect(140, 390, 500, 20, 0x77, 0x77, 0x00);
745         blevelRect(140, 410, 500, 130, 0x33, 0x33, 0x00);
746         drawString("Additional Information", 150, 394, FONT_WHITE);
747 }
748
749 /*
750 Simply displays a screen with all the mission information on it, pulled
751 back from the data stored in the currentMission object. The music for the
752 mission begins playing here.
753 */
754 void missionBriefScreen()
755 {
756         clearScreen(black);
757         updateScreen();
758
759         if (game.area != MISN_INTERCEPTION)
760         {
761                 clearScreen(black);
762                 drawBriefScreen();
763
764                 if (currentMission.timeLimit1[0] > 0)
765                 {
766                         char temp[50];
767                         if (game.area != MISN_MARS)
768                                 sprintf(temp, "TIME LIMIT: %d minutes", currentMission.timeLimit1[0]);
769                         else
770                                 sprintf(temp, "SURVIVAL FOR %d minutes", currentMission.timeLimit1[0]);
771                         drawString(temp, -1, 500, FONT_RED);
772                 }
773
774                 switch (game.area)
775                 {
776                         case MISN_URUSOR:
777                         case MISN_DORIM:
778                         case MISN_SIVEDI:
779                         case MISN_ALMARTHA:
780                         case MISN_ELLESH:
781                         case MISN_MARS:
782                         case MISN_VENUS:
783                                 drawString("Phoebe Lexx will not be present", 160, 420, FONT_WHITE);
784                                 if (game.hasWingMate2)
785                                         drawString("Ursula Lexx will not be present", 160, 450, FONT_WHITE);
786                                 break;
787                 }
788
789                 if ((game.area == MISN_URUSOR) ||
790                                 (game.area == MISN_POSWIC) ||
791                                 (game.area == MISN_EARTH))
792                         drawString("Sid Wilson will join you on this mission", 160, 480, FONT_WHITE);
793
794                 updateScreen();
795         }
796
797         loadGameGraphics();
798         textSurface(4, "Shield", 25, 550, FONT_WHITE);
799         textSurface(5, "Plasma:", 250, 550, FONT_WHITE);
800
801         if (player.weaponType[1] == W_CHARGER)
802                 textSurface(6, "Charge", 385, 550, FONT_WHITE);
803         else if (player.weaponType[1] == W_LASER)
804                 textSurface(6, "Heat", 405, 550, FONT_WHITE);
805         else
806                 textSurface(6, "Rockets:", 385, 550, FONT_WHITE);
807
808         textSurface(7, "Target", 550, 550, FONT_WHITE);
809         textSurface(8, "Cash: $", 25, 20, FONT_WHITE);
810         textSurface(9, "Objectives Remaining:", 550, 20, FONT_WHITE);
811         textSurface(10, "Time Remaining - ", 260, 20, FONT_WHITE);
812         textSurface(11, "Power", 25, 570, FONT_WHITE);
813         textSurface(12, "Output", 250, 570, FONT_WHITE);
814         textSurface(13, "Cooler", 485, 570, FONT_WHITE);
815         audio_playRandomTrack();
816
817         if (game.area != MISN_INTERCEPTION)
818         {
819                 drawString("PRESS ENTER TO CONTINUE...", -1, 550, FONT_WHITE);
820
821                 updateScreen();
822
823                 flushInput();
824                 engine.done = 0;
825                 engine.keyState[KEY_FIRE] = 0;
826                 engine.keyState[KEY_ALTFIRE] = 0;
827                 engine.keyState[KEY_ESCAPE] = 0;
828
829                 while (true)
830                 {
831                         delayFrame();
832                         getPlayerInput();
833                         if ((engine.keyState[KEY_FIRE]) || (engine.keyState[KEY_ALTFIRE]) ||
834                                         (engine.keyState[KEY_ESCAPE]))
835                                 break;
836                 }
837
838                 clearScreen(black);
839                 updateScreen();
840                 clearScreen(black);
841         }
842
843         engine.gameSection = SECTION_GAME;
844 }
845
846 /*
847 Display a screen showing all the information from the mission
848 the player has just done. This includes objectives that have been
849 completed and failed. A mission timer is also displayed at the bottom
850 of the screen.
851 */
852 void missionFinishedScreen()
853 {
854         int shield_bonus;
855         char temp[100];
856
857         if (game.area != MISN_INTERCEPTION)
858         {
859                 clearScreen(black);
860                 updateScreen();
861
862                 if (game.shots > 0)
863                         game.accuracy = (game.hits * 100) / game.shots;
864
865                 clearScreen(black);
866                 drawBriefScreen();
867
868                 for (int i = 0 ; i < 3 ; i++)
869                 {
870                         if (currentMission.primaryType[i] != NONE)
871                         {
872                                 if ((game.area != MISN_POSWIC) || (i != 1))
873                                         drawString("COMPLETED", 550, 114 + (i * 30), FONT_GREEN);
874                                 else
875                                         drawString("FAILED", 550, 114 + (i * 30), FONT_RED);
876                         }
877                 }
878
879                 if (currentMission.secondaryType[0] != NONE)
880                 {
881                         for (int i = 0 ; i < 3 ; i++)
882                         {
883                                 if (currentMission.secondaryType[i] != NONE)
884                                 {
885                                         strcpy(temp, currentMission.secondaryObjective[i]);
886                                         if (currentMission.completed2[i] >= 1)
887                                         {
888                                                 drawString("COMPLETED", 550, 274 + (i * 30), FONT_GREEN);
889                                                 game.secondaryMissionsCompleted++;
890                                         }
891                                         else
892                                         {
893                                                 drawString("FAILED", 550, 274 + (i * 30), FONT_RED);
894                                         }
895                                 }
896                         }
897                 }
898
899                 if (currentMission.remainingObjectives1 + currentMission.remainingObjectives2 == 0)
900                 {
901                         shield_bonus = player.shield * 10;
902                         sprintf(temp, "Shield Bonus: $%.3d", shield_bonus);
903                         drawString(temp, -1, 430, FONT_WHITE);
904                         game.cash += shield_bonus;
905                         game.cashEarned += shield_bonus;
906                 }
907
908                 game.timeTaken += engine.timeTaken;
909
910                 snprintf(temp, sizeof temp, "Mission Time: %2ld:%02ld:%02ld",
911                         engine.timeTaken / 3600, (engine.timeTaken / 60) % 60,
912                         engine.timeTaken % 60);
913
914                 drawString(temp, -1, 500, FONT_WHITE);
915
916                 // Do some mission specific stuff here...
917                 if (game.area == MISN_HAIL)
918                         game.cash -= 500;
919                 else if (game.area == MISN_ODEON)
920                         game.hasWingMate2 = 1;
921                 else if (game.area == MISN_ALMARTHA)
922                         game.cash -= 2000;
923
924                 checkForBossMission();
925
926                 updateScreen();
927
928                 flushInput();
929                 engine.done = 0;
930                 engine.keyState[KEY_FIRE] = 0;
931
932                 while (true)
933                 {
934                         delayFrame();
935                         getPlayerInput();
936                         if ((engine.keyState[KEY_FIRE]))
937                                 break;
938                 }
939         }
940
941         // Stop people from "selling" Laser ammo as rockets.
942         if (player.weaponType[1] == W_LASER)
943                 player.ammo[1] = 1;
944
945         audio_haltMusic();
946 }
947
948 /*
949 This is where all the missions are defined.
950 */
951 void initMissions()
952 {
953         clearAllMissions();
954
955         // Seconds to wait between attempting to add an enemy
956         int SOMETIMES    = 40 * 60;
957         int NORMAL       = 15 * 60;
958         int FREQUENT     = 5 * 60;
959         int ALWAYS       = 1 * 60;
960         int NEVER        = -1;
961
962
963         sprintf(missions[MISN_START].primaryObjective[0],
964                 "Escape from WEAPCO Persuit");
965         missions[MISN_START].primaryType[0] = M_DESTROY_ALL_TARGETS;
966         missions[MISN_START].completed1[0] = OB_INCOMPLETE;
967
968
969         sprintf(missions[MISN_HAIL].primaryObjective[0],
970                 "Collect $500 to pay Mercenary for FIREFLY");
971         missions[MISN_HAIL].primaryType[0] = M_COLLECT;
972         missions[MISN_HAIL].target1[0] = P_CASH;
973         missions[MISN_HAIL].targetValue1[0] = 500;
974         missions[MISN_HAIL].completed1[0] = OB_INCOMPLETE;
975
976         sprintf(missions[MISN_HAIL].primaryObjective[1],
977                 "Destroy all remaining WEAPCO fighters");
978         missions[MISN_HAIL].primaryType[1] = M_DESTROY_ALL_TARGETS;
979         missions[MISN_HAIL].completed1[1] = OB_INCOMPLETE;
980
981         missions[MISN_HAIL].addAliens = FREQUENT;
982
983
984         sprintf(missions[MISN_CERADSE].primaryObjective[0],
985                 "Collect 6 Cargo Pods");
986         missions[MISN_CERADSE].primaryType[0] = M_COLLECT;
987         missions[MISN_CERADSE].target1[0] = P_CARGO;
988         missions[MISN_CERADSE].targetValue1[0] = 6;
989         missions[MISN_CERADSE].completed1[0] = OB_INCOMPLETE;
990
991         sprintf(missions[MISN_CERADSE].primaryObjective[1],
992                 "Do not destroy *ANY* Cargo Pods");
993         missions[MISN_CERADSE].primaryType[1] = M_PROTECT_PICKUP;
994         missions[MISN_CERADSE].target1[1] = P_CARGO;
995         missions[MISN_CERADSE].targetValue1[1] = 0;
996         missions[MISN_CERADSE].completed1[1] = OB_CONDITION;
997
998         sprintf(missions[MISN_CERADSE].secondaryObjective[0],
999                 "Destroy all remaining WEAPCO fighters");
1000         missions[MISN_CERADSE].secondaryType[0] = M_DESTROY_ALL_TARGETS;
1001         missions[MISN_CERADSE].completed2[0] = OB_INCOMPLETE;
1002
1003         missions[MISN_CERADSE].addAliens = FREQUENT;
1004
1005
1006         sprintf(missions[MISN_HINSTAG].primaryObjective[0],
1007                 "Destroy 5 WEAPCO Missile Boats");
1008         missions[MISN_HINSTAG].primaryType[0] = M_DESTROY_TARGET_TYPE;
1009         missions[MISN_HINSTAG].target1[0] = CD_MISSILEBOAT;
1010         missions[MISN_HINSTAG].targetValue1[0] = 5;
1011         missions[MISN_HINSTAG].completed1[0] = OB_INCOMPLETE;
1012
1013         sprintf(missions[MISN_HINSTAG].secondaryObjective[0],
1014                 "Destroy all remaining WEAPCO fighters");
1015         missions[MISN_HINSTAG].secondaryType[0] = M_DESTROY_ALL_TARGETS;
1016         missions[MISN_HINSTAG].completed2[0] = OB_INCOMPLETE;
1017
1018         missions[MISN_HINSTAG].addAliens = NORMAL;
1019
1020
1021         sprintf(missions[MISN_JOLDAR].primaryObjective[0],
1022                 "Destroy 9 WEAPCO Miners");
1023         missions[MISN_JOLDAR].primaryType[0] = M_DESTROY_TARGET_TYPE;
1024         missions[MISN_JOLDAR].target1[0] = CD_MINER;
1025         missions[MISN_JOLDAR].targetValue1[0] = 9;
1026         missions[MISN_JOLDAR].completed1[0] = OB_INCOMPLETE;
1027
1028         sprintf(missions[MISN_JOLDAR].secondaryObjective[0],
1029                 "Destroy all remaining WEAPCO fighters");
1030         missions[MISN_JOLDAR].secondaryType[0] = M_DESTROY_ALL_TARGETS;
1031         missions[MISN_JOLDAR].completed2[0] = OB_INCOMPLETE;
1032
1033         missions[MISN_JOLDAR].addAliens = NORMAL;
1034
1035
1036         sprintf(missions[MISN_MOEBO].primaryObjective[0],
1037                 "Destroy WEAPCO Frigate");
1038         missions[MISN_MOEBO].primaryType[0] = M_DESTROY_TARGET_TYPE;
1039         missions[MISN_MOEBO].target1[0] = CD_BOSS;
1040         missions[MISN_MOEBO].targetValue1[0] = 1;
1041         missions[MISN_MOEBO].completed1[0] = OB_INCOMPLETE;
1042         
1043         missions[MISN_MOEBO].timeLimit1[0] = 3;
1044
1045         missions[MISN_MOEBO].addAliens = SOMETIMES;
1046
1047
1048         sprintf(missions[MISN_NEROD].primaryObjective[0], "Rescue Phoebe Lexx");
1049         missions[MISN_NEROD].primaryType[0] = M_DESTROY_TARGET_TYPE;
1050         missions[MISN_NEROD].target1[0] = CD_CARGOSHIP;
1051         missions[MISN_NEROD].targetValue1[0] = 1;
1052         missions[MISN_NEROD].completed1[0] = OB_INCOMPLETE;
1053
1054         sprintf(missions[MISN_NEROD].primaryObjective[1],
1055                 "Do not allow Phoebe to be killed");
1056         missions[MISN_NEROD].primaryType[1] = M_PROTECT_TARGET;
1057         missions[MISN_NEROD].target1[1] = CD_PHOEBE;
1058         missions[MISN_NEROD].targetValue1[1] = 0;
1059         missions[MISN_NEROD].completed1[1] = OB_CONDITION;
1060
1061         sprintf(missions[MISN_NEROD].primaryObjective[2],
1062                 "Destroy all WEAPCO forces");
1063         missions[MISN_NEROD].primaryType[2] = M_DESTROY_TARGET_TYPE;
1064         missions[MISN_NEROD].target1[2] = CD_ANY;
1065         missions[MISN_NEROD].targetValue1[2] = 35;
1066         missions[MISN_NEROD].completed1[2] = OB_INCOMPLETE;
1067
1068         missions[MISN_NEROD].addAliens = ALWAYS;
1069
1070
1071         sprintf(missions[MISN_ALLEZ].primaryObjective[0],
1072                 "Assist medical supply craft");
1073         missions[MISN_ALLEZ].primaryType[0] = M_ESCAPE_TARGET;
1074         missions[MISN_ALLEZ].target1[0] = CD_GOODTRANSPORT;
1075         missions[MISN_ALLEZ].targetValue1[0] = 0;
1076         missions[MISN_ALLEZ].completed1[0] = OB_INCOMPLETE;
1077
1078         sprintf(missions[MISN_ALLEZ].primaryObjective[1],
1079                 "Do not allow supply craft to be destroyed");
1080         missions[MISN_ALLEZ].primaryType[1] = M_PROTECT_TARGET;
1081         missions[MISN_ALLEZ].target1[1] = CD_GOODTRANSPORT;
1082         missions[MISN_ALLEZ].targetValue1[1] = 0;
1083         missions[MISN_ALLEZ].completed1[1] = OB_CONDITION;
1084         
1085         sprintf(missions[MISN_ALLEZ].secondaryObjective[0],
1086                 "Destroy all remaining WEAPCO fighters");
1087         missions[MISN_ALLEZ].secondaryType[0] = M_DESTROY_ALL_TARGETS;
1088         missions[MISN_ALLEZ].completed2[0] = OB_INCOMPLETE;
1089
1090         missions[MISN_ALLEZ].addAliens = FREQUENT;
1091
1092
1093         sprintf(missions[MISN_URUSOR].primaryObjective[0],
1094                 "Disable five WEAPCO supply craft");
1095         missions[MISN_URUSOR].primaryType[0] = M_DISABLE_TARGET;
1096         missions[MISN_URUSOR].target1[0] = CD_CARGOSHIP;
1097         missions[MISN_URUSOR].targetValue1[0] = 5;
1098         missions[MISN_URUSOR].completed1[0] = OB_INCOMPLETE;
1099
1100         sprintf(missions[MISN_URUSOR].primaryObjective[1],
1101                 "Destroy all remaining WEAPCO fighters");
1102         missions[MISN_URUSOR].primaryType[1] = M_DESTROY_ALL_TARGETS;
1103         missions[MISN_URUSOR].completed1[1] = OB_INCOMPLETE;
1104
1105         sprintf(missions[MISN_URUSOR].primaryObjective[2],
1106                 "Protect supply craft AND Sid Wilson");
1107         missions[MISN_URUSOR].primaryType[2] = M_PROTECT_TARGET;
1108         missions[MISN_URUSOR].target1[2] = CD_CARGOSHIP;
1109         missions[MISN_URUSOR].targetValue1[2] = 0;
1110         missions[MISN_URUSOR].completed1[2] = OB_CONDITION;
1111
1112         missions[MISN_URUSOR].addAliens = FREQUENT;
1113
1114
1115         sprintf(missions[MISN_DORIM].primaryObjective[0],
1116                 "Locate doctor's escape pod");
1117         missions[MISN_DORIM].primaryType[0] = M_COLLECT;
1118         missions[MISN_DORIM].target1[0] = P_ESCAPEPOD;
1119         missions[MISN_DORIM].targetValue1[0] = 1;
1120         missions[MISN_DORIM].completed1[0] = OB_INCOMPLETE;
1121
1122         sprintf(missions[MISN_DORIM].primaryObjective[1],
1123                 "Do not destroy doctor's escape pod");
1124         missions[MISN_DORIM].primaryType[1] = M_PROTECT_PICKUP;
1125         missions[MISN_DORIM].target1[1] = P_ESCAPEPOD;
1126         missions[MISN_DORIM].targetValue1[1] = 1; // DONE ON PURPOSE!! DO NOT CHANGE THIS!!!!
1127         missions[MISN_DORIM].completed1[1] = OB_CONDITION;
1128
1129         sprintf(missions[MISN_DORIM].secondaryObjective[0],
1130                 "Collect 10 pieces of Ore");
1131         missions[MISN_DORIM].secondaryType[0] = M_COLLECT;
1132         missions[MISN_DORIM].target2[0] = P_ORE;
1133         missions[MISN_DORIM].targetValue2[0] = 10;
1134         missions[MISN_DORIM].completed2[0] = OB_INCOMPLETE;
1135
1136         missions[MISN_DORIM].addAliens = ALWAYS;
1137
1138         missions[MISN_DORIM].timeLimit1[0] = 3;
1139         missions[MISN_DORIM].timeLimit2[0] = 3;
1140
1141
1142         sprintf(missions[MISN_ELAMALE].primaryObjective[0],
1143                 "Destroy WEAPCO ore mining craft");
1144         missions[MISN_ELAMALE].primaryType[0] = M_DESTROY_TARGET_TYPE;
1145         missions[MISN_ELAMALE].target1[0] = CD_BOSS;
1146         missions[MISN_ELAMALE].targetValue1[0] = 1;
1147         missions[MISN_ELAMALE].completed1[0] = OB_INCOMPLETE;
1148
1149         sprintf(missions[MISN_ELAMALE].secondaryObjective[0],
1150                 "Save present slaves");
1151         missions[MISN_ELAMALE].secondaryType[0] = M_PROTECT_PICKUP;
1152         missions[MISN_ELAMALE].target2[0] = P_SLAVES;
1153         missions[MISN_ELAMALE].completed2[0] = OB_CONDITION;
1154
1155         sprintf(missions[MISN_ELAMALE].primaryObjective[1], "Battle Kline");
1156         missions[MISN_ELAMALE].primaryType[1] = M_ESCAPE_TARGET;
1157         missions[MISN_ELAMALE].target1[1] = CD_KLINE;
1158         missions[MISN_ELAMALE].targetValue1[1] = 1;
1159         missions[MISN_ELAMALE].completed1[1] = OB_HIDDEN;
1160
1161         missions[MISN_ELAMALE].addAliens = NEVER;
1162
1163
1164         sprintf(missions[MISN_ODEON].primaryObjective[0], "Destroy Ursula's ship");
1165         missions[MISN_ODEON].primaryType[0] = M_DESTROY_TARGET_TYPE;
1166         missions[MISN_ODEON].target1[0] = CD_EVILURSULA;
1167         missions[MISN_ODEON].targetValue1[0] = 0;
1168         missions[MISN_ODEON].completed1[0] = OB_INCOMPLETE;
1169
1170         sprintf(missions[MISN_ODEON].primaryObjective[1],
1171                 "Capture Ursula's escape pod");
1172         missions[MISN_ODEON].primaryType[1] = M_COLLECT;
1173         missions[MISN_ODEON].target1[1] = P_ESCAPEPOD;
1174         missions[MISN_ODEON].targetValue1[1] = 1;
1175         missions[MISN_ODEON].completed1[1] = OB_INCOMPLETE;
1176
1177         sprintf(missions[MISN_ODEON].primaryObjective[2], "Do not kill Ursula");
1178         missions[MISN_ODEON].primaryType[2] = M_PROTECT_PICKUP;
1179         missions[MISN_ODEON].target1[2] = P_ESCAPEPOD;
1180         missions[MISN_ODEON].targetValue1[2] = 0;
1181         missions[MISN_ODEON].completed1[2] = OB_CONDITION;
1182
1183         sprintf(missions[MISN_ODEON].secondaryObjective[0],
1184                 "Destroy all remaining WEAPCO fighters");
1185         missions[MISN_ODEON].secondaryType[0] = M_DESTROY_ALL_TARGETS;
1186         missions[MISN_ODEON].completed2[0] = OB_INCOMPLETE;
1187
1188         missions[MISN_ODEON].addAliens = FREQUENT;
1189
1190
1191         sprintf(missions[MISN_FELLON].primaryObjective[0],
1192                 "Assist attack on WEAPCO ore mining craft");
1193         missions[MISN_FELLON].primaryType[0] = M_DESTROY_TARGET_TYPE;
1194         missions[MISN_FELLON].target1[0] = CD_BOSS;
1195         missions[MISN_FELLON].targetValue1[0] = 1;
1196         missions[MISN_FELLON].completed1[0] = OB_INCOMPLETE;
1197
1198         sprintf(missions[MISN_FELLON].primaryObjective[1],
1199                 "At least 1 rebel craft must survive");
1200         missions[MISN_FELLON].primaryType[1] = M_PROTECT_TARGET;
1201         missions[MISN_FELLON].target1[1] = CD_REBELCARRIER;
1202         missions[MISN_FELLON].targetValue1[1] = 2;
1203         missions[MISN_FELLON].completed1[1] = OB_CONDITION;
1204
1205         sprintf(missions[MISN_FELLON].primaryObjective[2],
1206                 "Destroy all present WEAPCO forces");
1207         missions[MISN_FELLON].primaryType[2] = M_DESTROY_ALL_TARGETS;
1208         missions[MISN_FELLON].completed1[2] = OB_INCOMPLETE;
1209
1210         missions[MISN_FELLON].addAliens = ALWAYS;
1211
1212
1213         sprintf(missions[MISN_SIVEDI].primaryObjective[0],
1214                 "Collect 25 pieces of Ore");
1215         missions[MISN_SIVEDI].primaryType[0] = M_COLLECT;
1216         missions[MISN_SIVEDI].target1[0] = P_ORE;
1217         missions[MISN_SIVEDI].targetValue1[0] = 25;
1218         missions[MISN_SIVEDI].completed1[0] = OB_INCOMPLETE;
1219
1220         sprintf(missions[MISN_SIVEDI].secondaryObjective[0],
1221                 "Collect 25 pieces of Ore");
1222         missions[MISN_SIVEDI].secondaryType[0] = M_COLLECT;
1223         missions[MISN_SIVEDI].target2[0] = P_ORE;
1224         missions[MISN_SIVEDI].targetValue2[0] = 25;
1225         missions[MISN_SIVEDI].completed2[0] = OB_INCOMPLETE;
1226
1227         missions[MISN_SIVEDI].addAliens = ALWAYS;
1228
1229
1230         sprintf(missions[MISN_ALMARTHA].primaryObjective[0],
1231                 "Collect $2000 to pay mercenary");
1232         missions[MISN_ALMARTHA].primaryType[0] = M_COLLECT;
1233         missions[MISN_ALMARTHA].target1[0] = P_CASH;
1234         missions[MISN_ALMARTHA].targetValue1[0] = 2000;
1235         missions[MISN_ALMARTHA].completed1[0] = OB_INCOMPLETE;
1236
1237         sprintf(missions[MISN_ALMARTHA].primaryObjective[1],
1238                 "Destroy all remaining WEAPCO fighters");
1239         missions[MISN_ALMARTHA].primaryType[1] = M_DESTROY_ALL_TARGETS;
1240         missions[MISN_ALMARTHA].completed1[1] = OB_INCOMPLETE;
1241
1242         missions[MISN_ALMARTHA].addAliens = ALWAYS;
1243
1244
1245         sprintf(missions[MISN_POSWIC].primaryObjective[0], "Destroy escorts");
1246         missions[MISN_POSWIC].primaryType[0] = M_DESTROY_TARGET_TYPE;
1247         missions[MISN_POSWIC].target1[0] = CD_ESCORT;
1248         missions[MISN_POSWIC].targetValue1[0] = 5;
1249         missions[MISN_POSWIC].completed1[0] = OB_INCOMPLETE;
1250
1251         sprintf(missions[MISN_POSWIC].primaryObjective[1],
1252                 "Disable executive transport");
1253         missions[MISN_POSWIC].primaryType[1] = M_ESCAPE_TARGET;
1254         missions[MISN_POSWIC].target1[1] = CD_BOSS;
1255         missions[MISN_POSWIC].targetValue1[1] = 1;
1256         missions[MISN_POSWIC].completed1[1] = OB_INCOMPLETE;
1257
1258         sprintf(missions[MISN_POSWIC].primaryObjective[2],
1259                 "Destroy all remaining WEAPCO fighters");
1260         missions[MISN_POSWIC].primaryType[2] = M_DESTROY_ALL_TARGETS;
1261         missions[MISN_POSWIC].completed1[2] = OB_INCOMPLETE;
1262
1263         missions[MISN_POSWIC].addAliens = NORMAL;
1264
1265
1266         sprintf(missions[MISN_ELLESH].primaryObjective[0],
1267                 "Destroy executive transport");
1268         missions[MISN_ELLESH].primaryType[0] = M_DESTROY_TARGET_TYPE;
1269         missions[MISN_ELLESH].target1[0] = CD_BOSS;
1270         missions[MISN_ELLESH].targetValue1[0] = 1;
1271         missions[MISN_ELLESH].completed1[0] = OB_INCOMPLETE;
1272
1273         missions[MISN_ELLESH].addAliens = ALWAYS;
1274
1275
1276         sprintf(missions[MISN_PLUTO].primaryObjective[0],
1277                 "Destroy planetary guardian");
1278         missions[MISN_PLUTO].primaryType[0] = M_DESTROY_TARGET_TYPE;
1279         missions[MISN_PLUTO].target1[0] = CD_PLUTOBOSS;
1280         missions[MISN_PLUTO].targetValue1[0] = 1;
1281         missions[MISN_PLUTO].completed1[0] = OB_INCOMPLETE;
1282
1283         sprintf(missions[MISN_PLUTO].primaryObjective[1],
1284                 "Destroy all remaining WEAPCO fighters");
1285         missions[MISN_PLUTO].primaryType[1] = M_DESTROY_ALL_TARGETS;
1286         missions[MISN_PLUTO].completed1[1] = OB_INCOMPLETE;
1287
1288         missions[MISN_PLUTO].timeLimit1[0] = 5;
1289         missions[MISN_PLUTO].timeLimit1[1] = 5;
1290
1291         missions[MISN_PLUTO].addAliens = ALWAYS;
1292
1293
1294         sprintf(missions[MISN_NEPTUNE].primaryObjective[0],
1295                 "Destroy planetary guardian");
1296         missions[MISN_NEPTUNE].primaryType[0] = M_DESTROY_TARGET_TYPE;
1297         missions[MISN_NEPTUNE].target1[0] = CD_NEPTUNEBOSS;
1298         missions[MISN_NEPTUNE].targetValue1[0] = 1;
1299         missions[MISN_NEPTUNE].completed1[0] = OB_INCOMPLETE;
1300
1301         sprintf(missions[MISN_NEPTUNE].primaryObjective[1],
1302                 "Destroy all remaining WEAPCO fighters");
1303         missions[MISN_NEPTUNE].primaryType[1] = M_DESTROY_ALL_TARGETS;
1304         missions[MISN_NEPTUNE].completed1[1] = OB_INCOMPLETE;
1305
1306         missions[MISN_NEPTUNE].timeLimit1[0] = 5;
1307         missions[MISN_NEPTUNE].timeLimit1[1] = 5;
1308
1309         missions[MISN_NEPTUNE].addAliens = ALWAYS;
1310
1311
1312         sprintf(missions[MISN_URANUS].primaryObjective[0],
1313                 "Destroy all present WEAPCO forces");
1314         missions[MISN_URANUS].primaryType[0] = M_DESTROY_TARGET_TYPE;
1315         missions[MISN_URANUS].target1[0] = CD_URANUSBOSS;
1316         missions[MISN_URANUS].targetValue1[0] = 1;
1317         missions[MISN_URANUS].completed1[0] = OB_INCOMPLETE;
1318
1319         sprintf(missions[MISN_URANUS].primaryObjective[1],
1320                 "Destroy all remaining WEAPCO fighters");
1321         missions[MISN_URANUS].primaryType[1] = M_DESTROY_ALL_TARGETS;
1322         missions[MISN_URANUS].completed1[1] = OB_INCOMPLETE;
1323
1324         missions[MISN_URANUS].timeLimit1[0] = 5;
1325         missions[MISN_URANUS].timeLimit1[1] = 5;
1326
1327         missions[MISN_URANUS].addAliens = ALWAYS;
1328
1329
1330         sprintf(missions[MISN_SATURN].primaryObjective[0],
1331                 "Destroy outer defence systems");
1332         missions[MISN_SATURN].primaryType[0] = M_DESTROY_TARGET_TYPE;
1333         missions[MISN_SATURN].target1[0] = CD_MOBILE_RAY;
1334         missions[MISN_SATURN].targetValue1[0] = 6;
1335         missions[MISN_SATURN].completed1[0] = OB_INCOMPLETE;
1336
1337         sprintf(missions[MISN_SATURN].primaryObjective[1],
1338                 "Destroy all remaining WEAPCO craft");
1339         missions[MISN_SATURN].primaryType[1] = M_DESTROY_ALL_TARGETS;
1340         missions[MISN_SATURN].completed1[1] = OB_INCOMPLETE;
1341
1342         missions[MISN_SATURN].addAliens = NORMAL;
1343
1344
1345         sprintf(missions[MISN_JUPITER].primaryObjective[0],
1346                 "Investigate distress call");
1347         missions[MISN_JUPITER].primaryType[0] = M_DESTROY_ALL_TARGETS;
1348         missions[MISN_JUPITER].completed1[0] = OB_CONDITION;
1349
1350         sprintf(missions[MISN_JUPITER].primaryObjective[1], "Defeat Krass Tyler");
1351         missions[MISN_JUPITER].primaryType[1] = M_DESTROY_TARGET_TYPE;
1352         missions[MISN_JUPITER].target1[1] = CD_KRASS;
1353         missions[MISN_JUPITER].targetValue1[1] = 1;
1354         missions[MISN_JUPITER].completed1[1] = OB_HIDDEN;
1355
1356         sprintf(missions[MISN_JUPITER].primaryObjective[2],
1357                 "Destroy Krass' support group");
1358         missions[MISN_JUPITER].primaryType[2] = M_DESTROY_ALL_TARGETS;
1359         missions[MISN_JUPITER].target1[1] = CD_FIREFLY;
1360         missions[MISN_JUPITER].targetValue1[1] = 4;
1361         missions[MISN_JUPITER].completed1[2] = OB_HIDDEN;
1362
1363         missions[MISN_JUPITER].addAliens = ALWAYS;
1364
1365
1366         sprintf(missions[MISN_MARS].primaryObjective[0], "Navigate asteroid belt");
1367         missions[MISN_MARS].primaryType[0] = M_DESTROY_TARGET_TYPE;
1368         missions[MISN_MARS].target1[0] = CD_BOSS;
1369         missions[MISN_MARS].targetValue1[0] = 1;
1370         missions[MISN_MARS].completed1[0] = OB_INCOMPLETE;
1371
1372         missions[MISN_MARS].timeLimit1[0] = 2;
1373
1374         missions[MISN_MARS].addAliens = ALWAYS;
1375
1376
1377         sprintf(missions[MISN_EARTH].primaryObjective[0],
1378                 "Destroy WEAPCO frontline forces");
1379         missions[MISN_EARTH].primaryType[0] = M_DESTROY_TARGET_TYPE;
1380         missions[MISN_EARTH].target1[0] = CD_ANY;
1381         missions[MISN_EARTH].targetValue1[0] = 100;
1382         missions[MISN_EARTH].completed1[0] = OB_INCOMPLETE;
1383
1384         missions[MISN_EARTH].addAliens = ALWAYS;
1385
1386
1387         sprintf(missions[MISN_VENUS].primaryObjective[0], "Defeat Kline");
1388         missions[MISN_VENUS].primaryType[0] = M_DESTROY_ALL_TARGETS;
1389         missions[MISN_VENUS].completed1[0] = OB_INCOMPLETE;
1390
1391
1392         strcpy(missions[MISN_INTERCEPTION].primaryObjective[0], "");
1393         missions[MISN_INTERCEPTION].primaryType[0] = M_DESTROY_ALL_TARGETS;
1394         missions[MISN_INTERCEPTION].completed1[0] = OB_INCOMPLETE;
1395 }