Home | History | Annotate | Line # | Download | only in huntd
execute.c revision 1.2
      1  1.2  lukem /*	$NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 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.2  lukem __RCSID("$NetBSD: execute.c,v 1.2 1997/10/10 16:33:13 lukem Exp $");
     11  1.2  lukem #endif /* not lint */
     12  1.2  lukem 
     13  1.2  lukem # include	<stdlib.h>
     14  1.1    mrg # include	"hunt.h"
     15  1.1    mrg 
     16  1.2  lukem static	void	cloak __P((PLAYER *));
     17  1.2  lukem static	void	face __P((PLAYER *, int));
     18  1.2  lukem static	void	fire __P((PLAYER *, int));
     19  1.2  lukem static	void	fire_slime __P((PLAYER *, int));
     20  1.2  lukem static	void	move_player __P((PLAYER *, int));
     21  1.2  lukem static	void	pickup __P((PLAYER *, int, int, int, int));
     22  1.2  lukem static	void	scan __P((PLAYER *));
     23  1.2  lukem 
     24  1.2  lukem 
     25  1.1    mrg # ifdef MONITOR
     26  1.1    mrg /*
     27  1.1    mrg  * mon_execute:
     28  1.1    mrg  *	Execute a single monitor command
     29  1.1    mrg  */
     30  1.2  lukem void
     31  1.1    mrg mon_execute(pp)
     32  1.2  lukem 	PLAYER	*pp;
     33  1.1    mrg {
     34  1.2  lukem 	char	ch;
     35  1.1    mrg 
     36  1.1    mrg 	ch = pp->p_cbuf[pp->p_ncount++];
     37  1.1    mrg 	switch (ch) {
     38  1.1    mrg 	  case CTRL('L'):
     39  1.1    mrg 		sendcom(pp, REDRAW);
     40  1.1    mrg 		break;
     41  1.1    mrg 	  case 'q':
     42  1.1    mrg 		(void) strcpy(pp->p_death, "| Quit |");
     43  1.1    mrg 		break;
     44  1.1    mrg 	}
     45  1.1    mrg }
     46  1.1    mrg # endif
     47  1.1    mrg 
     48  1.1    mrg /*
     49  1.1    mrg  * execute:
     50  1.1    mrg  *	Execute a single command
     51  1.1    mrg  */
     52  1.2  lukem void
     53  1.1    mrg execute(pp)
     54  1.2  lukem 	PLAYER	*pp;
     55  1.1    mrg {
     56  1.2  lukem 	char	ch;
     57  1.1    mrg 
     58  1.1    mrg 	ch = pp->p_cbuf[pp->p_ncount++];
     59  1.1    mrg 
     60  1.1    mrg # ifdef	FLY
     61  1.1    mrg 	if (pp->p_flying >= 0) {
     62  1.1    mrg 		switch (ch) {
     63  1.1    mrg 		  case CTRL('L'):
     64  1.1    mrg 			sendcom(pp, REDRAW);
     65  1.1    mrg 			break;
     66  1.1    mrg 		  case 'q':
     67  1.1    mrg 			(void) strcpy(pp->p_death, "| Quit |");
     68  1.1    mrg 			break;
     69  1.1    mrg 		}
     70  1.1    mrg 		return;
     71  1.1    mrg 	}
     72  1.1    mrg # endif
     73  1.1    mrg 
     74  1.1    mrg 	switch (ch) {
     75  1.1    mrg 	  case CTRL('L'):
     76  1.1    mrg 		sendcom(pp, REDRAW);
     77  1.1    mrg 		break;
     78  1.1    mrg 	  case 'h':
     79  1.1    mrg 		move_player(pp, LEFTS);
     80  1.1    mrg 		break;
     81  1.1    mrg 	  case 'H':
     82  1.1    mrg 		face(pp, LEFTS);
     83  1.1    mrg 		break;
     84  1.1    mrg 	  case 'j':
     85  1.1    mrg 		move_player(pp, BELOW);
     86  1.1    mrg 		break;
     87  1.1    mrg 	  case 'J':
     88  1.1    mrg 		face(pp, BELOW);
     89  1.1    mrg 		break;
     90  1.1    mrg 	  case 'k':
     91  1.1    mrg 		move_player(pp, ABOVE);
     92  1.1    mrg 		break;
     93  1.1    mrg 	  case 'K':
     94  1.1    mrg 		face(pp, ABOVE);
     95  1.1    mrg 		break;
     96  1.1    mrg 	  case 'l':
     97  1.1    mrg 		move_player(pp, RIGHT);
     98  1.1    mrg 		break;
     99  1.1    mrg 	  case 'L':
    100  1.1    mrg 		face(pp, RIGHT);
    101  1.1    mrg 		break;
    102  1.1    mrg 	  case 'f':
    103  1.1    mrg 	  case '1':
    104  1.1    mrg 		fire(pp, 0);		/* SHOT */
    105  1.1    mrg 		break;
    106  1.1    mrg 	  case 'g':
    107  1.1    mrg 	  case '2':
    108  1.1    mrg 		fire(pp, 1);		/* GRENADE */
    109  1.1    mrg 		break;
    110  1.1    mrg 	  case 'F':
    111  1.1    mrg 	  case '3':
    112  1.1    mrg 		fire(pp, 2);		/* SATCHEL */
    113  1.1    mrg 		break;
    114  1.1    mrg 	  case 'G':
    115  1.1    mrg 	  case '4':
    116  1.1    mrg 		fire(pp, 3);		/* 7x7 BOMB */
    117  1.1    mrg 		break;
    118  1.1    mrg 	  case '5':
    119  1.1    mrg 		fire(pp, 4);		/* 9x9 BOMB */
    120  1.1    mrg 		break;
    121  1.1    mrg 	  case '6':
    122  1.1    mrg 		fire(pp, 5);		/* 11x11 BOMB */
    123  1.1    mrg 		break;
    124  1.1    mrg 	  case '7':
    125  1.1    mrg 		fire(pp, 6);		/* 13x13 BOMB */
    126  1.1    mrg 		break;
    127  1.1    mrg 	  case '8':
    128  1.1    mrg 		fire(pp, 7);		/* 15x15 BOMB */
    129  1.1    mrg 		break;
    130  1.1    mrg 	  case '9':
    131  1.1    mrg 		fire(pp, 8);		/* 17x17 BOMB */
    132  1.1    mrg 		break;
    133  1.1    mrg 	  case '0':
    134  1.1    mrg 		fire(pp, 9);		/* 19x19 BOMB */
    135  1.1    mrg 		break;
    136  1.1    mrg 	  case '@':
    137  1.1    mrg 		fire(pp, 10);		/* 21x21 BOMB */
    138  1.1    mrg 		break;
    139  1.1    mrg # ifdef	OOZE
    140  1.1    mrg 	  case 'o':
    141  1.1    mrg 		fire_slime(pp, 0);	/* SLIME */
    142  1.1    mrg 		break;
    143  1.1    mrg 	  case 'O':
    144  1.1    mrg 		fire_slime(pp, 1);	/* SSLIME */
    145  1.1    mrg 		break;
    146  1.1    mrg 	  case 'p':
    147  1.1    mrg 		fire_slime(pp, 2);
    148  1.1    mrg 		break;
    149  1.1    mrg 	  case 'P':
    150  1.1    mrg 		fire_slime(pp, 3);
    151  1.1    mrg 		break;
    152  1.1    mrg # endif
    153  1.1    mrg 	  case 's':
    154  1.1    mrg 		scan(pp);
    155  1.1    mrg 		break;
    156  1.1    mrg 	  case 'c':
    157  1.1    mrg 		cloak(pp);
    158  1.1    mrg 		break;
    159  1.1    mrg 	  case 'q':
    160  1.1    mrg 		(void) strcpy(pp->p_death, "| Quit |");
    161  1.1    mrg 		break;
    162  1.1    mrg 	}
    163  1.1    mrg }
    164  1.1    mrg 
    165  1.1    mrg /*
    166  1.1    mrg  * move_player:
    167  1.1    mrg  *	Execute a move in the given direction
    168  1.1    mrg  */
    169  1.2  lukem static void
    170  1.1    mrg move_player(pp, dir)
    171  1.2  lukem 	PLAYER	*pp;
    172  1.2  lukem 	int	dir;
    173  1.1    mrg {
    174  1.2  lukem 	PLAYER	*newp;
    175  1.2  lukem 	int	x, y;
    176  1.2  lukem 	FLAG	moved;
    177  1.2  lukem 	BULLET	*bp;
    178  1.1    mrg 
    179  1.1    mrg 	y = pp->p_y;
    180  1.1    mrg 	x = pp->p_x;
    181  1.1    mrg 
    182  1.1    mrg 	switch (dir) {
    183  1.1    mrg 	  case LEFTS:
    184  1.1    mrg 		x--;
    185  1.1    mrg 		break;
    186  1.1    mrg 	  case RIGHT:
    187  1.1    mrg 		x++;
    188  1.1    mrg 		break;
    189  1.1    mrg 	  case ABOVE:
    190  1.1    mrg 		y--;
    191  1.1    mrg 		break;
    192  1.1    mrg 	  case BELOW:
    193  1.1    mrg 		y++;
    194  1.1    mrg 		break;
    195  1.1    mrg 	}
    196  1.1    mrg 
    197  1.1    mrg 	moved = FALSE;
    198  1.1    mrg 	switch (Maze[y][x]) {
    199  1.1    mrg 	  case SPACE:
    200  1.1    mrg # ifdef RANDOM
    201  1.1    mrg 	  case DOOR:
    202  1.1    mrg # endif
    203  1.1    mrg 		moved = TRUE;
    204  1.1    mrg 		break;
    205  1.1    mrg 	  case WALL1:
    206  1.1    mrg 	  case WALL2:
    207  1.1    mrg 	  case WALL3:
    208  1.1    mrg # ifdef REFLECT
    209  1.1    mrg 	  case WALL4:
    210  1.1    mrg 	  case WALL5:
    211  1.1    mrg # endif
    212  1.1    mrg 		break;
    213  1.1    mrg 	  case MINE:
    214  1.1    mrg 	  case GMINE:
    215  1.1    mrg 		if (dir == pp->p_face)
    216  1.1    mrg 			pickup(pp, y, x, 2, Maze[y][x]);
    217  1.1    mrg 		else if (opposite(dir, pp->p_face))
    218  1.1    mrg 			pickup(pp, y, x, 95, Maze[y][x]);
    219  1.1    mrg 		else
    220  1.1    mrg 			pickup(pp, y, x, 50, Maze[y][x]);
    221  1.1    mrg 		Maze[y][x] = SPACE;
    222  1.1    mrg 		moved = TRUE;
    223  1.1    mrg 		break;
    224  1.1    mrg 	  case SHOT:
    225  1.1    mrg 	  case GRENADE:
    226  1.1    mrg 	  case SATCHEL:
    227  1.1    mrg 	  case BOMB:
    228  1.1    mrg # ifdef OOZE
    229  1.1    mrg 	  case SLIME:
    230  1.1    mrg # endif
    231  1.1    mrg # ifdef DRONE
    232  1.1    mrg 	  case DSHOT:
    233  1.1    mrg # endif
    234  1.1    mrg 		bp = is_bullet(y, x);
    235  1.1    mrg 		if (bp != NULL)
    236  1.1    mrg 			bp->b_expl = TRUE;
    237  1.1    mrg 		Maze[y][x] = SPACE;
    238  1.1    mrg 		moved = TRUE;
    239  1.1    mrg 		break;
    240  1.1    mrg 	  case LEFTS:
    241  1.1    mrg 	  case RIGHT:
    242  1.1    mrg 	  case ABOVE:
    243  1.1    mrg 	  case BELOW:
    244  1.1    mrg 		if (dir != pp->p_face)
    245  1.1    mrg 			sendcom(pp, BELL);
    246  1.1    mrg 		else {
    247  1.1    mrg 			newp = play_at(y, x);
    248  1.1    mrg 			checkdam(newp, pp, pp->p_ident, STABDAM, KNIFE);
    249  1.1    mrg 		}
    250  1.1    mrg 		break;
    251  1.1    mrg # ifdef FLY
    252  1.1    mrg 	  case FLYER:
    253  1.1    mrg 		newp = play_at(y, x);
    254  1.1    mrg 		message(newp, "Oooh, there's a short guy waving at you!");
    255  1.1    mrg 		message(pp, "You couldn't quite reach him!");
    256  1.1    mrg 		break;
    257  1.1    mrg # endif
    258  1.1    mrg # ifdef BOOTS
    259  1.1    mrg 	  case BOOT:
    260  1.1    mrg 	  case BOOT_PAIR:
    261  1.1    mrg 		if (Maze[y][x] == BOOT)
    262  1.1    mrg 			pp->p_nboots++;
    263  1.1    mrg 		else
    264  1.1    mrg 			pp->p_nboots += 2;
    265  1.1    mrg 		for (newp = Boot; newp < &Boot[NBOOTS]; newp++) {
    266  1.1    mrg 			if (newp->p_flying < 0)
    267  1.1    mrg 				continue;
    268  1.1    mrg 			if (newp->p_y == y && newp->p_x == x) {
    269  1.1    mrg 				newp->p_flying = -1;
    270  1.1    mrg 				if (newp->p_undershot)
    271  1.1    mrg 					fixshots(y, x, newp->p_over);
    272  1.1    mrg 			}
    273  1.1    mrg 		}
    274  1.1    mrg 		if (pp->p_nboots == 2)
    275  1.1    mrg 			message(pp, "Wow!  A pair of boots!");
    276  1.1    mrg 		else
    277  1.1    mrg 			message(pp, "You can hobble around on one boot.");
    278  1.1    mrg 		Maze[y][x] = SPACE;
    279  1.1    mrg 		moved = TRUE;
    280  1.1    mrg 		break;
    281  1.1    mrg # endif
    282  1.1    mrg 	}
    283  1.1    mrg 	if (moved) {
    284  1.1    mrg 		if (pp->p_ncshot > 0)
    285  1.1    mrg 			if (--pp->p_ncshot == MAXNCSHOT) {
    286  1.1    mrg 				cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
    287  1.1    mrg 				outstr(pp, " ok", 3);
    288  1.1    mrg 			}
    289  1.1    mrg 		if (pp->p_undershot) {
    290  1.1    mrg 			fixshots(pp->p_y, pp->p_x, pp->p_over);
    291  1.1    mrg 			pp->p_undershot = FALSE;
    292  1.1    mrg 		}
    293  1.1    mrg 		drawplayer(pp, FALSE);
    294  1.1    mrg 		pp->p_over = Maze[y][x];
    295  1.1    mrg 		pp->p_y = y;
    296  1.1    mrg 		pp->p_x = x;
    297  1.1    mrg 		drawplayer(pp, TRUE);
    298  1.1    mrg 	}
    299  1.1    mrg }
    300  1.1    mrg 
    301  1.1    mrg /*
    302  1.1    mrg  * face:
    303  1.1    mrg  *	Change the direction the player is facing
    304  1.1    mrg  */
    305  1.2  lukem static void
    306  1.1    mrg face(pp, dir)
    307  1.2  lukem 	PLAYER	*pp;
    308  1.2  lukem 	int	dir;
    309  1.1    mrg {
    310  1.1    mrg 	if (pp->p_face != dir) {
    311  1.1    mrg 		pp->p_face = dir;
    312  1.1    mrg 		drawplayer(pp, TRUE);
    313  1.1    mrg 	}
    314  1.1    mrg }
    315  1.1    mrg 
    316  1.1    mrg /*
    317  1.1    mrg  * fire:
    318  1.1    mrg  *	Fire a shot of the given type in the given direction
    319  1.1    mrg  */
    320  1.2  lukem static void
    321  1.1    mrg fire(pp, req_index)
    322  1.2  lukem 	PLAYER	*pp;
    323  1.2  lukem 	int	req_index;
    324  1.1    mrg {
    325  1.1    mrg 	if (pp == NULL)
    326  1.1    mrg 		return;
    327  1.1    mrg # ifdef DEBUG
    328  1.1    mrg 	if (req_index < 0 || req_index >= MAXBOMB)
    329  1.1    mrg 		message(pp, "What you do?");
    330  1.1    mrg # endif
    331  1.1    mrg 	while (req_index >= 0 && pp->p_ammo < shot_req[req_index])
    332  1.1    mrg 		req_index--;
    333  1.1    mrg 	if (req_index < 0) {
    334  1.1    mrg 		message(pp, "Not enough charges.");
    335  1.1    mrg 		return;
    336  1.1    mrg 	}
    337  1.1    mrg 	if (pp->p_ncshot > MAXNCSHOT)
    338  1.1    mrg 		return;
    339  1.1    mrg 	if (pp->p_ncshot++ == MAXNCSHOT) {
    340  1.1    mrg 		cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
    341  1.1    mrg 		outstr(pp, "   ", 3);
    342  1.1    mrg 	}
    343  1.1    mrg 	pp->p_ammo -= shot_req[req_index];
    344  1.1    mrg 	(void) sprintf(Buf, "%3d", pp->p_ammo);
    345  1.1    mrg 	cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    346  1.1    mrg 	outstr(pp, Buf, 3);
    347  1.1    mrg 
    348  1.1    mrg 	add_shot(shot_type[req_index], pp->p_y, pp->p_x, pp->p_face,
    349  1.1    mrg 		shot_req[req_index], pp, FALSE, pp->p_face);
    350  1.1    mrg 	pp->p_undershot = TRUE;
    351  1.1    mrg 
    352  1.1    mrg 	/*
    353  1.1    mrg 	 * Show the object to everyone
    354  1.1    mrg 	 */
    355  1.1    mrg 	showexpl(pp->p_y, pp->p_x, shot_type[req_index]);
    356  1.1    mrg 	for (pp = Player; pp < End_player; pp++)
    357  1.1    mrg 		sendcom(pp, REFRESH);
    358  1.1    mrg # ifdef MONITOR
    359  1.1    mrg 	for (pp = Monitor; pp < End_monitor; pp++)
    360  1.1    mrg 		sendcom(pp, REFRESH);
    361  1.1    mrg # endif
    362  1.1    mrg }
    363  1.1    mrg 
    364  1.1    mrg # ifdef	OOZE
    365  1.1    mrg /*
    366  1.1    mrg  * fire_slime:
    367  1.1    mrg  *	Fire a slime shot in the given direction
    368  1.1    mrg  */
    369  1.2  lukem static void
    370  1.1    mrg fire_slime(pp, req_index)
    371  1.2  lukem 	PLAYER	*pp;
    372  1.2  lukem 	int	req_index;
    373  1.1    mrg {
    374  1.1    mrg 	if (pp == NULL)
    375  1.1    mrg 		return;
    376  1.1    mrg # ifdef DEBUG
    377  1.1    mrg 	if (req_index < 0 || req_index >= MAXSLIME)
    378  1.1    mrg 		message(pp, "What you do?");
    379  1.1    mrg # endif
    380  1.1    mrg 	while (req_index >= 0 && pp->p_ammo < slime_req[req_index])
    381  1.1    mrg 		req_index--;
    382  1.1    mrg 	if (req_index < 0) {
    383  1.1    mrg 		message(pp, "Not enough charges.");
    384  1.1    mrg 		return;
    385  1.1    mrg 	}
    386  1.1    mrg 	if (pp->p_ncshot > MAXNCSHOT)
    387  1.1    mrg 		return;
    388  1.1    mrg 	if (pp->p_ncshot++ == MAXNCSHOT) {
    389  1.1    mrg 		cgoto(pp, STAT_GUN_ROW, STAT_VALUE_COL);
    390  1.1    mrg 		outstr(pp, "   ", 3);
    391  1.1    mrg 	}
    392  1.1    mrg 	pp->p_ammo -= slime_req[req_index];
    393  1.1    mrg 	(void) sprintf(Buf, "%3d", pp->p_ammo);
    394  1.1    mrg 	cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    395  1.1    mrg 	outstr(pp, Buf, 3);
    396  1.1    mrg 
    397  1.1    mrg 	add_shot(SLIME, pp->p_y, pp->p_x, pp->p_face,
    398  1.1    mrg 		slime_req[req_index] * SLIME_FACTOR, pp, FALSE, pp->p_face);
    399  1.1    mrg 	pp->p_undershot = TRUE;
    400  1.1    mrg 
    401  1.1    mrg 	/*
    402  1.1    mrg 	 * Show the object to everyone
    403  1.1    mrg 	 */
    404  1.1    mrg 	showexpl(pp->p_y, pp->p_x, SLIME);
    405  1.1    mrg 	for (pp = Player; pp < End_player; pp++)
    406  1.1    mrg 		sendcom(pp, REFRESH);
    407  1.1    mrg # ifdef MONITOR
    408  1.1    mrg 	for (pp = Monitor; pp < End_monitor; pp++)
    409  1.1    mrg 		sendcom(pp, REFRESH);
    410  1.1    mrg # endif
    411  1.1    mrg }
    412  1.1    mrg # endif
    413  1.1    mrg 
    414  1.1    mrg /*
    415  1.1    mrg  * add_shot:
    416  1.1    mrg  *	Create a shot with the given properties
    417  1.1    mrg  */
    418  1.2  lukem void
    419  1.1    mrg add_shot(type, y, x, face, charge, owner, expl, over)
    420  1.1    mrg int	type;
    421  1.1    mrg int	y, x;
    422  1.1    mrg char	face;
    423  1.1    mrg int	charge;
    424  1.1    mrg PLAYER	*owner;
    425  1.1    mrg int	expl;
    426  1.1    mrg char	over;
    427  1.1    mrg {
    428  1.2  lukem 	BULLET	*bp;
    429  1.2  lukem 	int	size;
    430  1.1    mrg 
    431  1.1    mrg 	switch (type) {
    432  1.1    mrg 	  case SHOT:
    433  1.1    mrg 	  case MINE:
    434  1.1    mrg 		size = 1;
    435  1.1    mrg 		break;
    436  1.1    mrg 	  case GRENADE:
    437  1.1    mrg 	  case GMINE:
    438  1.1    mrg 		size = 2;
    439  1.1    mrg 		break;
    440  1.1    mrg 	  case SATCHEL:
    441  1.1    mrg 		size = 3;
    442  1.1    mrg 		break;
    443  1.1    mrg 	  case BOMB:
    444  1.1    mrg 		for (size = 3; size < MAXBOMB; size++)
    445  1.1    mrg 			if (shot_req[size] >= charge)
    446  1.1    mrg 				break;
    447  1.1    mrg 		size++;
    448  1.1    mrg 		break;
    449  1.1    mrg 	  default:
    450  1.1    mrg 		size = 0;
    451  1.1    mrg 		break;
    452  1.1    mrg 	}
    453  1.1    mrg 
    454  1.1    mrg 	bp = create_shot(type, y, x, face, charge, size, owner,
    455  1.1    mrg 		(owner == NULL) ? NULL : owner->p_ident, expl, over);
    456  1.1    mrg 	bp->b_next = Bullets;
    457  1.1    mrg 	Bullets = bp;
    458  1.1    mrg }
    459  1.1    mrg 
    460  1.1    mrg BULLET *
    461  1.1    mrg create_shot(type, y, x, face, charge, size, owner, score, expl, over)
    462  1.2  lukem 	int	type;
    463  1.2  lukem 	int	y, x;
    464  1.2  lukem 	char	face;
    465  1.2  lukem 	int	charge;
    466  1.2  lukem 	int	size;
    467  1.2  lukem 	PLAYER	*owner;
    468  1.2  lukem 	IDENT	*score;
    469  1.2  lukem 	int	expl;
    470  1.2  lukem 	char	over;
    471  1.1    mrg {
    472  1.2  lukem 	BULLET	*bp;
    473  1.1    mrg 
    474  1.1    mrg 	bp = (BULLET *) malloc(sizeof (BULLET));	/* NOSTRICT */
    475  1.1    mrg 	if (bp == NULL) {
    476  1.1    mrg 		if (owner != NULL)
    477  1.1    mrg 			message(owner, "Out of memory");
    478  1.1    mrg 		return NULL;
    479  1.1    mrg 	}
    480  1.1    mrg 
    481  1.1    mrg 	bp->b_face = face;
    482  1.1    mrg 	bp->b_x = x;
    483  1.1    mrg 	bp->b_y = y;
    484  1.1    mrg 	bp->b_charge = charge;
    485  1.1    mrg 	bp->b_owner = owner;
    486  1.1    mrg 	bp->b_score = score;
    487  1.1    mrg 	bp->b_type = type;
    488  1.1    mrg 	bp->b_size = size;
    489  1.1    mrg 	bp->b_expl = expl;
    490  1.1    mrg 	bp->b_over = over;
    491  1.1    mrg 	bp->b_next = NULL;
    492  1.1    mrg 
    493  1.1    mrg 	return bp;
    494  1.1    mrg }
    495  1.1    mrg 
    496  1.1    mrg /*
    497  1.1    mrg  * cloak:
    498  1.1    mrg  *	Turn on or increase length of a cloak
    499  1.1    mrg  */
    500  1.2  lukem static void
    501  1.1    mrg cloak(pp)
    502  1.2  lukem 	PLAYER	*pp;
    503  1.1    mrg {
    504  1.1    mrg 	if (pp->p_ammo <= 0) {
    505  1.1    mrg 		message(pp, "No more charges");
    506  1.1    mrg 		return;
    507  1.1    mrg 	}
    508  1.1    mrg # ifdef BOOTS
    509  1.1    mrg 	if (pp->p_nboots > 0) {
    510  1.1    mrg 		message(pp, "Boots are too noisy to cloak!");
    511  1.1    mrg 		return;
    512  1.1    mrg 	}
    513  1.1    mrg # endif
    514  1.1    mrg 	(void) sprintf(Buf, "%3d", --pp->p_ammo);
    515  1.1    mrg 	cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    516  1.1    mrg 	outstr(pp, Buf, 3);
    517  1.1    mrg 
    518  1.1    mrg 	pp->p_cloak += CLOAKLEN;
    519  1.1    mrg 
    520  1.1    mrg 	if (pp->p_scan >= 0)
    521  1.1    mrg 		pp->p_scan = -1;
    522  1.1    mrg 
    523  1.1    mrg 	showstat(pp);
    524  1.1    mrg }
    525  1.1    mrg 
    526  1.1    mrg /*
    527  1.1    mrg  * scan:
    528  1.1    mrg  *	Turn on or increase length of a scan
    529  1.1    mrg  */
    530  1.2  lukem static void
    531  1.1    mrg scan(pp)
    532  1.2  lukem 	PLAYER	*pp;
    533  1.1    mrg {
    534  1.1    mrg 	if (pp->p_ammo <= 0) {
    535  1.1    mrg 		message(pp, "No more charges");
    536  1.1    mrg 		return;
    537  1.1    mrg 	}
    538  1.1    mrg 	(void) sprintf(Buf, "%3d", --pp->p_ammo);
    539  1.1    mrg 	cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    540  1.1    mrg 	outstr(pp, Buf, 3);
    541  1.1    mrg 
    542  1.1    mrg 	pp->p_scan += SCANLEN;
    543  1.1    mrg 
    544  1.1    mrg 	if (pp->p_cloak >= 0)
    545  1.1    mrg 		pp->p_cloak = -1;
    546  1.1    mrg 
    547  1.1    mrg 	showstat(pp);
    548  1.1    mrg }
    549  1.1    mrg 
    550  1.1    mrg /*
    551  1.1    mrg  * pickup:
    552  1.1    mrg  *	check whether the object blew up or whether he picked it up
    553  1.1    mrg  */
    554  1.2  lukem void
    555  1.1    mrg pickup(pp, y, x, prob, obj)
    556  1.2  lukem 	PLAYER	*pp;
    557  1.2  lukem 	int	y, x;
    558  1.2  lukem 	int	prob;
    559  1.2  lukem 	int	obj;
    560  1.1    mrg {
    561  1.2  lukem 	int	req;
    562  1.1    mrg 
    563  1.1    mrg 	switch (obj) {
    564  1.1    mrg 	  case MINE:
    565  1.1    mrg 		req = BULREQ;
    566  1.1    mrg 		break;
    567  1.1    mrg 	  case GMINE:
    568  1.1    mrg 		req = GRENREQ;
    569  1.1    mrg 		break;
    570  1.1    mrg 	  default:
    571  1.1    mrg 		abort();
    572  1.1    mrg 	}
    573  1.1    mrg 	if (rand_num(100) < prob)
    574  1.1    mrg 		add_shot(obj, y, x, LEFTS, req, (PLAYER *) NULL,
    575  1.1    mrg 			TRUE, pp->p_face);
    576  1.1    mrg 	else {
    577  1.1    mrg 		pp->p_ammo += req;
    578  1.1    mrg 		(void) sprintf(Buf, "%3d", pp->p_ammo);
    579  1.1    mrg 		cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
    580  1.1    mrg 		outstr(pp, Buf, 3);
    581  1.1    mrg 	}
    582  1.1    mrg }
    583