1 /* omega copyright (C) by Laurence Raphael Brothers, 1987,1988,1989 */
2 /* guild1.c */
3 /* L_ functions */
4
5 /* These functions implement the various guilds. */
6 /* They are all l_ functions since they are basically activated*/
7 /* at some site or other. */
8
9 #include "glob.h"
10
11
l_merc_guild()12 void l_merc_guild()
13 {
14 pob newitem;
15
16 print1("Legion of Destiny, Mercenary Guild, Inc.");
17 if (nighttime())
18 print2("The barracks are under curfew right now.");
19 else {
20 print2("You enter Legion HQ, ");
21 if (Player.rank[LEGION] == COMMANDANT) {
22 nprint2("Your aide follows you to the staff room.");
23 morewait();
24 clearmsg();
25 }
26 if (Player.rank[LEGION] > 0) {
27 nprint2("and report to your commander.");
28 morewait();
29 }
30 switch(Player.rank[LEGION]) {
31 case 0:
32 nprint2("and see the Recruiting Centurion.");
33 morewait();
34 print2("Do you wish to join the Legion? [yn] ");
35 if (ynq2()=='y') {
36 clearmsg();
37 if (Player.rank[ARENA]>0) {
38 print1("The Centurion checks your record, and gets angry:");
39 print2("'The legion don't need any Arena Jocks. Git!'");
40 }
41 else if (Player.rank[ORDER] > 0) {
42 print1("The Centurion checks your record, and is amused:");
43 print2("'A paladin in the ranks? You must be joking.'");
44 }
45 else if (Player.con < 12) {
46 print1("The Centurion looks you over, sadly.");
47 print2("You are too fragile to join the legion.");
48 }
49 else if (Player.str < 10) {
50 print1("The Centurion looks at you contemptuously.");
51 print2("Your strength is too low to pass the physical!");
52 }
53 else {
54 print1("You are tested for strength and stamina...");
55 morewait();
56 nprint1(" and you pass!");
57 print2("Commandant ");
58 nprint2(Commandant);
59 nprint2(" shakes your hand.");
60 morewait();
61 print2("The Legion pays you a 500Au induction fee.");
62 morewait();
63 print1("You are also issued a shortsword and leather.");
64 print2("You are now a Legionaire.");
65 morewait();
66 clearmsg();
67 newitem = ((pob) checkmalloc(sizeof(objtype)));
68 *newitem = Objects[WEAPONID+1]; /* shortsword */
69 gain_item(newitem);
70 newitem = ((pob) checkmalloc(sizeof(objtype)));
71 *newitem = Objects[ARMORID+1]; /* leather */
72 gain_item(newitem);
73 Player.cash += 500;
74 Player.rank[LEGION] = LEGIONAIRE;
75 Player.guildxp[LEGION] = 1;
76 Player.str++; Player.con++;
77 Player.maxstr++; Player.maxcon++;
78 }
79 }
80 break;
81 case COMMANDANT:
82 print1("You find the disposition of your forces satisfactory.");
83 break;
84 case COLONEL:
85 if ((Player.level > Commandantlevel) &&
86 find_and_remove_item(CORPSEID,DEMON_EMP)) {
87 print1("You liberated the Demon Emperor's Regalia!");
88 morewait();
89 clearmsg();
90 print1("The Legion is assembled in salute to you!");
91 print2("The Regalia is held high for all to see and admire.");
92 morewait();
93 clearmsg();
94 print1("Commandant ");
95 nprint1(Commandant);
96 nprint1(" promotes you to replace him,");
97 print2("and announces his own overdue retirement.");
98 morewait();
99 clearmsg();
100 print1("You are the new Commandant of the Legion!");
101 print2("The Emperor's Regalia is sold for a ridiculous sum.");
102 strcpy(Commandant,Player.name);
103 Commandantlevel = Player.level;
104 morewait();
105 Commandantbehavior = fixnpc(4);
106 save_hiscore_npc(8);
107 clearmsg();
108 print1("You now know the Spell of Regeneration.");
109 Spells[S_REGENERATE].known = TRUE;
110 Player.rank[LEGION]=COMMANDANT;
111 Player.maxstr += 2;
112 Player.str += 2;
113 Player.maxcon += 2;
114 Player.con += 2;
115 print2("Your training is complete. You get top salary.");
116 Player.cash += 20000;
117 }
118 else if (Player.level <= Commandantlevel) {
119 clearmsg();
120 print1("Your CO expresses satisfaction with your progress.");
121 print2("But your service record does not yet permit promotion.");
122 }
123 else {
124 clearmsg();
125 print1("Why do you come empty handed?");
126 print2("You must return with the Regalia of the Demon Emperor!");
127 }
128 break;
129 case FORCE_LEADER:
130 clearmsg();
131 print1("Your CO expresses satisfaction with your progress.");
132 if (Player.guildxp[LEGION] < 4000)
133 print2("But your service record does not yet permit promotion.");
134 else {
135 print2("You have been promoted to Legion Colonel!");
136 morewait();
137 print1("Your next promotion is contingent on the return of");
138 print2("the Regalia of the Demon Emperor.");
139 morewait();
140 print1("The Demon Emperor holds court at the base of a volcano");
141 print2("to the far south, in the heart of a swamp.");
142 morewait();
143 clearmsg();
144 print1("You have been taught the spell of heroism!");
145 Spells[S_HERO].known = TRUE;
146 Player.rank[LEGION]=COLONEL;
147 Player.maxstr++;
148 Player.str++;
149 Player.maxcon++;
150 Player.con++;
151 print2("You are given advanced training, and a raise.");
152 Player.cash += 10000;
153 }
154 break;
155 case CENTURION:
156 clearmsg();
157 print1("Your CO expresses satisfaction with your progress.");
158 if (Player.guildxp[LEGION] < 1500)
159 print2("But your service record does not yet permit promotion.");
160 else {
161 print2("You are now a Legion Force-Leader!");
162 Player.rank[LEGION]=FORCE_LEADER;
163 Player.maxstr++;
164 Player.str++;
165 morewait();
166 clearmsg();
167 print1("You receive more training, and bonus pay.");
168 Player.cash += 5000;
169 }
170 break;
171 case LEGIONAIRE:
172 clearmsg();
173 print1("Your CO expresses satisfaction with your progress.");
174 if (Player.guildxp[LEGION] < 400)
175 print2("But your service record does not yet permit promotion.");
176 else {
177 print2("You are promoted to Legion Centurion!");
178 morewait();
179 clearmsg();
180 print1("You get advanced training, and a higher salary.");
181 Player.rank[LEGION] = CENTURION;
182 Player.maxcon++;
183 Player.con++;
184 Player.cash += 2000;
185 }
186 break;
187 }
188 }
189 }
190
l_castle()191 void l_castle()
192 {
193 pob o;
194 int x, y;
195
196 if (Player.level < 3) {
197 print1("You can't possibly enter the castle, you nobody!");
198 print2("Come back when you are famous.");
199 }
200 else {
201 print1("You are ushered into the castle.");
202 if (Player.rank[NOBILITY]<DUKE) {
203 print2("His Grace, ");
204 nprint2(Duke);
205 nprint2("-- Duke of Rampart! <fanfare>");
206 morewait();
207 clearmsg();
208 }
209 if (Player.rank[NOBILITY]==0) {
210 print1("Well, sirrah, wouldst embark on a quest? [yn] ");
211 if (ynq1() == 'y') {
212 print2("Splendid. Bring me the head of the Goblin King.");
213 Player.rank[NOBILITY]=COMMONER;
214 }
215 else {
216 print1("You scoundrel! Guards! Take this blackguard away!");
217 morewait();
218 p_damage(25,UNSTOPPABLE,"castle guards for lese majeste");
219 send_to_jail();
220 }
221 }
222 else if (Player.rank[NOBILITY]==COMMONER) {
223 if (find_and_remove_item(CORPSEID,GOBLIN_KING)) {
224 print1("Good job, sirrah! I promote you to the rank of esquire.");
225 Player.rank[NOBILITY]=ESQUIRE;
226 gain_experience(100);
227 print2("Now that you have proved yourself true, another quest!");
228 morewait();
229 print1("Bring to me a Holy Defender!");
230 print2("One is said to be in the possession of the Great Wyrm");
231 morewait();
232 clearmsg();
233 print1("in the depths of the sewers below the city.");
234 }
235 else print2("Do not return until you achieve the quest, caitiff!");
236 }
237 else if (Player.rank[NOBILITY]==ESQUIRE) {
238 if (find_and_remove_item(WEAPONID+34,-1)) {
239 print1("My thanks, squire. In return, I dub thee knight!");
240 Player.rank[NOBILITY]=KNIGHT;
241 gain_experience(1000);
242 print2("If thou wouldst please me further...");
243 morewait();
244 print1("Bring me a suit of dragonscale armor.");
245 print2("You might have to kill a dragon to get one....");
246 }
247 else print2("Greetings, squire. My sword? What, you don't have it?");
248 }
249 else if (Player.rank[NOBILITY]==KNIGHT) {
250 if (find_and_remove_item(ARMORID+12,-1)) {
251 print1("Thanks, good sir knight.");
252 print2("Here are letters patent to a peerage!");
253 Player.rank[NOBILITY]=LORD;
254 gain_experience(10000);
255 morewait();
256 print1("If you would do me a final service...");
257 print2("I require the Orb of Mastery. If you would be so kind...");
258 morewait();
259 print1("By the way, you might find the Orb in the possession");
260 print2("Of the Elemental Master on the Astral Plane");
261 }
262 else print2("Your quest is not yet complete, sir knight.");
263 }
264 else if (Player.rank[NOBILITY]==LORD) {
265 if (find_item(&o,ARTIFACTID+0,-1)) {
266 print1("My sincerest thanks, my lord.");
267 print2("You have proved yourself a true paragon of chivalry");
268 morewait();
269 print1("I abdicate the Duchy in your favor....");
270 print2("Oh, you can keep the Orb, by the way....");
271 Player.rank[NOBILITY]=DUKE;
272 gain_experience(10000);
273 strcpy(Duke,Player.name);
274 morewait();
275 Dukebehavior = fixnpc(4);
276 save_hiscore_npc(12);
277 for (y = 52; y < 63; y++)
278 for (x = 2; x < 52; x++) {
279 if (Level->site[x][y].p_locf == L_TRAP_SIREN) {
280 Level->site[x][y].p_locf = L_NO_OP;
281 lset(x, y, CHANGED);
282 }
283 if (x >= 12 && loc_statusp(x, y, SECRET)) {
284 lreset(x, y, SECRET);
285 lset(x, y, CHANGED);
286 }
287 if (x >= 20 && x <= 23 && y == 56) {
288 Level->site[x][y].locchar = FLOOR;
289 lset(x, y, CHANGED);
290 }
291 }
292
293 }
294 else print2("I didn't really think you were up to the task....");
295 }
296 }
297 }
298
299
l_arena()300 void l_arena()
301 {
302 char response;
303 pob newitem;
304 int i,prize,monsterlevel;
305 char *name, *corpse, *melee = NULL;
306
307 print1("Rampart Coliseum");
308 if (Player.rank[ARENA] == 0) {
309 print2("Enter the games, or Register as a Gladiator? [e,r,ESCAPE] ");
310 do response = (char) mcigetc();
311 while ((response != 'e') && (response != 'r') && (response != ESCAPE));
312 }
313 else {
314 print2("Enter the games? [yn] ");
315 response = ynq2();
316 if (response == 'y') response = 'e';
317 else response = ESCAPE;
318 }
319 if (response == 'r') {
320 if (Player.rank[ARENA]>0)
321 print2("You're already a gladiator....");
322 else if (Player.rank[ORDER]>0)
323 print2("We don't let Paladins into our Guild.");
324 else if (Player.rank[LEGION]>0)
325 print2("We don't train no stinkin' mercs!");
326 else if (Player.str < 13)
327 print2("Yer too weak to train!");
328 else if (Player.agi < 12)
329 print2("Too clumsy to be a gladiator!");
330 else {
331 print1("Ok, yer now an Arena Trainee.");
332 print2("Here's a wooden sword, and a shield");
333 morewait();
334 clearmsg();
335 newitem = ((pob) checkmalloc(sizeof(objtype)));
336 *newitem = Objects[WEAPONID+17]; /* club */
337 gain_item(newitem);
338 newitem = ((pob) checkmalloc(sizeof(objtype)));
339 *newitem = Objects[SHIELDID+2]; /* shield */
340 gain_item(newitem);
341 Player.rank[ARENA] = TRAINEE;
342 Arena_Opponent = 3;
343 morewait();
344 clearmsg();
345 print1("You've got 5000Au credit at the Gym.");
346 Gymcredit+=5000;
347 }
348 }
349 else if (response == 'e') {
350 print1("OK, we're arranging a match....");
351 morewait();
352 Arena_Monster = ((pmt) checkmalloc(sizeof(montype)));
353 Arena_Victory = FALSE;
354 switch(Arena_Opponent) {
355 case 0:
356 *Arena_Monster = Monsters[GEEK];
357 break;
358 case 1:
359 *Arena_Monster = Monsters[HORNET];
360 break;
361 case 2:
362 *Arena_Monster = Monsters[HYENA];
363 break;
364 case 3:
365 *Arena_Monster = Monsters[GOBLIN];
366 break;
367 case 4:
368 *Arena_Monster = Monsters[GRUNT];
369 break;
370 case 5:
371 *Arena_Monster = Monsters[TOVE];
372 break;
373 case 6:
374 *Arena_Monster = Monsters[APPR_NINJA];
375 break;
376 case 7:
377 *Arena_Monster = Monsters[SALAMANDER];
378 break;
379 case 8:
380 *Arena_Monster = Monsters[ANT];
381 break;
382 case 9:
383 *Arena_Monster = Monsters[MANTICORE];
384 break;
385 case 10:
386 *Arena_Monster = Monsters[SPECTRE];
387 break;
388 case 11:
389 *Arena_Monster = Monsters[BANDERSNATCH];
390 break;
391 case 12:
392 *Arena_Monster = Monsters[LICHE];
393 break;
394 case 13:
395 *Arena_Monster = Monsters[AUTO_MAJOR];
396 break;
397 case 14:
398 *Arena_Monster = Monsters[JABBERWOCK];
399 break;
400 case 15:
401 *Arena_Monster = Monsters[JOTUN];
402 break;
403 default:
404 if ((Player.rank[ARENA] < 5) && (Player.rank[ARENA] > 0)) {
405 strcpy(Str1,Champion);
406 strcat(Str1,", the arena champion");
407 *Arena_Monster = Monsters[HISCORE_NPC];
408 name = Arena_Monster->monstring = salloc(Str1);
409 strcpy(Str2,"The corpse of ");
410 strcat(Str2,Str1);
411 corpse = Arena_Monster->corpsestr = salloc(Str2);
412 Arena_Monster->level = 20;
413 Arena_Monster->hp = Championlevel*Championlevel*5;
414 Arena_Monster->hit = Championlevel*4;
415 Arena_Monster->ac = Championlevel*3;
416 Arena_Monster->dmg = 100+Championlevel*2;
417 Arena_Monster->xpv = Championlevel*Championlevel*5;
418 Arena_Monster->speed = 3;
419 melee = Arena_Monster->meleestr = (char *) checkmalloc(30*sizeof(char));
420 strcpy(Arena_Monster->meleestr,"");
421 for(i=0;i<Championlevel/5;i++)
422 strcat(Arena_Monster->meleestr,"L?R?");
423 m_status_set(Arena_Monster, MOBILE);
424 m_status_set(Arena_Monster, HOSTILE);
425 }
426 else {
427 do
428 i = random_range(ML9 - ML0) + ML0;
429 while (i == NPC || i == HISCORE_NPC || i == ZERO_NPC ||
430 (Monsters[i].uniqueness != COMMON) ||
431 (Monsters[i].dmg == 0));
432 *Arena_Monster = Monsters[i];
433 }
434 break;
435 }
436 monsterlevel = Arena_Monster->level;
437 if (Arena_Monster->level != 20) {
438 strcpy(Str1,nameprint());
439 strcat(Str1," the ");
440 strcat(Str1,Arena_Monster->monstring);
441 name = Arena_Monster->monstring = salloc(Str1);
442 strcpy(Str2,"The corpse of ");
443 strcat(Str2,Str1);
444 corpse = Arena_Monster->corpsestr = salloc(Str2);
445 }
446 Arena_Monster->uniqueness = UNIQUE_MADE;
447 print1("You have a challenger: ");
448 print2(Arena_Monster->monstring);
449 Arena_Monster->attacked = TRUE;
450 m_status_set(Arena_Monster,HOSTILE);
451 morewait();
452 clearmsg();
453 change_environment(E_ARENA);
454 print1("Let the battle begin....");
455
456 time_clock(TRUE);
457 while (Current_Environment == E_ARENA)
458 time_clock(FALSE);
459
460 /* WDT -- Sheldon Simms points out that these objects are not
461 * wastes of space; on the contrary, they can be carried out of the
462 * arena. Freeing them was causing subtle and hard to find problems.
463 * However, not freeing them is causing a couple of tiny memory leaks.
464 * This should be fixed, probably by modifying the object destruction
465 * procedures to account for this case. I'm not really concerned. */
466 /* David Given has proposed a nicer solution, but it still causes a
467 * memory leak. Obviously, we need a special field just for names
468 * in the monster struct. Yadda yadda -- I'll mmark this with a
469 * HACK!, and comme back to it later. */
470 free(name); /* hey - why waste space? */
471 /* can not free the corpse string... it is referenced in the */
472 /* corpse string of the corpse object. */
473 /* Unfortunately, this will cause a memory leak, but I don't see */
474 /* any way to avoid it. This fixes the munged arena corpse names */
475 /* problem. -DAG */
476 /* free(corpse); */
477
478 if (melee)
479 free(melee);
480 if (! Arena_Victory) {
481 print1("The crowd boos your craven behavior!!!");
482 if (Player.rank[ARENA] > 0) {
483 print2("You are thrown out of the Gladiator's Guild!");
484 morewait();
485 clearmsg();
486 if (Gymcredit > 0) print1("Your credit at the gym is cut off!");
487 Gymcredit = 0;
488 Player.rank[ARENA] = -1;
489 }
490 }
491 else {
492 Arena_Opponent++;
493 if (monsterlevel == 20) {
494 print1("The crowd roars its approval!");
495 if (Player.rank[ARENA]) {
496 print2("You are the new Arena Champion!");
497 Championlevel = Player.level;
498 strcpy(Champion,Player.name);
499 Player.rank[ARENA] = 5;
500 morewait();
501 Championbehavior = fixnpc(4);
502 save_hiscore_npc(11);
503 print1("You are awarded the Champion's Spear: Victrix!");
504 morewait();
505 newitem = ((pob) checkmalloc(sizeof(objtype)));
506 *newitem = Objects[WEAPONID+35];
507 gain_item(newitem);
508
509 }
510 else {
511 print1("As you are not an official gladiator,");
512 nprint1("you are not made Champion.");
513 morewait();
514 }
515 }
516 morewait();
517 clearmsg();
518 print1("Good fight! ");
519 nprint1("Your prize is: ");
520 prize = max(25,monsterlevel * 50);
521 if (Player.rank[ARENA] > 0) prize *= 2;
522 mnumprint(prize);
523 nprint1("Au.");
524 Player.cash+=prize;
525 if ((Player.rank[ARENA]<4) &&
526 (Arena_Opponent>5) &&
527 (Arena_Opponent % 3 == 0)) {
528 if (Player.rank[ARENA]>0) {
529 Player.rank[ARENA]++;
530 morewait();
531 print1("You've been promoted to a stronger class!");
532 print2("You are also entitled to additional training.");
533 Gymcredit+=Arena_Opponent*1000;
534 }
535 }
536 }
537 xredraw();
538 }
539 else clearmsg();
540 }
541