diff options
author | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-09-21 10:49:08 +0000 |
---|---|---|
committer | haranp <haranp@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-09-21 10:49:08 +0000 |
commit | 300b157c23f4b3a0727a19b3fd89d24e909f5184 (patch) | |
tree | c7a447c9301f2dac0182878f85b845d225fb671c | |
parent | 724da7b6f8eebce7b00ac5f58702b7cd2d868a69 (diff) | |
download | crawl-ref-300b157c23f4b3a0727a19b3fd89d24e909f5184.tar.gz crawl-ref-300b157c23f4b3a0727a19b3fd89d24e909f5184.zip |
Fix 2085598: Nemelex won't be disappointed if there are invisible monsters
nearby when drawing from Destruction, even if you can't see them.
Xom can now act on creatures you can't see.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6960 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/decks.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 38 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 11 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 7 |
5 files changed, 33 insertions, 28 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 509937bc9d..19cec487e0 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -1615,7 +1615,7 @@ static void _mass_drain(int pow) // to target. This is still exploitable by finding popcorn monsters. static bool _damaging_card(card_type card, int power, deck_rarity_type rarity) { - bool rc = there_are_monsters_nearby(); + bool rc = there_are_monsters_nearby(true, false); const int power_level = get_power_level(power, rarity); dist target; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 6f3fb1b150..5831e431db 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2320,23 +2320,27 @@ bool mons_is_safe(const struct monsters *mon, bool want_move) return (is_safe); } -// Return all monsters in range (default: LOS) that the player is able to see -// and recognize as being a monster. +// Return all nearby monsters in range (default: LOS) that the player +// is able to recognize as being monsters (i.e. no unknown mimics or +// submerged creatures.) // // want_move (??) Somehow affects what monsters are considered dangerous // just_check Return zero or one monsters only // dangerous_only Return only "dangerous" monsters +// require_visible Require that monsters be visible to the player // range search radius (defaults: LOS) // -void get_playervisible_monsters(std::vector<monsters*> &mons, - bool want_move, - bool just_check, - bool dangerous_only, - int range) +std::vector<monsters*> get_nearby_monsters(bool want_move, + bool just_check, + bool dangerous_only, + bool require_visible, + int range) { if (range == -1) range = LOS_RADIUS; + std::vector<monsters*> mons; + // Sweep every square within range. for ( radius_iterator ri(you.pos(), range); ri; ++ri ) { @@ -2345,20 +2349,21 @@ void get_playervisible_monsters(std::vector<monsters*> &mons, { if (see_grid(*ri)) { - monsters *mon = &env.mons[targ_monst]; + monsters *mon = &menv[targ_monst]; if (mon->alive() - && player_monster_visible(mon) + && (!require_visible || player_monster_visible(mon)) && !mons_is_submerged(mon) && (!mons_is_mimic(mon->type) || mons_is_known_mimic(mon)) && (!dangerous_only || !mons_is_safe(mon, want_move))) { mons.push_back(mon); if (just_check) // stop once you find one - return; + return mons; } } } } + return mons; } bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range) @@ -2388,8 +2393,8 @@ bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range) } // Monster check. - std::vector<monsters*> visible; - get_playervisible_monsters(visible, want_move, !announce, true, range); + std::vector<monsters*> visible = + get_nearby_monsters(want_move, !announce, true, true, range); // No monsters found. if (visible.empty()) @@ -2417,13 +2422,10 @@ bool i_feel_safe(bool announce, bool want_move, bool just_monsters, int range) return (false); } -bool there_are_monsters_nearby() +bool there_are_monsters_nearby(bool dangerous_only, bool require_visible) { - // Monster check. - std::vector<monsters*> visible; - get_playervisible_monsters(visible, false, true); - - return (!visible.empty()); + return (!get_nearby_monsters(false, true, + dangerous_only, require_visible).empty()); } static const char *shop_types[] = { diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index 442cefbbc0..35b5df6daa 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -72,14 +72,17 @@ void curare_hits_player(int agent, int degree); bool mons_is_safe(const monsters *mon, bool want_move = false); -void get_playervisible_monsters(std::vector<monsters*>& mons, - bool want_move = false, bool just_check = false, - bool dangerous_only = false, int range = -1); +std::vector<monsters*> get_nearby_monsters(bool want_move = false, + bool just_check = false, + bool dangerous_only = false, + bool require_visible = true, + int range = -1); bool i_feel_safe(bool announce = false, bool want_move = false, bool just_monsters = false, int range = -1); -bool there_are_monsters_nearby(); +bool there_are_monsters_nearby(bool dangerous_only = false, + bool require_visible = true); void setup_environment_effects(); diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index aaa5ccbcf1..f1f219a514 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -1441,8 +1441,7 @@ static void _print_next_monster_desc(const std::vector<monster_pane_info>& mons, void get_monster_pane_info(std::vector<monster_pane_info>& mons) { - std::vector<monsters*> visible; - get_playervisible_monsters(visible); + std::vector<monsters*> visible = get_nearby_monsters(); for (unsigned int i = 0; i < visible.size(); i++) { if (Options.target_zero_exp diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index eedd007294..c91c8f9554 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -589,14 +589,15 @@ static bool _xom_is_good(int sever) } else if (x_chance_in_y(7, sever)) { - if (there_are_monsters_nearby()) + if (there_are_monsters_nearby(false, false)) { monsters *mon = choose_random_nearby_monster(0, _choose_mutatable_monster); if (mon) { - god_speaks(GOD_XOM, _get_xom_speech("good monster polymorph").c_str()); + god_speaks(GOD_XOM, + _get_xom_speech("good monster polymorph").c_str()); monster_polymorph(mon, RANDOM_MONSTER, mons_wont_attack(mon) ? PPT_MORE : PPT_LESS, true); @@ -796,7 +797,7 @@ static bool _xom_is_bad(int sever) } else if (x_chance_in_y(8, sever)) { - if (there_are_monsters_nearby()) + if (there_are_monsters_nearby(false, false)) { monsters *mon = choose_random_nearby_monster(0, _choose_mutatable_monster); |