diff options
-rw-r--r-- | crawl-ref/source/abl-show.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 144 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 42 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 6 |
5 files changed, 172 insertions, 26 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 81ba6605a6..c2d1e5d6f9 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -953,10 +953,9 @@ static bool _activate_talent(const talent& tal) you.hunger, abil.food_cost * 2, expected_hunger); #endif // safety margin for natural hunger, mutations etc. - if (expected_hunger <= 150 - && !yesno("Invoking this ability might make you starve to death. " - "Continue anyway?", false, 'n')) + if (expected_hunger <= 150) { + mpr("You're too hungry."); crawl_state.zero_turns_taken(); return (false); } diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 58ca6ca19b..8c446d549a 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1674,6 +1674,138 @@ 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); +} + +static void _list_monsters() +{ + 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()) + { + mpr("There are no monsters in sight!"); + return; + } + else if (mons.size() == 1) + { + mprf("You can see %s.", + mons_type_name(mons[0]->type, DESC_NOCAP_A).c_str()); + return; + } + + std::sort( mons.begin(), mons.end(), _compare_monsters_attitude ); + std::vector<std::string> describe; + + 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 (_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]))); + } + + std::string msg = "You can see "; + msg += comma_separated_line(describe.begin(), describe.end(), + ", and ", ", "); + msg += "."; + + mpr(msg.c_str()); +} + /* note that in some actions, you don't want to clear afterwards. e.g. list_jewellery, etc. */ @@ -1905,10 +2037,13 @@ void process_command( command_type cmd ) break; case CMD_INSPECT_FLOOR: - // item_check(';'); request_autopickup(); break; + case CMD_FULL_VIEW: + _list_monsters(); + break; + case CMD_WIELD_WEAPON: wield_weapon(false); break; @@ -3253,8 +3388,9 @@ command_type keycode_to_command( keycode_type key ) case 'A': return CMD_DISPLAY_MUTATIONS; case 'C': return CMD_CLOSE_DOOR; + case 'D': return CMD_NO_CMD; case 'E': return CMD_EXPERIENCE_CHECK; - case 'F': return CMD_NO_CMD; + case 'F': return CMD_FULL_VIEW; case 'G': return CMD_NO_CMD; case 'I': return CMD_DISPLAY_SPELLS; case 'M': return CMD_MEMORISE_SPELL; @@ -3313,7 +3449,8 @@ command_type keycode_to_command( keycode_type key ) case CONTROL('E'): return CMD_FORGET_STASH; case CONTROL('F'): return CMD_SEARCH_STASHES; case CONTROL('G'): return CMD_INTERLEVEL_TRAVEL; - case CONTROL('M'): return CMD_NO_CMD; + case CONTROL('I'): return CMD_NO_CMD; // Backspace on most systems + case CONTROL('M'): return CMD_NO_CMD; // Enter on most systems case CONTROL('O'): return CMD_DISPLAY_OVERMAP; case CONTROL('P'): return CMD_REPLAY_MESSAGES; #ifdef USE_TILE @@ -3323,6 +3460,7 @@ command_type keycode_to_command( keycode_type key ) #endif case CONTROL('R'): return CMD_REDRAW_SCREEN; case CONTROL('S'): return CMD_MARK_STASH; + case CONTROL('T'): return CMD_NO_CMD; case CONTROL('V'): return CMD_TOGGLE_AUTOPRAYER; case CONTROL('W'): return CMD_FIX_WAYPOINT; case CONTROL('X'): return CMD_SAVE_GAME_NOW; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 49fcf96304..3cf7a32326 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -435,6 +435,7 @@ enum command_type CMD_DROP, CMD_BUTCHER, CMD_INSPECT_FLOOR, + CMD_FULL_VIEW, CMD_EXAMINE_OBJECT, CMD_EVOKE, CMD_WIELD_WEAPON, diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 5fd25a0030..1509bf7a5c 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -693,7 +693,8 @@ void formatted_mpr(const formatted_string& fs, msg_channel_type channel, // // If wrap_col > 0, text is wrapped at that column. // -void formatted_message_history(const std::string &st_nocolor, msg_channel_type channel, +void formatted_message_history(const std::string &st_nocolor, + msg_channel_type channel, int param, int wrap_col) { if (suppress_messages) @@ -741,11 +742,10 @@ void formatted_message_history(const std::string &st_nocolor, msg_channel_type c // message playback explicitly only handles colors for // the tutorial channel... guess we'll store bare strings // for the rest, then. - if (channel == MSGCH_TUTORIAL) { + if (channel == MSGCH_TUTORIAL) mpr_store_messages(fs.to_colour_string(), channel, param); - } else { + else mpr_store_messages(unformatted, channel, param); - } } } @@ -827,13 +827,17 @@ static bool is_channel_dumpworthy(msg_channel_type channel) std::string get_last_messages(int mcount) { - if (mcount <= 0) return std::string(); - if (mcount > NUM_STORED_MESSAGES) mcount = NUM_STORED_MESSAGES; + if (mcount <= 0) + return std::string(); + + if (mcount > NUM_STORED_MESSAGES) + mcount = NUM_STORED_MESSAGES; - bool full_buffer = Store_Message[ NUM_STORED_MESSAGES - 1 ].text.length() == 0; + bool full_buffer + = (Store_Message[ NUM_STORED_MESSAGES - 1 ].text.length() == 0); int initial = Next_Message - mcount; if (initial < 0 || initial > NUM_STORED_MESSAGES) - initial = full_buffer? initial + NUM_STORED_MESSAGES : 0; + initial = full_buffer ? initial + NUM_STORED_MESSAGES : 0; std::string text; int count = 0; @@ -853,25 +857,26 @@ std::string get_last_messages(int mcount) } // An extra line of clearance. - if (count) text += EOL; + if (count) + text += EOL; return text; } void replay_messages(void) { - int win_start_line = 0; - int keyin; + int win_start_line = 0; + int keyin; - bool full_buffer = true; - int num_msgs = NUM_STORED_MESSAGES; - int first_message = Next_Message; + bool full_buffer = true; + int num_msgs = NUM_STORED_MESSAGES; + int first_message = Next_Message; - const int num_lines = get_number_of_lines(); + const int num_lines = get_number_of_lines(); if (Store_Message[ NUM_STORED_MESSAGES - 1 ].text.length() == 0) { - full_buffer = false; + full_buffer = false; first_message = 0; num_msgs = Next_Message; } @@ -910,8 +915,9 @@ void replay_messages(void) if (line == first_message && i != 0) break; - int colour = channel_to_colour( Store_Message[ line ].channel, - Store_Message[ line ].param ); + int colour = prepare_message( Store_Message[ line ].text, + Store_Message[ line ].channel, + Store_Message[ line ].param ); if (colour == MSGCOL_MUTED) continue; diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index b9d4d7e152..64dd7bfa3a 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1767,8 +1767,8 @@ std::string cloud_name(cloud_type type) bool mons_is_safe(const struct monsters *mon, bool want_move) { - bool is_safe = mons_friendly(mon) || - mons_class_flag(mon->type, M_NO_EXP_GAIN); + bool is_safe = mons_friendly(mon) + || mons_class_flag(mon->type, M_NO_EXP_GAIN); #ifdef CLUA_BINDINGS bool moving = ((!you.delay_queue.empty() && @@ -1783,7 +1783,9 @@ bool mons_is_safe(const struct monsters *mon, bool want_move) if (clua.callfn("ch_mon_is_safe", "Mbbd>b", mon, is_safe, moving, dist, &result)) + { is_safe = result; + } #endif return is_safe; |