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.2 2003/06/17 04:25:24 dillon Exp $
5 * Routines in this file:
21 * subroutine to process an altar object
27 lprcat("\nDo you (p) pray (d) desecrate"); iopts();
30 while (1) switch(getchar())
32 case 'p': lprcat(" pray\nDo you (m) give money or (j) just pray? ");
33 while (1) switch(getchar())
35 case 'j': if (rnd(100)<75)
36 lprcat("\nnothing happens");
37 else if (rnd(13)<4) ohear();
38 else if (rnd(43) == 10)
40 if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
41 enchantarmor(); return;
43 else if (rnd(43) == 10)
45 if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
48 else createmonster(makemonst(level+1));
51 case 'm': lprcat("\n\n"); cursor(1,24); cltoeoln();
52 cursor(1,23); cltoeoln();
53 lprcat("how much do you donate? ");
54 k = readnum((long)c[GOLD]);
57 lprcat("\nYou don't have that much!");
61 if (k < c[GOLD]/10 || k<rnd(50))
62 { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
63 else if (rnd(101) > 50) { ohear(); return; }
64 else if (rnd(43) == 5)
66 if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
67 enchantarmor(); return;
69 else if (rnd(43) == 8)
71 if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
74 else lprcat("\nThank You.");
80 case 'd': lprcat(" desecrate");
82 { createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
86 lprcat("\nThe altar crumbles into a pile of dust before your eyes");
87 forget(); /* remember to destroy the altar */
90 lprcat("\nnothing happens");
95 if (rnd(100)<30) { createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
96 else lprcat("\nnothing happens");
103 function to cast a +3 protection on the player
108 lprcat("\nYou have been heard!");
109 if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
110 c[ALTPRO] += 500; /* protection field */
119 subroutine to process a throne object
126 lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
129 while (1) switch(getchar())
131 case 'p': lprcat(" pry off"); k=rnd(101);
134 for (i=0; i<rnd(4); i++) creategem(); /* gems pop off the throne */
135 item[playerx][playery]=ODEADTHRONE;
136 know[playerx][playery]=0;
138 else if (k<40 && arg==0)
140 createmonster(GNOMEKING);
141 item[playerx][playery]=OTHRONE2;
142 know[playerx][playery]=0;
144 else lprcat("\nnothing happens");
147 case 's': lprcat(" sit down"); k=rnd(101);
150 createmonster(GNOMEKING);
151 item[playerx][playery]=OTHRONE2;
152 know[playerx][playery]=0;
154 else if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
155 else lprcat("\nnothing happens");
159 case '\33': ignore(); return;
168 lprcat("\nDo you (s) sit down"); iopts();
171 while (1) switch(getchar())
173 case 's': lprcat(" sit down"); k=rnd(101);
174 if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
175 else lprcat("\nnothing happens");
179 case '\33': ignore(); return;
189 subroutine to process a throne object
194 lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
197 while (1) switch(getchar())
199 case 'o': lprcat(" open it"); k=rnd(101);
202 lprcat("\nThe chest explodes as you open it"); beep();
203 i = rnd(10); lastnum=281; /* in case he dies */
204 lprintf("\nYou suffer %d hit points damage!",(long)i);
206 switch(rnd(10)) /* see if he gets a curse */
208 case 1: c[ITCHING]+= rnd(1000)+100;
209 lprcat("\nYou feel an irritation spread over your skin!");
213 case 2: c[CLUMSINESS]+= rnd(1600)+200;
214 lprcat("\nYou begin to lose hand to eye coordination!");
218 case 3: c[HALFDAM]+= rnd(1600)+200;
220 lprcat("\nA sickness engulfs you!"); break;
222 item[playerx][playery]=know[playerx][playery]=0;
223 if (rnd(100)<69) creategem(); /* gems from the chest */
224 dropgold(rnd(110*iarg[playerx][playery]+200));
225 for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
227 else lprcat("\nnothing happens");
230 case 't': lprcat(" take");
231 if (take(OCHEST,iarg[playerx][playery])==0)
232 item[playerx][playery]=know[playerx][playery]=0;
236 case '\33': ignore(); return;
251 lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
252 while (1) switch(getchar())
254 case 'd': lprcat("drink");
257 lprcat("\nOops! You seem to have caught the dreadful sleep!");
258 beep(); lflush(); sleep(3); died(280); return;
263 c[HALFDAM] += 200+rnd(200);
264 lprcat("\nYou feel a sickness coming on");
266 else if (x<13) quaffpotion(23); /* see invisible */
268 lprcat("\nnothing seems to have happened");
269 else if (rnd(3) != 2)
270 fntchange(1); /* change char levels upward */
272 fntchange(-1); /* change char levels downward */
275 lprcat("\nThe fountains bubbling slowly quiets");
276 item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
277 know[playerx][playery]=0;
282 case 'i': ignore(); return;
284 case 'w': lprcat("wash yourself");
288 lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x);
289 lastnum=273; losehp(x); bottomline(); cursors();
293 lprcat("\nYou got the dirt off!");
296 lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
299 createmonster(WATERLORD); /* make water lord */
301 lprcat("\nnothing seems to have happened");
311 subroutine to process an up/down of a character attribute for ofountain
318 if (how < 0) { lprcat(" went down by one!"); --(*x); }
319 else { lprcat(" went up by one!"); (*x)++; }
324 a subroutine to raise or lower character levels
325 if x > 0 they are raised if x < 0 they are lowered
334 case 1: lprcat("Your strength"); fch(how,&c[0]); break;
335 case 2: lprcat("Your intelligence"); fch(how,&c[1]); break;
336 case 3: lprcat("Your wisdom"); fch(how,&c[2]); break;
337 case 4: lprcat("Your constitution"); fch(how,&c[3]); break;
338 case 5: lprcat("Your dexterity"); fch(how,&c[4]); break;
339 case 6: lprcat("Your charm"); fch(how,&c[5]); break;
340 case 7: j=rnd(level+1);
342 { lprintf("You lose %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); losemhp((int)j); }
344 { lprintf("You gain %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); }
347 case 8: j=rnd(level+1);
350 lprintf("You just gained %d spell",(long)j); raisemspells((int)j);
351 if (j>1) lprcat("s!"); else lprc('!');
355 lprintf("You just lost %d spell",(long)j); losemspells((int)j);
356 if (j>1) lprcat("s!"); else lprc('!');
360 case 9: j = 5*rnd((level+1)*(level+1));
363 lprintf("You just lost %d experience point",(long)j);
364 if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j);
368 lprintf("You just gained %d experience point",(long)j);
369 if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j);