]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hack/hack.search.c
1 /* $NetBSD: hack.search.c,v 1.4 1997/10/19 16:58:59 christos Exp $ */
4 * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
9 __RCSID("$NetBSD: hack.search.c,v 1.4 1997/10/19 16:58:59 christos Exp $");
17 { /* returns number of things found */
26 for (lx
= u
.ux
; (num
= levl
[lx
- 1][u
.uy
].typ
) && num
!= CORR
; lx
--);
27 for (hx
= u
.ux
; (num
= levl
[hx
+ 1][u
.uy
].typ
) && num
!= CORR
; hx
++);
28 for (ly
= u
.uy
; (num
= levl
[u
.ux
][ly
- 1].typ
) && num
!= CORR
; ly
--);
29 for (hy
= u
.uy
; (num
= levl
[u
.ux
][hy
+ 1].typ
) && num
!= CORR
; hy
++);
31 for (zy
= ly
; zy
<= hy
; zy
++)
32 for (zx
= lx
; zx
<= hx
; zx
++) {
33 if (levl
[zx
][zy
].typ
== SDOOR
) {
34 levl
[zx
][zy
].typ
= DOOR
;
37 } else if (levl
[zx
][zy
].typ
== SCORR
) {
38 levl
[zx
][zy
].typ
= CORR
;
39 atl(zx
, zy
, CORR_SYM
);
41 } else if ((ttmp
= t_at(zx
, zy
)) != NULL
) {
42 if (ttmp
->ttyp
== PIERC
) {
43 (void) makemon(PM_PIERCER
, zx
, zy
);
46 } else if (!ttmp
->tseen
) {
52 } else if ((mtmp
= m_at(zx
, zy
)) != NULL
)
69 pline("What are you looking for? The exit?");
71 for (x
= u
.ux
- 1; x
< u
.ux
+ 2; x
++)
72 for (y
= u
.uy
- 1; y
< u
.uy
+ 2; y
++)
73 if (x
!= u
.ux
|| y
!= u
.uy
) {
74 if (levl
[x
][y
].typ
== SDOOR
) {
77 levl
[x
][y
].typ
= DOOR
;
78 levl
[x
][y
].seen
= 0; /* force prl */
81 } else if (levl
[x
][y
].typ
== SCORR
) {
84 levl
[x
][y
].typ
= CORR
;
85 levl
[x
][y
].seen
= 0; /* force prl */
90 * Be careful not to find
91 * anything in an SCORR or
94 if ((mtmp
= m_at(x
, y
)) != NULL
)
97 pline("You find a mimic.");
100 for (trap
= ftrap
; trap
; trap
= trap
->ntrap
)
101 if (trap
->tx
== x
&& trap
->ty
== y
&&
102 !trap
->tseen
&& !rn2(8)) {
104 pline("You find a%s.", traps
[trap
->ttyp
]);
105 if (trap
->ttyp
== PIERC
) {
107 (void) makemon(PM_PIERCER
, x
, y
);
128 for (trap
= ftrap
; trap
; trap
= trap
->ntrap
)
129 if (trap
->tx
== x
&& trap
->ty
== y
&& trap
->tseen
) {
131 if ((u
.dz
< 0) != (!xdnstair
&& trap
->ttyp
== TRAPDOOR
))
133 pline("That is a%s.", traps
[trap
->ttyp
]);
136 pline("I can't see a trap there.");
150 /* NOTE: we must check if(mtmp->mimic) before calling this routine */
156 mtmp
->mappearance
= 0;