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