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 $ */
9 findit(void) /* returns number of things found */
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
++) ;
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
;
29 } else if(levl
[zx
][zy
].typ
== SCORR
) {
30 levl
[zx
][zy
].typ
= CORR
;
31 atl(zx
, zy
, CORR_SYM
);
33 } else if((ttmp
= t_at(zx
, zy
))) {
34 if(ttmp
->ttyp
== PIERC
){
35 makemon(PM_PIERCER
, zx
, zy
);
38 } else if(!ttmp
->tseen
) {
44 } else if((mtmp
= m_at(zx
,zy
))) if(mtmp
->mimic
){
60 pline("What are you looking for? The exit?");
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
) {
66 levl
[x
][y
].typ
= DOOR
;
67 levl
[x
][y
].seen
= 0; /* force prl */
70 } else if(levl
[x
][y
].typ
== SCORR
) {
72 levl
[x
][y
].typ
= CORR
;
73 levl
[x
][y
].seen
= 0; /* force prl */
77 /* Be careful not to find anything in an SCORR or SDOOR */
78 if((mtmp
= m_at(x
,y
))) if(mtmp
->mimic
){
80 pline("You find a mimic.");
83 for(trap
= ftrap
; trap
; trap
= trap
->ntrap
)
84 if(trap
->tx
== x
&& trap
->ty
== y
&&
85 !trap
->tseen
&& !rn2(8)) {
87 pline("You find a%s.", traps
[trap
->ttyp
]);
88 if(trap
->ttyp
== PIERC
) {
90 makemon(PM_PIERCER
,x
,y
);
94 if(!vism_at(x
,y
)) atl(x
,y
,'^');
106 if(!getdir(1)) return(0);
109 for(trap
= ftrap
; trap
; trap
= trap
->ntrap
)
110 if(trap
->tx
== x
&& trap
->ty
== y
&& trap
->tseen
) {
112 if((u
.dz
< 0) != (!xdnstair
&& trap
->ttyp
== TRAPDOOR
))
114 pline("That is a%s.", traps
[trap
->ttyp
]);
117 pline("I can't see a trap there.");
122 wakeup(struct monst
*mtmp
)
126 if(mtmp
->mimic
) seemimic(mtmp
);
129 /* NOTE: we must check if(mtmp->mimic) before calling this routine */
131 seemimic(struct monst
*mtmp
)
134 mtmp
->mappearance
= 0;