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