chiark / gitweb /
073cd40b79613dcf43cf086626d90a0eb6c54641
[newkind] / missions.c
1 /*
2  * Elite - The New Kind.
3  *
4  * Reverse engineered from the BBC disk version of Elite.
5  * Additional material by C.J.Pinder.
6  *
7  * The original Elite code is (C) I.Bell & D.Braben 1984.
8  * This version re-engineered in C by C.J.Pinder 1999-2001.
9  *
10  * email: <christian@newkind.co.uk>
11  *
12  *
13  */
14
15 /*
16  * missions.c
17  *
18  * Code to handle the special missions.
19  */
20
21 #include <stdlib.h>
22 #include <string.h>
23  
24 #include "config.h"
25 #include "elite.h"
26 #include "gfx.h"
27 #include "vector.h"
28 #include "space.h"
29 #include "planet.h"
30 #include "main.h"
31 #include "missions.h" 
32 #include "keyboard.h"
33  
34
35 char *mission1_brief_a =
36         "Greetings Commander, I am Captain Curruthers of "
37         "Her Majesty's Space Navy and I beg a moment of your "
38         "valuable time.  We would like you to do a little job "
39         "for us.  The ship you see here is a new model, the "
40         "Constrictor, equiped with a top secret new shield "
41         "generator.  Unfortunately it's been stolen.";
42
43 char *mission1_brief_b =
44         "It went missing from our ship yard on Xeer five months ago "
45         "and was last seen at Reesdice. Your mission should you decide "
46         "to accept it, is to seek and destroy this ship. You are "
47         "cautioned that only Military Lasers will get through the new "
48         "shields and that the Constrictor is fitted with an E.C.M. "
49         "System. Good Luck, Commander. ---MESSAGE ENDS.";
50
51 char *mission1_brief_c =
52         "It went missing from our ship yard on Xeer five months ago "
53         "and is believed to have jumped to this galaxy. "
54         "Your mission should you decide to accept it, is to seek and "
55         "destroy this ship. You are cautioned that only Military Lasers "
56         "will get through the new shields and that the Constrictor is "
57         "fitted with an E.C.M. System. Good Luck, Commander. ---MESSAGE ENDS.";
58
59 char *mission1_debrief =
60         "There will always be a place for you in Her Majesty's Space Navy. "
61         "And maybe sooner than you think... ---MESSAGE ENDS.";
62
63 char *mission1_pdesc[] =
64 {
65         "THE CONSTRICTOR WAS LAST SEEN AT REESDICE, COMMANDER.",
66         "A STRANGE LOOKING SHIP LEFT HERE A WHILE BACK. LOOKED BOUND FOR AREXE.",
67         "YEP, AN UNUSUAL NEW SHIP HAD A GALACTIC HYPERDRIVE FITTED HERE, USED IT TOO.",
68         "I HEAR A WEIRD LOOKING SHIP WAS SEEN AT ERRIUS.",
69         "THIS STRANGE SHIP DEHYPED HERE FROM NOWHERE, SUN SKIMMED AND JUMPED. I HEAR IT WENT TO INBIBE.",
70         "ROGUE SHIP WENT FOR ME AT AUSAR. MY LASERS DIDN'T EVEN SCRATCH ITS HULL.",
71         "OH DEAR ME YES. A FRIGHTFUL ROGUE WITH WHAT I BELIEVE YOU PEOPLE CALL A LEAD "
72                 "POSTERIOR SHOT UP LOTS OF THOSE BEASTLY PIRATES AND WENT TO USLERI.",
73         "YOU CAN TACKLE THE VICIOUS SCOUNDREL IF YOU LIKE. HE'S AT ORARRA.",
74         "THERE'S A REAL DEADLY PIRATE OUT THERE.",
75         "BOY ARE YOU IN THE WRONG GALAXY!",
76         "COMING SOON: ELITE - DARKNESS FALLS.",                         
77 };
78
79 char *mission2_brief_a =
80         "Attention Commander, I am Captain Fortesque of Her Majesty's Space Navy. "
81         "We have need of your services again. If you would be so good as to go to "
82         "Ceerdi you will be briefed.If succesful, you will be rewarded."
83         "---MESSAGE ENDS.";
84         
85 char *mission2_brief_b =
86         "Good Day Commander. I am Agent Blake of Naval Intelligence. As you know, "
87         "the Navy have been keeping the Thargoids off your ass out in deep space "
88         "for many years now. Well the situation has changed. Our boys are ready "
89         "for a push right to the home system of those murderers.";
90
91 char *mission2_brief_c =
92         "I have obtained the defence plans for their Hive Worlds. The beetles "
93         "know we've got something but not what. If I transmit the plans to our "
94         "base on Birera they'll intercept the transmission. I need a ship to "
95         "make the run. You're elected. The plans are unipulse coded within "
96         "this transmission. You will be paid. Good luck Commander. ---MESSAGE ENDS.";
97
98 char *mission2_debrief =
99         "You have served us well and we shall remember. "
100         "We did not expect the Thargoids to find out about you."
101         "For the moment please accept this Navy Extra Energy Unit as payment. "
102         "---MESSAGE ENDS.";
103
104         
105
106 char *mission_planet_desc (struct galaxy_seed planet)
107 {
108         int pnum;
109
110         if (!docked)
111                 return NULL;
112
113         if ((planet.a != docked_planet.a) ||
114             (planet.b != docked_planet.b) ||
115             (planet.c != docked_planet.c) ||
116             (planet.d != docked_planet.d) ||
117             (planet.e != docked_planet.e) ||
118             (planet.f != docked_planet.f))
119                 return NULL;
120         
121         pnum = find_planet_number (planet);
122         
123         if (cmdr.galaxy_number == 0)
124         {
125                 switch (pnum)
126                 {
127                         case 150:
128                                 return mission1_pdesc[0];
129                         
130                         case 36:
131                                 return mission1_pdesc[1];
132
133                         case 28:
134                                 return mission1_pdesc[2];                                                       
135                 }
136         }
137
138         if (cmdr.galaxy_number == 1)
139         {
140                 switch (pnum)
141                 {
142                         case 32:
143                         case 68:
144                         case 164:
145                         case 220:
146                         case 106:
147                         case 16:
148                         case 162:
149                         case 3:
150                         case 107:
151                         case 26:
152                         case 192:
153                         case 184:
154                         case 5:
155                                 return mission1_pdesc[3];
156                 
157                         case 253:
158                                 return mission1_pdesc[4];
159                         
160                         case 79:
161                                 return mission1_pdesc[5];
162
163                         case 53:
164                                 return mission1_pdesc[6];                                                       
165
166                         case 118:
167                                 return mission1_pdesc[7];                                                       
168
169                         case 193:
170                                 return mission1_pdesc[8];                                                       
171                 }
172         }
173
174         if ((cmdr.galaxy_number == 2) && (pnum == 101))
175                 return mission1_pdesc[9];                                                       
176         
177         return NULL;
178 }
179
180
181 void constrictor_mission_brief (void)
182 {
183         Matrix rotmat;
184
185         cmdr.mission = 1;
186
187         current_screen = SCR_FRONT_VIEW;
188
189         gfx_clear_display();
190         gfx_display_centre_text (10, "INCOMING MESSAGE", 140, GFX_COL_GOLD);
191         gfx_draw_line (0, 36, 511, 36);
192
193         gfx_display_pretty_text (16, 50, 300, 384, mission1_brief_a);
194         gfx_display_pretty_text (16, 200, 470, 384,
195               (cmdr.galaxy_number == 0) ? mission1_brief_b : mission1_brief_c);
196                 
197         gfx_display_centre_text (330, "Press space to continue.", 140, GFX_COL_GOLD);
198                 
199         clear_universe();
200         set_init_matrix (rotmat);
201         add_new_ship (SHIP_CONSTRICTOR, 200, 90, 600, rotmat, -127, -127);
202         flight_roll = 0;
203         flight_climb = 0;
204         flight_speed = 0;
205         identify = 0;
206
207         do
208         {
209                 gfx_clear_area (310, 50, 510, 180);
210                 update_universe ();
211                 universe[0].location.z = 600;
212                 gfx_update_screen();
213                 kbd_poll_keyboard();
214         } while (!kbd_space_pressed);
215 }       
216
217
218 void constrictor_mission_debrief (void)
219 {
220         int keyasc;
221
222         cmdr.mission = 3;
223         cmdr.score += 256;
224         cmdr.credits += 50000;
225         
226         gfx_clear_display();
227         gfx_display_centre_text (10, "INCOMING MESSAGE", 140, GFX_COL_GOLD);
228         gfx_draw_line (0, 36, 511, 36);
229
230         gfx_display_centre_text (100, "Congratulations Commander!", 140, GFX_COL_GOLD);
231         
232         gfx_display_pretty_text (116, 132, 400, 384, mission1_debrief);
233
234         gfx_display_centre_text (330, "Press space to continue.", 140, GFX_COL_GOLD);
235
236         gfx_update_screen();
237         
238         do
239         {
240                 keyasc = kbd_read_key();
241         } while (keyasc != ' ');
242 }
243
244
245 void thargoid_mission_first_brief (void)
246 {
247         int keyasc;
248
249         cmdr.mission = 4;
250         
251         gfx_clear_display();
252         gfx_display_centre_text (10, "INCOMING MESSAGE", 140, GFX_COL_GOLD);
253         gfx_draw_line (0, 36, 511, 36);
254
255         gfx_display_pretty_text (116, 132, 400, 384, mission2_brief_a);
256
257         gfx_display_centre_text (330, "Press space to continue.", 140, GFX_COL_GOLD);
258
259         gfx_update_screen();
260         
261         do
262         {
263                 keyasc = kbd_read_key();
264         } while (keyasc != ' ');
265 }
266
267
268 void thargoid_mission_second_brief (void)
269 {
270         int keyasc;
271
272         cmdr.mission = 5;
273         
274         gfx_clear_display();
275         gfx_display_centre_text (10, "INCOMING MESSAGE", 140, GFX_COL_GOLD);
276         gfx_draw_line (0, 36, 511, 36);
277
278         gfx_display_pretty_text (16, 50, 300, 384, mission2_brief_b);
279         gfx_display_pretty_text (16, 200, 470, 384, mission2_brief_c);
280
281         gfx_draw_sprite (IMG_BLAKE, 352, 46);
282         
283         gfx_display_centre_text (330, "Press space to continue.", 140, GFX_COL_GOLD);
284
285         gfx_update_screen();
286         
287         do
288         {
289                 keyasc = kbd_read_key();
290         } while (keyasc != ' ');
291 }
292
293
294 void thargoid_mission_debrief (void)
295 {
296         int keyasc;
297
298         cmdr.mission = 6;
299         cmdr.score += 256;
300         cmdr.energy_unit = 2;
301         
302         gfx_clear_display ();
303         gfx_display_centre_text (10, "INCOMING MESSAGE", 140, GFX_COL_GOLD);
304         gfx_draw_line (0, 36, 511, 36);
305
306         gfx_display_centre_text (100, "Well done Commander.", 140, GFX_COL_GOLD);
307         
308         gfx_display_pretty_text (116, 132, 400, 384, mission2_debrief);
309
310         gfx_display_centre_text (330, "Press space to continue.", 140, GFX_COL_GOLD);
311
312         gfx_update_screen();
313         
314         do
315         {
316                 keyasc = kbd_read_key();
317         } while (keyasc != ' ');
318 }
319
320
321
322 void check_mission_brief (void)
323 {
324         if ((cmdr.mission == 0) && (cmdr.score >= 256) && (cmdr.galaxy_number < 2))
325         {
326                 constrictor_mission_brief();
327                 return;
328         }
329
330         if (cmdr.mission == 2)
331         {
332                 constrictor_mission_debrief();
333                 return;
334         }
335
336         if ((cmdr.mission == 3) && (cmdr.score >= 1280) && (cmdr.galaxy_number == 2))
337         {
338                 thargoid_mission_first_brief();
339                 return;
340         }
341
342         if ((cmdr.mission == 4) && (docked_planet.d == 215) && (docked_planet.b == 84))
343         {
344                 thargoid_mission_second_brief();
345                 return;
346         }
347
348         if ((cmdr.mission == 5) && (docked_planet.d == 63) && (docked_planet.b == 72))
349         {
350                 thargoid_mission_debrief();
351                 return;
352         }
353 }
354