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