]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/expl.c
1 /* $NetBSD: expl.c,v 1.8 2014/03/29 21:33:41 dholland Exp $ */
3 * Copyright (c) 1983-2003, Regents of the University of California.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * + Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * + Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * + Neither the name of the University of California, San Francisco nor
16 * the names of its contributors may be used to endorse or promote
17 * products derived from this software without specific prior written
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
21 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
23 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
35 __RCSID("$NetBSD: expl.c,v 1.8 2014/03/29 21:33:41 dholland Exp $");
42 static EXPL
*Expl
[EXPLEN
]; /* explosion lists */
43 static EXPL
*Last_expl
; /* last explosion on Expl[0] */
45 static void remove_wall(int, int);
50 * Show the explosions as they currently are
53 showexpl(int y
, int x
, char type
)
58 if (y
< 0 || y
>= HEIGHT
)
60 if (x
< 0 || x
>= WIDTH
)
62 ep
= malloc(sizeof(*ep
));
67 if (Last_expl
== NULL
)
70 Last_expl
->e_next
= ep
;
72 for (pp
= Player
; pp
< End_player
; pp
++) {
73 if (pp
->p_maze
[y
][x
] == type
)
75 pp
->p_maze
[y
][x
] = type
;
80 for (pp
= Monitor
; pp
< End_monitor
; pp
++) {
81 if (pp
->p_maze
[y
][x
] == type
)
83 pp
->p_maze
[y
][x
] = type
;
99 if (y
>= UBOUND
&& y
< DBOUND
&& x
>= LBOUND
&& x
< RBOUND
)
107 * Roll the explosions over, so the next one in the list is at the
119 for (ep
= Expl
[EXPLEN
- 1]; ep
!= NULL
; ep
= nextep
) {
123 if (y
< UBOUND
|| y
>= DBOUND
|| x
< LBOUND
|| x
>= RBOUND
)
127 for (pp
= Player
; pp
< End_player
; pp
++)
128 if (pp
->p_maze
[y
][x
] == ep
->e_char
) {
129 pp
->p_maze
[y
][x
] = c
;
134 for (pp
= Monitor
; pp
< End_monitor
; pp
++)
139 for (x
= EXPLEN
- 1; x
> 0; x
--)
140 Expl
[x
] = Expl
[x
- 1];
141 Last_expl
= Expl
[0] = NULL
;
144 /* There's about 700 walls in the initial maze. So we pick a number
145 * that keeps the maze relatively full. */
148 static REGEN removed
[MAXREMOVE
];
149 static REGEN
*rem_index
= removed
;
152 * remove_wall - add a location where the wall was blown away.
153 * if there is no space left over, put the a wall at
154 * the location currently pointed at.
157 remove_wall(int y
, int x
)
160 #if defined(MONITOR) || defined(FLY)
168 while (r
->r_y
!= 0) {
170 switch (Maze
[r
->r_y
][r
->r_x
]) {
177 save_char
= Maze
[r
->r_y
][r
->r_x
];
181 if (Maze
[r
->r_y
][r
->r_x
] == SPACE
)
184 if (++r
>= &removed
[MAXREMOVE
])
190 /* Slot being used, put back this wall */
192 if (save_char
== SPACE
)
193 Maze
[r
->r_y
][r
->r_x
] = Orig_maze
[r
->r_y
][r
->r_x
];
195 pp
= play_at(r
->r_y
, r
->r_x
);
196 if (pp
->p_flying
>= 0)
197 pp
->p_flying
+= rand_num(10);
199 pp
->p_flying
= rand_num(20);
200 pp
->p_flyx
= 2 * rand_num(6) - 5;
201 pp
->p_flyy
= 2 * rand_num(6) - 5;
203 pp
->p_over
= Orig_maze
[r
->r_y
][r
->r_x
];
205 Maze
[r
->r_y
][r
->r_x
] = FLYER
;
206 showexpl(r
->r_y
, r
->r_x
, FLYER
);
209 Maze
[r
->r_y
][r
->r_x
] = Orig_maze
[r
->r_y
][r
->r_x
];
212 if (rand_num(100) == 0)
213 Maze
[r
->r_y
][r
->r_x
] = DOOR
;
216 if (rand_num(100) == 0) /* one percent of the time */
217 Maze
[r
->r_y
][r
->r_x
] = WALL4
;
220 for (pp
= Monitor
; pp
< End_monitor
; pp
++)
221 check(pp
, r
->r_y
, r
->r_x
);
227 if (++r
>= &removed
[MAXREMOVE
])
234 for (pp
= Monitor
; pp
< End_monitor
; pp
++)
241 * Clear out the walls array
248 for (rp
= removed
; rp
< &removed
[MAXREMOVE
]; rp
++)