shots.c revision 1.1.1.2 1 1.1 mrg /*
2 1.1.1.2 wiz * Copyright (c) 1983-2003, Regents of the University of California.
3 1.1.1.2 wiz * All rights reserved.
4 1.1.1.2 wiz *
5 1.1.1.2 wiz * Redistribution and use in source and binary forms, with or without
6 1.1.1.2 wiz * modification, are permitted provided that the following conditions are
7 1.1.1.2 wiz * met:
8 1.1.1.2 wiz *
9 1.1.1.2 wiz * + Redistributions of source code must retain the above copyright
10 1.1.1.2 wiz * notice, this list of conditions and the following disclaimer.
11 1.1.1.2 wiz * + Redistributions in binary form must reproduce the above copyright
12 1.1.1.2 wiz * notice, this list of conditions and the following disclaimer in the
13 1.1.1.2 wiz * documentation and/or other materials provided with the distribution.
14 1.1.1.2 wiz * + Neither the name of the University of California, San Francisco nor
15 1.1.1.2 wiz * the names of its contributors may be used to endorse or promote
16 1.1.1.2 wiz * products derived from this software without specific prior written
17 1.1.1.2 wiz * permission.
18 1.1.1.2 wiz *
19 1.1.1.2 wiz * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20 1.1.1.2 wiz * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 1.1.1.2 wiz * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22 1.1.1.2 wiz * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 1.1.1.2 wiz * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 1.1.1.2 wiz * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 1.1.1.2 wiz * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 1.1.1.2 wiz * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 1.1.1.2 wiz * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 1.1.1.2 wiz * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 1.1.1.2 wiz * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 1.1 mrg */
31 1.1 mrg
32 1.1 mrg # include "hunt.h"
33 1.1 mrg # include <signal.h>
34 1.1 mrg
35 1.1 mrg # define PLUS_DELTA(x, max) if (x < max) x++; else x--
36 1.1 mrg # define MINUS_DELTA(x, min) if (x > min) x--; else x++
37 1.1 mrg
38 1.1 mrg /*
39 1.1 mrg * moveshots:
40 1.1 mrg * Move the shots already in the air, taking explosions into account
41 1.1 mrg */
42 1.1 mrg moveshots()
43 1.1 mrg {
44 1.1 mrg register BULLET *bp, *next;
45 1.1 mrg register PLAYER *pp;
46 1.1 mrg register int x, y;
47 1.1 mrg register BULLET *blist;
48 1.1 mrg
49 1.1 mrg rollexpl();
50 1.1 mrg if (Bullets == NULL)
51 1.1 mrg goto ret;
52 1.1 mrg
53 1.1 mrg /*
54 1.1 mrg * First we move through the bullet list BULSPD times, looking
55 1.1 mrg * for things we may have run into. If we do run into
56 1.1 mrg * something, we set up the explosion and disappear, checking
57 1.1 mrg * for damage to any player who got in the way.
58 1.1 mrg */
59 1.1 mrg
60 1.1 mrg blist = Bullets;
61 1.1 mrg Bullets = NULL;
62 1.1 mrg for (bp = blist; bp != NULL; bp = next) {
63 1.1 mrg next = bp->b_next;
64 1.1 mrg x = bp->b_x;
65 1.1 mrg y = bp->b_y;
66 1.1 mrg Maze[y][x] = bp->b_over;
67 1.1 mrg for (pp = Player; pp < End_player; pp++)
68 1.1 mrg check(pp, y, x);
69 1.1 mrg # ifdef MONITOR
70 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++)
71 1.1 mrg check(pp, y, x);
72 1.1 mrg # endif
73 1.1 mrg
74 1.1 mrg switch (bp->b_type) {
75 1.1 mrg case SHOT:
76 1.1 mrg case GRENADE:
77 1.1 mrg case SATCHEL:
78 1.1 mrg case BOMB:
79 1.1 mrg if (move_normal_shot(bp)) {
80 1.1 mrg bp->b_next = Bullets;
81 1.1 mrg Bullets = bp;
82 1.1 mrg }
83 1.1 mrg break;
84 1.1 mrg # ifdef OOZE
85 1.1 mrg case SLIME:
86 1.1 mrg if (bp->b_expl || move_normal_shot(bp)) {
87 1.1 mrg bp->b_next = Bullets;
88 1.1 mrg Bullets = bp;
89 1.1 mrg }
90 1.1 mrg break;
91 1.1 mrg # endif
92 1.1 mrg # ifdef DRONE
93 1.1 mrg case DSHOT:
94 1.1 mrg if (move_drone(bp)) {
95 1.1 mrg bp->b_next = Bullets;
96 1.1 mrg Bullets = bp;
97 1.1 mrg }
98 1.1 mrg break;
99 1.1 mrg # endif
100 1.1 mrg default:
101 1.1 mrg bp->b_next = Bullets;
102 1.1 mrg Bullets = bp;
103 1.1 mrg break;
104 1.1 mrg }
105 1.1 mrg }
106 1.1 mrg
107 1.1 mrg blist = Bullets;
108 1.1 mrg Bullets = NULL;
109 1.1 mrg for (bp = blist; bp != NULL; bp = next) {
110 1.1 mrg next = bp->b_next;
111 1.1 mrg if (!bp->b_expl) {
112 1.1 mrg save_bullet(bp);
113 1.1 mrg # ifdef MONITOR
114 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++)
115 1.1 mrg check(pp, bp->b_y, bp->b_x);
116 1.1 mrg # endif
117 1.1 mrg # ifdef DRONE
118 1.1 mrg if (bp->b_type == DSHOT)
119 1.1 mrg for (pp = Player; pp < End_player; pp++)
120 1.1 mrg if (pp->p_scan >= 0)
121 1.1 mrg check(pp, bp->b_y, bp->b_x);
122 1.1 mrg # endif
123 1.1 mrg continue;
124 1.1 mrg }
125 1.1 mrg
126 1.1 mrg chkshot(bp, next);
127 1.1 mrg free((char *) bp);
128 1.1 mrg }
129 1.1 mrg
130 1.1 mrg for (pp = Player; pp < End_player; pp++)
131 1.1 mrg Maze[pp->p_y][pp->p_x] = pp->p_face;
132 1.1 mrg
133 1.1 mrg ret:
134 1.1 mrg # ifdef BOOTS
135 1.1 mrg for (pp = Boot; pp < &Boot[NBOOTS]; pp++)
136 1.1 mrg if (pp->p_flying >= 0)
137 1.1 mrg move_flyer(pp);
138 1.1 mrg # endif
139 1.1 mrg for (pp = Player; pp < End_player; pp++) {
140 1.1 mrg # ifdef FLY
141 1.1 mrg if (pp->p_flying >= 0)
142 1.1 mrg move_flyer(pp);
143 1.1 mrg # endif
144 1.1 mrg sendcom(pp, REFRESH); /* Flush out the explosions */
145 1.1 mrg look(pp);
146 1.1 mrg sendcom(pp, REFRESH);
147 1.1 mrg }
148 1.1 mrg # ifdef MONITOR
149 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++)
150 1.1 mrg sendcom(pp, REFRESH);
151 1.1 mrg # endif
152 1.1 mrg
153 1.1 mrg return;
154 1.1 mrg }
155 1.1 mrg
156 1.1 mrg /*
157 1.1 mrg * move_normal_shot:
158 1.1 mrg * Move a normal shot along its trajectory
159 1.1 mrg */
160 1.1 mrg move_normal_shot(bp)
161 1.1 mrg register BULLET *bp;
162 1.1 mrg {
163 1.1 mrg register int i, x, y;
164 1.1 mrg register PLAYER *pp;
165 1.1 mrg
166 1.1 mrg for (i = 0; i < BULSPD; i++) {
167 1.1 mrg if (bp->b_expl)
168 1.1 mrg break;
169 1.1 mrg
170 1.1 mrg x = bp->b_x;
171 1.1 mrg y = bp->b_y;
172 1.1 mrg
173 1.1 mrg switch (bp->b_face) {
174 1.1 mrg case LEFTS:
175 1.1 mrg x--;
176 1.1 mrg break;
177 1.1 mrg case RIGHT:
178 1.1 mrg x++;
179 1.1 mrg break;
180 1.1 mrg case ABOVE:
181 1.1 mrg y--;
182 1.1 mrg break;
183 1.1 mrg case BELOW:
184 1.1 mrg y++;
185 1.1 mrg break;
186 1.1 mrg }
187 1.1 mrg
188 1.1 mrg switch (Maze[y][x]) {
189 1.1 mrg case SHOT:
190 1.1 mrg if (rand_num(100) < 5) {
191 1.1 mrg zapshot(Bullets, bp);
192 1.1 mrg zapshot(bp->b_next, bp);
193 1.1 mrg }
194 1.1 mrg break;
195 1.1 mrg case GRENADE:
196 1.1 mrg if (rand_num(100) < 10) {
197 1.1 mrg zapshot(Bullets, bp);
198 1.1 mrg zapshot(bp->b_next, bp);
199 1.1 mrg }
200 1.1 mrg break;
201 1.1 mrg # ifdef REFLECT
202 1.1 mrg case WALL4: /* reflecting walls */
203 1.1 mrg switch (bp->b_face) {
204 1.1 mrg case LEFTS:
205 1.1 mrg bp->b_face = BELOW;
206 1.1 mrg break;
207 1.1 mrg case RIGHT:
208 1.1 mrg bp->b_face = ABOVE;
209 1.1 mrg break;
210 1.1 mrg case ABOVE:
211 1.1 mrg bp->b_face = RIGHT;
212 1.1 mrg break;
213 1.1 mrg case BELOW:
214 1.1 mrg bp->b_face = LEFTS;
215 1.1 mrg break;
216 1.1 mrg }
217 1.1 mrg Maze[y][x] = WALL5;
218 1.1 mrg # ifdef MONITOR
219 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++)
220 1.1 mrg check(pp, y, x);
221 1.1 mrg # endif
222 1.1 mrg break;
223 1.1 mrg case WALL5:
224 1.1 mrg switch (bp->b_face) {
225 1.1 mrg case LEFTS:
226 1.1 mrg bp->b_face = ABOVE;
227 1.1 mrg break;
228 1.1 mrg case RIGHT:
229 1.1 mrg bp->b_face = BELOW;
230 1.1 mrg break;
231 1.1 mrg case ABOVE:
232 1.1 mrg bp->b_face = LEFTS;
233 1.1 mrg break;
234 1.1 mrg case BELOW:
235 1.1 mrg bp->b_face = RIGHT;
236 1.1 mrg break;
237 1.1 mrg }
238 1.1 mrg Maze[y][x] = WALL4;
239 1.1 mrg # ifdef MONITOR
240 1.1 mrg for (pp = Monitor; pp < End_monitor; pp++)
241 1.1 mrg check(pp, y, x);
242 1.1 mrg # endif
243 1.1 mrg break;
244 1.1 mrg # endif
245 1.1 mrg # ifdef RANDOM
246 1.1 mrg case DOOR:
247 1.1 mrg switch (rand_num(4)) {
248 1.1 mrg case 0:
249 1.1 mrg bp->b_face = ABOVE;
250 1.1 mrg break;
251 1.1 mrg case 1:
252 1.1 mrg bp->b_face = BELOW;
253 1.1 mrg break;
254 1.1 mrg case 2:
255 1.1 mrg bp->b_face = LEFTS;
256 1.1 mrg break;
257 1.1 mrg case 3:
258 1.1 mrg bp->b_face = RIGHT;
259 1.1 mrg break;
260 1.1 mrg }
261 1.1 mrg break;
262 1.1 mrg # endif
263 1.1 mrg # ifdef FLY
264 1.1 mrg case FLYER:
265 1.1 mrg pp = play_at(y, x);
266 1.1 mrg message(pp, "Zing!");
267 1.1 mrg break;
268 1.1 mrg # endif
269 1.1 mrg case LEFTS:
270 1.1 mrg case RIGHT:
271 1.1 mrg case BELOW:
272 1.1 mrg case ABOVE:
273 1.1 mrg /*
274 1.1 mrg * give the person a chance to catch a
275 1.1 mrg * grenade if s/he is facing it
276 1.1 mrg */
277 1.1 mrg pp = play_at(y, x);
278 1.1 mrg pp->p_ident->i_shot += bp->b_charge;
279 1.1 mrg if (opposite(bp->b_face, Maze[y][x])) {
280 1.1 mrg if (rand_num(100) < 10) {
281 1.1 mrg if (bp->b_owner != NULL)
282 1.1 mrg message(bp->b_owner,
283 1.1 mrg "Your charge was absorbed!");
284 1.1 mrg if (bp->b_score != NULL)
285 1.1 mrg bp->b_score->i_robbed += bp->b_charge;
286 1.1 mrg pp->p_ammo += bp->b_charge;
287 1.1 mrg if (pp->p_damage + bp->b_size * MINDAM
288 1.1 mrg > pp->p_damcap)
289 1.1 mrg pp->p_ident->i_saved++;
290 1.1 mrg message(pp, "Absorbed charge (good shield!)");
291 1.1 mrg pp->p_ident->i_absorbed += bp->b_charge;
292 1.1 mrg free((char *) bp);
293 1.1 mrg (void) sprintf(Buf, "%3d", pp->p_ammo);
294 1.1 mrg cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
295 1.1 mrg outstr(pp, Buf, 3);
296 1.1 mrg return FALSE;
297 1.1 mrg }
298 1.1 mrg pp->p_ident->i_faced += bp->b_charge;
299 1.1 mrg }
300 1.1 mrg /*
301 1.1 mrg * Small chance that the bullet just misses the
302 1.1 mrg * person. If so, the bullet just goes on its
303 1.1 mrg * merry way without exploding.
304 1.1 mrg */
305 1.1 mrg if (rand_num(100) < 5) {
306 1.1 mrg pp->p_ident->i_ducked += bp->b_charge;
307 1.1 mrg if (pp->p_damage + bp->b_size * MINDAM
308 1.1 mrg > pp->p_damcap)
309 1.1 mrg pp->p_ident->i_saved++;
310 1.1 mrg if (bp->b_score != NULL)
311 1.1 mrg bp->b_score->i_missed += bp->b_charge;
312 1.1 mrg message(pp, "Zing!");
313 1.1 mrg if (bp->b_owner == NULL)
314 1.1 mrg break;
315 1.1 mrg message(bp->b_owner,
316 1.1 mrg ((bp->b_score->i_missed & 0x7) == 0x7) ?
317 1.1 mrg "My! What a bad shot you are!" :
318 1.1 mrg "Missed him");
319 1.1 mrg break;
320 1.1 mrg }
321 1.1 mrg /*
322 1.1 mrg * The shot hit that sucker! Blow it up.
323 1.1 mrg */
324 1.1 mrg /* FALLTHROUGH */
325 1.1 mrg # ifndef RANDOM
326 1.1 mrg case DOOR:
327 1.1 mrg # endif
328 1.1 mrg case WALL1:
329 1.1 mrg case WALL2:
330 1.1 mrg case WALL3:
331 1.1 mrg bp->b_expl = TRUE;
332 1.1 mrg break;
333 1.1 mrg }
334 1.1 mrg
335 1.1 mrg bp->b_x = x;
336 1.1 mrg bp->b_y = y;
337 1.1 mrg }
338 1.1 mrg return TRUE;
339 1.1 mrg }
340 1.1 mrg
341 1.1 mrg # ifdef DRONE
342 1.1 mrg /*
343 1.1 mrg * move_drone:
344 1.1 mrg * Move the drone to the next square
345 1.1 mrg */
346 1.1 mrg move_drone(bp)
347 1.1 mrg register BULLET *bp;
348 1.1 mrg {
349 1.1 mrg register int mask, count;
350 1.1 mrg register int n, dir;
351 1.1 mrg register PLAYER *pp;
352 1.1 mrg
353 1.1 mrg /*
354 1.1 mrg * See if we can give someone a blast
355 1.1 mrg */
356 1.1 mrg if (isplayer(Maze[bp->b_y][bp->b_x - 1])) {
357 1.1 mrg dir = WEST;
358 1.1 mrg goto drone_move;
359 1.1 mrg }
360 1.1 mrg if (isplayer(Maze[bp->b_y - 1][bp->b_x])) {
361 1.1 mrg dir = NORTH;
362 1.1 mrg goto drone_move;
363 1.1 mrg }
364 1.1 mrg if (isplayer(Maze[bp->b_y + 1][bp->b_x])) {
365 1.1 mrg dir = SOUTH;
366 1.1 mrg goto drone_move;
367 1.1 mrg }
368 1.1 mrg if (isplayer(Maze[bp->b_y][bp->b_x + 1])) {
369 1.1 mrg dir = EAST;
370 1.1 mrg goto drone_move;
371 1.1 mrg }
372 1.1 mrg
373 1.1 mrg /*
374 1.1 mrg * Find out what directions are clear
375 1.1 mrg */
376 1.1 mrg mask = count = 0;
377 1.1 mrg if (!iswall(bp->b_y, bp->b_x - 1))
378 1.1 mrg mask |= WEST, count++;
379 1.1 mrg if (!iswall(bp->b_y - 1, bp->b_x))
380 1.1 mrg mask |= NORTH, count++;
381 1.1 mrg if (!iswall(bp->b_y + 1, bp->b_x))
382 1.1 mrg mask |= SOUTH, count++;
383 1.1 mrg if (!iswall(bp->b_y, bp->b_x + 1))
384 1.1 mrg mask |= EAST, count++;
385 1.1 mrg
386 1.1 mrg /*
387 1.1 mrg * All blocked up, just you wait
388 1.1 mrg */
389 1.1 mrg if (count == 0)
390 1.1 mrg return TRUE;
391 1.1 mrg
392 1.1 mrg /*
393 1.1 mrg * Only one way to go.
394 1.1 mrg */
395 1.1 mrg if (count == 1) {
396 1.1 mrg dir = mask;
397 1.1 mrg goto drone_move;
398 1.1 mrg }
399 1.1 mrg
400 1.1 mrg /*
401 1.1 mrg * Get rid of the direction that we came from
402 1.1 mrg */
403 1.1 mrg switch (bp->b_face) {
404 1.1 mrg case LEFTS:
405 1.1 mrg if (mask & EAST)
406 1.1 mrg mask &= ~EAST, count--;
407 1.1 mrg break;
408 1.1 mrg case RIGHT:
409 1.1 mrg if (mask & WEST)
410 1.1 mrg mask &= ~WEST, count--;
411 1.1 mrg break;
412 1.1 mrg case ABOVE:
413 1.1 mrg if (mask & SOUTH)
414 1.1 mrg mask &= ~SOUTH, count--;
415 1.1 mrg break;
416 1.1 mrg case BELOW:
417 1.1 mrg if (mask & NORTH)
418 1.1 mrg mask &= ~NORTH, count--;
419 1.1 mrg break;
420 1.1 mrg }
421 1.1 mrg
422 1.1 mrg /*
423 1.1 mrg * Pick one of the remaining directions
424 1.1 mrg */
425 1.1 mrg n = rand_num(count);
426 1.1 mrg if (n >= 0 && mask & NORTH)
427 1.1 mrg dir = NORTH, n--;
428 1.1 mrg if (n >= 0 && mask & SOUTH)
429 1.1 mrg dir = SOUTH, n--;
430 1.1 mrg if (n >= 0 && mask & EAST)
431 1.1 mrg dir = EAST, n--;
432 1.1 mrg if (n >= 0 && mask & WEST)
433 1.1 mrg dir = WEST, n--;
434 1.1 mrg
435 1.1 mrg /*
436 1.1 mrg * Now that we know the direction of movement,
437 1.1 mrg * just update the position of the drone
438 1.1 mrg */
439 1.1 mrg drone_move:
440 1.1 mrg switch (dir) {
441 1.1 mrg case WEST:
442 1.1 mrg bp->b_x--;
443 1.1 mrg bp->b_face = LEFTS;
444 1.1 mrg break;
445 1.1 mrg case EAST:
446 1.1 mrg bp->b_x++;
447 1.1 mrg bp->b_face = RIGHT;
448 1.1 mrg break;
449 1.1 mrg case NORTH:
450 1.1 mrg bp->b_y--;
451 1.1 mrg bp->b_face = ABOVE;
452 1.1 mrg break;
453 1.1 mrg case SOUTH:
454 1.1 mrg bp->b_y++;
455 1.1 mrg bp->b_face = BELOW;
456 1.1 mrg break;
457 1.1 mrg }
458 1.1 mrg switch (Maze[bp->b_y][bp->b_x]) {
459 1.1 mrg case LEFTS:
460 1.1 mrg case RIGHT:
461 1.1 mrg case BELOW:
462 1.1 mrg case ABOVE:
463 1.1 mrg /*
464 1.1 mrg * give the person a chance to catch a
465 1.1 mrg * drone if s/he is facing it
466 1.1 mrg */
467 1.1 mrg if (rand_num(100) < 1 &&
468 1.1 mrg opposite(bp->b_face, Maze[bp->b_y][bp->b_x])) {
469 1.1 mrg pp = play_at(bp->b_y, bp->b_x);
470 1.1 mrg pp->p_ammo += bp->b_charge;
471 1.1 mrg message(pp, "**** Absorbed drone ****");
472 1.1 mrg free((char *) bp);
473 1.1 mrg (void) sprintf(Buf, "%3d", pp->p_ammo);
474 1.1 mrg cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
475 1.1 mrg outstr(pp, Buf, 3);
476 1.1 mrg return FALSE;
477 1.1 mrg }
478 1.1 mrg bp->b_expl = TRUE;
479 1.1 mrg break;
480 1.1 mrg }
481 1.1 mrg return TRUE;
482 1.1 mrg }
483 1.1 mrg # endif
484 1.1 mrg
485 1.1 mrg /*
486 1.1 mrg * save_bullet:
487 1.1 mrg * Put this bullet back onto the bullet list
488 1.1 mrg */
489 1.1 mrg save_bullet(bp)
490 1.1 mrg register BULLET *bp;
491 1.1 mrg {
492 1.1 mrg bp->b_over = Maze[bp->b_y][bp->b_x];
493 1.1 mrg switch (bp->b_over) {
494 1.1 mrg case SHOT:
495 1.1 mrg case GRENADE:
496 1.1 mrg case SATCHEL:
497 1.1 mrg case BOMB:
498 1.1 mrg # ifdef OOZE
499 1.1 mrg case SLIME:
500 1.1 mrg # ifdef VOLCANO
501 1.1 mrg case LAVA:
502 1.1 mrg # endif
503 1.1 mrg # endif
504 1.1 mrg # ifdef DRONE
505 1.1 mrg case DSHOT:
506 1.1 mrg # endif
507 1.1 mrg find_under(Bullets, bp);
508 1.1 mrg break;
509 1.1 mrg }
510 1.1 mrg
511 1.1 mrg switch (bp->b_over) {
512 1.1 mrg case LEFTS:
513 1.1 mrg case RIGHT:
514 1.1 mrg case ABOVE:
515 1.1 mrg case BELOW:
516 1.1 mrg # ifdef FLY
517 1.1 mrg case FLYER:
518 1.1 mrg # endif
519 1.1 mrg mark_player(bp);
520 1.1 mrg break;
521 1.1 mrg # ifdef BOOTS
522 1.1 mrg case BOOT:
523 1.1 mrg case BOOT_PAIR:
524 1.1 mrg mark_boot(bp);
525 1.1 mrg # endif
526 1.1 mrg
527 1.1 mrg default:
528 1.1 mrg Maze[bp->b_y][bp->b_x] = bp->b_type;
529 1.1 mrg break;
530 1.1 mrg }
531 1.1 mrg
532 1.1 mrg bp->b_next = Bullets;
533 1.1 mrg Bullets = bp;
534 1.1 mrg }
535 1.1 mrg
536 1.1 mrg /*
537 1.1 mrg * move_flyer:
538 1.1 mrg * Update the position of a player in flight
539 1.1 mrg */
540 1.1 mrg move_flyer(pp)
541 1.1 mrg register PLAYER *pp;
542 1.1 mrg {
543 1.1 mrg register int x, y;
544 1.1 mrg
545 1.1 mrg if (pp->p_undershot) {
546 1.1 mrg fixshots(pp->p_y, pp->p_x, pp->p_over);
547 1.1 mrg pp->p_undershot = FALSE;
548 1.1 mrg }
549 1.1 mrg Maze[pp->p_y][pp->p_x] = pp->p_over;
550 1.1 mrg x = pp->p_x + pp->p_flyx;
551 1.1 mrg y = pp->p_y + pp->p_flyy;
552 1.1 mrg if (x < 1) {
553 1.1 mrg x = 1 - x;
554 1.1 mrg pp->p_flyx = -pp->p_flyx;
555 1.1 mrg }
556 1.1 mrg else if (x > WIDTH - 2) {
557 1.1 mrg x = (WIDTH - 2) - (x - (WIDTH - 2));
558 1.1 mrg pp->p_flyx = -pp->p_flyx;
559 1.1 mrg }
560 1.1 mrg if (y < 1) {
561 1.1 mrg y = 1 - y;
562 1.1 mrg pp->p_flyy = -pp->p_flyy;
563 1.1 mrg }
564 1.1 mrg else if (y > HEIGHT - 2) {
565 1.1 mrg y = (HEIGHT - 2) - (y - (HEIGHT - 2));
566 1.1 mrg pp->p_flyy = -pp->p_flyy;
567 1.1 mrg }
568 1.1 mrg again:
569 1.1 mrg switch (Maze[y][x]) {
570 1.1 mrg default:
571 1.1 mrg switch (rand_num(4)) {
572 1.1 mrg case 0:
573 1.1 mrg PLUS_DELTA(x, WIDTH - 2);
574 1.1 mrg break;
575 1.1 mrg case 1:
576 1.1 mrg MINUS_DELTA(x, 1);
577 1.1 mrg break;
578 1.1 mrg case 2:
579 1.1 mrg PLUS_DELTA(y, HEIGHT - 2);
580 1.1 mrg break;
581 1.1 mrg case 3:
582 1.1 mrg MINUS_DELTA(y, 1);
583 1.1 mrg break;
584 1.1 mrg }
585 1.1 mrg goto again;
586 1.1 mrg case WALL1:
587 1.1 mrg case WALL2:
588 1.1 mrg case WALL3:
589 1.1 mrg # ifdef REFLECT
590 1.1 mrg case WALL4:
591 1.1 mrg case WALL5:
592 1.1 mrg # endif
593 1.1 mrg # ifdef RANDOM
594 1.1 mrg case DOOR:
595 1.1 mrg # endif
596 1.1 mrg if (pp->p_flying == 0)
597 1.1 mrg pp->p_flying++;
598 1.1 mrg break;
599 1.1 mrg case SPACE:
600 1.1 mrg break;
601 1.1 mrg }
602 1.1 mrg pp->p_y = y;
603 1.1 mrg pp->p_x = x;
604 1.1 mrg if (pp->p_flying-- == 0) {
605 1.1 mrg # ifdef BOOTS
606 1.1 mrg if (pp->p_face != BOOT && pp->p_face != BOOT_PAIR) {
607 1.1 mrg # endif
608 1.1 mrg checkdam(pp, (PLAYER *) NULL, (IDENT *) NULL,
609 1.1 mrg rand_num(pp->p_damage / 5), FALL);
610 1.1 mrg pp->p_face = rand_dir();
611 1.1 mrg showstat(pp);
612 1.1 mrg # ifdef BOOTS
613 1.1 mrg }
614 1.1 mrg else {
615 1.1 mrg if (Maze[y][x] == BOOT)
616 1.1 mrg pp->p_face = BOOT_PAIR;
617 1.1 mrg Maze[y][x] = SPACE;
618 1.1 mrg }
619 1.1 mrg # endif
620 1.1 mrg }
621 1.1 mrg pp->p_over = Maze[y][x];
622 1.1 mrg Maze[y][x] = pp->p_face;
623 1.1 mrg showexpl(y, x, pp->p_face);
624 1.1 mrg }
625 1.1 mrg
626 1.1 mrg /*
627 1.1 mrg * chkshot
628 1.1 mrg * Handle explosions
629 1.1 mrg */
630 1.1 mrg chkshot(bp, next)
631 1.1 mrg register BULLET *bp;
632 1.1 mrg BULLET *next;
633 1.1 mrg {
634 1.1 mrg register int y, x;
635 1.1 mrg register int dy, dx, absdy;
636 1.1 mrg register int delta, damage;
637 1.1 mrg register char expl;
638 1.1 mrg register PLAYER *pp;
639 1.1 mrg
640 1.1 mrg switch (bp->b_type) {
641 1.1 mrg case SHOT:
642 1.1 mrg case MINE:
643 1.1 mrg case GRENADE:
644 1.1 mrg case GMINE:
645 1.1 mrg case SATCHEL:
646 1.1 mrg case BOMB:
647 1.1 mrg delta = bp->b_size - 1;
648 1.1 mrg break;
649 1.1 mrg # ifdef OOZE
650 1.1 mrg case SLIME:
651 1.1 mrg # ifdef VOLCANO
652 1.1 mrg case LAVA:
653 1.1 mrg # endif
654 1.1 mrg chkslime(bp, next);
655 1.1 mrg return;
656 1.1 mrg # endif
657 1.1 mrg # ifdef DRONE
658 1.1 mrg case DSHOT:
659 1.1 mrg bp->b_type = SLIME;
660 1.1 mrg chkslime(bp, next);
661 1.1 mrg return;
662 1.1 mrg # endif
663 1.1 mrg }
664 1.1 mrg for (y = bp->b_y - delta; y <= bp->b_y + delta; y++) {
665 1.1 mrg if (y < 0 || y >= HEIGHT)
666 1.1 mrg continue;
667 1.1 mrg dy = y - bp->b_y;
668 1.1 mrg absdy = (dy < 0) ? -dy : dy;
669 1.1 mrg for (x = bp->b_x - delta; x <= bp->b_x + delta; x++) {
670 1.1 mrg if (x < 0 || x >= WIDTH)
671 1.1 mrg continue;
672 1.1 mrg dx = x - bp->b_x;
673 1.1 mrg if (dx == 0)
674 1.1 mrg expl = (dy == 0) ? '*' : '|';
675 1.1 mrg else if (dy == 0)
676 1.1 mrg expl = '-';
677 1.1 mrg else if (dx == dy)
678 1.1 mrg expl = '\\';
679 1.1 mrg else if (dx == -dy)
680 1.1 mrg expl = '/';
681 1.1 mrg else
682 1.1 mrg expl = '*';
683 1.1 mrg showexpl(y, x, expl);
684 1.1 mrg switch (Maze[y][x]) {
685 1.1 mrg case LEFTS:
686 1.1 mrg case RIGHT:
687 1.1 mrg case ABOVE:
688 1.1 mrg case BELOW:
689 1.1 mrg # ifdef FLY
690 1.1 mrg case FLYER:
691 1.1 mrg # endif
692 1.1 mrg if (dx < 0)
693 1.1 mrg dx = -dx;
694 1.1 mrg if (absdy > dx)
695 1.1 mrg damage = bp->b_size - absdy;
696 1.1 mrg else
697 1.1 mrg damage = bp->b_size - dx;
698 1.1 mrg pp = play_at(y, x);
699 1.1 mrg checkdam(pp, bp->b_owner, bp->b_score,
700 1.1 mrg damage * MINDAM, bp->b_type);
701 1.1 mrg break;
702 1.1 mrg case GMINE:
703 1.1 mrg case MINE:
704 1.1 mrg add_shot((Maze[y][x] == GMINE) ?
705 1.1 mrg GRENADE : SHOT,
706 1.1 mrg y, x, LEFTS,
707 1.1 mrg (Maze[y][x] == GMINE) ?
708 1.1 mrg GRENREQ : BULREQ,
709 1.1 mrg (PLAYER *) NULL, TRUE, SPACE);
710 1.1 mrg Maze[y][x] = SPACE;
711 1.1 mrg break;
712 1.1 mrg }
713 1.1 mrg }
714 1.1 mrg }
715 1.1 mrg }
716 1.1 mrg
717 1.1 mrg # ifdef OOZE
718 1.1 mrg /*
719 1.1 mrg * chkslime:
720 1.1 mrg * handle slime shot exploding
721 1.1 mrg */
722 1.1 mrg chkslime(bp, next)
723 1.1 mrg register BULLET *bp;
724 1.1 mrg BULLET *next;
725 1.1 mrg {
726 1.1 mrg register BULLET *nbp;
727 1.1 mrg
728 1.1 mrg switch (Maze[bp->b_y][bp->b_x]) {
729 1.1 mrg case WALL1:
730 1.1 mrg case WALL2:
731 1.1 mrg case WALL3:
732 1.1 mrg # ifdef REFLECT
733 1.1 mrg case WALL4:
734 1.1 mrg case WALL5:
735 1.1 mrg # endif
736 1.1 mrg # ifdef RANDOM
737 1.1 mrg case DOOR:
738 1.1 mrg # endif
739 1.1 mrg switch (bp->b_face) {
740 1.1 mrg case LEFTS:
741 1.1 mrg bp->b_x++;
742 1.1 mrg break;
743 1.1 mrg case RIGHT:
744 1.1 mrg bp->b_x--;
745 1.1 mrg break;
746 1.1 mrg case ABOVE:
747 1.1 mrg bp->b_y++;
748 1.1 mrg break;
749 1.1 mrg case BELOW:
750 1.1 mrg bp->b_y--;
751 1.1 mrg break;
752 1.1 mrg }
753 1.1 mrg break;
754 1.1 mrg }
755 1.1 mrg nbp = (BULLET *) malloc(sizeof (BULLET));
756 1.1 mrg *nbp = *bp;
757 1.1 mrg # ifdef VOLCANO
758 1.1 mrg move_slime(nbp, nbp->b_type == SLIME ? SLIMESPEED : LAVASPEED, next);
759 1.1 mrg # else
760 1.1 mrg move_slime(nbp, SLIMESPEED, next);
761 1.1 mrg # endif
762 1.1 mrg }
763 1.1 mrg
764 1.1 mrg /*
765 1.1 mrg * move_slime:
766 1.1 mrg * move the given slime shot speed times and add it back if
767 1.1 mrg * it hasn't fizzled yet
768 1.1 mrg */
769 1.1 mrg move_slime(bp, speed, next)
770 1.1 mrg register BULLET *bp;
771 1.1 mrg register int speed;
772 1.1 mrg BULLET *next;
773 1.1 mrg {
774 1.1 mrg register int i, j, dirmask, count;
775 1.1 mrg register PLAYER *pp;
776 1.1 mrg register BULLET *nbp;
777 1.1 mrg
778 1.1 mrg if (speed == 0) {
779 1.1 mrg if (bp->b_charge <= 0)
780 1.1 mrg free((char *) bp);
781 1.1 mrg else
782 1.1 mrg save_bullet(bp);
783 1.1 mrg return;
784 1.1 mrg }
785 1.1 mrg
786 1.1 mrg # ifdef VOLCANO
787 1.1 mrg showexpl(bp->b_y, bp->b_x, bp->b_type == LAVA ? LAVA : '*');
788 1.1 mrg # else
789 1.1 mrg showexpl(bp->b_y, bp->b_x, '*');
790 1.1 mrg # endif
791 1.1 mrg switch (Maze[bp->b_y][bp->b_x]) {
792 1.1 mrg case LEFTS:
793 1.1 mrg case RIGHT:
794 1.1 mrg case ABOVE:
795 1.1 mrg case BELOW:
796 1.1 mrg # ifdef FLY
797 1.1 mrg case FLYER:
798 1.1 mrg # endif
799 1.1 mrg pp = play_at(bp->b_y, bp->b_x);
800 1.1 mrg message(pp, "You've been slimed.");
801 1.1 mrg checkdam(pp, bp->b_owner, bp->b_score, MINDAM, bp->b_type);
802 1.1 mrg break;
803 1.1 mrg case SHOT:
804 1.1 mrg case GRENADE:
805 1.1 mrg case SATCHEL:
806 1.1 mrg case BOMB:
807 1.1 mrg # ifdef DRONE
808 1.1 mrg case DSHOT:
809 1.1 mrg # endif
810 1.1 mrg explshot(next, bp->b_y, bp->b_x);
811 1.1 mrg explshot(Bullets, bp->b_y, bp->b_x);
812 1.1 mrg break;
813 1.1 mrg }
814 1.1 mrg
815 1.1 mrg if (--bp->b_charge <= 0) {
816 1.1 mrg free((char *) bp);
817 1.1 mrg return;
818 1.1 mrg }
819 1.1 mrg
820 1.1 mrg dirmask = 0;
821 1.1 mrg count = 0;
822 1.1 mrg switch (bp->b_face) {
823 1.1 mrg case LEFTS:
824 1.1 mrg if (!iswall(bp->b_y, bp->b_x - 1))
825 1.1 mrg dirmask |= WEST, count++;
826 1.1 mrg if (!iswall(bp->b_y - 1, bp->b_x))
827 1.1 mrg dirmask |= NORTH, count++;
828 1.1 mrg if (!iswall(bp->b_y + 1, bp->b_x))
829 1.1 mrg dirmask |= SOUTH, count++;
830 1.1 mrg if (dirmask == 0)
831 1.1 mrg if (!iswall(bp->b_y, bp->b_x + 1))
832 1.1 mrg dirmask |= EAST, count++;
833 1.1 mrg break;
834 1.1 mrg case RIGHT:
835 1.1 mrg if (!iswall(bp->b_y, bp->b_x + 1))
836 1.1 mrg dirmask |= EAST, count++;
837 1.1 mrg if (!iswall(bp->b_y - 1, bp->b_x))
838 1.1 mrg dirmask |= NORTH, count++;
839 1.1 mrg if (!iswall(bp->b_y + 1, bp->b_x))
840 1.1 mrg dirmask |= SOUTH, count++;
841 1.1 mrg if (dirmask == 0)
842 1.1 mrg if (!iswall(bp->b_y, bp->b_x - 1))
843 1.1 mrg dirmask |= WEST, count++;
844 1.1 mrg break;
845 1.1 mrg case ABOVE:
846 1.1 mrg if (!iswall(bp->b_y - 1, bp->b_x))
847 1.1 mrg dirmask |= NORTH, count++;
848 1.1 mrg if (!iswall(bp->b_y, bp->b_x - 1))
849 1.1 mrg dirmask |= WEST, count++;
850 1.1 mrg if (!iswall(bp->b_y, bp->b_x + 1))
851 1.1 mrg dirmask |= EAST, count++;
852 1.1 mrg if (dirmask == 0)
853 1.1 mrg if (!iswall(bp->b_y + 1, bp->b_x))
854 1.1 mrg dirmask |= SOUTH, count++;
855 1.1 mrg break;
856 1.1 mrg case BELOW:
857 1.1 mrg if (!iswall(bp->b_y + 1, bp->b_x))
858 1.1 mrg dirmask |= SOUTH, count++;
859 1.1 mrg if (!iswall(bp->b_y, bp->b_x - 1))
860 1.1 mrg dirmask |= WEST, count++;
861 1.1 mrg if (!iswall(bp->b_y, bp->b_x + 1))
862 1.1 mrg dirmask |= EAST, count++;
863 1.1 mrg if (dirmask == 0)
864 1.1 mrg if (!iswall(bp->b_y - 1, bp->b_x))
865 1.1 mrg dirmask |= NORTH, count++;
866 1.1 mrg break;
867 1.1 mrg }
868 1.1 mrg if (count == 0) {
869 1.1 mrg /*
870 1.1 mrg * No place to go. Just sit here for a while and wait
871 1.1 mrg * for adjacent squares to clear out.
872 1.1 mrg */
873 1.1 mrg save_bullet(bp);
874 1.1 mrg return;
875 1.1 mrg }
876 1.1 mrg if (bp->b_charge < count) {
877 1.1 mrg /* Only bp->b_charge paths may be taken */
878 1.1 mrg while (count > bp->b_charge) {
879 1.1 mrg if (dirmask & WEST)
880 1.1 mrg dirmask &= ~WEST;
881 1.1 mrg else if (dirmask & EAST)
882 1.1 mrg dirmask &= ~EAST;
883 1.1 mrg else if (dirmask & NORTH)
884 1.1 mrg dirmask &= ~NORTH;
885 1.1 mrg else if (dirmask & SOUTH)
886 1.1 mrg dirmask &= ~SOUTH;
887 1.1 mrg count--;
888 1.1 mrg }
889 1.1 mrg }
890 1.1 mrg
891 1.1 mrg i = bp->b_charge / count;
892 1.1 mrg j = bp->b_charge % count;
893 1.1 mrg if (dirmask & WEST) {
894 1.1 mrg count--;
895 1.1 mrg nbp = create_shot(bp->b_type, bp->b_y, bp->b_x - 1, LEFTS,
896 1.1 mrg i, bp->b_size, bp->b_owner, bp->b_score, TRUE, SPACE);
897 1.1 mrg move_slime(nbp, speed - 1, next);
898 1.1 mrg }
899 1.1 mrg if (dirmask & EAST) {
900 1.1 mrg count--;
901 1.1 mrg nbp = create_shot(bp->b_type, bp->b_y, bp->b_x + 1, RIGHT,
902 1.1 mrg (count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
903 1.1 mrg bp->b_score, TRUE, SPACE);
904 1.1 mrg move_slime(nbp, speed - 1, next);
905 1.1 mrg }
906 1.1 mrg if (dirmask & NORTH) {
907 1.1 mrg count--;
908 1.1 mrg nbp = create_shot(bp->b_type, bp->b_y - 1, bp->b_x, ABOVE,
909 1.1 mrg (count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
910 1.1 mrg bp->b_score, TRUE, SPACE);
911 1.1 mrg move_slime(nbp, speed - 1, next);
912 1.1 mrg }
913 1.1 mrg if (dirmask & SOUTH) {
914 1.1 mrg count--;
915 1.1 mrg nbp = create_shot(bp->b_type, bp->b_y + 1, bp->b_x, BELOW,
916 1.1 mrg (count < j) ? i + 1 : i, bp->b_size, bp->b_owner,
917 1.1 mrg bp->b_score, TRUE, SPACE);
918 1.1 mrg move_slime(nbp, speed - 1, next);
919 1.1 mrg }
920 1.1 mrg
921 1.1 mrg free((char *) bp);
922 1.1 mrg }
923 1.1 mrg
924 1.1 mrg /*
925 1.1 mrg * iswall:
926 1.1 mrg * returns whether the given location is a wall
927 1.1 mrg */
928 1.1 mrg iswall(y, x)
929 1.1 mrg register int y, x;
930 1.1 mrg {
931 1.1 mrg if (y < 0 || x < 0 || y >= HEIGHT || x >= WIDTH)
932 1.1 mrg return TRUE;
933 1.1 mrg switch (Maze[y][x]) {
934 1.1 mrg case WALL1:
935 1.1 mrg case WALL2:
936 1.1 mrg case WALL3:
937 1.1 mrg # ifdef REFLECT
938 1.1 mrg case WALL4:
939 1.1 mrg case WALL5:
940 1.1 mrg # endif
941 1.1 mrg # ifdef RANDOM
942 1.1 mrg case DOOR:
943 1.1 mrg # endif
944 1.1 mrg # ifdef OOZE
945 1.1 mrg case SLIME:
946 1.1 mrg # ifdef VOLCANO
947 1.1 mrg case LAVA:
948 1.1 mrg # endif
949 1.1 mrg # endif
950 1.1 mrg return TRUE;
951 1.1 mrg }
952 1.1 mrg return FALSE;
953 1.1 mrg }
954 1.1 mrg # endif
955 1.1 mrg
956 1.1 mrg /*
957 1.1 mrg * zapshot:
958 1.1 mrg * Take a shot out of the air.
959 1.1 mrg */
960 1.1 mrg zapshot(blist, obp)
961 1.1 mrg register BULLET *blist, *obp;
962 1.1 mrg {
963 1.1 mrg register BULLET *bp;
964 1.1 mrg register FLAG explode;
965 1.1 mrg
966 1.1 mrg explode = FALSE;
967 1.1 mrg for (bp = blist; bp != NULL; bp = bp->b_next) {
968 1.1 mrg if (bp->b_x != obp->b_x || bp->b_y != obp->b_y)
969 1.1 mrg continue;
970 1.1 mrg if (bp->b_face == obp->b_face)
971 1.1 mrg continue;
972 1.1 mrg explode = TRUE;
973 1.1 mrg break;
974 1.1 mrg }
975 1.1 mrg if (!explode)
976 1.1 mrg return;
977 1.1 mrg explshot(blist, obp->b_y, obp->b_x);
978 1.1 mrg }
979 1.1 mrg
980 1.1 mrg /*
981 1.1 mrg * explshot -
982 1.1 mrg * Make all shots at this location blow up
983 1.1 mrg */
984 1.1 mrg explshot(blist, y, x)
985 1.1 mrg register BULLET *blist;
986 1.1 mrg register int y, x;
987 1.1 mrg {
988 1.1 mrg register BULLET *bp;
989 1.1 mrg
990 1.1 mrg for (bp = blist; bp != NULL; bp = bp->b_next)
991 1.1 mrg if (bp->b_x == x && bp->b_y == y) {
992 1.1 mrg bp->b_expl = TRUE;
993 1.1 mrg if (bp->b_owner != NULL)
994 1.1 mrg message(bp->b_owner, "Shot intercepted");
995 1.1 mrg }
996 1.1 mrg }
997 1.1 mrg
998 1.1 mrg /*
999 1.1 mrg * play_at:
1000 1.1 mrg * Return a pointer to the player at the given location
1001 1.1 mrg */
1002 1.1 mrg PLAYER *
1003 1.1 mrg play_at(y, x)
1004 1.1 mrg register int y, x;
1005 1.1 mrg {
1006 1.1 mrg register PLAYER *pp;
1007 1.1 mrg
1008 1.1 mrg for (pp = Player; pp < End_player; pp++)
1009 1.1 mrg if (pp->p_x == x && pp->p_y == y)
1010 1.1 mrg return pp;
1011 1.1 mrg fprintf(stderr, "driver: couldn't find player at (%d,%d)\n", x, y);
1012 1.1 mrg abort();
1013 1.1 mrg /* NOTREACHED */
1014 1.1 mrg }
1015 1.1 mrg
1016 1.1 mrg /*
1017 1.1 mrg * opposite:
1018 1.1 mrg * Return TRUE if the bullet direction faces the opposite direction
1019 1.1 mrg * of the player in the maze
1020 1.1 mrg */
1021 1.1 mrg opposite(face, dir)
1022 1.1 mrg int face;
1023 1.1 mrg char dir;
1024 1.1 mrg {
1025 1.1 mrg switch (face) {
1026 1.1 mrg case LEFTS:
1027 1.1 mrg return (dir == RIGHT);
1028 1.1 mrg case RIGHT:
1029 1.1 mrg return (dir == LEFTS);
1030 1.1 mrg case ABOVE:
1031 1.1 mrg return (dir == BELOW);
1032 1.1 mrg case BELOW:
1033 1.1 mrg return (dir == ABOVE);
1034 1.1 mrg default:
1035 1.1 mrg return FALSE;
1036 1.1 mrg }
1037 1.1 mrg }
1038 1.1 mrg
1039 1.1 mrg /*
1040 1.1 mrg * is_bullet:
1041 1.1 mrg * Is there a bullet at the given coordinates? If so, return
1042 1.1 mrg * a pointer to the bullet, otherwise return NULL
1043 1.1 mrg */
1044 1.1 mrg BULLET *
1045 1.1 mrg is_bullet(y, x)
1046 1.1 mrg register int y, x;
1047 1.1 mrg {
1048 1.1 mrg register BULLET *bp;
1049 1.1 mrg
1050 1.1 mrg for (bp = Bullets; bp != NULL; bp = bp->b_next)
1051 1.1 mrg if (bp->b_y == y && bp->b_x == x)
1052 1.1 mrg return bp;
1053 1.1 mrg return NULL;
1054 1.1 mrg }
1055 1.1 mrg
1056 1.1 mrg /*
1057 1.1 mrg * fixshots:
1058 1.1 mrg * change the underlying character of the shots at a location
1059 1.1 mrg * to the given character.
1060 1.1 mrg */
1061 1.1 mrg fixshots(y, x, over)
1062 1.1 mrg register int y, x;
1063 1.1 mrg char over;
1064 1.1 mrg {
1065 1.1 mrg register BULLET *bp;
1066 1.1 mrg
1067 1.1 mrg for (bp = Bullets; bp != NULL; bp = bp->b_next)
1068 1.1 mrg if (bp->b_y == y && bp->b_x == x)
1069 1.1 mrg bp->b_over = over;
1070 1.1 mrg }
1071 1.1 mrg
1072 1.1 mrg /*
1073 1.1 mrg * find_under:
1074 1.1 mrg * find the underlying character for a bullet when it lands
1075 1.1 mrg * on another bullet.
1076 1.1 mrg */
1077 1.1 mrg find_under(blist, bp)
1078 1.1 mrg register BULLET *blist, *bp;
1079 1.1 mrg {
1080 1.1 mrg register BULLET *nbp;
1081 1.1 mrg
1082 1.1 mrg for (nbp = blist; nbp != NULL; nbp = nbp->b_next)
1083 1.1 mrg if (bp->b_y == nbp->b_y && bp->b_x == nbp->b_x) {
1084 1.1 mrg bp->b_over = nbp->b_over;
1085 1.1 mrg break;
1086 1.1 mrg }
1087 1.1 mrg }
1088 1.1 mrg
1089 1.1 mrg /*
1090 1.1 mrg * mark_player:
1091 1.1 mrg * mark a player as under a shot
1092 1.1 mrg */
1093 1.1 mrg mark_player(bp)
1094 1.1 mrg register BULLET *bp;
1095 1.1 mrg {
1096 1.1 mrg register PLAYER *pp;
1097 1.1 mrg
1098 1.1 mrg for (pp = Player; pp < End_player; pp++)
1099 1.1 mrg if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) {
1100 1.1 mrg pp->p_undershot = TRUE;
1101 1.1 mrg break;
1102 1.1 mrg }
1103 1.1 mrg }
1104 1.1 mrg
1105 1.1 mrg # ifdef BOOTS
1106 1.1 mrg /*
1107 1.1 mrg * mark_boot:
1108 1.1 mrg * mark a boot as under a shot
1109 1.1 mrg */
1110 1.1 mrg mark_boot(bp)
1111 1.1 mrg register BULLET *bp;
1112 1.1 mrg {
1113 1.1 mrg register PLAYER *pp;
1114 1.1 mrg
1115 1.1 mrg for (pp = Boot; pp < &Boot[NBOOTS]; pp++)
1116 1.1 mrg if (pp->p_y == bp->b_y && pp->p_x == bp->b_x) {
1117 1.1 mrg pp->p_undershot = TRUE;
1118 1.1 mrg break;
1119 1.1 mrg }
1120 1.1 mrg }
1121 1.1 mrg # endif
1122