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