1: /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
   2: /* hack.search.c - version 1.0.3 */
   3: 
   4: #include "hack.h"
   5: 
   6: extern struct monst *makemon();
   7: 
   8: findit()    /* returns number of things found */
   9: {
  10:     int num;
  11:     register xchar zx,zy;
  12:     register struct trap *ttmp;
  13:     register struct monst *mtmp;
  14:     xchar lx,hx,ly,hy;
  15: 
  16:     if(u.uswallow) return(0);
  17:     for(lx = u.ux; (num = levl[lx-1][u.uy].typ) && num != CORR; lx--) ;
  18:     for(hx = u.ux; (num = levl[hx+1][u.uy].typ) && num != CORR; hx++) ;
  19:     for(ly = u.uy; (num = levl[u.ux][ly-1].typ) && num != CORR; ly--) ;
  20:     for(hy = u.uy; (num = levl[u.ux][hy+1].typ) && num != CORR; hy++) ;
  21:     num = 0;
  22:     for(zy = ly; zy <= hy; zy++)
  23:         for(zx = lx; zx <= hx; zx++) {
  24:             if(levl[zx][zy].typ == SDOOR) {
  25:                 levl[zx][zy].typ = DOOR;
  26:                 atl(zx, zy, '+');
  27:                 num++;
  28:             } else if(levl[zx][zy].typ == SCORR) {
  29:                 levl[zx][zy].typ = CORR;
  30:                 atl(zx, zy, CORR_SYM);
  31:                 num++;
  32:             } else if(ttmp = t_at(zx, zy)) {
  33:                 if(ttmp->ttyp == PIERC){
  34:                     (void) makemon(PM_PIERCER, zx, zy);
  35:                     num++;
  36:                     deltrap(ttmp);
  37:                 } else if(!ttmp->tseen) {
  38:                     ttmp->tseen = 1;
  39:                     if(!vism_at(zx, zy))
  40:                         atl(zx,zy,'^');
  41:                     num++;
  42:                 }
  43:             } else if(mtmp = m_at(zx,zy)) if(mtmp->mimic){
  44:                 seemimic(mtmp);
  45:                 num++;
  46:             }
  47:         }
  48:     return(num);
  49: }
  50: 
  51: dosearch()
  52: {
  53:     register xchar x,y;
  54:     register struct trap *trap;
  55:     register struct monst *mtmp;
  56: 
  57:     if(u.uswallow)
  58:         pline("What are you looking for? The exit?");
  59:     else
  60:     for(x = u.ux-1; x < u.ux+2; x++)
  61:     for(y = u.uy-1; y < u.uy+2; y++) if(x != u.ux || y != u.uy) {
  62:         if(levl[x][y].typ == SDOOR) {
  63:             if(rn2(7)) continue;
  64:             levl[x][y].typ = DOOR;
  65:             levl[x][y].seen = 0;    /* force prl */
  66:             prl(x,y);
  67:             nomul(0);
  68:         } else if(levl[x][y].typ == SCORR) {
  69:             if(rn2(7)) continue;
  70:             levl[x][y].typ = CORR;
  71:             levl[x][y].seen = 0;    /* force prl */
  72:             prl(x,y);
  73:             nomul(0);
  74:         } else {
  75:         /* Be careful not to find anything in an SCORR or SDOOR */
  76:             if(mtmp = m_at(x,y)) if(mtmp->mimic){
  77:                 seemimic(mtmp);
  78:                 pline("You find a mimic.");
  79:                 return(1);
  80:             }
  81:             for(trap = ftrap; trap; trap = trap->ntrap)
  82:             if(trap->tx == x && trap->ty == y &&
  83:                !trap->tseen && !rn2(8)) {
  84:                 nomul(0);
  85:                 pline("You find a%s.", traps[trap->ttyp]);
  86:                 if(trap->ttyp == PIERC) {
  87:                     deltrap(trap);
  88:                     (void) makemon(PM_PIERCER,x,y);
  89:                     return(1);
  90:                 }
  91:                 trap->tseen = 1;
  92:                 if(!vism_at(x,y)) atl(x,y,'^');
  93:             }
  94:         }
  95:     }
  96:     return(1);
  97: }
  98: 
  99: doidtrap() {
 100: register struct trap *trap;
 101: register int x,y;
 102:     if(!getdir(1)) return(0);
 103:     x = u.ux + u.dx;
 104:     y = u.uy + u.dy;
 105:     for(trap = ftrap; trap; trap = trap->ntrap)
 106:         if(trap->tx == x && trap->ty == y && trap->tseen) {
 107:             if(u.dz)
 108:             if((u.dz < 0) != (!xdnstair && trap->ttyp == TRAPDOOR))
 109:                 continue;
 110:             pline("That is a%s.", traps[trap->ttyp]);
 111:             return(0);
 112:         }
 113:     pline("I can't see a trap there.");
 114:     return(0);
 115: }
 116: 
 117: wakeup(mtmp)
 118: register struct monst *mtmp;
 119: {
 120:     mtmp->msleep = 0;
 121:     setmangry(mtmp);
 122:     if(mtmp->mimic) seemimic(mtmp);
 123: }
 124: 
 125: /* NOTE: we must check if(mtmp->mimic) before calling this routine */
 126: seemimic(mtmp)
 127: register struct monst *mtmp;
 128: {
 129:         mtmp->mimic = 0;
 130:         mtmp->mappearance = 0;
 131:         unpmon(mtmp);
 132:         pmon(mtmp);
 133: }

Defined functions

doidtrap defined in line 99; used 2 times
dosearch defined in line 51; used 3 times
findit defined in line 8; used 1 times
seemimic defined in line 126; used 5 times
Last modified: 1985-10-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2612
Valid CSS Valid XHTML 1.0 Strict