-+-+-+-+-+-+-+-+ START OF PART 39 -+-+-+-+-+-+-+-+ X `7D /* to escape casting a spell */ X#ifdef EXTRA X c`5BSPELLSCAST`5D++; X#endif X for (lprc('\n'),j= -1,i=0; i=SPNUM) return; /* no such spell */ X if (c`5BTIMESTOP`5D) `7B lprcat(" It didn't seem to work"); return; `7 VD /* not if time stopped */ X clev = c`5BLEVEL`5D; X if ((rnd(23)==7) `7C`7C (rnd(18) > c`5BINTELLIGENCE`5D)) X `7B lprcat(" It didn't work!"); return; `7D X if (clev*3+2 < x) X `7B X lprcat(" Nothing happens. You seem inexperienced at this"); X return; X `7D X X switch(x) X `7B X/* ----- LEVEL 1 SPELLS ----- */ X X case 0: if (c`5BPROTECTIONTIME`5D==0) c`5BMOREDEFENSES`5D+=2; /* p Vrotection field +2 */ X c`5BPROTECTIONTIME`5D += 250; return; X X case 1: i = rnd(((clev+1)<<1)) + clev + 3; X godirect(x,i,(clev>=2)?" Your missiles hit the %s":" Your V missile hit the %s",100,'+'); /* magic missile */ X X return; X X case 2: if (c`5BDEXCOUNT`5D==0) c`5BDEXTERITY`5D+=3; /* dexterity V */ X c`5BDEXCOUNT`5D += 400; return; X X case 3: i=rnd(3)+1; X p=" While the %s slept, you smashed it %d times"; X ws: direct(x,fullhit(i),p,i); /* sleep */ return; X X case 4: /* charm monster */ c`5BCHARMCOUNT`5D += c`5BCHARISMA`5D V<<1; return; X X case 5: godirect(x,rnd(10)+15+clev," The sound damages the %s",70,' V@'); /* sonic spear */ X return; X X/* ----- LEVEL 2 SPELLS ----- */ X X case 6: i=rnd(3)+2; p=" While the %s is entangled, you hit %d times V"; X goto ws; /* web */ X X case 7: if (c`5BSTRCOUNT`5D==0) c`5BSTREXTRA`5D+=3; /* strength V */ X c`5BSTRCOUNT`5D += 150+rnd(100); return; X X case 8: yl = playery-5; /* enlightenment */ X yh = playery+6; xl = playerx-15; xh = playerx+16; X vxy(&xl,&yl); vxy(&xh,&yh); /* check bounds */ X for (i=yl; i<=yh; i++) /* enlightenment */ X for (j=xl; j<=xh; j++) X know`5Bj`5D`5Bi`5D=KNOWALL; X draws(xl,xh+1,yl,yh+1); return; X X case 9: raisehp(20+(clev<<1)); return; /* healing */ X X case 10: c`5BBLINDCOUNT`5D=0; return; /* cure blindness */ X X case 11: createmonster(makemonst(level+1)+8); return; X X case 12: if (rnd(11)+7 <= c`5BWISDOM`5D) direct(x,rnd(20)+20+clev V," The %s believed!",0); X else lprcat(" It didn't believe the illusions!"); X return; X X case 13: /* if he has the amulet of invisibility then add more ti Vme */ X for (j=i=0; i<26; i++) X if (iven`5Bi`5D==OAMULET) j+= 1+ivenarg`5Bi`5D; X c`5BINVISIBILITY`5D += (j<<7)+12; return; X X/* ----- LEVEL 3 SPELLS ----- */ X X case 14: godirect(x,rnd(25+clev)+25+clev," The fireball hits the V %s",40,'*'); return; /* fireball */ X X case 15: godirect(x,rnd(25)+20+clev," Your cone of cold strikes V the %s",60,'O'); /* cold */ X return; X X case 16: dirpoly(x); return; /* polymorph */ X X case 17: c`5BCANCELLATION`5D+= 5+clev; return; /* cancellation V */ X X case 18: c`5BHASTESELF`5D+= 7+clev; return; /* haste self */ X X case 19: omnidirect(x,30+rnd(10)," The %s gasps for air"); /* c Vloud kill */ X return; X X case 20: xh = min(playerx+1,MAXX-2); yh = min(playery+1,MAXY- V2); X for (i=max(playerx-1,1); i<=xh; i++) /* vaporize rock */ X for (j=max(playery-1,1); j<=yh; j++) X `7B X kn = &know`5Bi`5D`5Bj`5D; X pm = &mitem`5Bi`5D`5Bj`5D; X switch(*(p= &item`5Bi`5D`5Bj`5D)) X `7B X case OWALL: if (level < MAXLEVEL+MAXVLEVEL-1) X *p = *kn = 0; X break; X X case OSTATUE: if (c`5BHARDGAME`5D<3) X `7B X *p=OBOOK; iarg`5Bi`5D`5Bj`5D=le Vvel; *kn=0; X `7D X break; X X case OTHRONE: X *p= OTHRONE2; X create_guardian( GNOMEKING, i, j ); X break; X X case OALTAR: X create_guardian( DEMONPRINCE, i, j ); X break; X X case OFOUNTAIN: X create_guardian( WATERLORD, i, j ); X break; X `7D; X switch(*pm) X `7B X case XORN: ifblind(i,j); hitm(i,j,200); break; V /* Xorn takes damage from vpr */ X `7D X `7D X return; X X/* ----- LEVEL 4 SPELLS ----- */ X X case 21: direct(x,100+clev," The %s shrivels up",0); /* dehydrat Vion */ X return; X X case 22: godirect(x,rnd(25)+20+(clev<<1)," A lightning bolt hits V the %s",1,'`7E'); /* lightning */ X return; X X case 23: i=min(c`5BHP`5D-1,c`5BHPMAX`5D/2); /* drain life */ X direct(x,i+i,"",0); c`5BHP`5D -= i; return; X X case 24: if (c`5BGLOBE`5D==0) c`5BMOREDEFENSES`5D += 10; X c`5BGLOBE`5D += 200; loseint(); /* globe of invulnerab Vility */ X return; X X case 25: omnidirect(x,32+clev," The %s struggles for air in your V flood!"); /* flood */ X return; X X case 26: if (rnd(151)==63) `7B beep(); lprcat("\nYour heart stopp Ved!\n"); nap(4000); died(270); return; `7D X if (c`5BWISDOM`5D>rnd(10)+10) direct(x,2000," The %s's V heart stopped",0); /* finger of death */ X else lprcat(" It didn't work"); return; X X/* ----- LEVEL 5 SPELLS ----- */ X X case 27: c`5BSCAREMONST`5D += rnd(10)+clev; return; /* scare mo Vnster */ X X case 28: c`5BHOLDMONST`5D += rnd(10)+clev; return; /* hold mons Vter */ X X case 29: c`5BTIMESTOP`5D += rnd(20)+(clev<<1); return; /* time V stop */ X X case 30: tdirect(x); return; /* teleport away */ X X case 31: omnidirect(x,35+rnd(10)+clev," The %s cringes from the V flame"); /* magic fire */ X return; X X/* ----- LEVEL 6 SPELLS ----- */ X X case 32: if ((rnd(23)==5) && (wizard==0)) /* sphere of annihilati Von */ X `7B X beep(); lprcat("\nYou have been enveloped by the zon Ve of nothingness!\n"); X nap(4000); died(258); return; X `7D X xl=playerx; yl=playery; X loseint(); X i=dirsub(&xl,&yl); /* get direction of sphere */ X newsphere(xl,yl,i,rnd(20)+11); /* make a sphere */ X return; X X case 33: genmonst(); spelknow`5B33`5D=0; /* genocide */ X loseint(); X return; X X case 34: /* summon demon */ X if (rnd(100) > 30) `7B direct(x,150," The demon strikes V at the %s",0); return; `7D X if (rnd(100) > 15) `7B lprcat(" Nothing seems to have h Vappened"); return; `7D X lprcat(" The demon turned on you and vanished!"); beep( V); X i=rnd(40)+30; lastnum=277; X losehp(i); /* must say killed by a demon */ return; X X case 35: /* walk through walls */ X c`5BWTW`5D += rnd(10)+5; return; X X case 36: /* alter reality */ X `7B X struct isave *save; /* pointer to item save structure */ X int sc; sc=0; /* # items saved */ X save = (struct isave *)malloc(sizeof(struct isave)*MAXX* VMAXY*2); X if (save == NULL) X `7B X lprcat("\nPolinneaus won't let you mess with his dungeon!"); X return; X `7D X for (j=0; j0) /* put objects back in level */ X `7B X --sc; X if (save`5Bsc`5D.type == 0) X `7B X int trys; X for (trys=100, i=j=1; --trys>0 && item`5Bi`5D`5B Vj`5D; i=rnd(MAXX-1), j=rnd(MAXY-1)); X if (trys) `7B item`5Bi`5D`5Bj`5D=save`5Bsc`5D.id V; iarg`5Bi`5D`5Bj`5D=save`5Bsc`5D.arg; `7D X `7D X else X `7B /* put monsters back in */ X int trys; X for (trys=100, i=j=1; --trys>0 && (item`5Bi`5D`5 VBj`5D==OWALL `7C`7C mitem`5Bi`5D`5Bj`5D); i=rnd(MAXX-1), j=rnd(MAXY-1)); X if (trys) `7B mitem`5Bi`5D`5Bj`5D=save`5Bsc`5D.i Vd; hitp`5Bi`5D`5Bj`5D=save`5Bsc`5D.arg; `7D X `7D X `7D X loseint(); X draws(0,MAXX,0,MAXY); if (wizard==0) spelknow`5B36`5D=0 V; X free((char*)save); positionplayer(); return; X `7D X X case 37: /* permanence */ adjtime(-99999L); spelknow`5B37`5D=0; V /* forget */ X loseint(); X return; X X default: lprintf(" spell %d not available!",(long)x); beep(); r Veturn; X `7D; X `7D X X/* X Create a guardian for a throne/altar/fountain, as a result of the player X using a VPR spell or pulverization scroll on it. X*/ Xstatic void create_guardian( monst, x, y ) Xint monst; /* monster code for the guardian */ Xint x, y; /* coords of the object being guarded */ X `7B X int k ; X X /* prevent the guardian from being created on top of the player X */ X if ((x == playerx) && (y == playery)) X `7B X k = rnd(8); X x += diroffx`5Bk`5D; X y += diroffy`5Bk`5D; X `7D X know`5Bx`5D`5By`5D = 0; X mitem`5Bx`5D`5By`5D = monst ; X hitp`5Bx`5D`5By`5D = monster`5Bmonst`5D.hitpoints; X `7D X X/* X * loseint() Routine to subtract 1 from your int (intelligence) if > V 3 X * X * No arguments and no return value X */ Xstatic loseint() X `7B X if (--c`5BINTELLIGENCE`5D<3) c`5BINTELLIGENCE`5D=3; X `7D X X/* X * isconfuse() Routine to check to see if player is confused X * X * This routine prints out a message saying "You can't aim your magic!" X * returns 0 if not confused, non-zero (time remaining confused) if confuse Vd X */ Xstatic isconfuse() X `7B X if (c`5BCONFUSE`5D) `7B lprcat(" You can't aim your magic!"); beep(); `7 VD X return(c`5BCONFUSE`5D); X `7D X X/* X * nospell(x,monst) Routine to return 1 if a spell doesn't affect a mons Vter X * int x,monst; X * X * Subroutine to return 1 if the spell can't affect the monster X * otherwise returns 0 X * Enter with the spell number in x, and the monster number in monst. X */ Xstatic nospell(x,monst) X int x,monst; X `7B X register int tmp; X if (x>=SPNUM `7C`7C monst>=MAXMONST+8 `7C`7C monst<0 `7C`7C x<0) return( V0); /* bad spell or monst */ X if ((tmp=spelweird`5Bmonst-1`5D`5Bx`5D)==0) return(0); X cursors(); lprc('\n'); lprintf(spelmes`5Btmp`5D,monster`5Bmonst`5D.nam Ve); return(1); X `7D X X/* X * fullhit(xx) Function to return full damage against a monster (aka we Vb) X * int xx; X * X * Function to return hp damage to monster due to a number of full hits X * Enter with the number of full hits being done X */ Xfullhit(xx) X int xx; X `7B X register int i; X if (xx<0 `7C`7C xx>20) return(0); /* fullhits are out of range */ X if (c`5BLANCEDEATH`5D) return(10000); /* lance of death */ X i = xx * ((c`5BWCLASS`5D>>1)+c`5BSTRENGTH`5D+c`5BSTREXTRA`5D-c`5BHARDGAM VE`5D-12+c`5BMOREDAM`5D); +-+-+-+-+-+-+-+- END OF PART 39 +-+-+-+-+-+-+-+-