diff options
Diffstat (limited to 'crawl-ref/source/acr.cc')
-rw-r--r-- | crawl-ref/source/acr.cc | 145 |
1 files changed, 1 insertions, 144 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 92d10ac2ca..88d22351ad 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1706,149 +1706,6 @@ static void _experience_check() #endif } -static bool _mons_hostile(const monsters *mon) -{ - return (!mons_friendly(mon) && !mons_neutral(mon)); -} - -static const char* _get_monster_name(const monsters *mon, bool list_a = false) -{ - std::string desc = ""; - bool adj = false; - if (mons_friendly(mon)) - { - desc += "friendly "; - adj = true; - } - else if (mons_neutral(mon)) - { - desc += "neutral "; - adj = true; - } - - if (adj && list_a) - { - desc = "a " + desc; - list_a = false; - } - desc += mons_type_name(mon->type, (list_a ? DESC_NOCAP_A : DESC_PLAIN)); - - return desc.c_str(); -} - -// Returns true if the first monster is more aggressive (in terms of -// hostile/neutral/friendly) than the second or, if both monsters share the -// same attitude, if the first monster has a lower type. -// If monster type and attitude are the same, return false. -static bool _compare_monsters_attitude( const monsters *m1, const monsters *m2 ) -{ - if (_mons_hostile(m1) && !_mons_hostile(m2)) - return (true); - - if (mons_neutral(m1)) - { - if (mons_friendly(m2)) - return (true); - if (_mons_hostile(m2)) - return (false); - } - - if (mons_friendly(m1) && !mons_friendly(m2)) - return (false); - - // If we get here then monsters have the same attitude. - // FIX ME: replace with difficulty comparison - return (m1->type < m2->type); -} - -void get_visible_monsters(std::vector<std::string>& describe) -{ - int ystart = you.y_pos - 9, xstart = you.x_pos - 9; - int yend = you.y_pos + 9, xend = you.x_pos + 9; - if ( xstart < 0 ) xstart = 0; - if ( ystart < 0 ) ystart = 0; - if ( xend >= GXM ) xend = GXM; - if ( yend >= GYM ) yend = GYM; - - std::vector<const monsters*> mons; - // monster check - for ( int y = ystart; y < yend; ++y ) - for ( int x = xstart; x < xend; ++x ) - if ( see_grid(x,y) ) - { - const unsigned short targ_monst = mgrd[x][y]; - if ( targ_monst != NON_MONSTER ) - { - const monsters *mon = &menv[targ_monst]; - if ( player_monster_visible(mon) - && !mons_is_submerged(mon) - && !mons_is_mimic(mon->type)) - { - mons.push_back(mon); - } - } - } - - if (mons.empty()) - return; - - std::sort( mons.begin(), mons.end(), _compare_monsters_attitude ); - - int count = 0; - int size = mons.size(); - for (int i = 0; i < size; ++i) - { - if (i > 0 && _compare_monsters_attitude(mons[i-1], mons[i])) - { - if (count == 1) - describe.push_back(_get_monster_name(mons[i-1], true)); - else - { - describe.push_back(number_in_words(count) + " " - + pluralise(_get_monster_name(mons[i-1]))); - } - count = 0; - } - count++; - } - // handle last monster - if (mons.size() == 1 || - _compare_monsters_attitude(mons[size-2], mons[size-1])) - { - describe.push_back(_get_monster_name(mons[size-1], true)); - } - else - { - describe.push_back(number_in_words(count) + " " - + pluralise(_get_monster_name(mons[size-1]))); - } -} - -static void _mpr_monsters() -{ - std::vector<std::string> describe; - get_visible_monsters(describe); - - if (describe.empty()) - { - mpr("There are no monsters in sight!"); - } - else if (describe.size() == 1) - { - mprf("You can see %s.", describe[0].c_str()); - } - else - { - std::string msg = "You can see "; - msg += comma_separated_line(describe.begin(), - describe.end(), - ", and ", ", "); - msg += "."; - mpr(msg.c_str()); - } - -} - static void _print_friendly_pickup_setting(bool was_changed) { std::string now = (was_changed? "now " : ""); @@ -2135,7 +1992,7 @@ void process_command( command_type cmd ) break; case CMD_FULL_VIEW: - _mpr_monsters(); + mpr(mpr_monster_list().c_str()); break; case CMD_WIELD_WEAPON: |