From 843b0034d812492266b0aa07c812b9f54890feaa Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 9 Jan 2007 10:32:10 +0000 Subject: Tweaked travel/explore so that it doesn't cut off before trying to move to a square with an invisible monster/mimic. Travel now cuts off when the PC attempts to attack the invisible monster. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@813 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/delay.cc | 7 ++++++- crawl-ref/source/enum.h | 2 ++ crawl-ref/source/fight.cc | 5 ++++- crawl-ref/source/initfile.cc | 3 ++- crawl-ref/source/message.cc | 3 ++- crawl-ref/source/travel.cc | 24 ++++++++---------------- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 1570cef9b6..e40d3526be 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -959,6 +959,11 @@ bool interrupt_activity( activity_interrupt_type ai, if (delay == DELAY_NOT_DELAYED) return (false); +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "Activity interrupt: %s", + activity_interrupt_name(ai)); +#endif + // First try to stop the current delay. const delay_queue_item &item = you.delay_queue.front(); @@ -1004,7 +1009,7 @@ static const char *activity_interrupt_names[] = { "force", "keypress", "full_hp", "full_mp", "statue", "hungry", "message", "hp_loss", "burden", "stat", - "monster", "monster_attack", "teleport" + "monster", "monster_attack", "teleport", "hit_monster" }; const char *activity_interrupt_name(activity_interrupt_type ai) diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 29db359ba7..76f0763b15 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -153,6 +153,8 @@ enum activity_interrupt_type AI_SEE_MONSTER, AI_MONSTER_ATTACKS, AI_TELEPORT, + AI_HIT_MONSTER, // Player hit monster (invis or + // mimic) during travel/explore. // Always the last. NUM_AINTERRUPTS diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 7117abb97f..717a14fb7c 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -366,7 +366,7 @@ int calc_heavy_armour_penalty( bool random_factor ) { // Returns true if you hit the monster. bool you_attack(int monster_attacked, bool unarmed_attacks) { - struct monsters *defender = &menv[monster_attacked]; + monsters *defender = &menv[monster_attacked]; int your_to_hit; int damage_done = 0; @@ -398,6 +398,9 @@ bool you_attack(int monster_attacked, bool unarmed_attacks) special_damage_message[0] = 0; base_damage_message[0] = 0; + // We're trying to hit a monster, break out of travel/explore now. + interrupt_activity(AI_HIT_MONSTER, defender); + if (ur_armed && you.inv[weapon].base_type == OBJ_WEAPONS && is_random_artefact( you.inv[weapon] )) { diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index f00b30b004..cdd7ef9164 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -431,7 +431,8 @@ void game_options::set_default_activity_interrupts() "interrupt_passwall = interrupt_butcher", "interrupt_multidrop = interrupt_butcher", "interrupt_macro = interrupt_multidrop", - "interrupt_travel = interrupt_butcher, statue, hungry, burden, monster", + "interrupt_travel = interrupt_butcher, statue, hungry, " + "burden, monster, hit_monster", "interrupt_run = interrupt_travel, message", "interrupt_rest = interrupt_run", diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 0a31361717..c9c3bef60a 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -319,7 +319,8 @@ static void base_mpr(const char *inf, int channel, int param) } } - interrupt_activity( AI_MESSAGE, channel_to_str(channel) + ":" + inf ); + if (channel != MSGCH_DIAGNOSTICS && channel != MSGCH_EQUIPMENT) + interrupt_activity( AI_MESSAGE, channel_to_str(channel) + ":" + inf ); // Check messages for all forms of running now. if (you.running) diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 8cdb247a1e..673e17db04 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -441,26 +441,18 @@ static bool is_travel_ok(int x, int y, bool ignore_hostile) } // Returns true if the location at (x,y) is monster-free and contains no clouds. -static bool is_safe(int x, int y) +static bool is_safe_move(int x, int y) { unsigned char mon = mgrd[x][y]; if (mon != NON_MONSTER) { - // If this is an invisible critter, say we're safe to get here, but - // turn off travel - the result should be that the player bashes into - // the monster and stops travelling right there. Same treatment applies - // to mimics. - if (!player_monster_visible(&menv[mon]) || - mons_is_mimic( menv[mon].type )) + // Stop before wasting energy on plants and fungi. + if (player_monster_visible(&menv[mon]) + && mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) { - you.running.stop(); - return true; + return (false); } - // Stop before wasting energy on plants and fungi. - if (mons_class_flag( menv[mon].type, M_NO_EXP_GAIN )) - return false; - // If this is any *other* monster, it'll be visible and // a) Friendly, in which case we'll displace it, no problem. // b) Unfriendly, in which case we're in deep trouble, since travel @@ -468,11 +460,11 @@ static bool is_safe(int x, int y) } const int cloud = env.cgrid[x][y]; if (cloud == EMPTY_CLOUD) - return true; + return (true); // We can also safely run through smoke. const cloud_type ctype = (cloud_type) env.cloud[ cloud ].type; - return !is_damaging_cloud(ctype); + return (!is_damaging_cloud(ctype)); } static bool player_is_permalevitating() @@ -1278,7 +1270,7 @@ void find_travel_pos(int youx, int youy, if (dx == dest_x && dy == dest_y) { // Hallelujah, we're home! - if (is_safe(x, y) && move_x && move_y) + if (is_safe_move(x, y) && move_x && move_y) { *move_x = sgn(x - dest_x); *move_y = sgn(y - dest_y); -- cgit v1.2.3-54-g00ecf