-+-+-+-+-+-+-+-+ START OF PART 26 -+-+-+-+-+-+-+-+ X * createmonster(monstno) Function to create a monster next to the pla Vyer X * int monstno; X * X * int cgood(x,y,itm,monst) Function to check location for emptiness X * int x,y,itm,monst; X * X * createitem(it,arg) Routine to place an item next to the player X * int it,arg; X * X * vxy(x,y) Routine to verify/fix (*x,*y) for being within bound Vs X * int *x,*y; X * X * hitmonster(x,y) Function to hit a monster at the designated coordina Vtes X * int x,y; X * X * hitm(x,y,amt) Function to just hit a monster at a given coordinate Vs X * int x,y,amt; X * X * hitplayer(x,y) Function for the monster to hit the player from (x,y V) X * int x,y; X * X * dropsomething(monst) Function to create an object when a monster dies X * int monst; X * X * dropgold(amount) Function to drop some gold around player X * int amount; X * X * something(level) Function to create a random item around player X * int level; X * X * newobject(lev,i) Routine to return a randomly selected new object X * int lev,*i; X * X * spattack(atckno,xx,yy) Function to process special attacks from monster Vs X * int atckno,xx,yy; X * X * checkloss(x) Routine to subtract hp from user and flag bottomline dis Vplay X * int x; X * X */ X#include "header.h" X#include "larndefs.h" X#include "monsters.h" X#include "objects.h" X#include "player.h" X X#include X#define min(x,y) (((x)>(y))?(y):(x)) X#define max(x,y) (((x)>(y))?(x):(y)) X Xextern fullhit(), ifblind(); X X/* X * createmonster(monstno) Function to create a monster next to the pla Vyer X * int monstno; X * X * Enter with the monster number (1 to MAXMONST+8) X * Returns no value. X */ Xcreatemonster(mon) X int mon; X `7B X register int x,y,k,i; X if (mon<1 `7C`7C mon>MAXMONST+8) /* check for monster number out of b Vounds */ X `7B X beep(); lprintf("\ncan't createmonst(%d)\n",(long)mon); nap(3000); r Veturn; X `7D X while (monster`5Bmon`5D.genocided && mon8) k=1; /* wraparound the diroff arrays */ X x = playerx + diroffx`5Bk`5D; y = playery + diroffy`5Bk`5D; X if (cgood(x,y,0,1)) /* if we can create here */ X `7B X mitem`5Bx`5D`5By`5D = mon; X hitp`5Bx`5D`5By`5D = monster`5Bmon`5D.hitpoints; X stealth`5Bx`5D`5By`5D=0; X know`5Bx`5D`5By`5D &= `7EKNOWHERE; X switch(mon) X `7B X case ROTHE: case POLTERGEIST: case VAMPIRE: stealth`5Bx`5D`5 VBy`5D=1; X `7D; X return; X `7D X `7D X `7D X X/* X * int cgood(x,y,itm,monst) Function to check location for emptiness X * int x,y,itm,monst; X * X * Routine to return TRUE if a location does not have itm or monst there X * returns FALSE (0) otherwise X * Enter with itm or monst TRUE or FALSE if checking it X * Example: if itm==TRUE check for no item at this location X * if monst==TRUE check for no monster at this location X * This routine will return FALSE if at a wall,door or the dungeon exit X * on level 1 X */ Xstatic int cgood(x,y,itm,monst) X register int x,y; X int itm,monst; X `7B X /* cannot create either monster or item if: X - out of bounds X - wall X - closed door X - dungeon entrance X */ X if (((y < 0) `7C`7C (y > MAXY-1) `7C`7C (x < 0) `7C`7C (x > MAXX-1)) `7C V`7C X (item`5Bx`5D`5By`5D == OWALL) `7C`7C X (item`5Bx`5D`5By`5D == OCLOSEDDOOR) `7C`7C X ((level == 1) && (x == 33) && (y == MAXY-1))) X return( FALSE ); X X /* if checking for an item, return False if one there already X */ X if ( itm && item`5Bx`5D`5By`5D) X return( FALSE ); X X /* if checking for a monster, return False if one there already _or_ X there is a pit/trap there. X */ X if (monst) X `7B X if (mitem`5Bx`5D`5By`5D) X return (FALSE); X switch(item`5Bx`5D`5By`5D) X `7B X /* note: not invisible traps, since monsters are not affected X by them. X */ X case OPIT: case OANNIHILATION: X case OTELEPORTER: case OTRAPARROW: X case ODARTRAP: case OTRAPDOOR: X return(FALSE); X break; X default: X break; X `7D X `7D X return(TRUE); X `7D X X/* X * createitem(it,arg) Routine to place an item next to the player X * int it,arg; X * X * Enter with the item number and its argument (iven`5B`5D, ivenarg`5B`5D) X * Returns no value, thus we don't know about createitem() failures. X */ Xcreateitem(it,arg) X int it,arg; X `7B X register int x,y,k,i; X if (it >= MAXOBJ) return; /* no such object */ X for (k=rnd(8), i= -8; i<0; i++,k++) /* choose direction, then try all */ X `7B X if (k>8) k=1; /* wraparound the diroff arrays */ X x = playerx + diroffx`5Bk`5D; y = playery + diroffy`5Bk`5D; X if (cgood(x,y,1,0)) /* if we can create here */ X `7B X item`5Bx`5D`5By`5D = it; know`5Bx`5D`5By`5D=0; iarg`5Bx`5D`5By V`5D=arg; return; X `7D X `7D X `7D X X X/* X * vxy(x,y) Routine to verify/fix coordinates for being within bounds X * int *x,*y; X * X * Function to verify x & y are within the bounds for a level X * If *x or *y is not within the absolute bounds for a level, fix them so t Vhat X * they are on the level. X * Returns TRUE if it was out of bounds, and the *x & *y in the calling X * routine are affected. X */ Xvxy(x,y) X int *x,*y; X `7B X int flag=0; X if (*x<0) `7B *x=0; flag++; `7D X if (*y<0) `7B *y=0; flag++; `7D X if (*x>=MAXX) `7B *x=MAXX-1; flag++; `7D X if (*y>=MAXY) `7B *y=MAXY-1; flag++; `7D X return(flag); X `7D X X/* X * hitmonster(x,y) Function to hit a monster at the designated coordina Vtes X * int x,y; X * X * This routine is used for a bash & slash type attack on a monster X * Enter with the coordinates of the monster in (x,y). X * Returns no value. X */ Xhitmonster(x,y) X int x,y; X `7B X extern char lastmonst`5B`5D ; X register int tmp,monst,damag,flag; X if (c`5BTIMESTOP`5D) return; /* not if time stopped */ X vxy(&x,&y); /* verify coordinates are within range */ X if ((monst = mitem`5Bx`5D`5By`5D) == 0) return; X hit3flag=1; ifblind(x,y); X tmp = monster`5Bmonst`5D.armorclass + c`5BLEVEL`5D + c`5BDEXTERITY`5D + V c`5BWCLASS`5D/4 - 12; X cursors(); X if ((rnd(20) < tmp-c`5BHARDGAME`5D) `7C`7C (rnd(71) < 5)) /* need at lea Vst random chance to hit */ X `7B X lprcat("\nYou hit"); flag=1; X damag = fullhit(1); X if (damag<9999) damag=rnd(damag)+1; X `7D X else X `7B X lprcat("\nYou missed"); flag=0; X `7D X lprcat(" the "); lprcat(lastmonst); X if (flag) /* if the monster was hit */ X if ((monst==RUSTMONSTER) `7C`7C (monst==DISENCHANTRESS) `7C`7C (monst= V=CUBE)) X if (c`5BWIELD`5D>=0) X if (ivenarg`5Bc`5BWIELD`5D`5D > -10) X `7B X lprintf("\nYour weapon is dulled by the %s",lastmonst); beep(); X --ivenarg`5Bc`5BWIELD`5D`5D; X X /* fix for dulled rings of strength,cleverness, and dexterity X bug. X */ X switch (iven`5Bc`5BWIELD`5D`5D) X `7B X case ODEXRING : X c`5BDEXTERITY`5D--; X break; X case OSTRRING : X c`5BSTREXTRA`5D--; X break; X case OCLEVERRING : X c`5BINTELLIGENCE`5D--; X break; X `7D X `7D X if (flag) hitm(x,y,damag); X if (monst == VAMPIRE) if (hitp`5Bx`5D`5By`5D<25) `7B mitem`5Bx`5D`5By`5 VD=BAT; know`5Bx`5D`5By`5D=0; `7D X `7D X X/* X * hitm(x,y,amt) Function to just hit a monster at a given coordinate Vs X * int x,y,amt; X * X * Returns the number of hitpoints the monster absorbed X * This routine is used to specifically damage a monster at a location (x,y V) X * Called by hitmonster(x,y) X */ Xhitm(x,y,amt) X int x,y; X register amt; X `7B X extern char lastmonst`5B`5D ; X register int monst; X int hpoints,amt2; X vxy(&x,&y); /* verify coordinates are within range */ X amt2 = amt; /* save initial damage so we can return it */ X monst = mitem`5Bx`5D`5By`5D; X if (c`5BHALFDAM`5D) amt >>= 1; /* if half damage curse adjust damage po Vints */ X if (amt<=0) amt2 = amt = 1; X lasthx=x; lasthy=y; X stealth`5Bx`5D`5By`5D=1; /* make sure hitting monst breaks stealth co Vndition */ X c`5BHOLDMONST`5D=0; /* hit a monster breaks hold monster spell */ X switch(monst) /* if a dragon and orb(s) of dragon slaying */ X `7B X case WHITEDRAGON: case REDDRAGON: case GREENDRAGON: X case BRONZEDRAGON: case PLATINUMDRAGON: case SILVERDRAGON: X amt *= 1+(c`5BSLAYING`5D<<1); break; X `7D X/* invincible monster fix is here */ X if (hitp`5Bx`5D`5By`5D > monster`5Bmonst`5D.hitpoints) X hitp`5Bx`5D`5By`5D = monster`5Bmonst`5D.hitpoints; X if ((hpoints = hitp`5Bx`5D`5By`5D) <= amt) X `7B X#ifdef EXTRA X c`5BMONSTKILLED`5D++; X#endif X lprintf("\nThe %s died!",lastmonst); X raiseexperience((long)monster`5Bmonst`5D.experience); X amt = monster`5Bmonst`5D.gold; if (amt>0) dropgold(rnd(amt)+amt); X dropsomething(monst); disappear(x,y); bottomline(); X return(hpoints); X `7D X hitp`5Bx`5D`5By`5D = hpoints-amt; return(amt2); X `7D X X/* X * hitplayer(x,y) Function for the monster to hit the player from (x,y V) X * int x,y; X * X * Function for the monster to hit the player with monster at location x,y X * Returns nothing of value. X */ Xhitplayer(x,y) X int x,y; X `7B X extern char lastmonst`5B`5D ; X register int dam,tmp,mster,bias; X vxy(&x,&y); /* verify coordinates are within range */ X lastnum = mster = mitem`5Bx`5D`5By`5D; X/* spirit naga's and poltergeist's do nothing if scarab of negate spirit V */ X if (c`5BNEGATESPIRIT`5D `7C`7C c`5BSPIRITPRO`5D) if ((mster ==POLTERGEI VST) `7C`7C (mster ==SPIRITNAGA)) return; X/* if undead and cube of undead control */ X if (c`5BCUBEofUNDEAD`5D `7C`7C c`5BUNDEADPRO`5D) if ((mster ==VAMPIRE) ` V7C`7C (mster ==WRAITH) `7C`7C (mster ==ZOMBIE)) return; X if ((know`5Bx`5D`5By`5D & KNOWHERE) == 0) X show1cell(x,y); X bias = (c`5BHARDGAME`5D) + 1; X hitflag = hit2flag = hit3flag = 1; X yrepcount=0; X cursors(); ifblind(x,y); X if (c`5BINVISIBILITY`5D) if (rnd(33)<20)`20 X `7B X lprintf("\nThe %s misses wildly",lastmonst); return; X `7D X if (c`5BCHARMCOUNT`5D) if (rnd(30)+5*monster`5Bmster`5D.level-c`5BCHARIS VMA`5D<30) X `7B X lprintf("\nThe %s is awestruck at your magnificence!",lastmonst); X return; X `7D X if (mster==BAT) dam=1; X else X `7B X dam = monster`5Bmster`5D.damage; X dam += rnd((int)((dam<1)?1:dam)) + monster`5Bmster`5D.level; X `7D X tmp = 0; X if (monster`5Bmster`5D.attack>0) X if (((dam + bias + 8) > c`5BAC`5D) `7C`7C (rnd((int)((c`5BAC`5D>0)?c`5 VBAC`5D:1))==1)) X `7B if (spattack(monster`5Bmster`5D.attack,x,y)) `7B lflushall(); re Vturn; `7D X tmp = 1; bias -= 2; cursors(); `7D X if (((dam + bias) > c`5BAC`5D) `7C`7C (rnd((int)((c`5BAC`5D>0)?c`5BAC`5D V:1))==1)) X `7B X lprintf("\n The %s hit you ",lastmonst); tmp = 1; X if ((dam -= c`5BAC`5D) < 0) dam=0; X if (dam > 0) `7B losehp(dam); bottomhp(); lflushall(); `7D X `7D X if (tmp == 0) lprintf("\n The %s missed ",lastmonst); X `7D X X/* X * dropsomething(monst) Function to create an object when a monster dies X * int monst; X * X * Function to create an object near the player when certain monsters are k Villed X * Enter with the monster number X * Returns nothing of value. X */ Xstatic dropsomething(monst) X int monst; X `7B X switch(monst) X `7B X case ORC: case NYMPH: case ELF: case TROGLODYT VE: X case TROLL: case ROTHE: case VIOLETFUNGI: X case PLATINUMDRAGON: case GNOMEKING: case REDDRAGON: X something(level); return; X X case LEPRECHAUN: if (rnd(101)>=75) creategem(); X if (rnd(5)==1) dropsomething(LEPRECHAUN); return; X `7D X `7D X X/* X * dropgold(amount) Function to drop some gold around player X * int amount; X * X * Enter with the number of gold pieces to drop X * Returns nothing of value. X */ Xdropgold(amount) X register int amount; X `7B X if (amount > 250)`20 X createitem(OMAXGOLD,amount/100); `20 X else `20 X createitem(OGOLDPILE,amount); X `7D X X/* X * something(level) Function to create a random item around player X * int level; X * X * Function to create an item from a designed probability around player X * Enter with the cave level on which something is to be dropped X * Returns nothing of value. X */ Xsomething(level) X int level; X `7B X register int j; X int i; X if (level<0 `7C`7C level>MAXLEVEL+MAXVLEVEL) return; /* correct level V? */ X if (rnd(101)<8) X something(level); /* possibly more than one item */ X j = newobject(level,&i); X createitem(j,i); X `7D X X/* X * newobject(lev,i) Routine to return a randomly selected new object X * int lev,*i; X * X * Routine to return a randomly selected object to be created X * Returns the object number created, and sets *i for its argument X * Enter with the cave level and a pointer to the items arg X */ +-+-+-+-+-+-+-+- END OF PART 26 +-+-+-+-+-+-+-+-