X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/f12b51f99bbe8bb6ad7eca12b047ba9b46836ee6..HEAD:/rogue/monster.c diff --git a/rogue/monster.c b/rogue/monster.c index 2bcc25d4..1d644f65 100644 --- a/rogue/monster.c +++ b/rogue/monster.c @@ -1,4 +1,4 @@ -/* $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 @@ -37,7 +37,7 @@ #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 */ @@ -87,41 +87,51 @@ const char *const m_names[] = { "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; @@ -131,7 +141,7 @@ put_mons() 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); } @@ -141,9 +151,7 @@ put_mons() } object * -gr_monster(monster, mn) - object *monster; - int mn; +gr_monster(object *monster, int mn) { if (!monster) { monster = alloc_object(); @@ -168,7 +176,7 @@ gr_monster(monster, mn) } void -mv_mons() +mv_mons(void) { object *monster, *next_monster, *test_mons; boolean flew; @@ -224,8 +232,7 @@ NM: test_mons = level_monsters.next_monster; } void -party_monsters(rn, n) - int rn, n; +party_monsters(int rn, int n) { short i, j; short row, col; @@ -253,7 +260,7 @@ party_monsters(rn, n) } } if (found) { - monster = gr_monster((object *) 0, 0); + monster = gr_monster((object *)0, 0); if (!(monster->m_flags & IMITATES)) { monster->m_flags |= WAKENS; } @@ -266,8 +273,7 @@ party_monsters(rn, n) } char -gmc_row_col(row, col) - int row, col; +gmc_row_col(int row, int col) { object *monster; @@ -286,8 +292,7 @@ gmc_row_col(row, col) } char -gmc(monster) - object *monster; +gmc(object *monster) { if ((!(detect_monster || see_invisible || r_see_invisible) && (monster->m_flags & INVISIBLE)) @@ -301,9 +306,7 @@ gmc(monster) } 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]; @@ -440,10 +443,8 @@ O: } } -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); @@ -453,9 +454,7 @@ mtry(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; @@ -504,9 +503,7 @@ move_mon_to(monster, row, col) } 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; @@ -546,8 +543,7 @@ mon_can_go(monster, row, col) } void -wake_up(monster) - object *monster; +wake_up(object *monster) { if (!(monster->m_flags & NAPPING)) { monster->m_flags &= (~(ASLEEP | IMITATES | WAKENS)); @@ -555,10 +551,7 @@ wake_up(monster) } 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; @@ -592,8 +585,7 @@ wake_room(rn, entering, row, col) } const char * -mon_name(monster) - const object *monster; +mon_name(const object *monster) { short ch; @@ -609,9 +601,8 @@ mon_name(monster) 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; @@ -623,14 +614,16 @@ rogue_is_around(row, col) } 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 { @@ -654,7 +647,7 @@ wanderer() } void -show_monsters() +show_monsters(void) { object *monster; @@ -676,7 +669,7 @@ show_monsters() } void -create_monster() +create_monster(void) { short row, col; short i; @@ -688,7 +681,7 @@ create_monster() 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; @@ -700,37 +693,36 @@ create_monster() } } 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++) { @@ -744,8 +736,7 @@ aim_monster(monster) } int -rogue_can_see(row, col) - int row, col; +rogue_can_see(int row, int col) { int retval; @@ -757,9 +748,8 @@ rogue_can_see(row, col) return(retval); } -int -move_confused(monster) - object *monster; +static int +move_confused(object *monster) { short i, row, col; @@ -788,9 +778,8 @@ move_confused(monster) return(0); } -int -flit(monster) - object *monster; +static int +flit(object *monster) { short i, row, col; @@ -816,7 +805,7 @@ flit(monster) } char -gr_obj_char() +gr_obj_char(void) { short r; const char *rs = "%!?]=/):*"; @@ -826,9 +815,8 @@ gr_obj_char() return(rs[r]); } -int -no_room_for_monster(rn) - int rn; +static int +no_room_for_monster(int rn) { short i, j; @@ -843,11 +831,11 @@ no_room_for_monster(rn) } 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; @@ -862,9 +850,7 @@ aggravate() } 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; @@ -883,7 +869,7 @@ mon_sees(monster, row, col) } void -mv_aquatars() +mv_aquatars(void) { object *monster;