1 /* object.c Larn is copyrighted 1986 by Noah Morgan. */ 2 /* $FreeBSD: src/games/larn/object.c,v 1.4 1999/11/16 02:57:23 billf Exp $ */ 3 /* $DragonFly: src/games/larn/object.c,v 1.3 2006/01/22 03:43:37 swildner Exp $ */ 4 #include "header.h" 5 6 /* 7 *************** 8 LOOK_FOR_OBJECT 9 *************** 10 11 subroutine to look for an object and give the player his options 12 if an object was found. 13 */ 14 lookforobject() 15 { 16 int i,j; 17 if (c[TIMESTOP]) return; /* can't find objects is time is stopped */ 18 i=item[playerx][playery]; if (i==0) return; 19 showcell(playerx,playery); cursors(); yrepcount=0; 20 switch(i) 21 { 22 case OGOLDPILE: case OMAXGOLD: 23 case OKGOLD: case ODGOLD: lprcat("\n\nYou have found some gold!"); ogold(i); break; 24 25 case OPOTION: lprcat("\n\nYou have found a magic potion"); 26 i = iarg[playerx][playery]; 27 if (potionname[i][0]) lprintf(" of %s",&potionname[i][1]); opotion(i); break; 28 29 case OSCROLL: lprcat("\n\nYou have found a magic scroll"); 30 i = iarg[playerx][playery]; 31 if (scrollname[i][0]) lprintf(" of %s",&scrollname[i][1]); 32 oscroll(i); break; 33 34 case OALTAR: if (nearbymonst()) return; 35 lprcat("\n\nThere is a Holy Altar here!"); oaltar(); break; 36 37 case OBOOK: lprcat("\n\nYou have found a book."); obook(); break; 38 39 case OCOOKIE: lprcat("\n\nYou have found a fortune cookie."); ocookie(); break; 40 41 case OTHRONE: if (nearbymonst()) return; 42 lprintf("\n\nThere is %s here!",objectname[i]); othrone(0); break; 43 44 case OTHRONE2: if (nearbymonst()) return; 45 lprintf("\n\nThere is %s here!",objectname[i]); othrone(1); break; 46 47 case ODEADTHRONE: lprintf("\n\nThere is %s here!",objectname[i]); odeadthrone(); break; 48 49 case OORB: lprcat("\n\nYou have found the Orb!!!!!"); oorb(); break; 50 51 case OPIT: lprcat("\n\nYou're standing at the top of a pit."); opit(); break; 52 53 case OSTAIRSUP: lprcat("\n\nThere is a circular staircase here"); ostairs(1); /* up */ break; 54 55 case OELEVATORUP: lprcat("\n\nYou feel heavy for a moment, but the feeling disappears"); 56 oelevator(1); /* up */ break; 57 58 case OFOUNTAIN: if (nearbymonst()) return; 59 lprcat("\n\nThere is a fountain here"); ofountain(); break; 60 61 case OSTATUE: if (nearbymonst()) return; 62 lprcat("\n\nYou are standing in front of a statue"); ostatue(); break; 63 64 case OCHEST: lprcat("\n\nThere is a chest here"); ochest(); break; 65 66 case OIVTELETRAP: if (rnd(11)<6) return; 67 item[playerx][playery] = OTELEPORTER; 68 know[playerx][playery] = 1; 69 70 case OTELEPORTER: lprcat("\nZaaaappp! You've been teleported!\n"); 71 beep(); nap(3000); oteleport(0); 72 break; 73 74 case OSCHOOL: if (nearbymonst()) return; 75 lprcat("\n\nYou have found the College of Larn."); 76 lprcat("\nDo you (g) go inside, or (i) stay here? "); 77 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 78 if (i == 'g') { oschool(); /* the college of larn */ } 79 else lprcat(" stay here"); 80 break; 81 82 case OMIRROR: if (nearbymonst()) return; 83 lprcat("\n\nThere is a mirror here"); omirror(); break; 84 85 case OBANK2: 86 case OBANK: if (nearbymonst()) return; 87 if (i==OBANK) lprcat("\n\nYou have found the bank of Larn."); 88 else lprcat("\n\nYou have found a branch office of the bank of Larn."); 89 lprcat("\nDo you (g) go inside, or (i) stay here? "); 90 j=0; while ((j!='g') && (j!='i') && (j!='\33')) j=getchar(); 91 if (j == 'g') { if (i==OBANK) obank(); else obank2(); /* the bank of larn */ } 92 else lprcat(" stay here"); 93 break; 94 95 case ODEADFOUNTAIN: if (nearbymonst()) return; 96 lprcat("\n\nThere is a dead fountain here"); break; 97 98 case ODNDSTORE: if (nearbymonst()) return; 99 lprcat("\n\nThere is a DND store here."); 100 lprcat("\nDo you (g) go inside, or (i) stay here? "); 101 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 102 if (i == 'g') 103 dndstore(); /* the dnd adventurers store */ 104 else lprcat(" stay here"); 105 break; 106 107 case OSTAIRSDOWN: lprcat("\n\nThere is a circular staircase here"); ostairs(-1); /* down */ break; 108 109 case OELEVATORDOWN: lprcat("\n\nYou feel light for a moment, but the feeling disappears"); 110 oelevator(-1); /* down */ 111 break; 112 113 case OOPENDOOR: lprintf("\n\nYou have found %s",objectname[i]); 114 lprcat("\nDo you (c) close it"); iopts(); 115 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); 116 if ((i=='\33') || (i=='i')) { ignore(); break; } 117 lprcat("close"); forget(); 118 item[playerx][playery]=OCLOSEDDOOR; 119 iarg[playerx][playery]=0; 120 playerx = lastpx; playery = lastpy; 121 break; 122 123 case OCLOSEDDOOR: lprintf("\n\nYou have found %s",objectname[i]); 124 lprcat("\nDo you (o) try to open it"); iopts(); 125 i=0; while ((i!='o') && (i!='i') && (i!='\33')) i=getchar(); 126 if ((i=='\33') || (i=='i')) 127 { ignore(); playerx = lastpx; 128 playery = lastpy; break; } 129 else 130 { 131 lprcat("open"); 132 if (rnd(11)<7) 133 { 134 switch(iarg[playerx][playery]) 135 { 136 case 6: c[AGGRAVATE] += rnd(400); break; 137 138 case 7: lprcat("\nYou are jolted by an electric shock "); 139 lastnum=274; losehp(rnd(20)); bottomline(); break; 140 141 case 8: loselevel(); break; 142 143 case 9: lprcat("\nYou suddenly feel weaker "); 144 if (c[STRENGTH]>3) c[STRENGTH]--; 145 bottomline(); break; 146 147 default: break; 148 } 149 playerx = lastpx; playery = lastpy; 150 } 151 else 152 { 153 forget(); item[playerx][playery]=OOPENDOOR; 154 } 155 } 156 break; 157 158 case OENTRANCE: lprcat("\nYou have found "); lprcat(objectname[OENTRANCE]); 159 lprcat("\nDo you (g) go inside"); iopts(); 160 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 161 if (i == 'g') 162 { 163 newcavelevel(1); playerx=33; playery=MAXY-2; 164 item[33][MAXY-1]=know[33][MAXY-1]=mitem[33][MAXY-1]=0; 165 draws(0,MAXX,0,MAXY); bot_linex(); return; 166 } 167 else ignore(); 168 break; 169 170 case OVOLDOWN: lprcat("\nYou have found "); lprcat(objectname[OVOLDOWN]); 171 lprcat("\nDo you (c) climb down"); iopts(); 172 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); 173 if ((i=='\33') || (i=='i')) { ignore(); break; } 174 if (level!=0) { lprcat("\nThe shaft only extends 5 feet downward!"); return; } 175 if (packweight() > 45+3*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep(); 176 lastnum=275; losehp(30+rnd(20)); bottomhp(); } 177 178 else lprcat("climb down"); nap(3000); newcavelevel(MAXLEVEL); 179 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */ 180 if (item[j][i]==OVOLUP) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); } 181 draws(0,MAXX,0,MAXY); bot_linex(); return; 182 183 case OVOLUP: lprcat("\nYou have found "); lprcat(objectname[OVOLUP]); 184 lprcat("\nDo you (c) climb up"); iopts(); 185 i=0; while ((i!='c') && (i!='i') && (i!='\33')) i=getchar(); 186 if ((i=='\33') || (i=='i')) { ignore(); break; } 187 if (level!=11) { lprcat("\nThe shaft only extends 8 feet upwards before you find a blockage!"); return; } 188 if (packweight() > 45+5*(c[STRENGTH]+c[STREXTRA])) { lprcat("\nYou slip and fall down the shaft"); beep(); 189 lastnum=275; losehp(15+rnd(20)); bottomhp(); return; } 190 lprcat("climb up"); lflush(); nap(3000); newcavelevel(0); 191 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) /* put player near volcano shaft */ 192 if (item[j][i]==OVOLDOWN) { playerx=j; playery=i; j=MAXX; i=MAXY; positionplayer(); } 193 draws(0,MAXX,0,MAXY); bot_linex(); return; 194 195 case OTRAPARROWIV: if (rnd(17)<13) return; /* for an arrow trap */ 196 item[playerx][playery] = OTRAPARROW; 197 know[playerx][playery] = 0; 198 199 case OTRAPARROW: lprcat("\nYou are hit by an arrow"); beep(); /* for an arrow trap */ 200 lastnum=259; losehp(rnd(10)+level); 201 bottomhp(); return; 202 203 case OIVDARTRAP: if (rnd(17)<13) return; /* for a dart trap */ 204 item[playerx][playery] = ODARTRAP; 205 know[playerx][playery] = 0; 206 207 case ODARTRAP: lprcat("\nYou are hit by a dart"); beep(); /* for a dart trap */ 208 lastnum=260; losehp(rnd(5)); 209 if ((--c[STRENGTH]) < 3) c[STRENGTH] = 3; 210 bottomline(); return; 211 212 case OIVTRAPDOOR: if (rnd(17)<13) return; /* for a trap door */ 213 item[playerx][playery] = OTRAPDOOR; 214 know[playerx][playery] = 1; 215 216 case OTRAPDOOR: lastnum = 272; /* a trap door */ 217 if ((level==MAXLEVEL-1) || (level==MAXLEVEL+MAXVLEVEL-1)) 218 { lprcat("\nYou fell through a bottomless trap door!"); beep(); nap(3000); died(271); } 219 lprcat("\nYou fall through a trap door!"); beep(); /* for a trap door */ 220 losehp(rnd(5+level)); 221 nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); bot_linex(); 222 return; 223 224 225 case OTRADEPOST: if (nearbymonst()) return; 226 lprcat("\nYou have found the Larn trading Post."); 227 lprcat("\nDo you (g) go inside, or (i) stay here? "); 228 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 229 if (i == 'g') otradepost(); else lprcat("stay here"); 230 return; 231 232 case OHOME: if (nearbymonst()) return; 233 lprcat("\nYou have found your way home."); 234 lprcat("\nDo you (g) go inside, or (i) stay here? "); 235 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 236 if (i == 'g') ohome(); else lprcat("stay here"); 237 return; 238 239 case OWALL: break; 240 241 case OANNIHILATION: died(283); return; /* annihilated by sphere of annihilation */ 242 243 case OLRS: if (nearbymonst()) return; 244 lprcat("\n\nThere is an LRS office here."); 245 lprcat("\nDo you (g) go inside, or (i) stay here? "); 246 i=0; while ((i!='g') && (i!='i') && (i!='\33')) i=getchar(); 247 if (i == 'g') 248 olrs(); /* the larn revenue service */ 249 else lprcat(" stay here"); 250 break; 251 252 default: finditem(i); break; 253 }; 254 } 255 256 /* 257 function to say what object we found and ask if player wants to take it 258 */ 259 finditem(itm) 260 int itm; 261 { 262 int tmp,i; 263 lprintf("\n\nYou have found %s ",objectname[itm]); 264 tmp=iarg[playerx][playery]; 265 switch(itm) 266 { 267 case ODIAMOND: case ORUBY: case OEMERALD: 268 case OSAPPHIRE: case OSPIRITSCARAB: case OORBOFDRAGON: 269 case OCUBEofUNDEAD: case ONOTHEFT: break; 270 271 default: 272 if (tmp>0) lprintf("+ %d",(long)tmp); else if (tmp<0) lprintf(" %d",(long)tmp); 273 } 274 lprcat("\nDo you want to (t) take it"); iopts(); 275 i=0; while (i!='t' && i!='i' && i!='\33') i=getchar(); 276 if (i == 't') 277 { lprcat("take"); if (take(itm,tmp)==0) forget(); return; } 278 ignore(); 279 } 280 281 282 /* 283 ******* 284 OSTAIRS 285 ******* 286 287 subroutine to process the stair cases 288 if dir > 0 the up else down 289 */ 290 ostairs(dir) 291 int dir; 292 { 293 int k; 294 lprcat("\nDo you (s) stay here "); 295 if (dir > 0) lprcat("(u) go up "); else lprcat("(d) go down "); 296 lprcat("or (f) kick stairs? "); 297 298 while (1) switch(getchar()) 299 { 300 case '\33': 301 case 's': case 'i': lprcat("stay here"); return; 302 303 case 'f': lprcat("kick stairs"); 304 if (rnd(2) == 1) 305 lprcat("\nI hope you feel better. Showing anger rids you of frustration."); 306 else 307 { 308 k=rnd((level+1)<<1); 309 lprintf("\nYou hurt your foot dumb dumb! You suffer %d hit points",(long)k); 310 lastnum=276; losehp(k); bottomline(); 311 } 312 return; 313 314 case 'u': lprcat("go up"); 315 if (dir < 0) lprcat("\nThe stairs don't go up!"); 316 else 317 if (level>=2 && level!=11) 318 { 319 k = level; newcavelevel(level-1); 320 draws(0,MAXX,0,MAXY); bot_linex(); 321 } 322 else lprcat("\nThe stairs lead to a dead end!"); 323 return; 324 325 case 'd': lprcat("go down"); 326 if (dir > 0) lprcat("\nThe stairs don't go down!"); 327 else 328 if (level!=0 && level!=10 && level!=13) 329 { 330 k = level; newcavelevel(level+1); 331 draws(0,MAXX,0,MAXY); bot_linex(); 332 } 333 else lprcat("\nThe stairs lead to a dead end!"); 334 return; 335 }; 336 } 337 338 339 /* 340 ********* 341 OTELEPORTER 342 ********* 343 344 subroutine to handle a teleport trap +/- 1 level maximum 345 */ 346 oteleport(err) 347 int err; 348 { 349 int tmp; 350 if (err) if (rnd(151)<3) died(264); /* stuck in a rock */ 351 c[TELEFLAG]=1; /* show ?? on bottomline if been teleported */ 352 if (level==0) tmp=0; 353 else if (level < MAXLEVEL) 354 { tmp=rnd(5)+level-3; if (tmp>=MAXLEVEL) tmp=MAXLEVEL-1; 355 if (tmp<1) tmp=1; } 356 else 357 { tmp=rnd(3)+level-2; if (tmp>=MAXLEVEL+MAXVLEVEL) tmp=MAXLEVEL+MAXVLEVEL-1; 358 if (tmp<MAXLEVEL) tmp=MAXLEVEL; } 359 playerx = rnd(MAXX-2); playery = rnd(MAXY-2); 360 if (level != tmp) newcavelevel(tmp); positionplayer(); 361 draws(0,MAXX,0,MAXY); bot_linex(); 362 } 363 364 /* 365 ******* 366 OPOTION 367 ******* 368 369 function to process a potion 370 */ 371 opotion(pot) 372 int pot; 373 { 374 lprcat("\nDo you (d) drink it, (t) take it"); iopts(); 375 while (1) switch(getchar()) 376 { 377 case '\33': 378 case 'i': ignore(); return; 379 380 case 'd': lprcat("drink\n"); forget(); /* destroy potion */ 381 quaffpotion(pot); return; 382 383 case 't': lprcat("take\n"); if (take(OPOTION,pot)==0) forget(); 384 return; 385 }; 386 } 387 388 /* 389 function to drink a potion 390 */ 391 quaffpotion(pot) 392 int pot; 393 { 394 int i,j,k; 395 if (pot<0 || pot>=MAXPOTION) return; /* check for within bounds */ 396 potionname[pot][0] = ' '; 397 switch(pot) 398 { 399 case 9: lprcat("\nYou feel greedy . . ."); nap(2000); 400 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) 401 if ((item[j][i]==OGOLDPILE) || (item[j][i]==OMAXGOLD)) 402 { 403 know[j][i]=1; show1cell(j,i); 404 } 405 showplayer(); return; 406 407 case 19: lprcat("\nYou feel greedy . . ."); nap(2000); 408 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) 409 { 410 k=item[j][i]; 411 if ((k==ODIAMOND) || (k==ORUBY) || (k==OEMERALD) || (k==OMAXGOLD) 412 || (k==OSAPPHIRE) || (k==OLARNEYE) || (k==OGOLDPILE)) 413 { 414 know[j][i]=1; show1cell(j,i); 415 } 416 } 417 showplayer(); return; 418 419 case 20: c[HP] = c[HPMAX]; break; /* instant healing */ 420 421 case 1: lprcat("\nYou feel better"); 422 if (c[HP] == c[HPMAX]) raisemhp(1); 423 else if ((c[HP] += rnd(20)+20+c[LEVEL]) > c[HPMAX]) c[HP]=c[HPMAX]; break; 424 425 case 2: lprcat("\nSuddenly, you feel much more skillful!"); 426 raiselevel(); raisemhp(1); return; 427 428 case 3: lprcat("\nYou feel strange for a moment"); 429 c[rund(6)]++; break; 430 431 case 4: lprcat("\nYou feel more self confident!"); 432 c[WISDOM] += rnd(2); break; 433 434 case 5: lprcat("\nWow! You feel great!"); 435 if (c[STRENGTH]<12) c[STRENGTH]=12; else c[STRENGTH]++; break; 436 437 case 6: lprcat("\nYour charm went up by one!"); c[CHARISMA]++; break; 438 439 case 8: lprcat("\nYour intelligence went up by one!"); 440 c[INTELLIGENCE]++; break; 441 442 case 10: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) 443 if (mitem[j][i]) 444 { 445 know[j][i]=1; show1cell(j,i); 446 } 447 /* monster detection */ return; 448 449 case 12: lprcat("\nThis potion has no taste to it"); return; 450 451 case 15: lprcat("\nWOW!!! You feel Super-fantastic!!!"); 452 if (c[HERO]==0) for (i=0; i<6; i++) c[i] += 11; 453 c[HERO] += 250; break; 454 455 case 16: lprcat("\nYou have a greater intestinal constitude!"); 456 c[CONSTITUTION]++; break; 457 458 case 17: lprcat("\nYou now have incredibly bulging muscles!!!"); 459 if (c[GIANTSTR]==0) c[STREXTRA] += 21; 460 c[GIANTSTR] += 700; break; 461 462 case 18: lprcat("\nYou feel a chill run up your spine!"); 463 c[FIRERESISTANCE] += 1000; break; 464 465 case 0: lprcat("\nYou fall asleep. . ."); 466 i=rnd(11)-(c[CONSTITUTION]>>2)+2; while(--i>0) { parse2(); nap(1000); } 467 cursors(); lprcat("\nYou woke up!"); return; 468 469 case 7: lprcat("\nYou become dizzy!"); 470 if (--c[STRENGTH] < 3) c[STRENGTH]=3; break; 471 472 case 11: lprcat("\nYou stagger for a moment . ."); 473 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) 474 know[j][i]=0; 475 nap(2000); draws(0,MAXX,0,MAXY); /* potion of forgetfulness */ return; 476 477 case 13: lprcat("\nYou can't see anything!"); /* blindness */ 478 c[BLINDCOUNT]+=500; return; 479 480 case 14: lprcat("\nYou feel confused"); c[CONFUSE]+= 20+rnd(9); return; 481 482 case 21: lprcat("\nYou don't seem to be affected"); return; /* cure dianthroritis */ 483 484 case 22: lprcat("\nYou feel a sickness engulf you"); /* poison */ 485 c[HALFDAM] += 200 + rnd(200); return; 486 487 case 23: lprcat("\nYou feel your vision sharpen"); /* see invisible */ 488 c[SEEINVISIBLE] += rnd(1000)+400; 489 monstnamelist[INVISIBLESTALKER] = 'I'; return; 490 }; 491 bottomline(); /* show new stats */ return; 492 } 493 494 /* 495 ******* 496 OSCROLL 497 ******* 498 499 function to process a magic scroll 500 */ 501 oscroll(typ) 502 int typ; 503 { 504 lprcat("\nDo you "); 505 if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts(); 506 while (1) switch(getchar()) 507 { 508 case '\33': 509 case 'i': ignore(); return; 510 511 case 'r': if (c[BLINDCOUNT]) break; 512 lprcat("read"); forget(); 513 if (typ==2 || typ==15) { show1cell(playerx,playery); cursors(); } 514 /* destroy it */ read_scroll(typ); return; 515 516 case 't': lprcat("take"); if (take(OSCROLL,typ)==0) forget(); /* destroy it */ 517 return; 518 }; 519 } 520 521 /* 522 data for the function to read a scroll 523 */ 524 static int xh,yh,yl,xl; 525 static char curse[] = { BLINDCOUNT, CONFUSE, AGGRAVATE, HASTEMONST, ITCHING, 526 LAUGHING, DRAINSTRENGTH, CLUMSINESS, INFEEBLEMENT, HALFDAM }; 527 static char exten[] = { PROTECTIONTIME, DEXCOUNT, STRCOUNT, CHARMCOUNT, 528 INVISIBILITY, CANCELLATION, HASTESELF, GLOBE, SCAREMONST, HOLDMONST, TIMESTOP }; 529 char time_change[] = { HASTESELF,HERO,ALTPRO,PROTECTIONTIME,DEXCOUNT, 530 STRCOUNT,GIANTSTR,CHARMCOUNT,INVISIBILITY,CANCELLATION, 531 HASTESELF,AGGRAVATE,SCAREMONST,STEALTH,AWARENESS,HOLDMONST,HASTEMONST, 532 FIRERESISTANCE,GLOBE,SPIRITPRO,UNDEADPRO,HALFDAM,SEEINVISIBLE, 533 ITCHING,CLUMSINESS, WTW }; 534 /* 535 * function to adjust time when time warping and taking courses in school 536 */ 537 adjtime(tim) 538 long tim; 539 { 540 int j; 541 for (j=0; j<26; j++) /* adjust time related parameters */ 542 if (c[time_change[j]]) 543 if ((c[time_change[j]] -= tim) < 1) c[time_change[j]]=1; 544 regen(); 545 } 546 547 /* 548 function to read a scroll 549 */ 550 read_scroll(typ) 551 int typ; 552 { 553 int i,j; 554 if (typ<0 || typ>=MAXSCROLL) return; /* be sure we are within bounds */ 555 scrollname[typ][0] = ' '; 556 switch(typ) 557 { 558 case 0: lprcat("\nYour armor glows for a moment"); enchantarmor(); return; 559 560 case 1: lprcat("\nYour weapon glows for a moment"); enchweapon(); return; /* enchant weapon */ 561 562 case 2: lprcat("\nYou have been granted enlightenment!"); 563 yh = min(playery+7,MAXY); xh = min(playerx+25,MAXX); 564 yl = max(playery-7,0); xl = max(playerx-25,0); 565 for (i=yl; i<yh; i++) for (j=xl; j<xh; j++) know[j][i]=1; 566 nap(2000); draws(xl,xh,yl,yh); return; 567 568 case 3: lprcat("\nThis scroll seems to be blank"); return; 569 570 case 4: createmonster(makemonst(level+1)); return; /* this one creates a monster */ 571 572 case 5: something(level); /* create artifact */ return; 573 574 case 6: c[AGGRAVATE]+=800; return; /* aggravate monsters */ 575 576 case 7: gtime += (i = rnd(1000) - 850); /* time warp */ 577 if (i>=0) lprintf("\nYou went forward in time by %d mobuls",(long)((i+99)/100)); 578 else lprintf("\nYou went backward in time by %d mobuls",(long)(-(i+99)/100)); 579 adjtime((long)i); /* adjust time for time warping */ 580 return; 581 582 case 8: oteleport(0); return; /* teleportation */ 583 584 case 9: c[AWARENESS] += 1800; return; /* expanded awareness */ 585 586 case 10: c[HASTEMONST] += rnd(55)+12; return; /* haste monster */ 587 588 case 11: for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) 589 if (mitem[j][i]) 590 hitp[j][i] = monster[mitem[j][i]].hitpoints; 591 return; /* monster healing */ 592 case 12: c[SPIRITPRO] += 300 + rnd(200); bottomline(); return; /* spirit protection */ 593 594 case 13: c[UNDEADPRO] += 300 + rnd(200); bottomline(); return; /* undead protection */ 595 596 case 14: c[STEALTH] += 250 + rnd(250); bottomline(); return; /* stealth */ 597 598 case 15: lprcat("\nYou have been granted enlightenment!"); /* magic mapping */ 599 for (i=0; i<MAXY; i++) for (j=0; j<MAXX; j++) know[j][i]=1; 600 nap(2000); draws(0,MAXX,0,MAXY); return; 601 602 case 16: c[HOLDMONST] += 30; bottomline(); return; /* hold monster */ 603 604 case 17: for (i=0; i<26; i++) /* gem perfection */ 605 switch(iven[i]) 606 { 607 case ODIAMOND: case ORUBY: 608 case OEMERALD: case OSAPPHIRE: 609 j = ivenarg[i]; j &= 255; j <<= 1; 610 if (j > 255) j=255; /* double value */ 611 ivenarg[i] = j; break; 612 } 613 break; 614 615 case 18: for (i=0; i<11; i++) c[exten[i]] <<= 1; /* spell extension */ 616 break; 617 618 case 19: for (i=0; i<26; i++) /* identify */ 619 { 620 if (iven[i]==OPOTION) potionname[ivenarg[i]][0] = ' '; 621 if (iven[i]==OSCROLL) scrollname[ivenarg[i]][0] = ' '; 622 } 623 break; 624 625 case 20: for (i=0; i<10; i++) /* remove curse */ 626 if (c[curse[i]]) c[curse[i]] = 1; 627 break; 628 629 case 21: annihilate(); break; /* scroll of annihilation */ 630 631 case 22: godirect(22,150,"The ray hits the %s",0,' '); /* pulverization */ 632 break; 633 case 23: c[LIFEPROT]++; break; /* life protection */ 634 }; 635 } 636 637 638 oorb() 639 { 640 } 641 642 opit() 643 { 644 int i; 645 if (rnd(101)<81) 646 if (rnd(70) > 9*c[DEXTERITY]-packweight() || rnd(101)<5) 647 if (level==MAXLEVEL-1) obottomless(); else 648 if (level==MAXLEVEL+MAXVLEVEL-1) obottomless(); else 649 { 650 if (rnd(101)<20) 651 { 652 i=0; lprcat("\nYou fell into a pit! Your fall is cushioned by an unknown force\n"); 653 } 654 else 655 { 656 i = rnd(level*3+3); 657 lprintf("\nYou fell into a pit! You suffer %d hit points damage",(long)i); 658 lastnum=261; /* if he dies scoreboard will say so */ 659 } 660 losehp(i); nap(2000); newcavelevel(level+1); draws(0,MAXX,0,MAXY); 661 } 662 } 663 664 obottomless() 665 { 666 lprcat("\nYou fell into a bottomless pit!"); beep(); nap(3000); died(262); 667 } 668 oelevator(dir) 669 int dir; 670 { 671 #ifdef lint 672 int x; 673 x=dir; 674 dir=x; 675 #endif /* lint */ 676 } 677 678 ostatue() 679 { 680 } 681 682 omirror() 683 { 684 } 685 686 obook() 687 { 688 lprcat("\nDo you "); 689 if (c[BLINDCOUNT]==0) lprcat("(r) read it, "); lprcat("(t) take it"); iopts(); 690 while (1) switch(getchar()) 691 { 692 case '\33': 693 case 'i': ignore(); return; 694 695 case 'r': if (c[BLINDCOUNT]) break; 696 lprcat("read"); 697 /* no more book */ readbook(iarg[playerx][playery]); forget(); return; 698 699 case 't': lprcat("take"); if (take(OBOOK,iarg[playerx][playery])==0) forget(); /* no more book */ 700 return; 701 }; 702 } 703 704 /* 705 function to read a book 706 */ 707 readbook(lev) 708 int lev; 709 { 710 int i,tmp; 711 if (lev<=3) i = rund((tmp=splev[lev])?tmp:1); else 712 i = rnd((tmp=splev[lev]-9)?tmp:1) + 9; 713 spelknow[i]=1; 714 lprintf("\nSpell \"%s\": %s\n%s",spelcode[i],spelname[i],speldescript[i]); 715 if (rnd(10)==4) 716 { lprcat("\nYour int went up by one!"); c[INTELLIGENCE]++; bottomline(); } 717 } 718 719 ocookie() 720 { 721 char *p; 722 lprcat("\nDo you (e) eat it, (t) take it"); iopts(); 723 while (1) switch(getchar()) 724 { 725 case '\33': 726 case 'i': ignore(); return; 727 728 case 'e': lprcat("eat\nThe cookie tasted good."); 729 forget(); /* no more cookie */ 730 if (c[BLINDCOUNT]) return; 731 if (!(p=fortune(fortfile))) return; 732 lprcat(" A message inside the cookie reads:\n"); lprcat(p); 733 return; 734 735 case 't': lprcat("take"); if (take(OCOOKIE,0)==0) forget(); /* no more book */ 736 return; 737 }; 738 } 739 740 741 /* routine to pick up some gold -- if arg==OMAXGOLD then the pile is worth 100* the argument */ 742 ogold(arg) 743 int arg; 744 { 745 long i; 746 i = iarg[playerx][playery]; 747 if (arg==OMAXGOLD) i *= 100; 748 else if (arg==OKGOLD) i *= 1000; 749 else if (arg==ODGOLD) i *= 10; 750 lprintf("\nIt is worth %d!",(long)i); c[GOLD] += i; bottomgold(); 751 item[playerx][playery] = know[playerx][playery] = 0; /* destroy gold */ 752 } 753 754 ohome() 755 { 756 int i; 757 nosignal = 1; /* disable signals */ 758 for (i=0; i<26; i++) if (iven[i]==OPOTION) if (ivenarg[i]==21) 759 { 760 iven[i]=0; /* remove the potion of cure dianthroritis from inventory */ 761 clear(); lprcat("Congratulations. You found a potion of cure dianthroritis.\n"); 762 lprcat("\nFrankly, No one thought you could do it. Boy! Did you surprise them!\n"); 763 if (gtime>TIMELIMIT) 764 { 765 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n"); 766 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n"); 767 nap(5000); died(269); 768 } 769 else 770 { 771 lprcat("\nThe doctor is now administering the potion, and in a few moments\n"); 772 lprcat("Your daughter should be well on her way to recovery.\n"); 773 nap(6000); 774 lprcat("\nThe potion is"); nap(3000); lprcat(" working! The doctor thinks that\n"); 775 lprcat("your daughter will recover in a few days. Congratulations!\n"); 776 beep(); nap(5000); died(263); 777 } 778 } 779 780 while (1) 781 { 782 clear(); lprintf("Welcome home %s. Latest word from the doctor is not good.\n",logname); 783 784 if (gtime>TIMELIMIT) 785 { 786 lprcat("\nThe doctor has the sad duty to inform you that your daughter died!\n"); 787 lprcat("You didn't make it in time. In your agony, you kill the doctor,\nyour wife, and yourself! Too bad!\n"); 788 nap(5000); died(269); 789 } 790 791 lprcat("\nThe diagnosis is confirmed as dianthroritis. He guesses that\n"); 792 lprintf("your daughter has only %d mobuls left in this world. It's up to you,\n",(long)((TIMELIMIT-gtime+99)/100)); 793 lprintf("%s, to find the only hope for your daughter, the very rare\n",logname); 794 lprcat("potion of cure dianthroritis. It is rumored that only deep in the\n"); 795 lprcat("depths of the caves can this potion be found.\n\n\n"); 796 lprcat("\n ----- press "); standout("return"); 797 lprcat(" to continue, "); standout("escape"); 798 lprcat(" to leave ----- "); 799 i=getchar(); while (i!='\33' && i!='\n') i=getchar(); 800 if (i=='\33') { drawscreen(); nosignal = 0; /* enable signals */ return; } 801 } 802 } 803 804 /* routine to save program space */ 805 iopts() 806 { lprcat(", or (i) ignore it? "); } 807 ignore() 808 { lprcat("ignore\n"); } 809 810