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