]>
git.cameronkatri.com Git - bsdgames-darwin.git/blob - hunt/huntd/execute.c
1 /* $NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 lukem Exp $ */
4 * Copyright (c) 1985 Conrad C. Huang, Gregory S. Couch, Kenneth C.R.C. Arnold
5 * San Francisco, California
10 __RCSID("$NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 lukem Exp $");
16 static void cloak
__P((PLAYER
*));
17 static void face
__P((PLAYER
*, int));
18 static void fire
__P((PLAYER
*, int));
19 static void fire_slime
__P((PLAYER
*, int));
20 static void move_player
__P((PLAYER
*, int));
21 static void pickup
__P((PLAYER
*, int, int, int, int));
22 static void scan
__P((PLAYER
*));
28 * Execute a single monitor command
36 ch
= pp
->p_cbuf
[pp
->p_ncount
++];
42 (void) strcpy(pp
->p_death
, "| Quit |");
50 * Execute a single command
58 ch
= pp
->p_cbuf
[pp
->p_ncount
++];
61 if (pp
->p_flying
>= 0) {
67 (void) strcpy(pp
->p_death
, "| Quit |");
79 move_player(pp
, LEFTS
);
85 move_player(pp
, BELOW
);
91 move_player(pp
, ABOVE
);
97 move_player(pp
, RIGHT
);
104 fire(pp
, 0); /* SHOT */
108 fire(pp
, 1); /* GRENADE */
112 fire(pp
, 2); /* SATCHEL */
116 fire(pp
, 3); /* 7x7 BOMB */
119 fire(pp
, 4); /* 9x9 BOMB */
122 fire(pp
, 5); /* 11x11 BOMB */
125 fire(pp
, 6); /* 13x13 BOMB */
128 fire(pp
, 7); /* 15x15 BOMB */
131 fire(pp
, 8); /* 17x17 BOMB */
134 fire(pp
, 9); /* 19x19 BOMB */
137 fire(pp
, 10); /* 21x21 BOMB */
141 fire_slime(pp
, 0); /* SLIME */
144 fire_slime(pp
, 1); /* SSLIME */
160 (void) strcpy(pp
->p_death
, "| Quit |");
167 * Execute a move in the given direction
198 switch (Maze
[y
][x
]) {
215 if (dir
== pp
->p_face
)
216 pickup(pp
, y
, x
, 2, Maze
[y
][x
]);
217 else if (opposite(dir
, pp
->p_face
))
218 pickup(pp
, y
, x
, 95, Maze
[y
][x
]);
220 pickup(pp
, y
, x
, 50, Maze
[y
][x
]);
234 bp
= is_bullet(y
, x
);
244 if (dir
!= pp
->p_face
)
247 newp
= play_at(y
, x
);
248 checkdam(newp
, pp
, pp
->p_ident
, STABDAM
, KNIFE
);
253 newp
= play_at(y
, x
);
254 message(newp
, "Oooh, there's a short guy waving at you!");
255 message(pp
, "You couldn't quite reach him!");
261 if (Maze
[y
][x
] == BOOT
)
265 for (newp
= Boot
; newp
< &Boot
[NBOOTS
]; newp
++) {
266 if (newp
->p_flying
< 0)
268 if (newp
->p_y
== y
&& newp
->p_x
== x
) {
270 if (newp
->p_undershot
)
271 fixshots(y
, x
, newp
->p_over
);
274 if (pp
->p_nboots
== 2)
275 message(pp
, "Wow! A pair of boots!");
277 message(pp
, "You can hobble around on one boot.");
284 if (pp
->p_ncshot
> 0)
285 if (--pp
->p_ncshot
== MAXNCSHOT
) {
286 cgoto(pp
, STAT_GUN_ROW
, STAT_VALUE_COL
);
287 outstr(pp
, " ok", 3);
289 if (pp
->p_undershot
) {
290 fixshots(pp
->p_y
, pp
->p_x
, pp
->p_over
);
291 pp
->p_undershot
= FALSE
;
293 drawplayer(pp
, FALSE
);
294 pp
->p_over
= Maze
[y
][x
];
297 drawplayer(pp
, TRUE
);
303 * Change the direction the player is facing
310 if (pp
->p_face
!= dir
) {
312 drawplayer(pp
, TRUE
);
318 * Fire a shot of the given type in the given direction
328 if (req_index
< 0 || req_index
>= MAXBOMB
)
329 message(pp
, "What you do?");
331 while (req_index
>= 0 && pp
->p_ammo
< shot_req
[req_index
])
334 message(pp
, "Not enough charges.");
337 if (pp
->p_ncshot
> MAXNCSHOT
)
339 if (pp
->p_ncshot
++ == MAXNCSHOT
) {
340 cgoto(pp
, STAT_GUN_ROW
, STAT_VALUE_COL
);
343 pp
->p_ammo
-= shot_req
[req_index
];
344 (void) sprintf(Buf
, "%3d", pp
->p_ammo
);
345 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);
348 add_shot(shot_type
[req_index
], pp
->p_y
, pp
->p_x
, pp
->p_face
,
349 shot_req
[req_index
], pp
, FALSE
, pp
->p_face
);
350 pp
->p_undershot
= TRUE
;
353 * Show the object to everyone
355 showexpl(pp
->p_y
, pp
->p_x
, shot_type
[req_index
]);
356 for (pp
= Player
; pp
< End_player
; pp
++)
357 sendcom(pp
, REFRESH
);
359 for (pp
= Monitor
; pp
< End_monitor
; pp
++)
360 sendcom(pp
, REFRESH
);
367 * Fire a slime shot in the given direction
370 fire_slime(pp
, req_index
)
377 if (req_index
< 0 || req_index
>= MAXSLIME
)
378 message(pp
, "What you do?");
380 while (req_index
>= 0 && pp
->p_ammo
< slime_req
[req_index
])
383 message(pp
, "Not enough charges.");
386 if (pp
->p_ncshot
> MAXNCSHOT
)
388 if (pp
->p_ncshot
++ == MAXNCSHOT
) {
389 cgoto(pp
, STAT_GUN_ROW
, STAT_VALUE_COL
);
392 pp
->p_ammo
-= slime_req
[req_index
];
393 (void) sprintf(Buf
, "%3d", pp
->p_ammo
);
394 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);
397 add_shot(SLIME
, pp
->p_y
, pp
->p_x
, pp
->p_face
,
398 slime_req
[req_index
] * SLIME_FACTOR
, pp
, FALSE
, pp
->p_face
);
399 pp
->p_undershot
= TRUE
;
402 * Show the object to everyone
404 showexpl(pp
->p_y
, pp
->p_x
, SLIME
);
405 for (pp
= Player
; pp
< End_player
; pp
++)
406 sendcom(pp
, REFRESH
);
408 for (pp
= Monitor
; pp
< End_monitor
; pp
++)
409 sendcom(pp
, REFRESH
);
416 * Create a shot with the given properties
419 add_shot(type
, y
, x
, face
, charge
, owner
, expl
, over
)
444 for (size
= 3; size
< MAXBOMB
; size
++)
445 if (shot_req
[size
] >= charge
)
454 bp
= create_shot(type
, y
, x
, face
, charge
, size
, owner
,
455 (owner
== NULL
) ? NULL
: owner
->p_ident
, expl
, over
);
456 bp
->b_next
= Bullets
;
461 create_shot(type
, y
, x
, face
, charge
, size
, owner
, score
, expl
, over
)
474 bp
= (BULLET
*) malloc(sizeof (BULLET
)); /* NOSTRICT */
477 message(owner
, "Out of memory");
484 bp
->b_charge
= charge
;
498 * Turn on or increase length of a cloak
504 if (pp
->p_ammo
<= 0) {
505 message(pp
, "No more charges");
509 if (pp
->p_nboots
> 0) {
510 message(pp
, "Boots are too noisy to cloak!");
514 (void) sprintf(Buf
, "%3d", --pp
->p_ammo
);
515 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);
518 pp
->p_cloak
+= CLOAKLEN
;
528 * Turn on or increase length of a scan
534 if (pp
->p_ammo
<= 0) {
535 message(pp
, "No more charges");
538 (void) sprintf(Buf
, "%3d", --pp
->p_ammo
);
539 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);
542 pp
->p_scan
+= SCANLEN
;
544 if (pp
->p_cloak
>= 0)
552 * check whether the object blew up or whether he picked it up
555 pickup(pp
, y
, x
, prob
, obj
)
573 if (rand_num(100) < prob
)
574 add_shot(obj
, y
, x
, LEFTS
, req
, (PLAYER
*) NULL
,
578 (void) sprintf(Buf
, "%3d", pp
->p_ammo
);
579 cgoto(pp
, STAT_AMMO_ROW
, STAT_VALUE_COL
);