136993Sbostic /* moreobj.c Larn is copyrighted 1986 by Noah Morgan.
236993Sbostic *
336993Sbostic * Routines in this file:
436993Sbostic *
536993Sbostic * oaltar()
636993Sbostic * othrone()
736993Sbostic * ochest()
836993Sbostic * ofountain()
936993Sbostic */
1036993Sbostic #include "header.h"
1136993Sbostic
12*46749Sbostic static void ohear();
13*46749Sbostic
1436993Sbostic /*
1536993Sbostic * ******
1636993Sbostic * OALTAR
1736993Sbostic * ******
1836993Sbostic *
1936993Sbostic * subroutine to process an altar object
2036993Sbostic */
oaltar()2136993Sbostic oaltar()
2236993Sbostic {
2336993Sbostic unsigned long k;
2436993Sbostic
2536993Sbostic lprcat("\nDo you (p) pray (d) desecrate"); iopts();
2636993Sbostic while (1)
2736993Sbostic {
2836993Sbostic while (1) switch(getchar())
2936993Sbostic {
3036993Sbostic case 'p': lprcat(" pray\nDo you (m) give money or (j) just pray? ");
3136993Sbostic while (1) switch(getchar())
3236993Sbostic {
3336993Sbostic case 'j': if (rnd(100)<75)
3436993Sbostic lprcat("\nnothing happens");
3536993Sbostic else if (rnd(13)<4) ohear();
3636993Sbostic else if (rnd(43) == 10)
3736993Sbostic {
3836993Sbostic if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
3936993Sbostic enchantarmor(); return;
4036993Sbostic }
4136993Sbostic else if (rnd(43) == 10)
4236993Sbostic {
4336993Sbostic if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
4436993Sbostic enchweapon(); return;
4536993Sbostic }
4636993Sbostic else createmonster(makemonst(level+1));
4736993Sbostic return;
4836993Sbostic
4936993Sbostic case 'm': lprcat("\n\n"); cursor(1,24); cltoeoln();
5036993Sbostic cursor(1,23); cltoeoln();
5136993Sbostic lprcat("how much do you donate? ");
5236993Sbostic k = readnum((long)c[GOLD]);
5336993Sbostic if (c[GOLD]<k)
5436993Sbostic {
5536993Sbostic lprcat("\nYou don't have that much!");
5636993Sbostic return;
5736993Sbostic }
5836993Sbostic c[GOLD] -= k;
5936993Sbostic if (k < c[GOLD]/10 || k<rnd(50))
6036993Sbostic { createmonster(makemonst(level+1)); c[AGGRAVATE] += 200; }
6136993Sbostic else if (rnd(101) > 50) { ohear(); return; }
6236993Sbostic else if (rnd(43) == 5)
6336993Sbostic {
6436993Sbostic if (c[WEAR]) lprcat("\nYou feel your armor vibrate for a moment");
6536993Sbostic enchantarmor(); return;
6636993Sbostic }
6736993Sbostic else if (rnd(43) == 8)
6836993Sbostic {
6936993Sbostic if (c[WIELD]) lprcat("\nYou feel your weapon vibrate for a moment");
7036993Sbostic enchweapon(); return;
7136993Sbostic }
7236993Sbostic else lprcat("\nThank You.");
7336993Sbostic bottomline(); return;
7436993Sbostic
7536993Sbostic case '\33': return;
7636993Sbostic };
7736993Sbostic
7836993Sbostic case 'd': lprcat(" desecrate");
7936993Sbostic if (rnd(100)<60)
8036993Sbostic { createmonster(makemonst(level+2)+8); c[AGGRAVATE] += 2500; }
8136993Sbostic else
8236993Sbostic if (rnd(101)<30)
8336993Sbostic {
8436993Sbostic lprcat("\nThe altar crumbles into a pile of dust before your eyes");
8536993Sbostic forget(); /* remember to destroy the altar */
8636993Sbostic }
8736993Sbostic else
8836993Sbostic lprcat("\nnothing happens");
8936993Sbostic return;
9036993Sbostic
9136993Sbostic case 'i':
9236993Sbostic case '\33': ignore();
9336993Sbostic if (rnd(100)<30) { createmonster(makemonst(level+1)); c[AGGRAVATE] += rnd(450); }
9436993Sbostic else lprcat("\nnothing happens");
9536993Sbostic return;
9636993Sbostic };
9736993Sbostic }
9836993Sbostic }
9936993Sbostic
10036993Sbostic /*
10136993Sbostic function to cast a +3 protection on the player
10236993Sbostic */
103*46749Sbostic static void
ohear()104*46749Sbostic ohear()
10536993Sbostic {
10636993Sbostic lprcat("\nYou have been heard!");
10736993Sbostic if (c[ALTPRO]==0) c[MOREDEFENSES]+=3;
10836993Sbostic c[ALTPRO] += 500; /* protection field */
10936993Sbostic bottomline();
11036993Sbostic }
11136993Sbostic
11236993Sbostic /*
11336993Sbostic *******
11436993Sbostic OTHRONE
11536993Sbostic *******
11636993Sbostic
11736993Sbostic subroutine to process a throne object
11836993Sbostic */
othrone(arg)11936993Sbostic othrone(arg)
12036993Sbostic int arg;
12136993Sbostic {
12236993Sbostic register int i,k;
12336993Sbostic
12436993Sbostic lprcat("\nDo you (p) pry off jewels, (s) sit down"); iopts();
12536993Sbostic while (1)
12636993Sbostic {
12736993Sbostic while (1) switch(getchar())
12836993Sbostic {
12936993Sbostic case 'p': lprcat(" pry off"); k=rnd(101);
13036993Sbostic if (k<25)
13136993Sbostic {
13236993Sbostic for (i=0; i<rnd(4); i++) creategem(); /* gems pop off the throne */
13336993Sbostic item[playerx][playery]=ODEADTHRONE;
13436993Sbostic know[playerx][playery]=0;
13536993Sbostic }
13636993Sbostic else if (k<40 && arg==0)
13736993Sbostic {
13836993Sbostic createmonster(GNOMEKING);
13936993Sbostic item[playerx][playery]=OTHRONE2;
14036993Sbostic know[playerx][playery]=0;
14136993Sbostic }
14236993Sbostic else lprcat("\nnothing happens");
14336993Sbostic return;
14436993Sbostic
14536993Sbostic case 's': lprcat(" sit down"); k=rnd(101);
14636993Sbostic if (k<30 && arg==0)
14736993Sbostic {
14836993Sbostic createmonster(GNOMEKING);
14936993Sbostic item[playerx][playery]=OTHRONE2;
15036993Sbostic know[playerx][playery]=0;
15136993Sbostic }
15236993Sbostic else if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
15336993Sbostic else lprcat("\nnothing happens");
15436993Sbostic return;
15536993Sbostic
15636993Sbostic case 'i':
15736993Sbostic case '\33': ignore(); return;
15836993Sbostic };
15936993Sbostic }
16036993Sbostic }
16136993Sbostic
odeadthrone()16236993Sbostic odeadthrone()
16336993Sbostic {
16436993Sbostic register int k;
16536993Sbostic
16636993Sbostic lprcat("\nDo you (s) sit down"); iopts();
16736993Sbostic while (1)
16836993Sbostic {
16936993Sbostic while (1) switch(getchar())
17036993Sbostic {
17136993Sbostic case 's': lprcat(" sit down"); k=rnd(101);
17236993Sbostic if (k<35) { lprcat("\nZaaaappp! You've been teleported!\n"); beep(); oteleport(0); }
17336993Sbostic else lprcat("\nnothing happens");
17436993Sbostic return;
17536993Sbostic
17636993Sbostic case 'i':
17736993Sbostic case '\33': ignore(); return;
17836993Sbostic };
17936993Sbostic }
18036993Sbostic }
18136993Sbostic
18236993Sbostic /*
18336993Sbostic ******
18436993Sbostic OCHEST
18536993Sbostic ******
18636993Sbostic
18736993Sbostic subroutine to process a throne object
18836993Sbostic */
ochest()18936993Sbostic ochest()
19036993Sbostic {
19136993Sbostic register int i,k;
19236993Sbostic lprcat("\nDo you (t) take it, (o) try to open it"); iopts();
19336993Sbostic while (1)
19436993Sbostic {
19536993Sbostic while (1) switch(getchar())
19636993Sbostic {
19736993Sbostic case 'o': lprcat(" open it"); k=rnd(101);
19836993Sbostic if (k<40)
19936993Sbostic {
20036993Sbostic lprcat("\nThe chest explodes as you open it"); beep();
20136993Sbostic i = rnd(10); lastnum=281; /* in case he dies */
20236993Sbostic lprintf("\nYou suffer %d hit points damage!",(long)i);
20336993Sbostic checkloss(i);
20436993Sbostic switch(rnd(10)) /* see if he gets a curse */
20536993Sbostic {
20636993Sbostic case 1: c[ITCHING]+= rnd(1000)+100;
20736993Sbostic lprcat("\nYou feel an irritation spread over your skin!");
20836993Sbostic beep();
20936993Sbostic break;
21036993Sbostic
21136993Sbostic case 2: c[CLUMSINESS]+= rnd(1600)+200;
21236993Sbostic lprcat("\nYou begin to lose hand to eye coordination!");
21336993Sbostic beep();
21436993Sbostic break;
21536993Sbostic
21636993Sbostic case 3: c[HALFDAM]+= rnd(1600)+200;
21736993Sbostic beep();
21836993Sbostic lprcat("\nA sickness engulfs you!"); break;
21936993Sbostic };
22036993Sbostic item[playerx][playery]=know[playerx][playery]=0;
22136993Sbostic if (rnd(100)<69) creategem(); /* gems from the chest */
22236993Sbostic dropgold(rnd(110*iarg[playerx][playery]+200));
22336993Sbostic for (i=0; i<rnd(4); i++) something(iarg[playerx][playery]+2);
22436993Sbostic }
22536993Sbostic else lprcat("\nnothing happens");
22636993Sbostic return;
22736993Sbostic
22836993Sbostic case 't': lprcat(" take");
22936993Sbostic if (take(OCHEST,iarg[playerx][playery])==0)
23036993Sbostic item[playerx][playery]=know[playerx][playery]=0;
23136993Sbostic return;
23236993Sbostic
23336993Sbostic case 'i':
23436993Sbostic case '\33': ignore(); return;
23536993Sbostic };
23636993Sbostic }
23736993Sbostic }
23836993Sbostic
23936993Sbostic /*
24036993Sbostic *********
24136993Sbostic OFOUNTAIN
24236993Sbostic *********
24336993Sbostic */
24436993Sbostic
ofountain()24536993Sbostic ofountain()
24636993Sbostic {
24736993Sbostic register int x;
24836993Sbostic cursors();
24936993Sbostic lprcat("\nDo you (d) drink, (w) wash yourself"); iopts();
25036993Sbostic while (1) switch(getchar())
25136993Sbostic {
25236993Sbostic case 'd': lprcat("drink");
25336993Sbostic if (rnd(1501)<2)
25436993Sbostic {
25536993Sbostic lprcat("\nOops! You seem to have caught the dreadful sleep!");
25636993Sbostic beep(); lflush(); sleep(3); died(280); return;
25736993Sbostic }
25836993Sbostic x = rnd(100);
25936993Sbostic if (x<7)
26036993Sbostic {
26136993Sbostic c[HALFDAM] += 200+rnd(200);
26236993Sbostic lprcat("\nYou feel a sickness coming on");
26336993Sbostic }
26436993Sbostic else if (x<13) quaffpotion(23); /* see invisible */
26536993Sbostic else if (x < 45)
26636993Sbostic lprcat("\nnothing seems to have happened");
26736993Sbostic else if (rnd(3) != 2)
26836993Sbostic fntchange(1); /* change char levels upward */
26936993Sbostic else
27036993Sbostic fntchange(-1); /* change char levels downward */
27136993Sbostic if (rnd(12)<3)
27236993Sbostic {
27336993Sbostic lprcat("\nThe fountains bubbling slowly quiets");
27436993Sbostic item[playerx][playery]=ODEADFOUNTAIN; /* dead fountain */
27536993Sbostic know[playerx][playery]=0;
27636993Sbostic }
27736993Sbostic return;
27836993Sbostic
27936993Sbostic case '\33':
28036993Sbostic case 'i': ignore(); return;
28136993Sbostic
28236993Sbostic case 'w': lprcat("wash yourself");
28336993Sbostic if (rnd(100) < 11)
28436993Sbostic {
28536993Sbostic x=rnd((level<<2)+2);
28636993Sbostic lprintf("\nOh no! The water was foul! You suffer %d hit points!",(long)x);
28736993Sbostic lastnum=273; losehp(x); bottomline(); cursors();
28836993Sbostic }
28936993Sbostic else
29036993Sbostic if (rnd(100) < 29)
29136993Sbostic lprcat("\nYou got the dirt off!");
29236993Sbostic else
29336993Sbostic if (rnd(100) < 31)
29436993Sbostic lprcat("\nThis water seems to be hard water! The dirt didn't come off!");
29536993Sbostic else
29636993Sbostic if (rnd(100) < 34)
29736993Sbostic createmonster(WATERLORD); /* make water lord */
29836993Sbostic else
29936993Sbostic lprcat("\nnothing seems to have happened");
30036993Sbostic return;
30136993Sbostic }
30236993Sbostic }
30336993Sbostic
30436993Sbostic /*
305*46749Sbostic ***
306*46749Sbostic FCH
307*46749Sbostic ***
308*46749Sbostic
309*46749Sbostic subroutine to process an up/down of a character attribute for ofountain
310*46749Sbostic */
311*46749Sbostic static void
fch(how,x)312*46749Sbostic fch(how,x)
313*46749Sbostic int how;
314*46749Sbostic long *x;
315*46749Sbostic {
316*46749Sbostic if (how < 0) { lprcat(" went down by one!"); --(*x); }
317*46749Sbostic else { lprcat(" went up by one!"); (*x)++; }
318*46749Sbostic bottomline();
319*46749Sbostic }
320*46749Sbostic
321*46749Sbostic /*
32236993Sbostic a subroutine to raise or lower character levels
32336993Sbostic if x > 0 they are raised if x < 0 they are lowered
32436993Sbostic */
fntchange(how)32536993Sbostic fntchange(how)
32636993Sbostic int how;
32736993Sbostic {
32836993Sbostic register long j;
32936993Sbostic lprc('\n');
33036993Sbostic switch(rnd(9))
33136993Sbostic {
33236993Sbostic case 1: lprcat("Your strength"); fch(how,&c[0]); break;
33336993Sbostic case 2: lprcat("Your intelligence"); fch(how,&c[1]); break;
33436993Sbostic case 3: lprcat("Your wisdom"); fch(how,&c[2]); break;
33536993Sbostic case 4: lprcat("Your constitution"); fch(how,&c[3]); break;
33636993Sbostic case 5: lprcat("Your dexterity"); fch(how,&c[4]); break;
33736993Sbostic case 6: lprcat("Your charm"); fch(how,&c[5]); break;
33836993Sbostic case 7: j=rnd(level+1);
33936993Sbostic if (how < 0)
34036993Sbostic { lprintf("You lose %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); losemhp((int)j); }
34136993Sbostic else
34236993Sbostic { lprintf("You gain %d hit point",(long)j); if (j>1) lprcat("s!"); else lprc('!'); raisemhp((int)j); }
34336993Sbostic bottomline(); break;
34436993Sbostic
34536993Sbostic case 8: j=rnd(level+1);
34636993Sbostic if (how > 0)
34736993Sbostic {
34836993Sbostic lprintf("You just gained %d spell",(long)j); raisemspells((int)j);
34936993Sbostic if (j>1) lprcat("s!"); else lprc('!');
35036993Sbostic }
35136993Sbostic else
35236993Sbostic {
35336993Sbostic lprintf("You just lost %d spell",(long)j); losemspells((int)j);
35436993Sbostic if (j>1) lprcat("s!"); else lprc('!');
35536993Sbostic }
35636993Sbostic bottomline(); break;
35736993Sbostic
35836993Sbostic case 9: j = 5*rnd((level+1)*(level+1));
35936993Sbostic if (how < 0)
36036993Sbostic {
36136993Sbostic lprintf("You just lost %d experience point",(long)j);
36236993Sbostic if (j>1) lprcat("s!"); else lprc('!'); loseexperience((long)j);
36336993Sbostic }
36436993Sbostic else
36536993Sbostic {
36636993Sbostic lprintf("You just gained %d experience point",(long)j);
36736993Sbostic if (j>1) lprcat("s!"); else lprc('!'); raiseexperience((long)j);
36836993Sbostic }
36936993Sbostic break;
37036993Sbostic }
37136993Sbostic cursors();
37236993Sbostic }
373