X-Git-Url: https://git.cameronkatri.com/bsdgames-darwin.git/blobdiff_plain/77e3814f0c0e3dea4d0032e25666f77e6f83bfff..88ff9c0697c57951fd41e8543aacb033ef78a94f:/rogue/spec_hit.c diff --git a/rogue/spec_hit.c b/rogue/spec_hit.c index 25bb5db4..69e314c3 100644 --- a/rogue/spec_hit.c +++ b/rogue/spec_hit.c @@ -1,6 +1,8 @@ +/* $NetBSD: spec_hit.c,v 1.9 2011/05/23 23:01:17 joerg Exp $ */ + /* - * Copyright (c) 1988 The Regents of the University of California. - * All rights reserved. + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. * * This code is derived from software contributed to Berkeley by * Timothy C. Stoehr. @@ -13,11 +15,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -34,8 +32,13 @@ * SUCH DAMAGE. */ +#include #ifndef lint -static char sccsid[] = "@(#)spec_hit.c 5.3 (Berkeley) 6/1/90"; +#if 0 +static char sccsid[] = "@(#)spec_hit.c 8.1 (Berkeley) 5/31/93"; +#else +__RCSID("$NetBSD: spec_hit.c,v 1.9 2011/05/23 23:01:17 joerg Exp $"); +#endif #endif /* not lint */ /* @@ -52,17 +55,22 @@ static char sccsid[] = "@(#)spec_hit.c 5.3 (Berkeley) 6/1/90"; #include "rogue.h" +static void disappear(object *); +static void drain_life(void); +static void drop_level(void); +static void freeze(object *); +static int get_dir(short, short, short, short); +static boolean gold_at(short, short); +static void steal_gold(object *); +static void steal_item(object *); +static void sting(object *); +static boolean try_to_cough(short, short, object *); + short less_hp = 0; boolean being_held; -extern short cur_level, max_level, blind, levitate, ring_exp; -extern long level_points[]; -extern boolean detect_monster, mon_disappeared; -extern boolean sustain_strength, maintain_armor; -extern char *you_can_move_again; - -special_hit(monster) -object *monster; +void +special_hit(object *monster) { if ((monster->m_flags & CONFUSED) && rand_percent(66)) { return; @@ -92,8 +100,8 @@ object *monster; } } -rust(monster) -object *monster; +void +rust(object *monster) { if ((!rogue.armor) || (get_armor_class(rogue.armor) <= 1) || (rogue.armor->which_kind == LEATHER)) { @@ -101,18 +109,18 @@ object *monster; } if ((rogue.armor->is_protected) || maintain_armor) { if (monster && (!(monster->m_flags & RUST_VANISHED))) { - message("the rust vanishes instantly", 0); + messagef(0, "the rust vanishes instantly"); monster->m_flags |= RUST_VANISHED; } } else { rogue.armor->d_enchant--; - message("your armor weakens", 0); + messagef(0, "your armor weakens"); print_stats(STAT_ARMOR); } } -freeze(monster) -object *monster; +void +freeze(object *monster) { short freeze_percent = 99; short i, n; @@ -127,7 +135,7 @@ object *monster; if (freeze_percent > 10) { monster->m_flags |= FREEZING_ROGUE; - message("you are frozen", 1); + messagef(1, "you are frozen"); n = get_rand(4, 8); for (i = 0; i < n; i++) { @@ -137,15 +145,15 @@ object *monster; for (i = 0; i < 50; i++) { mv_mons(); } - killed_by((object *)0, HYPOTHERMIA); + killed_by(NULL, HYPOTHERMIA); } - message(you_can_move_again, 1); + messagef(1, "%s", you_can_move_again); monster->m_flags &= (~FREEZING_ROGUE); } } -steal_gold(monster) -object *monster; +void +steal_gold(object *monster) { int amount; @@ -159,16 +167,16 @@ object *monster; amount = rogue.gold; } rogue.gold -= amount; - message("your purse feels lighter", 0); + messagef(0, "your purse feels lighter"); print_stats(STAT_GOLD); disappear(monster); } -steal_item(monster) -object *monster; +void +steal_item(object *monster) { object *obj; - short i, n, t; + short i, n, t = 0; char desc[80]; boolean has_something = 0; @@ -203,13 +211,12 @@ object *monster; } } } - (void) strcpy(desc, "she stole "); if (obj->what_is != WEAPON) { t = obj->quantity; obj->quantity = 1; } - get_desc(obj, desc+10); - message(desc, 0); + get_desc(obj, desc, sizeof(desc)); + messagef(0, "she stole %s", desc); obj->quantity = ((obj->what_is != WEAPON) ? t : 1); @@ -218,8 +225,8 @@ DSPR: disappear(monster); } -disappear(monster) -object *monster; +static void +disappear(object *monster) { short row, col; @@ -235,8 +242,8 @@ object *monster; mon_disappeared = 1; } -cough_up(monster) -object *monster; +void +cough_up(object *monster) { object *obj; short row, col, i, n; @@ -250,7 +257,7 @@ object *monster; obj->what_is = GOLD; obj->quantity = get_rand((cur_level * 15), (cur_level * 30)); } else { - if (!rand_percent((int) monster->drop_percent)) { + if (!rand_percent((int)monster->drop_percent)) { return; } obj = gr_object(); @@ -279,11 +286,11 @@ object *monster; free_object(obj); } -try_to_cough(row, col, obj) -short row, col; -object *obj; +static boolean +try_to_cough(short row, short col, object *obj) { - if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) || (col>(DCOLS-1))) { + if ((row < MIN_ROW) || + (row > (DROWS-2)) || (col < 0) || (col>(DCOLS-1))) { return(0); } if ((!(dungeon[row][col] & (OBJECT | STAIRS | TRAP))) && @@ -298,8 +305,8 @@ object *obj; return(0); } -seek_gold(monster) -object *monster; +boolean +seek_gold(object *monster) { short i, j, rn, s; @@ -330,8 +337,8 @@ object *monster; return(0); } -gold_at(row, col) -short row, col; +static boolean +gold_at(short row, short col) { if (dungeon[row][col] & OBJECT) { object *obj; @@ -344,38 +351,35 @@ short row, col; return(0); } -check_gold_seeker(monster) -object *monster; +void +check_gold_seeker(object *monster) { monster->m_flags &= (~SEEKS_GOLD); } -check_imitator(monster) -object *monster; +boolean +check_imitator(object *monster) { - char msg[80]; - if (monster->m_flags & IMITATES) { wake_up(monster); if (!blind) { mvaddch(monster->row, monster->col, get_dungeon_char(monster->row, monster->col)); check_message(); - sprintf(msg, "wait, that's a %s!", mon_name(monster)); - message(msg, 1); + messagef(1, "wait, that's a %s!", mon_name(monster)); } return(1); } return(0); } -imitating(row, col) -register short row, col; +boolean +imitating(short row, short col) { if (dungeon[row][col] & MONSTER) { - object *object_at(), *monster; + object *monster; - if (monster = object_at(&level_monsters, row, col)) { + if ((monster = object_at(&level_monsters, row, col)) != NULL) { if (monster->m_flags & IMITATES) { return(1); } @@ -384,11 +388,10 @@ register short row, col; return(0); } -sting(monster) -object *monster; +static void +sting(object *monster) { short sting_chance = 35; - char msg[80]; if ((rogue.str_current <= 3) || sustain_strength) { return; @@ -399,15 +402,15 @@ object *monster; sting_chance -= (6 * ((rogue.exp + ring_exp) - 8)); } if (rand_percent(sting_chance)) { - sprintf(msg, "the %s's bite has weakened you", - mon_name(monster)); - message(msg, 0); + messagef(0, "the %s's bite has weakened you", + mon_name(monster)); rogue.str_current--; print_stats(STAT_STRENGTH); } } -drop_level() +static void +drop_level(void) { int hp; @@ -426,7 +429,8 @@ drop_level() add_exp(1, 0); } -drain_life() +void +drain_life(void) { short n; @@ -436,7 +440,7 @@ drain_life() n = get_rand(1, 3); /* 1 Hp, 2 Str, 3 both */ if ((n != 2) || (!sustain_strength)) { - message("you feel weaker", 0); + messagef(0, "you feel weaker"); } if (n != 2) { rogue.hp_max--; @@ -454,11 +458,9 @@ drain_life() print_stats((STAT_STRENGTH | STAT_HP)); } -m_confuse(monster) -object *monster; +boolean +m_confuse(object *monster) { - char msg[80]; - if (!rogue_can_see(monster->row, monster->col)) { return(0); } @@ -468,16 +470,16 @@ object *monster; } if (rand_percent(55)) { monster->m_flags &= (~CONFUSES); - sprintf(msg, "the gaze of the %s has confused you", mon_name(monster)); - message(msg, 1); + messagef(1, "the gaze of the %s has confused you", + mon_name(monster)); cnfs(); return(1); } return(0); } -flame_broil(monster) -object *monster; +boolean +flame_broil(object *monster) { short row, col, dir; @@ -502,8 +504,8 @@ object *monster; return(1); } -get_dir(srow, scol, drow, dcol) -short srow, scol, drow, dcol; +static int +get_dir(short srow, short scol, short drow, short dcol) { if (srow == drow) { if (scol < dcol) {