-/* $NetBSD: monster.c,v 1.8 2003/08/07 09:37:38 agc Exp $ */
+/* $NetBSD: monster.c,v 1.17 2013/08/11 03:44:27 dholland Exp $ */
/*
* Copyright (c) 1988, 1993
#if 0
static char sccsid[] = "@(#)monster.c 8.1 (Berkeley) 5/31/93";
#else
-__RCSID("$NetBSD: monster.c,v 1.8 2003/08/07 09:37:38 agc Exp $");
+__RCSID("$NetBSD: monster.c,v 1.17 2013/08/11 03:44:27 dholland Exp $");
#endif
#endif /* not lint */
"zombie"
};
-object mon_tab[MONSTERS] = {
- {(ASLEEP|WAKENS|WANDERS|RUSTS),"0d0",25,'A',20,9,18,100,0,0,0,0,0},
- {(ASLEEP|WANDERS|FLITS|FLIES),"1d3",10,'B',2,1,8,60,0,0,0,0,0},
- {(ASLEEP|WANDERS),"3d3/2d5",32,'C',15,7,16,85,0,10,0,0,0},
- {(ASLEEP|WAKENS|FLAMES),"4d6/4d9",145,'D',5000,21,126,100,0,90,0,0,0},
- {(ASLEEP|WAKENS),"1d3",11,'E',2,1,7,65,0,0,0,0,0},
- {(HOLDS|STATIONARY),"5d5",73,'F',91,12,126,80,0,0,0,0,0},
+#define FILL 0,0,0,0,0,0,0,0,0,0,0,0,0,NULL
+
+static object mon_tab[MONSTERS] = {
+ {(ASLEEP|WAKENS|WANDERS|RUSTS),"0d0",25,'A',20,9,18,100,0,0, FILL},
+ {(ASLEEP|WANDERS|FLITS|FLIES),"1d3",10,'B',2,1,8,60,0,0, FILL},
+ {(ASLEEP|WANDERS),"3d3/2d5",32,'C',15,7,16,85,0,10, FILL},
+ {(ASLEEP|WAKENS|FLAMES),"4d6/4d9",145,'D',5000,21,126,100,0,90, FILL},
+ {(ASLEEP|WAKENS),"1d3",11,'E',2,1,7,65,0,0, FILL},
+ {(HOLDS|STATIONARY),"5d5",73,'F',91,12,126,80,0,0, FILL},
{(ASLEEP|WAKENS|WANDERS|FLIES),"5d5/5d5",115,'G',
- 2000,20,126,85,0,10,0,0,0},
- {(ASLEEP|WAKENS|WANDERS),"1d3/1d2",15,'H',3,1,10,67,0,0,0,0,0},
- {(ASLEEP|FREEZES),"0d0",15,'I',5,2,11,68,0,0,0,0,0},
- {(ASLEEP|WANDERS),"3d10/4d5",132,'J',3000,21,126,100,0,0,0,0,0},
- {(ASLEEP|WAKENS|WANDERS|FLIES),"1d4",10,'K',2,1,6,60,0,0,0,0,0},
- {(ASLEEP|STEALS_GOLD),"0d0",25,'L',21,6,16,75,0,0,0,0,0},
+ 2000,20,126,85,0,10, FILL},
+ {(ASLEEP|WAKENS|WANDERS),"1d3/1d2",15,'H',3,1,10,67,0,0, FILL},
+ {(ASLEEP|FREEZES),"0d0",15,'I',5,2,11,68,0,0, FILL},
+ {(ASLEEP|WANDERS),"3d10/4d5",132,'J',3000,21,126,100,0,0, FILL},
+ {(ASLEEP|WAKENS|WANDERS|FLIES),"1d4",10,'K',2,1,6,60,0,0, FILL},
+ {(ASLEEP|STEALS_GOLD),"0d0",25,'L',21,6,16,75,0,0, FILL},
{(ASLEEP|WAKENS|WANDERS|CONFUSES),"4d4/3d7",97,'M',
- 250,18,126,85,0,25,0,0,0},
- {(ASLEEP|STEALS_ITEM),"0d0",25,'N',39,10,19,75,0,100,0,0,0},
- {(ASLEEP|WANDERS|WAKENS|SEEKS_GOLD),"1d6",25,'O',5,4,13,70,0,10,0,0,0},
- {(ASLEEP|INVISIBLE|WANDERS|FLITS),"5d4",76,'P',120,15,24,80,0,50,0,0,0},
- {(ASLEEP|WAKENS|WANDERS),"3d5",30,'Q',20,8,17,78,0,20,0,0,0},
- {(ASLEEP|WAKENS|WANDERS|STINGS),"2d5",19,'R',10,3,12,70,0,0,0,0,0},
- {(ASLEEP|WAKENS|WANDERS),"1d3",8,'S',2,1,9,50,0,0,0,0,0},
- {(ASLEEP|WAKENS|WANDERS),"4d6/1d4",75,'T',125,13,22,75,0,33,0,0,0},
+ 250,18,126,85,0,25, FILL},
+ {(ASLEEP|STEALS_ITEM),"0d0",25,'N',39,10,19,75,0,100, FILL},
+ {(ASLEEP|WANDERS|WAKENS|SEEKS_GOLD),"1d6",25,'O',5,4,13,70,0,10, FILL},
+ {(ASLEEP|INVISIBLE|WANDERS|FLITS),"5d4",76,'P',120,15,24,80,0,50, FILL},
+ {(ASLEEP|WAKENS|WANDERS),"3d5",30,'Q',20,8,17,78,0,20, FILL},
+ {(ASLEEP|WAKENS|WANDERS|STINGS),"2d5",19,'R',10,3,12,70,0,0, FILL},
+ {(ASLEEP|WAKENS|WANDERS),"1d3",8,'S',2,1,9,50,0,0, FILL},
+ {(ASLEEP|WAKENS|WANDERS),"4d6/1d4",75,'T',125,13,22,75,0,33, FILL},
{(ASLEEP|WAKENS|WANDERS),"4d10",90,'U',
- 200,17,26,85,0,33,0,0,0},
+ 200,17,26,85,0,33, FILL},
{(ASLEEP|WAKENS|WANDERS|DRAINS_LIFE),"1d14/1d4",55,'V',
- 350,19,126,85,0,18,0,0,0},
- {(ASLEEP|WANDERS|DROPS_LEVEL),"2d8",45,'W',55,14,23,75,0,0,0,0,0},
- {(ASLEEP|IMITATES),"4d6",42,'X',110,16,25,75,0,0,0,0,0},
- {(ASLEEP|WANDERS),"3d6",35,'Y',50,11,20,80,0,20,0,0,0},
- {(ASLEEP|WAKENS|WANDERS),"1d7",21,'Z',8,5,14,69,0,0,0,0,0}
+ 350,19,126,85,0,18, FILL},
+ {(ASLEEP|WANDERS|DROPS_LEVEL),"2d8",45,'W',55,14,23,75,0,0, FILL},
+ {(ASLEEP|IMITATES),"4d6",42,'X',110,16,25,75,0,0, FILL},
+ {(ASLEEP|WANDERS),"3d6",35,'Y',50,11,20,80,0,20, FILL},
+ {(ASLEEP|WAKENS|WANDERS),"1d7",21,'Z',8,5,14,69,0,0, FILL}
};
+static void aim_monster(object *);
+static int flit(object *);
+static int move_confused(object *);
+static int mtry(object *, short, short);
+static int no_room_for_monster(int);
+static void put_m_at(short, short, object *);
+static int rogue_is_around(int, int);
+
void
-put_mons()
+put_mons(void)
{
short i;
short n;
n = get_rand(4, 6);
for (i = 0; i < n; i++) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
if ((monster->m_flags & WANDERS) && coin_toss()) {
wake_up(monster);
}
}
object *
-gr_monster(monster, mn)
- object *monster;
- int mn;
+gr_monster(object *monster, int mn)
{
if (!monster) {
monster = alloc_object();
}
void
-mv_mons()
+mv_mons(void)
{
object *monster, *next_monster, *test_mons;
boolean flew;
}
void
-party_monsters(rn, n)
- int rn, n;
+party_monsters(int rn, int n)
{
short i, j;
short row, col;
}
}
if (found) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster((object *)0, 0);
if (!(monster->m_flags & IMITATES)) {
monster->m_flags |= WAKENS;
}
}
char
-gmc_row_col(row, col)
- int row, col;
+gmc_row_col(int row, int col)
{
object *monster;
}
char
-gmc(monster)
- object *monster;
+gmc(object *monster)
{
if ((!(detect_monster || see_invisible || r_see_invisible) &&
(monster->m_flags & INVISIBLE))
}
void
-mv_1_monster(monster, row, col)
- object *monster;
- short row, col;
+mv_1_monster(object *monster, short row, short col)
{
short i, n;
boolean tried[6];
}
}
-int
-mtry(monster, row, col)
- object *monster;
- short row, col;
+static int
+mtry(object *monster, short row, short col)
{
if (mon_can_go(monster, row, col)) {
move_mon_to(monster, row, col);
}
void
-move_mon_to(monster, row, col)
- object *monster;
- short row, col;
+move_mon_to(object *monster, short row, short col)
{
short c;
int mrow, mcol;
}
int
-mon_can_go(monster, row, col)
- const object *monster;
- short row, col;
+mon_can_go(const object *monster, short row, short col)
{
object *obj;
short dr, dc;
}
void
-wake_up(monster)
- object *monster;
+wake_up(object *monster)
{
if (!(monster->m_flags & NAPPING)) {
monster->m_flags &= (~(ASLEEP | IMITATES | WAKENS));
}
void
-wake_room(rn, entering, row, col)
- short rn;
- boolean entering;
- short row, col;
+wake_room(short rn, boolean entering, short row, short col)
{
object *monster;
short wake_percent;
}
const char *
-mon_name(monster)
- const object *monster;
+mon_name(const object *monster)
{
short ch;
return(m_names[ch]);
}
-int
-rogue_is_around(row, col)
- int row, col;
+static int
+rogue_is_around(int row, int col)
{
short rdif, cdif, retval;
}
void
-wanderer()
+wanderer(void)
{
object *monster;
short row, col, i;
boolean found = 0;
+ monster = NULL; /* XXXGCC -Wuninitialized [powerpc] */
+
for (i = 0; ((i < 15) && (!found)); i++) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster(NULL, 0);
if (!(monster->m_flags & (WAKENS | WANDERS))) {
free_object(monster);
} else {
}
void
-show_monsters()
+show_monsters(void)
{
object *monster;
}
void
-create_monster()
+create_monster(void)
{
short row, col;
short i;
for (i = 0; i < 9; i++) {
rand_around(i, &row, &col);
- if (((row == rogue.row) && (col = rogue.col)) ||
+ if (((row == rogue.row) && (col == rogue.col)) ||
(row < MIN_ROW) || (row > (DROWS-2)) ||
(col < 0) || (col > (DCOLS-1))) {
continue;
}
}
if (found) {
- monster = gr_monster((object *) 0, 0);
+ monster = gr_monster((object *)0, 0);
put_m_at(row, col, monster);
mvaddch(row, col, gmc(monster));
if (monster->m_flags & (WANDERS | WAKENS)) {
wake_up(monster);
}
} else {
- message("you hear a faint cry of anguish in the distance", 0);
+ messagef(0, "you hear a faint cry of anguish in the distance");
}
}
-void
-put_m_at(row, col, monster)
- short row, col;
- object *monster;
+static void
+put_m_at(short row, short col, object *monster)
{
monster->row = row;
monster->col = col;
dungeon[row][col] |= MONSTER;
monster->trail_char = mvinch(row, col);
- (void) add_to_pack(monster, &level_monsters, 0);
+ (void)add_to_pack(monster, &level_monsters, 0);
aim_monster(monster);
}
-void
-aim_monster(monster)
- object *monster;
+static void
+aim_monster(object *monster)
{
short i, rn, d, r;
rn = get_room_number(monster->row, monster->col);
+ if (rn == NO_ROOM)
+ clean_up("aim_monster: monster not in room");
r = get_rand(0, 12);
for (i = 0; i < 4; i++) {
}
int
-rogue_can_see(row, col)
- int row, col;
+rogue_can_see(int row, int col)
{
int retval;
return(retval);
}
-int
-move_confused(monster)
- object *monster;
+static int
+move_confused(object *monster)
{
short i, row, col;
return(0);
}
-int
-flit(monster)
- object *monster;
+static int
+flit(object *monster)
{
short i, row, col;
}
char
-gr_obj_char()
+gr_obj_char(void)
{
short r;
const char *rs = "%!?]=/):*";
return(rs[r]);
}
-int
-no_room_for_monster(rn)
- int rn;
+static int
+no_room_for_monster(int rn)
{
short i, j;
}
void
-aggravate()
+aggravate(void)
{
object *monster;
- message("you hear a high pitched humming noise", 0);
+ messagef(0, "you hear a high pitched humming noise");
monster = level_monsters.next_monster;
}
boolean
-mon_sees(monster, row, col)
- const object *monster;
- int row, col;
+mon_sees(const object *monster, int row, int col)
{
short rn, rdif, cdif, retval;
}
void
-mv_aquatars()
+mv_aquatars(void)
{
object *monster;