From f945c65280cfb899a523faa5a510a897e2758ea0 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 29 Jul 2008 10:13:35 +0000 Subject: Fix 2030729: + and * not working when examining (targetting?) Merge r6641 into branch: skip direction keys when targetting via monster list. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.4@6713 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/cmd-keys.h | 3 +++ crawl-ref/source/directn.cc | 28 ++++++++++++++++++++++++---- crawl-ref/source/fight.cc | 13 +++++++++---- crawl-ref/source/newgame.cc | 2 +- crawl-ref/source/output.cc | 20 +++++++++++++++++++- 5 files changed, 56 insertions(+), 10 deletions(-) diff --git a/crawl-ref/source/cmd-keys.h b/crawl-ref/source/cmd-keys.h index 34ef74e4ee..2ca4c401d4 100644 --- a/crawl-ref/source/cmd-keys.h +++ b/crawl-ref/source/cmd-keys.h @@ -139,8 +139,11 @@ {'f', CMD_TARGET_MAYBE_PREV_TARGET}, {'t', CMD_TARGET_MAYBE_PREV_TARGET}, {'-', CMD_TARGET_CYCLE_BACK}, +{'+', CMD_TARGET_CYCLE_FORWARD}, {'=', CMD_TARGET_CYCLE_FORWARD}, {'/', CMD_TARGET_OBJ_CYCLE_BACK}, +{';', CMD_TARGET_OBJ_CYCLE_BACK}, +{'*', CMD_TARGET_OBJ_CYCLE_FORWARD}, {'\'', CMD_TARGET_OBJ_CYCLE_FORWARD}, {'b', CMD_TARGET_DOWN_LEFT}, {'h', CMD_TARGET_LEFT}, diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 77ee90a963..5f06f3f977 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -467,6 +467,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, @@ -483,7 +499,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; @@ -662,7 +678,8 @@ 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.tx, moves.ty, monsfind_pos, 1, _find_mlist, needs_path, idx, range, Options.target_wrap)) @@ -2710,18 +2727,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 9f1f518690..e2e10491df 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -3427,7 +3427,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; @@ -3438,8 +3438,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; } @@ -3736,7 +3741,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 450f4ddffe..750d171260 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -3797,7 +3797,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 1f3568775c..f33225686d 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -1365,6 +1365,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) @@ -1387,7 +1405,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