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:
14 static void ohear(void);
15 static void fch(int, long *);
16 static void fntchange(int);
23 * subroutine to process an altar object
30 lprcat("\nDo you (p) pray (d) desecrate"); iopts();
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");
51 else createmonster(makemonst(level
+1));
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
]);
60 lprcat("\nYou don't have that much!");
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");
77 else lprcat("\nThank You.");
83 case 'd': lprcat(" desecrate");
85 { createmonster(makemonst(level
+2)+8); c
[AGGRAVATE
] += 2500; }
89 lprcat("\nThe altar crumbles into a pile of dust before your eyes");
90 forget(); /* remember to destroy the altar */
93 lprcat("\nnothing happens");
98 if (rnd(100)<30) { createmonster(makemonst(level
+1)); c
[AGGRAVATE
] += rnd(450); }
99 else lprcat("\nnothing happens");
106 function to cast a +3 protection on the player
111 lprcat("\nYou have been heard!");
112 if (c
[ALTPRO
]==0) c
[MOREDEFENSES
]+=3;
113 c
[ALTPRO
] += 500; /* protection field */
122 subroutine to process a throne object
129 lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
132 while (1) switch(getchr())
134 case 'p': lprcat(" pry off"); k
=rnd(101);
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");
150 case 's': lprcat(" sit down"); k
=rnd(101);
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");
162 case '\33': ignore(); return;
172 lprcat("\nDo you (s) sit down"); iopts();
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");
183 case '\33': ignore(); return;
193 subroutine to process a throne object
199 lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
202 while (1) switch(getchr())
204 case 'o': lprcat(" open it"); k
=rnd(101);
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
);
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!");
218 case 2: c
[CLUMSINESS
]+= rnd(1600)+200;
219 lprcat("\nYou begin to lose hand to eye coordination!");
223 case 3: c
[HALFDAM
]+= rnd(1600)+200;
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");
235 case 't': lprcat(" take");
236 if (take(OCHEST
,iarg
[playerx
][playery
])==0)
237 item
[playerx
][playery
]=know
[playerx
][playery
]=0;
241 case '\33': ignore(); return;
256 lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
257 while (1) switch(getchr())
259 case 'd': lprcat("drink");
262 lprcat("\nOops! You seem to have caught the dreadful sleep!");
263 beep(); lflush(); sleep(3); died(280); return;
268 c
[HALFDAM
] += 200+rnd(200);
269 lprcat("\nYou feel a sickness coming on");
271 else if (x
<13) quaffpotion(23); /* see invisible */
273 lprcat("\nnothing seems to have happened");
274 else if (rnd(3) != 2)
275 fntchange(1); /* change char levels upward */
277 fntchange(-1); /* change char levels downward */
280 lprcat("\nThe fountains bubbling slowly quiets");
281 item
[playerx
][playery
]=ODEADFOUNTAIN
; /* dead fountain */
282 know
[playerx
][playery
]=0;
287 case 'i': ignore(); return;
289 case 'w': lprcat("wash yourself");
293 lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x
);
294 lastnum
=273; losehp(x
); bottomline(); cursors();
298 lprcat("\nYou got the dirt off!");
301 lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
304 createmonster(WATERLORD
); /* make water lord */
306 lprcat("\nnothing seems to have happened");
316 subroutine to process an up/down of a character attribute for ofountain
319 fch(int how
, long *x
)
321 if (how
< 0) { lprcat(" went down by one!"); --(*x
); }
322 else { lprcat(" went up by one!"); (*x
)++; }
327 a subroutine to raise or lower character levels
328 if x > 0 they are raised if x < 0 they are lowered
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);
345 { lprintf("You lose %d hit point",(long)j
); if (j
>1) lprcat("s!"); else lprc('!'); losemhp((int)j
); }
347 { lprintf("You gain %d hit point",(long)j
); if (j
>1) lprcat("s!"); else lprc('!'); raisemhp((int)j
); }
350 case 8: j
=rnd(level
+1);
353 lprintf("You just gained %d spell",(long)j
); raisemspells((int)j
);
354 if (j
>1) lprcat("s!"); else lprc('!');
358 lprintf("You just lost %d spell",(long)j
); losemspells((int)j
);
359 if (j
>1) lprcat("s!"); else lprc('!');
363 case 9: j
= 5*rnd((level
+1)*(level
+1));
366 lprintf("You just lost %d experience point",(long)j
);
367 if (j
>1) lprcat("s!"); else lprc('!'); loseexperience((long)j
);
371 lprintf("You just gained %d experience point",(long)j
);
372 if (j
>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j
);