]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/object.c
Use <dirent.h> instead of <sys/dir.h>.
[bsdgames-darwin.git] / larn / object.c
1 #ifndef lint
2 static char rcsid[] = "$Id: object.c,v 1.3 1993/08/02 17:20:16 mycroft Exp $";
3 #endif /* not lint */
4
5 /* object.c Larn is copyrighted 1986 by Noah Morgan. */
6 #include "header.h"
7
8 /*
9 ***************
10 LOOK_FOR_OBJECT
11 ***************
12
13 subroutine to look for an object and give the player his options
14 if an object was found.
15 */
16 lookforobject()
17 {
18 register int i,j;
19 if (c[TIMESTOP]) return; /* can't find objects is time is stopped */
20 i=item[playerx][playery]; if (i==0) return;
21 showcell(playerx,playery); cursors(); yrepcount=0;
22 switch(i)
23 {
24 case OGOLDPILE: case OMAXGOLD:
25 case OKGOLD: case ODGOLD: lprcat("\n\nYou have found some gold!"); ogold(i); break;
26
27 case OPOTION: lprcat("\n\nYou have found a magic potion");
28 i = iarg[playerx][playery];
29 if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]); opotion(i); break;
30
31 case OSCROLL: lprcat("\n\nYou have found a magic scroll");
32 i = iarg[playerx][playery];
33 if (scrollname[i][0]) lprintf(" of %s",&scrollname[i][1]);
34 oscroll(i); break;
35
36 case OALTAR: if (nearbymonst()) return;
37 lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break;
38
39 case OBOOK: lprcat("\n\nYou have found a book."); obook(); break;
40
41 case OCOOKIE: lprcat("\n\nYou have found a fortune cookie."); ocookie(); break;
42
43 case OTHRONE: if (nearbymonst()) return;
44 lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break;
45
46 case OTHRONE2: if (nearbymonst()) return;
47 lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break;
48
49 case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break;
50
51 case OORB: lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break;
52
53 case OPIT: lprcat("\n\nYou're standing at the top of a pit."); opit(); break;
54
55 case OSTAIRSUP: lprcat("\n\nThere is a circular staircase here"); ostairs(1); /* up */ break;
56
57 case OELEVATORUP: lprcat("\n\nYou feel heavy for a moment, but the feeling disappears");
58 oelevator(1); /* up */ break;
59
60 case OFOUNTAIN: if (nearbymonst()) return;
61 lprcat("\n\nThere is a fountain here"); ofountain(); break;
62
63 case OSTATUE: if (nearbymonst()) return;
64 lprcat("\n\nYou are standing in front of a statue"); ostatue(); break;
65
66 case OCHEST: lprcat("\n\nThere is a chest here"); ochest(); break;
67
68 case OIVTELETRAP: if (rnd(11)<6) return;
69 item[playerx][playery] = OTELEPORTER;
70 know[playerx][playery] = 1;
71
72 case OTELEPORTER: lprcat("\nZaaaappp! You've been teleported!\n");
73 beep(); nap(3000); oteleport(0);
74 break;
75
76 case OSCHOOL: if (nearbymonst()) return;
77 lprcat("\n\nYou have found the College of Larn.");
78 lprcat("\nDo you (g) go inside, or (i) stay here? ");
79 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
80 if (i == 'g') { oschool(); /* the college of larn */ }
81 else lprcat(" stay here");
82 break;
83
84 case OMIRROR: if (nearbymonst()) return;
85 lprcat("\n\nThere is a mirror here"); omirror(); break;
86
87 case OBANK2:
88 case OBANK: if (nearbymonst()) return;
89 if (i==OBANK) lprcat("\n\nYou have found the bank of Larn.");
90 else lprcat("\n\nYou have found a branch office of the bank of Larn.");
91 lprcat("\nDo you (g) go inside, or (i) stay here? ");
92 j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar();
93 if (j == 'g') { if (i==OBANK) obank(); else obank2(); /* the bank of larn */ }
94 else lprcat(" stay here");
95 break;
96
97 case ODEADFOUNTAIN: if (nearbymonst()) return;
98 lprcat("\n\nThere is a dead fountain here"); break;
99
100 case ODNDSTORE: if (nearbymonst()) return;
101 lprcat("\n\nThere is a DND store here.");
102 lprcat("\nDo you (g) go inside, or (i) stay here? ");
103 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
104 if (i == 'g')
105 dndstore(); /* the dnd adventurers store */
106 else lprcat(" stay here");
107 break;
108
109 case OSTAIRSDOWN: lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break;
110
111 case OELEVATORDOWN: lprcat("\n\nYou feel light for a moment, but the feeling disappears");
112 oelevator(-1); /* down */
113 break;
114
115 case OOPENDOOR: lprintf("\n\nYou have found %s",objectname[i]);
116 lprcat("\nDo you (c) close it"); iopts();
117 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
118 if ((i=='\33') || (i=='i')) { ignore(); break; }
119 lprcat("close"); forget();
120 item[playerx][playery]=OCLOSEDDOOR;
121 iarg[playerx][playery]=0;
122 playerx = lastpx; playery = lastpy;
123 break;
124
125 case OCLOSEDDOOR: lprintf("\n\nYou have found %s",objectname[i]);
126 lprcat("\nDo you (o) try to open it"); iopts();
127 i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar();
128 if ((i=='\33') || (i=='i'))
129 { ignore(); playerx = lastpx;
130 playery = lastpy; break; }
131 else
132 {
133 lprcat("open");
134 if (rnd(11)<7)
135 {
136 switch(iarg[playerx][playery])
137 {
138 case 6: c[AGGRAVATE] += rnd(400); break;
139
140 case 7: lprcat("\nYou are jolted by an electric shock ");
141 lastnum=274; losehp(rnd(20)); bottomline(); break;
142
143 case 8: loselevel(); break;
144
145 case 9: lprcat("\nYou suddenly feel weaker ");
146 if (c[STRENGTH]>3) c[STRENGTH]--;
147 bottomline(); break;
148
149 default: break;
150 }
151 playerx = lastpx; playery = lastpy;
152 }
153 else
154 {
155 forget(); item[playerx][playery]=OOPENDOOR;
156 }
157 }
158 break;
159
160 case OENTRANCE: lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]);
161 lprcat("\nDo you (g) go inside"); iopts();
162 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
163 if (i == 'g')
164 {
165 newcavelevel(1); playerx=33; playery=MAXY-2;
166 item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0;
167 draws(0,MAXX,0,MAXY); bot_linex(); return;
168 }
169 else ignore();
170 break;
171
172 case OVOLDOWN: lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]);
173 lprcat("\nDo you (c) climb down"); iopts();
174 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
175 if ((i=='\33') || (i=='i')) { ignore(); break; }
176 if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; }
177 if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
178 lastnum=275; losehp(30+rnd(20)); bottomhp(); }
179
180 else lprcat("climb down"); nap(3000); newcavelevel(MAXLEVEL);
181 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */
182 if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
183 draws(0,MAXX,0,MAXY); bot_linex(); return;
184
185 case OVOLUP: lprcat("\nYou have found "); lprcat(objectname[OVOLUP]);
186 lprcat("\nDo you (c) climb up"); iopts();
187 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar();
188 if ((i=='\33') || (i=='i')) { ignore(); break; }
189 if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; }
190 if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep();
191 lastnum=275; losehp(15+rnd(20)); bottomhp(); return; }
192 lprcat("climb up"); lflush(); nap(3000); newcavelevel(0);
193 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */
194 if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); }
195 draws(0,MAXX,0,MAXY); bot_linex(); return;
196
197 case OTRAPARROWIV: if (rnd(17)<13) return; /* for an arrow trap */
198 item[playerx][playery] = OTRAPARROW;
199 know[playerx][playery] = 0;
200
201 case OTRAPARROW: lprcat("\nYou are hit by an arrow"); beep(); /* for an arrow trap */
202 lastnum=259; losehp(rnd(10)+level);
203 bottomhp(); return;
204
205 case OIVDARTRAP: if (rnd(17)<13) return; /* for a dart trap */
206 item[playerx][playery] = ODARTRAP;
207 know[playerx][playery] = 0;
208
209 case ODARTRAP: lprcat("\nYou are hit by a dart"); beep(); /* for a dart trap */
210 lastnum=260; losehp(rnd(5));
211 if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3;
212 bottomline(); return;
213
214 case OIVTRAPDOOR: if (rnd(17)<13) return; /* for a trap door */
215 item[playerx][playery] = OTRAPDOOR;
216 know[playerx][playery] = 1;
217
218 case OTRAPDOOR: lastnum = 272; /* a trap door */
219 if ((level==MAXLEVEL-1) || (level==MAXLEVEL+MAXVLEVEL-1))
220 { lprcat("\nYou fell through a bottomless trap door!"); beep(); nap(3000); died(271); }
221 lprcat("\nYou fall through a trap door!"); beep(); /* for a trap door */
222 losehp(rnd(5+level));
223 nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); bot_linex();
224 return;
225
226
227 case OTRADEPOST: if (nearbymonst()) return;
228 lprcat("\nYou have found the Larn trading Post.");
229 lprcat("\nDo you (g) go inside, or (i) stay here? ");
230 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
231 if (i == 'g') otradepost(); else lprcat("stay here");
232 return;
233
234 case OHOME: if (nearbymonst()) return;
235 lprcat("\nYou have found your way home.");
236 lprcat("\nDo you (g) go inside, or (i) stay here? ");
237 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
238 if (i == 'g') ohome(); else lprcat("stay here");
239 return;
240
241 case OWALL: break;
242
243 case OANNIHILATION: died(283); return; /* annihilated by sphere of annihilation */
244
245 case OLRS: if (nearbymonst()) return;
246 lprcat("\n\nThere is an LRS office here.");
247 lprcat("\nDo you (g) go inside, or (i) stay here? ");
248 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar();
249 if (i == 'g')
250 olrs(); /* the larn revenue service */
251 else lprcat(" stay here");
252 break;
253
254 default: finditem(i); break;
255 };
256 }
257
258 /*
259 function to say what object we found and ask if player wants to take it
260 */
261 finditem(itm)
262 int itm;
263 {
264 int tmp,i;
265 lprintf("\n\nYou have found %s ",objectname[itm]);
266 tmp=iarg[playerx][playery];
267 switch(itm)
268 {
269 case ODIAMOND: case ORUBY: case OEMERALD:
270 case OSAPPHIRE: case OSPIRITSCARAB: case OORBOFDRAGON:
271 case OCUBEofUNDEAD: case ONOTHEFT: break;
272
273 default:
274 if (tmp>0) lprintf("+ %d",(long)tmp); else if (tmp<0) lprintf(" %d",(long)tmp);
275 }
276 lprcat("\nDo you want to (t) take it"); iopts();
277 i=0; while (i!='t' && i!='i' && i!='\33') i=getchar();
278 if (i == 't')
279 { lprcat("take"); if (take(itm,tmp)==0) forget(); return; }
280 ignore();
281 }
282
283 \f
284 /*
285 *******
286 OSTAIRS
287 *******
288
289 subroutine to process the stair cases
290 if dir > 0 the up else down
291 */
292 ostairs(dir)
293 int dir;
294 {
295 register int k;
296 lprcat("\nDo you (s) stay here ");
297 if (dir > 0) lprcat("(u) go up "); else lprcat("(d) go down ");
298 lprcat("or (f) kick stairs? ");
299
300 while (1) switch(getchar())
301 {
302 case '\33':
303 case 's': case 'i': lprcat("stay here"); return;
304
305 case 'f': lprcat("kick stairs");
306 if (rnd(2) == 1)
307 lprcat("\nI hope you feel better. Showing anger rids you of frustration.");
308 else
309 {
310 k=rnd((level+1)<<1);
311 lprintf("\nYou hurt your foot dumb dumb! You suffer %d hit points",(long)k);
312 lastnum=276; losehp(k); bottomline();
313 }
314 return;
315
316 case 'u': lprcat("go up");
317 if (dir < 0) lprcat("\nThe stairs don't go up!");
318 else
319 if (level>=2 && level!=11)
320 {
321 k = level; newcavelevel(level-1);
322 draws(0,MAXX,0,MAXY); bot_linex();
323 }
324 else lprcat("\nThe stairs lead to a dead end!");
325 return;
326
327 case 'd': lprcat("go down");
328 if (dir > 0) lprcat("\nThe stairs don't go down!");
329 else
330 if (level!=0 && level!=10 && level!=13)
331 {
332 k = level; newcavelevel(level+1);
333 draws(0,MAXX,0,MAXY); bot_linex();
334 }
335 else lprcat("\nThe stairs lead to a dead end!");
336 return;
337 };
338 }
339
340 \f
341 /*
342 *********
343 OTELEPORTER
344 *********
345
346 subroutine to handle a teleport trap +/- 1 level maximum
347 */
348 oteleport(err)
349 int err;
350 {
351 register int tmp;
352 if (err) if (rnd(151)<3) died(264); /* stuck in a rock */
353 c[TELEFLAG]=1; /* show ?? on bottomline if been teleported */
354 if (level==0) tmp=0;
355 else if (level < MAXLEVEL)
356 { tmp=rnd(5)+level-3; if (tmp>=MAXLEVEL) tmp=MAXLEVEL-1;
357 if (tmp<1) tmp=1; }
358 else
359 { tmp=rnd(3)+level-2; if (tmp>=MAXLEVEL+MAXVLEVEL) tmp=MAXLEVEL+MAXVLEVEL-1;
360 if (tmp<MAXLEVEL) tmp=MAXLEVEL; }
361 playerx = rnd(MAXX-2); playery = rnd(MAXY-2);
362 if (level != tmp) newcavelevel(tmp); positionplayer();
363 draws(0,MAXX,0,MAXY); bot_linex();
364 }
365 \f
366 /*
367 *******
368 OPOTION
369 *******
370
371 function to process a potion
372 */
373 opotion(pot)
374 int pot;
375 {
376 lprcat("\nDo you (d) drink it, (t) take it"); iopts();
377 while (1) switch(getchar())
378 {
379 case '\33':
380 case 'i': ignore(); return;
381
382 case 'd': lprcat("drink\n"); forget(); /* destroy potion */
383 quaffpotion(pot); return;
384
385 case 't': lprcat("take\n"); if (take(OPOTION,pot)==0) forget();
386 return;
387 };
388 }
389
390 /*
391 function to drink a potion
392 */
393 quaffpotion(pot)
394 int pot;
395 {
396 register int i,j,k;
397 if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */
398 potionname[pot] = potionhide[pot];
399 switch(pot)
400 {
401 case 9: lprcat("\nYou feel greedy . . ."); nap(2000);
402 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)
403 if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD))
404 {
405 know[j][i]=1; show1cell(j,i);
406 }
407 showplayer(); return;
408
409 case 19: lprcat("\nYou feel greedy . . ."); nap(2000);
410 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)
411 {
412 k=item[j][i];
413 if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD)
414 || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE))
415 {
416 know[j][i]=1; show1cell(j,i);
417 }
418 }
419 showplayer(); return;
420
421 case 20: c[HP] = c[HPMAX]; break; /* instant healing */
422
423 case 1: lprcat("\nYou feel better");
424 if (c[HP] == c[HPMAX]) raisemhp(1);
425 else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX]; break;
426
427 case 2: lprcat("\nSuddenly, you feel much more skillful!");
428 raiselevel(); raisemhp(1); return;
429
430 case 3: lprcat("\nYou feel strange for a moment");
431 c[rund(6)]++; break;
432
433 case 4: lprcat("\nYou feel more self confident!");
434 c[WISDOM] += rnd(2); break;
435
436 case 5: lprcat("\nWow! You feel great!");
437 if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++; break;
438
439 case 6: lprcat("\nYour charm went up by one!"); c[CHARISMA]++; break;
440
441 case 8: lprcat("\nYour intelligence went up by one!");
442 c[INTELLIGENCE]++; break;
443
444 case 10: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)
445 if (mitem[j][i])
446 {
447 know[j][i]=1; show1cell(j,i);
448 }
449 /* monster detection */ return;
450
451 case 12: lprcat("\nThis potion has no taste to it"); return;
452
453 case 15: lprcat("\nWOW!!! You feel Super-fantastic!!!");
454 if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11;
455 c[HERO] += 250; break;
456
457 case 16: lprcat("\nYou have a greater intestinal constitude!");
458 c[CONSTITUTION]++; break;
459
460 case 17: lprcat("\nYou now have incredibly bulging muscles!!!");
461 if (c[GIANTSTR]==0) c[STREXTRA] += 21;
462 c[GIANTSTR] += 700; break;
463
464 case 18: lprcat("\nYou feel a chill run up your spine!");
465 c[FIRERESISTANCE] += 1000; break;
466
467 case 0: lprcat("\nYou fall asleep. . .");
468 i=rnd(11)-(c[CONSTITUTION]>>2)+2; while(--i>0) { parse2(); nap(1000); }
469 cursors(); lprcat("\nYou woke up!"); return;
470
471 case 7: lprcat("\nYou become dizzy!");
472 if (--c[STRENGTH] < 3) c[STRENGTH]=3; break;
473
474 case 11: lprcat("\nYou stagger for a moment . .");
475 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)
476 know[j][i]=0;
477 nap(2000); draws(0,MAXX,0,MAXY); /* potion of forgetfulness */ return;
478
479 case 13: lprcat("\nYou can't see anything!"); /* blindness */
480 c[BLINDCOUNT]+=500; return;
481
482 case 14: lprcat("\nYou feel confused"); c[CONFUSE]+= 20+rnd(9); return;
483
484 case 21: lprcat("\nYou don't seem to be affected"); return; /* cure dianthroritis */
485
486 case 22: lprcat("\nYou feel a sickness engulf you"); /* poison */
487 c[HALFDAM] += 200 + rnd(200); return;
488
489 case 23: lprcat("\nYou feel your vision sharpen"); /* see invisible */
490 c[SEEINVISIBLE] += rnd(1000)+400;
491 monstnamelist[INVISIBLESTALKER] = 'I'; return;
492 };
493 bottomline(); /* show new stats */ return;
494 }
495 \f
496 /*
497 *******
498 OSCROLL
499 *******
500
501 function to process a magic scroll
502 */
503 oscroll(typ)
504 int typ;
505 {
506 lprcat("\nDo you ");
507 if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
508 while (1) switch(getchar())
509 {
510 case '\33':
511 case 'i': ignore(); return;
512
513 case 'r': if (c[BLINDCOUNT]) break;
514 lprcat("read"); forget();
515 if (typ==2 || typ==15) { show1cell(playerx,playery); cursors(); }
516 /* destroy it */ read_scroll(typ); return;
517
518 case 't': lprcat("take"); if (take(OSCROLL,typ)==0) forget(); /* destroy it */
519 return;
520 };
521 }
522
523 /*
524 data for the function to read a scroll
525 */
526 static int xh,yh,yl,xl;
527 static char curse[] = { BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING,
528 LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM };
529 static char exten[] = { PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT,
530 INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP };
531 char time_change[] = { HASTESELF,HERO,ALTPRO,PROTECTIONTIME,DEXCOUNT,
532 STRCOUNT,GIANTSTR,CHARMCOUNT,INVISIBILITY,CANCELLATION,
533 HASTESELF,AGGRAVATE,SCAREMONST,STEALTH,AWARENESS,HOLDMONST,HASTEMONST,
534 FIRERESISTANCE,GLOBE,SPIRITPRO,UNDEADPRO,HALFDAM,SEEINVISIBLE,
535 ITCHING,CLUMSINESS, WTW };
536 /*
537 * function to adjust time when time warping and taking courses in school
538 */
539 adjtime(tim)
540 register long tim;
541 {
542 register int j;
543 for (j=0; j<26; j++) /* adjust time related parameters */
544 if (c[time_change[j]])
545 if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1;
546 regen();
547 }
548
549 /*
550 function to read a scroll
551 */
552 read_scroll(typ)
553 int typ;
554 {
555 register int i,j;
556 if (typ<0 || typ>=MAXSCROLL) return; /* be sure we are within bounds */
557 scrollname[typ] = scrollhide[typ];
558 switch(typ)
559 {
560 case 0: lprcat("\nYour armor glows for a moment"); enchantarmor(); return;
561
562 case 1: lprcat("\nYour weapon glows for a moment"); enchweapon(); return; /* enchant weapon */
563
564 case 2: lprcat("\nYou have been granted enlightenment!");
565 yh = min(playery+7,MAXY); xh = min(playerx+25,MAXX);
566 yl = max(playery-7,0); xl = max(playerx-25,0);
567 for (i=yl; i<yh; i++) for (j=xl; j<xh; j++) know[j][i]=1;
568 nap(2000); draws(xl,xh,yl,yh); return;
569
570 case 3: lprcat("\nThis scroll seems to be blank"); return;
571
572 case 4: createmonster(makemonst(level+1)); return; /* this one creates a monster */
573
574 case 5: something(level); /* create artifact */ return;
575
576 case 6: c[AGGRAVATE]+=800; return; /* aggravate monsters */
577
578 case 7: gtime += (i = rnd(1000) - 850); /* time warp */
579 if (i>=0) lprintf("\nYou went forward in time by %d mobuls",(long)((i+99)/100));
580 else lprintf("\nYou went backward in time by %d mobuls",(long)(-(i+99)/100));
581 adjtime((long)i); /* adjust time for time warping */
582 return;
583
584 case 8: oteleport(0); return; /* teleportation */
585
586 case 9: c[AWARENESS] += 1800; return; /* expanded awareness */
587
588 case 10: c[HASTEMONST] += rnd(55)+12; return; /* haste monster */
589
590 case 11: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++)
591 if (mitem[j][i])
592 hitp[j][i] = monster[mitem[j][i]].hitpoints;
593 return; /* monster healing */
594 case 12: c[SPIRITPRO] += 300 + rnd(200); bottomline(); return; /* spirit protection */
595
596 case 13: c[UNDEADPRO] += 300 + rnd(200); bottomline(); return; /* undead protection */
597
598 case 14: c[STEALTH] += 250 + rnd(250); bottomline(); return; /* stealth */
599
600 case 15: lprcat("\nYou have been granted enlightenment!"); /* magic mapping */
601 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=1;
602 nap(2000); draws(0,MAXX,0,MAXY); return;
603
604 case 16: c[HOLDMONST] += 30; bottomline(); return; /* hold monster */
605
606 case 17: for (i=0; i<26; i++) /* gem perfection */
607 switch(iven[i])
608 {
609 case ODIAMOND: case ORUBY:
610 case OEMERALD: case OSAPPHIRE:
611 j = ivenarg[i]; j &= 255; j <<= 1;
612 if (j > 255) j=255; /* double value */
613 ivenarg[i] = j; break;
614 }
615 break;
616
617 case 18: for (i=0; i<11; i++) c[exten[i]] <<= 1; /* spell extension */
618 break;
619
620 case 19: for (i=0; i<26; i++) /* identify */
621 {
622 if (iven[i]==OPOTION) potionname[ivenarg[i]] = potionhide[ivenarg[i]];
623 if (iven[i]==OSCROLL) scrollname[ivenarg[i]] = scrollhide[ivenarg[i]];
624 }
625 break;
626
627 case 20: for (i=0; i<10; i++) /* remove curse */
628 if (c[curse[i]]) c[curse[i]] = 1;
629 break;
630
631 case 21: annihilate(); break; /* scroll of annihilation */
632
633 case 22: godirect(22,150,"The ray hits the %s",0,' '); /* pulverization */
634 break;
635 case 23: c[LIFEPROT]++; break; /* life protection */
636 };
637 }
638
639 \f
640 oorb()
641 {
642 }
643
644 opit()
645 {
646 register int i;
647 if (rnd(101)<81)
648 if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5)
649 if (level==MAXLEVEL-1) obottomless(); else
650 if (level==MAXLEVEL+MAXVLEVEL-1) obottomless(); else
651 {
652 if (rnd(101)<20)
653 {
654 i=0; lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n");
655 }
656 else
657 {
658 i = rnd(level*3+3);
659 lprintf("\nYou fell into a pit! You suffer %d hit points damage",(long)i);
660 lastnum=261; /* if he dies scoreboard will say so */
661 }
662 losehp(i); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY);
663 }
664 }
665
666 obottomless()
667 {
668 lprcat("\nYou fell into a bottomless pit!"); beep(); nap(3000); died(262);
669 }
670 oelevator(dir)
671 int dir;
672 {
673 #ifdef lint
674 int x;
675 x=dir;
676 dir=x;
677 #endif lint
678 }
679
680 ostatue()
681 {
682 }
683
684 omirror()
685 {
686 }
687
688 obook()
689 {
690 lprcat("\nDo you ");
691 if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts();
692 while (1) switch(getchar())
693 {
694 case '\33':
695 case 'i': ignore(); return;
696
697 case 'r': if (c[BLINDCOUNT]) break;
698 lprcat("read");
699 /* no more book */ readbook(iarg[playerx][playery]); forget(); return;
700
701 case 't': lprcat("take"); if (take(OBOOK,iarg[playerx][playery])==0) forget(); /* no more book */
702 return;
703 };
704 }
705
706 /*
707 function to read a book
708 */
709 readbook(lev)
710 register int lev;
711 {
712 register int i,tmp;
713 if (lev<=3) i = rund((tmp=splev[lev])?tmp:1); else
714 i = rnd((tmp=splev[lev]-9)?tmp:1) + 9;
715 spelknow[i]=1;
716 lprintf("\nSpell \"%s\": %s\n%s",spelcode[i],spelname[i],speldescript[i]);
717 if (rnd(10)==4)
718 { lprcat("\nYour int went up by one!"); c[INTELLIGENCE]++; bottomline(); }
719 }
720
721 ocookie()
722 {
723 char *p;
724 lprcat("\nDo you (e) eat it, (t) take it"); iopts();
725 while (1) switch(getchar())
726 {
727 case '\33':
728 case 'i': ignore(); return;
729
730 case 'e': lprcat("eat\nThe cookie tasted good.");
731 forget(); /* no more cookie */
732 if (c[BLINDCOUNT]) return;
733 if (!(p=fortune(fortfile))) return;
734 lprcat(" A message inside the cookie reads:\n"); lprcat(p);
735 return;
736
737 case 't': lprcat("take"); if (take(OCOOKIE,0)==0) forget(); /* no more book */
738 return;
739 };
740 }
741
742
743 /* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 100* the argument */
744 ogold(arg)
745 int arg;
746 {
747 register long i;
748 i = iarg[playerx][playery];
749 if (arg==OMAXGOLD) i *= 100;
750 else if (arg==OKGOLD) i *= 1000;
751 else if (arg==ODGOLD) i *= 10;
752 lprintf("\nIt is worth %d!",(long)i); c[GOLD] += i; bottomgold();
753 item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */
754 }
755
756 ohome()
757 {
758 register int i;
759 nosignal = 1; /* disable signals */
760 for (i=0; i<26; i++) if (iven[i]==OPOTION) if (ivenarg[i]==21)
761 {
762 iven[i]=0; /* remove the potion of cure dianthroritis from inventory */
763 clear(); lprcat("Congratulations. You found a potion of cure dianthroritis.\n");
764 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n");
765 if (gtime>TIMELIMIT)
766 {
767 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
768 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
769 nap(5000); died(269);
770 }
771 else
772 {
773 lprcat("\nThe doctor is now administering the potion, and in a few moments\n");
774 lprcat("Your daughter should be well on her way to recovery.\n");
775 nap(6000);
776 lprcat("\nThe potion is"); nap(3000); lprcat(" working! The doctor thinks that\n");
777 lprcat("your daughter will recover in a few days. Congratulations!\n");
778 beep(); nap(5000); died(263);
779 }
780 }
781
782 while (1)
783 {
784 clear(); lprintf("Welcome home %s. Latest word from the doctor is not good.\n",logname);
785
786 if (gtime>TIMELIMIT)
787 {
788 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n");
789 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n");
790 nap(5000); died(269);
791 }
792
793 lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n");
794 lprintf("your daughter has only %d mobuls left in this world. It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100));
795 lprintf("%s, to find the only hope for your daughter, the very rare\n",logname);
796 lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n");
797 lprcat("depths of the caves can this potion be found.\n\n\n");
798 lprcat("\n ----- press "); standout("return");
799 lprcat(" to continue, "); standout("escape");
800 lprcat(" to leave ----- ");
801 i=getchar(); while (i!='\33' && i!='\n') i=getchar();
802 if (i=='\33') { drawscreen(); nosignal = 0; /* enable signals */ return; }
803 }
804 }
805
806 /* routine to save program space */
807 iopts()
808 { lprcat(", or (i) ignore it? "); }
809 ignore()
810 { lprcat("ignore\n"); }
811