From 40a5bf9e8b1a16569a2d4bbaf446bf1ea412ca43 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sat, 21 Jun 2008 02:35:05 +0000 Subject: When going back to one level from another, make all pacified monsters on it leave the level. Currently, this happens instantly, although there should probably be a time limit added. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6027 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/effects.cc | 21 ++++++++++++++------- crawl-ref/source/monstuff.cc | 13 +++++++------ crawl-ref/source/monstuff.h | 2 ++ 3 files changed, 23 insertions(+), 13 deletions(-) diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 4cc4195aea..23dd3a989a 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -2827,7 +2827,7 @@ void update_level(double elapsedTime) mprf(MSGCH_DIAGNOSTICS, "turns: %d", turns ); #endif - update_corpses( elapsedTime ); + update_corpses(elapsedTime); if (env.sanctuary_time) { @@ -2851,6 +2851,13 @@ void update_level(double elapsedTime) mons_total++; #endif + // Pacified monsters that can move leave the level. + if (mons_is_pacified(mon) && !mons_is_truly_stationary(mon)) + { + make_mons_leave_level(mon); + continue; + } + // following monsters don't get movement if (mon->flags & MF_JUST_SUMMONED) continue; @@ -2859,10 +2866,10 @@ void update_level(double elapsedTime) // const bool healthy = (mon->hit_points * 2 > mon->max_hit_points); // This is the monster healing code, moved here from tag.cc: - if (monster_descriptor( mon->type, MDSC_REGENERATES ) + if (monster_descriptor(mon->type, MDSC_REGENERATES) || mon->type == MONS_PLAYER_GHOST) { - heal_monster( mon, turns, false ); + heal_monster(mon, turns, false); } else if (!mons_class_flag(mon->type, M_NO_REGEN)) { @@ -2870,14 +2877,14 @@ void update_level(double elapsedTime) const int regen_rate = std::max(mons_natural_regen_rate(mon) * 2, 5); - heal_monster( mon, div_rand_round(turns * regen_rate, 50), - false ); + heal_monster(mon, div_rand_round(turns * regen_rate, 50), + false); } _catchup_monster_moves(mon, turns); if (turns >= 10 && mon->alive()) - mon->timeout_enchantments( turns / 10 ); + mon->timeout_enchantments(turns / 10); } #if DEBUG_DIAGNOSTICS @@ -2885,7 +2892,7 @@ void update_level(double elapsedTime) #endif for (int i = 0; i < MAX_CLOUDS; i++) - delete_cloud( i ); + delete_cloud(i); } static void _maybe_restart_fountain_flow(const int x, const int y, diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 110e3e5182..f4bfeb84fb 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -2417,7 +2417,7 @@ static bool _mons_find_nearest_level_exit(const monsters *mon, level_exit &e) // If _mons_find_level_exits() is ever expanded to handle more grid // types, this should be expanded along with it. -static void _mons_handle_level_exit(const monsters *mon, int x, int y) +static void _mons_indicate_level_exit(const monsters *mon, int x, int y) { switch (mon->travel_target) { @@ -2461,11 +2461,12 @@ static void _mons_handle_level_exit(const monsters *mon, int x, int y) } } -static void _make_mons_leave_level(monsters *mon) +void make_mons_leave_level(monsters *mon) { if (mons_is_leaving(mon)) { - _mons_handle_level_exit(mon, mon->target_x, mon->target_y); + if (mons_near(mon) && player_monster_visible(mon)) + _mons_indicate_level_exit(mon, mon->target_x, mon->target_y); // Monsters leaving the level take their stuff with them. mon->flags |= MF_HARD_RESET; @@ -3286,7 +3287,7 @@ static void _handle_behaviour(monsters *mon) if (grid_distance(mon->x, mon->y, you.x_pos, you.y_pos) >= LOS_RADIUS * LOS_RADIUS * 4) { - _make_mons_leave_level(mon); + make_mons_leave_level(mon); return; } @@ -3310,7 +3311,7 @@ static void _handle_behaviour(monsters *mon) || mon->travel_target == MTRAV_SUBMERSIBLE) && mon->x == mon->target_x && mon->y == mon->target_y) { - _make_mons_leave_level(mon); + make_mons_leave_level(mon); return; } break; @@ -6021,7 +6022,7 @@ static void _handle_monster_move(int i, monsters *monster) && monster->x + mmov_x == monster->target_x && monster->y + mmov_y == monster->target_y) { - _make_mons_leave_level(monster); + make_mons_leave_level(monster); break; } diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h index fdc4044fe5..2677d8a8da 100644 --- a/crawl-ref/source/monstuff.h +++ b/crawl-ref/source/monstuff.h @@ -136,6 +136,8 @@ bool simple_monster_message(const monsters *monster, const char *event, int param = 0, description_level_type descrip = DESC_CAP_THE); +void make_mons_leave_level(monsters *mon); + bool choose_any_monster(const monsters* mon); monsters *choose_random_nearby_monster( int weight, -- cgit v1.2.3-54-g00ecf