From e37ab8471fcc8761a0d4a4954918ec4c679ed1bb Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Wed, 2 Jul 2008 14:39:19 +0000 Subject: Only apply targeting via monster list to spells and such where targeting monsters is actually needed. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6338 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/debug.cc | 8 +++++--- crawl-ref/source/decks.cc | 2 +- crawl-ref/source/directn.cc | 6 ++++-- crawl-ref/source/directn.h | 3 ++- crawl-ref/source/item_use.cc | 4 +++- crawl-ref/source/spells1.cc | 6 +++--- crawl-ref/source/spl-cast.cc | 2 +- crawl-ref/source/spl-util.cc | 10 ++++++---- crawl-ref/source/spl-util.h | 2 +- crawl-ref/source/traps.cc | 2 +- 11 files changed, 28 insertions(+), 19 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 1248faf706..6fcbf754ce 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3813,7 +3813,7 @@ static void _close_door(int door_x, int door_y) door_move.dx = door_x; door_move.dy = door_y; - if (!(door_x || door_y)) + if (!door_x && !door_y) { mpr("Which direction?", MSGCH_PROMPT); direction( door_move, DIR_DIR ); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 7b08beaec1..d146230f75 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -708,9 +708,11 @@ void wizard_level_travel( bool down ) // This lets us, for example, use &U to exit from Pandemonium and // &D to go to the next level. command_type real_dir = grid_stair_direction(stairs); - if ((down && real_dir == CMD_GO_UPSTAIRS) - || (!down && real_dir == CMD_GO_DOWNSTAIRS)) + if (down && real_dir == CMD_GO_UPSTAIRS + || !down && real_dir == CMD_GO_DOWNSTAIRS) + { down = !down; + } if (down) down_stairs(you.your_level, stairs); @@ -4103,7 +4105,7 @@ static void _move_player(int x, int y) static void _move_monster(int x, int y, int mid1) { dist moves; - direction(moves, DIR_NONE, TARG_ANY, -1, true, false, + direction(moves, DIR_NONE, TARG_ANY, -1, true, false, true, "Move monster to where?"); if (!moves.isValid || !in_bounds(moves.tx, moves.ty)) diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 9766a536fe..d2a47c5ab0 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -1678,7 +1678,7 @@ static bool _damaging_card(card_type card, int power, deck_rarity_type rarity) snprintf(info, INFO_SIZE, "You have drawn %s. Aim where? ", card_name(card)); - if (spell_direction(target, beam, DIR_NONE, TARG_ENEMY, true, info) + if (spell_direction(target, beam, DIR_NONE, TARG_ENEMY, true, true, info) && player_tracer(ztype, power/4, beam)) { zapping(ztype, random2(power/4), beam); diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index e85c5a4163..02fd4582fc 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -471,7 +471,8 @@ static void _fill_monster_list(bool full_info) void direction(dist& moves, targeting_type restricts, targ_mode_type mode, int range, bool just_looking, - bool needs_path, const char *prompt, targeting_behaviour *beh) + bool needs_path, bool may_target_monster, const char *prompt, + targeting_behaviour *beh) { static targeting_behaviour stock_behaviour; if (!beh) @@ -480,7 +481,8 @@ void direction(dist& moves, targeting_type restricts, beh->just_looking = just_looking; #ifndef USE_TILE - if (!just_looking && Options.mlist_targetting == MLIST_TARGET_HIDDEN) + if (!just_looking && may_target_monster && restricts != DIR_DIR + && Options.mlist_targetting == MLIST_TARGET_HIDDEN) { Options.mlist_targetting = MLIST_TARGET_ON; bool full_info = update_monster_pane(); diff --git a/crawl-ref/source/directn.h b/crawl-ref/source/directn.h index b6cbd52bed..d071ab28ec 100644 --- a/crawl-ref/source/directn.h +++ b/crawl-ref/source/directn.h @@ -150,7 +150,8 @@ struct dist void direction( dist &moves, targeting_type restricts = DIR_NONE, targ_mode_type mode = TARG_ANY, int range = -1, bool just_looking = false, bool needs_path = true, - const char *prompt = NULL, targeting_behaviour *mod = NULL ); + bool may_target_monster = true, const char *prompt = NULL, + targeting_behaviour *mod = NULL ); bool in_los_bounds(int x, int y); bool in_viewport_bounds(int x, int y); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index d8a59d1aa1..2bb692af9c 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1456,9 +1456,11 @@ static bool _fire_choose_item_and_target(int& slot, dist& target, } beh.message_ammo_prompt(); + // XXX: This stuff should be done by direction()! message_current_target(); - direction( target, DIR_NONE, TARG_ENEMY, -1, false, !teleport, NULL, &beh ); + direction( target, DIR_NONE, TARG_ENEMY, -1, false, !teleport, true, + NULL, &beh ); if (beh.m_slot == -1) { diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 0636b4850e..1ea322128b 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -103,7 +103,7 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) // query for location {dlb}: while (true) { - direction(beam, DIR_TARGET, TARG_ANY, -1, false, false, + direction(beam, DIR_TARGET, TARG_ANY, -1, false, false, false, "Blink to where?"); if (!beam.isValid || coord_def(beam.tx, beam.ty) == you.pos()) @@ -499,7 +499,7 @@ bool conjure_flame(int pow) done_first_message = true; } - direction( spelld, DIR_TARGET, TARG_ENEMY, -1, false, false ); + direction( spelld, DIR_TARGET, TARG_ENEMY, -1, false, false, false ); if (!spelld.isValid) { @@ -686,7 +686,7 @@ static int _healing_spell(int healed, int target_x = -1, int target_y = -1) if (target_x == -1 || target_y == -1) { spd.isValid = spell_direction(spd, beam, DIR_TARGET, TARG_ANY, true, - "Heal whom?"); + true, "Heal whom?"); } else { diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 92c4499f7a..72fc1c163b 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1031,7 +1031,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) const bool needs_path = (!testbits(flags, SPFLAG_GRID) && !testbits(flags, SPFLAG_TARGET)); - if (!spell_direction(spd, beam, dir, targ, needs_path, prompt)) + if (!spell_direction(spd, beam, dir, targ, needs_path, true, prompt)) return (SPRET_ABORT); if (testbits( flags, SPFLAG_NOT_SELF ) && spd.isMe) diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index 4dcf356d95..364ab2461a 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -551,7 +551,7 @@ int apply_random_around_square( int (*func) (int, int, int, int), return (rv); } // end apply_random_around_square() -// apply func to one square of player's choice beside the player +// Apply func to one square of player's choice beside the player. int apply_one_neighbouring_square(int (*func) (int, int, int, int), int power) { struct dist bmove; @@ -571,7 +571,7 @@ int apply_one_neighbouring_square(int (*func) (int, int, int, int), int power) canned_msg(MSG_NOTHING_HAPPENS); return (rv); -} // end apply_one_neighbouring_square() +} int apply_area_within_radius( int (*func) (int, int, int, int), int x, int y, int pow, int radius, int ctype ) @@ -792,12 +792,14 @@ void apply_area_cloud( int (*func) (int, int, int, int, cloud_type, // Return false if the user canceled, true otherwise. bool spell_direction( dist &spelld, bolt &pbolt, targeting_type restrict, targ_mode_type mode, - bool needs_path, const char *prompt ) + bool needs_path, bool may_target_monster, + const char *prompt ) { if (restrict != DIR_DIR) message_current_target(); - direction( spelld, restrict, mode, -1, false, needs_path, prompt ); + direction( spelld, restrict, mode, -1, false, needs_path, + may_target_monster, prompt ); if (!spelld.isValid) { diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index d1e3097312..f245210455 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -131,7 +131,7 @@ int apply_area_within_radius(int (*func) (int, int, int, int), bool spell_direction( dist &spelld, bolt &pbolt, targeting_type restrict = DIR_NONE, targ_mode_type mode = TARG_ENEMY, - bool needs_path = true, + bool needs_path = true, bool may_target_monster = true, const char *prompt = NULL ); void apply_area_cloud(int (*func) (int, int, int, int, cloud_type, diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index e28d838b0b..d321f6e860 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -1146,7 +1146,7 @@ int num_traps_for_place(int level_number, const level_id &place) } } - switch(place.level_type) + switch (place.level_type) { case LEVEL_DUNGEON: if (branches[place.branch].num_traps_function != NULL) -- cgit v1.2.3-54-g00ecf