]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.search.c
2 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
6 static char rcsid
[] = "$NetBSD: hack.search.c,v 1.3 1995/03/23 08:31:28 cgd Exp $";
11 extern struct monst
*makemon();
13 findit() /* returns number of things found */
17 register struct trap
*ttmp
;
18 register struct monst
*mtmp
;
21 if(u
.uswallow
) return(0);
22 for(lx
= u
.ux
; (num
= levl
[lx
-1][u
.uy
].typ
) && num
!= CORR
; lx
--) ;
23 for(hx
= u
.ux
; (num
= levl
[hx
+1][u
.uy
].typ
) && num
!= CORR
; hx
++) ;
24 for(ly
= u
.uy
; (num
= levl
[u
.ux
][ly
-1].typ
) && num
!= CORR
; ly
--) ;
25 for(hy
= u
.uy
; (num
= levl
[u
.ux
][hy
+1].typ
) && num
!= CORR
; hy
++) ;
27 for(zy
= ly
; zy
<= hy
; zy
++)
28 for(zx
= lx
; zx
<= hx
; zx
++) {
29 if(levl
[zx
][zy
].typ
== SDOOR
) {
30 levl
[zx
][zy
].typ
= DOOR
;
33 } else if(levl
[zx
][zy
].typ
== SCORR
) {
34 levl
[zx
][zy
].typ
= CORR
;
35 atl(zx
, zy
, CORR_SYM
);
37 } else if(ttmp
= t_at(zx
, zy
)) {
38 if(ttmp
->ttyp
== PIERC
){
39 (void) makemon(PM_PIERCER
, zx
, zy
);
42 } else if(!ttmp
->tseen
) {
48 } else if(mtmp
= m_at(zx
,zy
)) if(mtmp
->mimic
){
59 register struct trap
*trap
;
60 register struct monst
*mtmp
;
63 pline("What are you looking for? The exit?");
65 for(x
= u
.ux
-1; x
< u
.ux
+2; x
++)
66 for(y
= u
.uy
-1; y
< u
.uy
+2; y
++) if(x
!= u
.ux
|| y
!= u
.uy
) {
67 if(levl
[x
][y
].typ
== SDOOR
) {
69 levl
[x
][y
].typ
= DOOR
;
70 levl
[x
][y
].seen
= 0; /* force prl */
73 } else if(levl
[x
][y
].typ
== SCORR
) {
75 levl
[x
][y
].typ
= CORR
;
76 levl
[x
][y
].seen
= 0; /* force prl */
80 /* Be careful not to find anything in an SCORR or SDOOR */
81 if(mtmp
= m_at(x
,y
)) if(mtmp
->mimic
){
83 pline("You find a mimic.");
86 for(trap
= ftrap
; trap
; trap
= trap
->ntrap
)
87 if(trap
->tx
== x
&& trap
->ty
== y
&&
88 !trap
->tseen
&& !rn2(8)) {
90 pline("You find a%s.", traps
[trap
->ttyp
]);
91 if(trap
->ttyp
== PIERC
) {
93 (void) makemon(PM_PIERCER
,x
,y
);
97 if(!vism_at(x
,y
)) atl(x
,y
,'^');
105 register struct trap
*trap
;
107 if(!getdir(1)) return(0);
110 for(trap
= ftrap
; trap
; trap
= trap
->ntrap
)
111 if(trap
->tx
== x
&& trap
->ty
== y
&& trap
->tseen
) {
113 if((u
.dz
< 0) != (!xdnstair
&& trap
->ttyp
== TRAPDOOR
))
115 pline("That is a%s.", traps
[trap
->ttyp
]);
118 pline("I can't see a trap there.");
123 register struct monst
*mtmp
;
127 if(mtmp
->mimic
) seemimic(mtmp
);
130 /* NOTE: we must check if(mtmp->mimic) before calling this routine */
132 register struct monst
*mtmp
;
135 mtmp
->mappearance
= 0;