From faed135e4f21ba80b74be7aab83d34cfabcf2efc Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 23 Jul 2008 17:33:20 +0000 Subject: Implement 2022051: Skip hjklyubn (well, currently only bhjkl) when targetting via monster list, so you can both directly target a monster and manually move your cursor. Has the side-effect of reallowing direct selection of monsters via 'x'. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6641 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/directn.cc | 44 +++++++++++++++++++++++++++++++++++--------- crawl-ref/source/fight.cc | 13 +++++++++---- crawl-ref/source/newgame.cc | 2 +- crawl-ref/source/output.cc | 20 +++++++++++++++++++- 4 files changed, 64 insertions(+), 15 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index b895559f14..e1bf61f6e4 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -88,12 +88,16 @@ enum LOSSelect static void _describe_feature(const coord_def& where, bool oos); static void _describe_cell(const coord_def& where); -static bool _find_object( const coord_def& where, int mode, bool need_path, int range ); -static bool _find_monster( const coord_def& where, int mode, bool need_path, int range ); -static bool _find_feature( const coord_def& where, int mode, bool need_path, int range ); +static bool _find_object( const coord_def& where, int mode, bool need_path, + int range ); +static bool _find_monster( const coord_def& where, int mode, bool need_path, + int range ); +static bool _find_feature( const coord_def& where, int mode, bool need_path, + int range ); #ifndef USE_TILE -static bool _find_mlist( const coord_def& where, int mode, bool need_path, int range ); +static bool _find_mlist( const coord_def& where, int mode, bool need_path, + int range ); #endif static char _find_square_wrapper( const coord_def& targ, @@ -492,6 +496,22 @@ static void _fill_monster_list(bool full_info) start = end; } } + +static int _mlist_letter_to_index(char idx) +{ + if (idx >= 'b') + idx--; + if (idx >= 'h') + idx--; + if (idx >= 'j') + idx--; + if (idx >= 'k') + idx--; + if (idx >= 'l') + idx--; + + return (idx - 'a'); +} #endif void direction(dist& moves, targeting_type restricts, @@ -507,7 +527,7 @@ void direction(dist& moves, targeting_type restricts, beh->just_looking = just_looking; #ifndef USE_TILE - if (!just_looking && may_target_monster && restricts != DIR_DIR + if (may_target_monster && restricts != DIR_DIR && Options.mlist_targetting == MLIST_TARGET_HIDDEN) { Options.mlist_targetting = MLIST_TARGET_ON; @@ -684,7 +704,9 @@ void direction(dist& moves, targeting_type restricts, if (key_command >= CMD_TARGET_CYCLE_MLIST && key_command <= CMD_TARGET_CYCLE_MLIST_END) { - const int idx = key_command - CMD_TARGET_CYCLE_MLIST; + const int idx = _mlist_letter_to_index(key_command + 'a' + - CMD_TARGET_CYCLE_MLIST); + if (_find_square_wrapper(moves.target(), monsfind_pos, 1, _find_mlist, needs_path, idx, range, Options.target_wrap)) @@ -1326,7 +1348,8 @@ static bool _mons_is_valid_target(monsters *mon, int mode, int range) } #ifndef USE_TILE -static bool _find_mlist( const coord_def& where, int idx, bool need_path, int range = -1) +static bool _find_mlist( const coord_def& where, int idx, bool need_path, + int range = -1) { if ((int) mlist.size() <= idx) return (false); @@ -2724,18 +2747,21 @@ command_type targeting_behaviour::get_command(int key) if (key == -1) key = get_key(); + command_type cmd = key_to_command(key, KC_TARGETING); + if (cmd >= CMD_MIN_TARGET && cmd < CMD_TARGET_CYCLE_TARGET_MODE) + return (cmd); + #ifndef USE_TILE // Overrides the movement keys while mlist_targetting is active. if (Options.mlist_targetting == MLIST_TARGET_ON && islower(key)) return static_cast (CMD_TARGET_CYCLE_MLIST + (key - 'a')); #endif - command_type cmd = key_to_command(key, KC_TARGETING); // XXX: hack if (cmd == CMD_TARGET_SELECT && key == ' ' && just_looking) cmd = CMD_TARGET_CANCEL; - return cmd; + return (cmd); } bool targeting_behaviour::should_redraw() diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 5fe29481fd..82460bd819 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -3418,7 +3418,7 @@ std::string melee_attack::mons_weapon_desc() if (!you.can_see(attacker)) return (""); - if (weapon && attacker->id() != MONS_DANCING_WEAPON) + if (weapon) { std::string result = ""; const item_def wpn = *weapon; @@ -3429,8 +3429,13 @@ std::string melee_attack::mons_weapon_desc() if (dx == 2 && dy <= 2 || dy == 2 && dx <= 2) result += " from afar"; } - result += " with "; - result += weapon->name(DESC_NOCAP_A); + + if (attacker->id() != MONS_DANCING_WEAPON) + { + result += " with "; + result += weapon->name(DESC_NOCAP_A); + } + return result; } @@ -3727,7 +3732,7 @@ void melee_attack::mons_apply_attack_flavour(const mon_attack_def &attk) break; case AF_DRAIN_STR: - if ((one_chance_in(20) || (damage_done > 0 && one_chance_in(3))) + if ((one_chance_in(20) || damage_done > 0 && one_chance_in(3)) && defender->res_negative_energy() < random2(4)) { defender->drain_stat(STAT_STRENGTH, 1, attacker); diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index 91586103f1..6f55fc505c 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -3796,7 +3796,7 @@ spec_query: break; case CK_BKSP: case ' ': - you.species = SP_UNKNOWN; + you.species = SP_UNKNOWN; Options.race = 0; return (true); case '#': diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 0c7e129b14..30ab854b2e 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -1344,6 +1344,24 @@ void monster_pane_info::to_string( int count, std::string& desc, desc = out.str(); } +static char _mlist_index_to_letter(int index) +{ + index += 'a'; + + if (index >= 'b') + index++; + if (index >= 'h') + index++; + if (index >= 'j') + index++; + if (index >= 'k') + index++; + if (index >= 'l') + index++; + + return (index); +} + static void _print_next_monster_desc(const std::vector& mons, int& start, bool zombified = false, int idx = -1) @@ -1366,7 +1384,7 @@ static void _print_next_monster_desc(const std::vector& mons, if (idx >= 0) { textcolor(WHITE); - cprintf( stringize_glyph('a' + idx).c_str() ); + cprintf( stringize_glyph(_mlist_index_to_letter(idx)).c_str() ); cprintf(" - "); printed += 4; } -- cgit v1.2.3-54-g00ecf