Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / games / larn / moreobj.c
blob3f7c55da204634e3a0af446bba06928c5dae8f2c
1 /* $NetBSD: moreobj.c,v 1.10 2008/02/04 01:07:01 dholland Exp $ */
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.10 2008/02/04 01:07:01 dholland Exp $");
13 #endif /* not lint */
14 #include <stdlib.h>
15 #include <unistd.h>
16 #include "header.h"
17 #include "extern.h"
19 static void fch(int, long *);
22 * subroutine to process an altar object
24 void
25 oaltar()
28 lprcat("\nDo you (p) pray (d) desecrate");
29 iopts();
30 while (1) {
31 while (1)
32 switch (ttgetch()) {
33 case 'p':
34 lprcat(" pray\nDo you (m) give money or (j) just pray? ");
35 while (1)
36 switch (ttgetch()) {
37 case 'j':
38 act_just_pray();
39 return;
41 case 'm':
42 act_donation_pray();
43 return;
45 case '\33':
46 return;
49 case 'd':
50 lprcat(" desecrate");
51 act_desecrate_altar();
52 return;
54 case 'i':
55 case '\33':
56 ignore();
57 act_ignore_altar();
58 return;
64 subroutine to process a throne object
66 void
67 othrone(arg)
68 int arg;
71 lprcat("\nDo you (p) pry off jewels, (s) sit down");
72 iopts();
73 while (1) {
74 while (1)
75 switch (ttgetch()) {
76 case 'p':
77 lprcat(" pry off");
78 act_remove_gems(arg);
79 return;
81 case 's':
82 lprcat(" sit down");
83 act_sit_throne(arg);
84 return;
86 case 'i':
87 case '\33':
88 ignore();
89 return;
94 void
95 odeadthrone()
97 int k;
99 lprcat("\nDo you (s) sit down");
100 iopts();
101 while (1) {
102 while (1)
103 switch (ttgetch()) {
104 case 's':
105 lprcat(" sit down");
106 k = rnd(101);
107 if (k < 35) {
108 lprcat("\nZaaaappp! You've been teleported!\n");
109 beep();
110 oteleport(0);
111 } else
112 lprcat("\nnothing happens");
113 return;
115 case 'i':
116 case '\33':
117 ignore();
118 return;
124 subroutine to process a throne object
126 void
127 ochest()
130 lprcat("\nDo you (t) take it, (o) try to open it");
131 iopts();
132 while (1) {
133 while (1)
134 switch (ttgetch()) {
135 case 'o':
136 lprcat(" open it");
137 act_open_chest(playerx, playery);
138 return;
140 case 't':
141 lprcat(" take");
142 if (take(OCHEST, iarg[playerx][playery]) == 0)
143 item[playerx][playery] = know[playerx][playery] = 0;
144 return;
146 case 'i':
147 case '\33':
148 ignore();
149 return;
155 process a fountain object
157 void
158 ofountain()
161 cursors();
162 lprcat("\nDo you (d) drink, (w) wash yourself");
163 iopts();
164 while (1)
165 switch (ttgetch()) {
166 case 'd':
167 lprcat("drink");
168 act_drink_fountain();
169 return;
171 case '\33':
172 case 'i':
173 ignore();
174 return;
176 case 'w':
177 lprcat("wash yourself");
178 act_wash_fountain();
179 return;
188 subroutine to process an up/down of a character attribute for ofountain
190 static void
191 fch(how, x)
192 int how;
193 long *x;
195 if (how < 0) {
196 lprcat(" went down by one!");
197 --(*x);
198 } else {
199 lprcat(" went up by one!");
200 (*x)++;
202 bottomline();
206 a subroutine to raise or lower character levels
207 if x > 0 they are raised if x < 0 they are lowered
209 void
210 fntchange(how)
211 int how;
213 long j;
214 lprc('\n');
215 switch (rnd(9)) {
216 case 1:
217 lprcat("Your strength");
218 fch(how, &c[0]);
219 break;
220 case 2:
221 lprcat("Your intelligence");
222 fch(how, &c[1]);
223 break;
224 case 3:
225 lprcat("Your wisdom");
226 fch(how, &c[2]);
227 break;
228 case 4:
229 lprcat("Your constitution");
230 fch(how, &c[3]);
231 break;
232 case 5:
233 lprcat("Your dexterity");
234 fch(how, &c[4]);
235 break;
236 case 6:
237 lprcat("Your charm");
238 fch(how, &c[5]);
239 break;
240 case 7:
241 j = rnd(level + 1);
242 if (how < 0) {
243 lprintf("You lose %ld hit point", (long) j);
244 if (j > 1)
245 lprcat("s!");
246 else
247 lprc('!');
248 losemhp((int) j);
249 } else {
250 lprintf("You gain %ld hit point", (long) j);
251 if (j > 1)
252 lprcat("s!");
253 else
254 lprc('!');
255 raisemhp((int) j);
257 bottomline();
258 break;
260 case 8:
261 j = rnd(level + 1);
262 if (how > 0) {
263 lprintf("You just gained %ld spell", (long) j);
264 raisemspells((int) j);
265 if (j > 1)
266 lprcat("s!");
267 else
268 lprc('!');
269 } else {
270 lprintf("You just lost %ld spell", (long) j);
271 losemspells((int) j);
272 if (j > 1)
273 lprcat("s!");
274 else
275 lprc('!');
277 bottomline();
278 break;
280 case 9:
281 j = 5 * rnd((level + 1) * (level + 1));
282 if (how < 0) {
283 lprintf("You just lost %ld experience point", (long) j);
284 if (j > 1)
285 lprcat("s!");
286 else
287 lprc('!');
288 loseexperience((long) j);
289 } else {
290 lprintf("You just gained %ld experience point", (long) j);
291 if (j > 1)
292 lprcat("s!");
293 else
294 lprc('!');
295 raiseexperience((long) j);
297 break;
299 cursors();