1 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
2 /* hack.search.c - version 1.0.3 */
6 extern struct monst *makemon();
8 findit() /* returns number of things found */
12 register struct trap *ttmp;
13 register struct monst *mtmp;
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++) ;
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;
28 } else if(levl[zx][zy].typ == SCORR) {
29 levl[zx][zy].typ = CORR;
30 atl(zx, zy, CORR_SYM);
32 } else if(ttmp = t_at(zx, zy)) {
33 if(ttmp->ttyp == PIERC){
34 (void) makemon(PM_PIERCER, zx, zy);
37 } else if(!ttmp->tseen) {
43 } else if(mtmp = m_at(zx,zy)) if(mtmp->mimic){
54 register struct trap *trap;
55 register struct monst *mtmp;
58 pline("What are you looking for? The exit?");
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) {
64 levl[x][y].typ = DOOR;
65 levl[x][y].seen = 0; /* force prl */
68 } else if(levl[x][y].typ == SCORR) {
70 levl[x][y].typ = CORR;
71 levl[x][y].seen = 0; /* force prl */
75 /* Be careful not to find anything in an SCORR or SDOOR */
76 if(mtmp = m_at(x,y)) if(mtmp->mimic){
78 pline("You find a mimic.");
81 for(trap = ftrap; trap; trap = trap->ntrap)
82 if(trap->tx == x && trap->ty == y &&
83 !trap->tseen && !rn2(8)) {
85 pline("You find a%s.", traps[trap->ttyp]);
86 if(trap->ttyp == PIERC) {
88 (void) makemon(PM_PIERCER,x,y);
92 if(!vism_at(x,y)) atl(x,y,'^');
100 register struct trap *trap;
102 if(!getdir(1)) return(0);
105 for(trap = ftrap; trap; trap = trap->ntrap)
106 if(trap->tx == x && trap->ty == y && trap->tseen) {
108 if((u.dz < 0) != (!xdnstair && trap->ttyp == TRAPDOOR))
110 pline("That is a%s.", traps[trap->ttyp]);
113 pline("I can't see a trap there.");
118 register struct monst *mtmp;
122 if(mtmp->mimic) seemimic(mtmp);
125 /* NOTE: we must check if(mtmp->mimic) before calling this routine */
127 register struct monst *mtmp;
130 mtmp->mappearance = 0;