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