Install dma(8) config files with mode 640 as root:mail to prevent ``normal''
[dragonfly/netmp.git] / games / larn / moreobj.c
blob69f79cc6fc5a43aac536ef0589ae94ddcf056a2a
1 /* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
2 * $FreeBSD: src/games/larn/moreobj.c,v 1.4 1999/11/16 02:57:22 billf Exp $
3 * $DragonFly: src/games/larn/moreobj.c,v 1.3 2006/08/26 17:05:05 pavalos Exp $
5 * Routines in this file:
7 * oaltar()
8 * othrone()
9 * ochest()
10 * ofountain()
12 #include "header.h"
14 static void ohear(void);
15 static void fch(int, long *);
16 static void fntchange(int);
19 * ******
20 * OALTAR
21 * ******
23 * subroutine to process an altar object
25 void
26 oaltar(void)
28 unsigned long k;
30 lprcat("\nDo you (p) pray (d) desecrate"); iopts();
31 while (1)
33 while (1) switch(getchr())
35 case 'p': lprcat(" pray\nDo you (m) give money or (j) just pray? ");
36 while (1) switch(getchr())
38 case 'j': if (rnd(100)<75)
39 lprcat("\nnothing happens");
40 else if (rnd(13)<4) ohear();
41 else if (rnd(43) == 10)
43 if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
44 enchantarmor(); return;
46 else if (rnd(43) == 10)
48 if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
49 enchweapon(); return;
51 else createmonster(makemonst(level+1));
52 return;
54 case 'm': lprcat("\n\n"); cursor(1,24); cltoeoln();
55 cursor(1,23); cltoeoln();
56 lprcat("how much do you donate? ");
57 k = readnum((long)c[GOLD]);
58 if (c[GOLD]<(long)k)
60 lprcat("\nYou don't have that much!");
61 return;
63 c[GOLD] -= k;
64 if ((long)k < c[GOLD]/10 || (long)k<rnd(50))
65 { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
66 else if (rnd(101) > 50) { ohear(); return; }
67 else if (rnd(43) == 5)
69 if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
70 enchantarmor(); return;
72 else if (rnd(43) == 8)
74 if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
75 enchweapon(); return;
77 else lprcat("\nThank You.");
78 bottomline(); return;
80 case '\33': return;
83 case 'd': lprcat(" desecrate");
84 if (rnd(100)<60)
85 { createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
86 else
87 if (rnd(101)<30)
89 lprcat("\nThe altar crumbles into a pile of dust before your eyes");
90 forget(); /* remember to destroy the altar */
92 else
93 lprcat("\nnothing happens");
94 return;
96 case 'i':
97 case '\33': ignore();
98 if (rnd(100)<30) { createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
99 else lprcat("\nnothing happens");
100 return;
106 function to cast a +3 protection on the player
108 static void
109 ohear(void)
111 lprcat("\nYou have been heard!");
112 if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
113 c[ALTPRO] += 500; /* protection field */
114 bottomline();
118 *******
119 OTHRONE
120 *******
122 subroutine to process a throne object
124 void
125 othrone(int arg)
127 int i,k;
129 lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
130 while (1)
132 while (1) switch(getchr())
134 case 'p': lprcat(" pry off"); k=rnd(101);
135 if (k<25)
137 for (i=0; i<rnd(4); i++) creategem(); /* gems pop off the throne */
138 item[playerx][playery]=ODEADTHRONE;
139 know[playerx][playery]=0;
141 else if (k<40 && arg==0)
143 createmonster(GNOMEKING);
144 item[playerx][playery]=OTHRONE2;
145 know[playerx][playery]=0;
147 else lprcat("\nnothing happens");
148 return;
150 case 's': lprcat(" sit down"); k=rnd(101);
151 if (k<30 && arg==0)
153 createmonster(GNOMEKING);
154 item[playerx][playery]=OTHRONE2;
155 know[playerx][playery]=0;
157 else if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
158 else lprcat("\nnothing happens");
159 return;
161 case 'i':
162 case '\33': ignore(); return;
167 void
168 odeadthrone(void)
170 int k;
172 lprcat("\nDo you (s) sit down"); iopts();
173 while (1)
175 while (1) switch(getchr())
177 case 's': lprcat(" sit down"); k=rnd(101);
178 if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
179 else lprcat("\nnothing happens");
180 return;
182 case 'i':
183 case '\33': ignore(); return;
189 ******
190 OCHEST
191 ******
193 subroutine to process a throne object
195 void
196 ochest(void)
198 int i,k;
199 lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
200 while (1)
202 while (1) switch(getchr())
204 case 'o': lprcat(" open it"); k=rnd(101);
205 if (k<40)
207 lprcat("\nThe chest explodes as you open it"); beep();
208 i = rnd(10); lastnum=281; /* in case he dies */
209 lprintf("\nYou suffer %d hit points damage!",(long)i);
210 checkloss(i);
211 switch(rnd(10)) /* see if he gets a curse */
213 case 1: c[ITCHING]+= rnd(1000)+100;
214 lprcat("\nYou feel an irritation spread over your skin!");
215 beep();
216 break;
218 case 2: c[CLUMSINESS]+= rnd(1600)+200;
219 lprcat("\nYou begin to lose hand to eye coordination!");
220 beep();
221 break;
223 case 3: c[HALFDAM]+= rnd(1600)+200;
224 beep();
225 lprcat("\nA sickness engulfs you!"); break;
227 item[playerx][playery]=know[playerx][playery]=0;
228 if (rnd(100)<69) creategem(); /* gems from the chest */
229 dropgold(rnd(110*iarg[playerx][playery]+200));
230 for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
232 else lprcat("\nnothing happens");
233 return;
235 case 't': lprcat(" take");
236 if (take(OCHEST,iarg[playerx][playery])==0)
237 item[playerx][playery]=know[playerx][playery]=0;
238 return;
240 case 'i':
241 case '\33': ignore(); return;
247 *********
248 OFOUNTAIN
249 *********
251 void
252 ofountain(void)
254 int x;
255 cursors();
256 lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
257 while (1) switch(getchr())
259 case 'd': lprcat("drink");
260 if (rnd(1501)<2)
262 lprcat("\nOops! You seem to have caught the dreadful sleep!");
263 beep(); lflush(); sleep(3); died(280); return;
265 x = rnd(100);
266 if (x<7)
268 c[HALFDAM] += 200+rnd(200);
269 lprcat("\nYou feel a sickness coming on");
271 else if (x<13) quaffpotion(23); /* see invisible */
272 else if (x < 45)
273 lprcat("\nnothing seems to have happened");
274 else if (rnd(3) != 2)
275 fntchange(1); /* change char levels upward */
276 else
277 fntchange(-1); /* change char levels downward */
278 if (rnd(12)<3)
280 lprcat("\nThe fountains bubbling slowly quiets");
281 item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
282 know[playerx][playery]=0;
284 return;
286 case '\33':
287 case 'i': ignore(); return;
289 case 'w': lprcat("wash yourself");
290 if (rnd(100) < 11)
292 x=rnd((level<<2)+2);
293 lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x);
294 lastnum=273; losehp(x); bottomline(); cursors();
296 else
297 if (rnd(100) < 29)
298 lprcat("\nYou got the dirt off!");
299 else
300 if (rnd(100) < 31)
301 lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
302 else
303 if (rnd(100) < 34)
304 createmonster(WATERLORD); /* make water lord */
305 else
306 lprcat("\nnothing seems to have happened");
307 return;
316 subroutine to process an up/down of a character attribute for ofountain
318 static void
319 fch(int how, long *x)
321 if (how < 0) { lprcat(" went down by one!"); --(*x); }
322 else { lprcat(" went up by one!"); (*x)++; }
323 bottomline();
327 a subroutine to raise or lower character levels
328 if x > 0 they are raised if x < 0 they are lowered
330 static void
331 fntchange(int how)
333 long j;
334 lprc('\n');
335 switch(rnd(9))
337 case 1: lprcat("Your strength"); fch(how,&c[0]); break;
338 case 2: lprcat("Your intelligence"); fch(how,&c[1]); break;
339 case 3: lprcat("Your wisdom"); fch(how,&c[2]); break;
340 case 4: lprcat("Your constitution"); fch(how,&c[3]); break;
341 case 5: lprcat("Your dexterity"); fch(how,&c[4]); break;
342 case 6: lprcat("Your charm"); fch(how,&c[5]); break;
343 case 7: j=rnd(level+1);
344 if (how < 0)
345 { lprintf("You lose %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); losemhp((int)j); }
346 else
347 { lprintf("You gain %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); }
348 bottomline(); break;
350 case 8: j=rnd(level+1);
351 if (how > 0)
353 lprintf("You just gained %d spell",(long)j); raisemspells((int)j);
354 if (j>1) lprcat("s!"); else lprc('!');
356 else
358 lprintf("You just lost %d spell",(long)j); losemspells((int)j);
359 if (j>1) lprcat("s!"); else lprc('!');
361 bottomline(); break;
363 case 9: j = 5*rnd((level+1)*(level+1));
364 if (how < 0)
366 lprintf("You just lost %d experience point",(long)j);
367 if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j);
369 else
371 lprintf("You just gained %d experience point",(long)j);
372 if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j);
374 break;
376 cursors();