]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - larn/moreobj.c
Remove dup Hitler fortune. One of the two fortunes I moved yesterday, was
[bsdgames-darwin.git] / larn / moreobj.c
1 /* $NetBSD: moreobj.c,v 1.6 2004/01/27 20:30:30 jsm Exp $ */
2
3 /*
4 * moreobj.c Larn is copyrighted 1986 by Noah Morgan.
5 *
6 * Routines in this file:
7 *
8 * oaltar() othrone() ochest() ofountain()
9 */
10 #include <sys/cdefs.h>
11 #ifndef lint
12 __RCSID("$NetBSD: moreobj.c,v 1.6 2004/01/27 20:30:30 jsm Exp $");
13 #endif /* not lint */
14 #include <stdlib.h>
15 #include <unistd.h>
16 #include "header.h"
17 #include "extern.h"
18
19 static void ohear(void);
20 static void fch(int, long *);
21
22 /*
23 * ******
24 * OALTAR
25 * ******
26 *
27 * subroutine to process an altar object
28 */
29 void
30 oaltar()
31 {
32 unsigned long k;
33
34 lprcat("\nDo you (p) pray (d) desecrate");
35 iopts();
36 while (1) {
37 while (1)
38 switch (lgetchar()) {
39 case 'p':
40 lprcat(" pray\nDo you (m) give money or (j) just pray? ");
41 while (1)
42 switch (lgetchar()) {
43 case 'j':
44 if (rnd(100) < 75)
45 lprcat("\nnothing happens");
46 else if (rnd(13) < 4)
47 ohear();
48 else if (rnd(43) == 10) {
49 if (c[WEAR])
50 lprcat("\nYou feel your armor vibrate for a moment");
51 enchantarmor();
52 return;
53 } else if (rnd(43) == 10) {
54 if (c[WIELD])
55 lprcat("\nYou feel your weapon vibrate for a moment");
56 enchweapon();
57 return;
58 } else
59 createmonster(makemonst(level + 1));
60 return;
61
62 case 'm':
63 lprcat("\n\n");
64 cursor(1, 24);
65 cltoeoln();
66 cursor(1, 23);
67 cltoeoln();
68 lprcat("how much do you donate? ");
69 k = readnum((long) c[GOLD]);
70 if (c[GOLD] < k) {
71 lprcat("\nYou don't have that much!");
72 return;
73 }
74 c[GOLD] -= k;
75 if (k < c[GOLD] / 10 || k < rnd(50)) {
76 createmonster(makemonst(level + 1));
77 c[AGGRAVATE] += 200;
78 } else if (rnd(101) > 50) {
79 ohear();
80 return;
81 } else if (rnd(43) == 5) {
82 if (c[WEAR])
83 lprcat("\nYou feel your armor vibrate for a moment");
84 enchantarmor();
85 return;
86 } else if (rnd(43) == 8) {
87 if (c[WIELD])
88 lprcat("\nYou feel your weapon vibrate for a moment");
89 enchweapon();
90 return;
91 } else
92 lprcat("\nThank You.");
93 bottomline();
94 return;
95
96 case '\33':
97 return;
98 };
99
100 case 'd':
101 lprcat(" desecrate");
102 if (rnd(100) < 60) {
103 createmonster(makemonst(level + 2) + 8);
104 c[AGGRAVATE] += 2500;
105 } else if (rnd(101) < 30) {
106 lprcat("\nThe altar crumbles into a pile of dust before your eyes");
107 forget(); /* remember to destroy
108 * the altar */
109 } else
110 lprcat("\nnothing happens");
111 return;
112
113 case 'i':
114 case '\33':
115 ignore();
116 if (rnd(100) < 30) {
117 createmonster(makemonst(level + 1));
118 c[AGGRAVATE] += rnd(450);
119 } else
120 lprcat("\nnothing happens");
121 return;
122 };
123 }
124 }
125
126 /*
127 function to cast a +3 protection on the player
128 */
129 static void
130 ohear()
131 {
132 lprcat("\nYou have been heard!");
133 if (c[ALTPRO] == 0)
134 c[MOREDEFENSES] += 3;
135 c[ALTPRO] += 500; /* protection field */
136 bottomline();
137 }
138
139 /*
140 *******
141 OTHRONE
142 *******
143
144 subroutine to process a throne object
145 */
146 void
147 othrone(arg)
148 int arg;
149 {
150 int i, k;
151
152 lprcat("\nDo you (p) pry off jewels, (s) sit down");
153 iopts();
154 while (1) {
155 while (1)
156 switch (lgetchar()) {
157 case 'p':
158 lprcat(" pry off");
159 k = rnd(101);
160 if (k < 25) {
161 for (i = 0; i < rnd(4); i++)
162 creategem(); /* gems pop off the
163 * throne */
164 item[playerx][playery] = ODEADTHRONE;
165 know[playerx][playery] = 0;
166 } else if (k < 40 && arg == 0) {
167 createmonster(GNOMEKING);
168 item[playerx][playery] = OTHRONE2;
169 know[playerx][playery] = 0;
170 } else
171 lprcat("\nnothing happens");
172 return;
173
174 case 's':
175 lprcat(" sit down");
176 k = rnd(101);
177 if (k < 30 && arg == 0) {
178 createmonster(GNOMEKING);
179 item[playerx][playery] = OTHRONE2;
180 know[playerx][playery] = 0;
181 } else if (k < 35) {
182 lprcat("\nZaaaappp! You've been teleported!\n");
183 beep();
184 oteleport(0);
185 } else
186 lprcat("\nnothing happens");
187 return;
188
189 case 'i':
190 case '\33':
191 ignore();
192 return;
193 };
194 }
195 }
196
197 void
198 odeadthrone()
199 {
200 int k;
201
202 lprcat("\nDo you (s) sit down");
203 iopts();
204 while (1) {
205 while (1)
206 switch (lgetchar()) {
207 case 's':
208 lprcat(" sit down");
209 k = rnd(101);
210 if (k < 35) {
211 lprcat("\nZaaaappp! You've been teleported!\n");
212 beep();
213 oteleport(0);
214 } else
215 lprcat("\nnothing happens");
216 return;
217
218 case 'i':
219 case '\33':
220 ignore();
221 return;
222 };
223 }
224 }
225
226 /*
227 ******
228 OCHEST
229 ******
230
231 subroutine to process a throne object
232 */
233 void
234 ochest()
235 {
236 int i, k;
237 lprcat("\nDo you (t) take it, (o) try to open it");
238 iopts();
239 while (1) {
240 while (1)
241 switch (lgetchar()) {
242 case 'o':
243 lprcat(" open it");
244 k = rnd(101);
245 if (k < 40) {
246 lprcat("\nThe chest explodes as you open it");
247 beep();
248 i = rnd(10);
249 lastnum = 281; /* in case he dies */
250 lprintf("\nYou suffer %d hit points damage!", (long) i);
251 checkloss(i);
252 switch (rnd(10)) { /* see if he gets a
253 * curse */
254 case 1:
255 c[ITCHING] += rnd(1000) + 100;
256 lprcat("\nYou feel an irritation spread over your skin!");
257 beep();
258 break;
259
260 case 2:
261 c[CLUMSINESS] += rnd(1600) + 200;
262 lprcat("\nYou begin to lose hand to eye coordination!");
263 beep();
264 break;
265
266 case 3:
267 c[HALFDAM] += rnd(1600) + 200;
268 beep();
269 lprcat("\nA sickness engulfs you!");
270 break;
271 };
272 item[playerx][playery] = know[playerx][playery] = 0;
273 if (rnd(100) < 69)
274 creategem(); /* gems from the chest */
275 dropgold(rnd(110 * iarg[playerx][playery] + 200));
276 for (i = 0; i < rnd(4); i++)
277 something(iarg[playerx][playery] + 2);
278 } else
279 lprcat("\nnothing happens");
280 return;
281
282 case 't':
283 lprcat(" take");
284 if (take(OCHEST, iarg[playerx][playery]) == 0)
285 item[playerx][playery] = know[playerx][playery] = 0;
286 return;
287
288 case 'i':
289 case '\33':
290 ignore();
291 return;
292 };
293 }
294 }
295
296 /*
297 *********
298 OFOUNTAIN
299 *********
300 */
301
302 void
303 ofountain()
304 {
305 int x;
306 cursors();
307 lprcat("\nDo you (d) drink, (w) wash yourself");
308 iopts();
309 while (1)
310 switch (lgetchar()) {
311 case 'd':
312 lprcat("drink");
313 if (rnd(1501) < 2) {
314 lprcat("\nOops! You seem to have caught the dreadful sleep!");
315 beep();
316 lflush();
317 sleep(3);
318 died(280);
319 return;
320 }
321 x = rnd(100);
322 if (x < 7) {
323 c[HALFDAM] += 200 + rnd(200);
324 lprcat("\nYou feel a sickness coming on");
325 } else if (x < 13)
326 quaffpotion(23); /* see invisible */
327 else if (x < 45)
328 lprcat("\nnothing seems to have happened");
329 else if (rnd(3) != 2)
330 fntchange(1); /* change char levels upward */
331 else
332 fntchange(-1); /* change char levels
333 * downward */
334 if (rnd(12) < 3) {
335 lprcat("\nThe fountains bubbling slowly quiets");
336 item[playerx][playery] = ODEADFOUNTAIN; /* dead fountain */
337 know[playerx][playery] = 0;
338 }
339 return;
340
341 case '\33':
342 case 'i':
343 ignore();
344 return;
345
346 case 'w':
347 lprcat("wash yourself");
348 if (rnd(100) < 11) {
349 x = rnd((level << 2) + 2);
350 lprintf("\nOh no! The water was foul! You suffer %d hit points!", (long) x);
351 lastnum = 273;
352 losehp(x);
353 bottomline();
354 cursors();
355 } else if (rnd(100) < 29)
356 lprcat("\nYou got the dirt off!");
357 else if (rnd(100) < 31)
358 lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
359 else if (rnd(100) < 34)
360 createmonster(WATERLORD); /* make water lord */
361 else
362 lprcat("\nnothing seems to have happened");
363 return;
364 }
365 }
366
367 /*
368 ***
369 FCH
370 ***
371
372 subroutine to process an up/down of a character attribute for ofountain
373 */
374 static void
375 fch(how, x)
376 int how;
377 long *x;
378 {
379 if (how < 0) {
380 lprcat(" went down by one!");
381 --(*x);
382 } else {
383 lprcat(" went up by one!");
384 (*x)++;
385 }
386 bottomline();
387 }
388
389 /*
390 a subroutine to raise or lower character levels
391 if x > 0 they are raised if x < 0 they are lowered
392 */
393 void
394 fntchange(how)
395 int how;
396 {
397 long j;
398 lprc('\n');
399 switch (rnd(9)) {
400 case 1:
401 lprcat("Your strength");
402 fch(how, &c[0]);
403 break;
404 case 2:
405 lprcat("Your intelligence");
406 fch(how, &c[1]);
407 break;
408 case 3:
409 lprcat("Your wisdom");
410 fch(how, &c[2]);
411 break;
412 case 4:
413 lprcat("Your constitution");
414 fch(how, &c[3]);
415 break;
416 case 5:
417 lprcat("Your dexterity");
418 fch(how, &c[4]);
419 break;
420 case 6:
421 lprcat("Your charm");
422 fch(how, &c[5]);
423 break;
424 case 7:
425 j = rnd(level + 1);
426 if (how < 0) {
427 lprintf("You lose %d hit point", (long) j);
428 if (j > 1)
429 lprcat("s!");
430 else
431 lprc('!');
432 losemhp((int) j);
433 } else {
434 lprintf("You gain %d hit point", (long) j);
435 if (j > 1)
436 lprcat("s!");
437 else
438 lprc('!');
439 raisemhp((int) j);
440 }
441 bottomline();
442 break;
443
444 case 8:
445 j = rnd(level + 1);
446 if (how > 0) {
447 lprintf("You just gained %d spell", (long) j);
448 raisemspells((int) j);
449 if (j > 1)
450 lprcat("s!");
451 else
452 lprc('!');
453 } else {
454 lprintf("You just lost %d spell", (long) j);
455 losemspells((int) j);
456 if (j > 1)
457 lprcat("s!");
458 else
459 lprc('!');
460 }
461 bottomline();
462 break;
463
464 case 9:
465 j = 5 * rnd((level + 1) * (level + 1));
466 if (how < 0) {
467 lprintf("You just lost %d experience point", (long) j);
468 if (j > 1)
469 lprcat("s!");
470 else
471 lprc('!');
472 loseexperience((long) j);
473 } else {
474 lprintf("You just gained %d experience point", (long) j);
475 if (j > 1)
476 lprcat("s!");
477 else
478 lprc('!');
479 raiseexperience((long) j);
480 }
481 break;
482 }
483 cursors();
484 }