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