summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-11 22:55:29 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-11 22:55:29 +0000
commit9fd7f5bc149e7fa7ae2597bc39ca7fd348997424 (patch)
treefa2bd181febcf019dad6e9d9987f3c01fa07436b
parentf200b503f68b2eb90fd9a5677c79e093df07544c (diff)
downloadcrawl-ref-9fd7f5bc149e7fa7ae2597bc39ca7fd348997424.tar.gz
crawl-ref-9fd7f5bc149e7fa7ae2597bc39ca7fd348997424.zip
Extend monster pathfinding to monsters circumventing pools of deep water
or lava. I've added some more checks to avoid hampering performance too much, but of course there's still space for improvement. Once per turn check whether the player can see water and/or lava, and only if this is the case run the additional checks (monster habitat, grid_see_grid) when a monster tries to move. Smart monsters that have a ranged attack won't use pathfinding either since they can directly fire at the player. (This is identical to their pre-pathfinding behaviour.) Also fix butterflies really not interrupting resting. (Setting it to 0 doesn't work for some reason.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5737 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/settings/init.txt2
-rw-r--r--crawl-ref/source/acr.cc42
-rw-r--r--crawl-ref/source/externs.h6
-rw-r--r--crawl-ref/source/food.cc2
-rw-r--r--crawl-ref/source/item_use.cc6
-rw-r--r--crawl-ref/source/items.cc12
-rw-r--r--crawl-ref/source/mon-util.cc15
-rw-r--r--crawl-ref/source/mon-util.h3
-rw-r--r--crawl-ref/source/monplace.cc9
-rw-r--r--crawl-ref/source/monstuff.cc179
-rw-r--r--crawl-ref/source/player.cc2
-rw-r--r--crawl-ref/source/spl-data.h2
-rw-r--r--crawl-ref/source/tags.cc6
-rw-r--r--crawl-ref/source/view.cc2
14 files changed, 190 insertions, 98 deletions
diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt
index 23938b11d2..015dae219e 100644
--- a/crawl-ref/settings/init.txt
+++ b/crawl-ref/settings/init.txt
@@ -175,7 +175,7 @@ runrest_ignore_message = safely over a trap
runrest_ignore_message = You feel.*sick
runrest_ignore_poison = 2:30
runrest_ignore_monster = fish:2
-runrest_ignore_monster = butterfly:0
+runrest_ignore_monster = butterfly:1
# runrest_ignore_monster = swamp worm:3
# trap_prompt = false
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index a548ec7d7b..58cc596549 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -1332,6 +1332,34 @@ static bool _cmd_is_repeatable(command_type cmd, bool is_again = false)
return false;
}
+static void _check_lava_water_in_sight()
+{
+ // Check the player's vision for lava or deep water,
+ // to avoid unnecessary pathfinding later.
+ you.lava_in_sight = you.water_in_sight = false;
+ coord_def gp;
+ for (gp.y = (you.y_pos - 8); (gp.y <= you.y_pos + 8); gp.y++)
+ for (gp.x = (you.x_pos - 8); (gp.x <= you.x_pos + 8); gp.x++)
+ {
+ if (!in_bounds(gp))
+ continue;
+
+ const coord_def ep = gp - you.pos() + coord_def(9, 9);
+ if (env.show(ep))
+ {
+ dungeon_feature_type feat = grd[gp.x][gp.y];
+ if (feat == DNGN_LAVA)
+ you.lava_in_sight = true;
+ else if (feat == DNGN_DEEP_WATER)
+ you.water_in_sight = true;
+
+ if (you.lava_in_sight && you.water_in_sight)
+ break;
+ }
+ }
+}
+
+
// Used to determine whether to apply the berserk penalty at end of round.
bool apply_berserk_penalty = false;
@@ -1361,9 +1389,11 @@ static void _input()
Options.tut_just_triggered = false;
+ bool player_feels_safe = i_feel_safe();
+
// He, we don't want those "Whew, it's safe to rest now" messages when
// you were just cast into the Abyss. Right?
- if (i_feel_safe() && you.level_type != LEVEL_ABYSS)
+ if (player_feels_safe && you.level_type != LEVEL_ABYSS)
{
if (Options.tutorial_left)
{
@@ -1416,7 +1446,8 @@ static void _input()
// XXX: Is there some smart way to avoid autoswitching back if we're
// just about to continue butchering?
- if (i_feel_safe() && you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
+ if (!you.turn_is_over && player_feels_safe
+ && you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])
{
int weap = you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED];
if (weap == ENDOFPACK)
@@ -1429,18 +1460,21 @@ static void _input()
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
+ if (!you.turn_is_over)
+ _check_lava_water_in_sight();
+
handle_delay();
const coord_def cwhere = grid2view(you.pos());
cgotoxy(cwhere.x, cwhere.y);
- if ( you_are_delayed() )
+ if (you_are_delayed())
{
_world_reacts();
return;
}
- if ( you.turn_is_over )
+ if (you.turn_is_over)
{
_world_reacts();
return;
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index d3b8a8b7d5..b193f6f7ad 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -674,8 +674,8 @@ public:
FixedVector<unsigned int, 50> skill_points;
FixedVector<unsigned char, 50> skill_order;
- skill_type sage_bonus_skill; // if Sage is in effect, which skill it affects
- int sage_bonus_degree; // how much bonus XP to give in that skill
+ skill_type sage_bonus_skill; // If Sage is in effect, which skill it affects.
+ int sage_bonus_degree; // How much bonus XP to give in that skill.
int skill_cost_level;
int total_skill_points;
@@ -743,6 +743,8 @@ public:
// failures
dungeon_feature_type transit_stair;
bool entering_level;
+ bool lava_in_sight; // Is there lava in LoS?
+ bool water_in_sight; // Is there deep water in LoS?
// Warning: these two are quite different.
//
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index adcb48127b..a964d9e753 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -174,6 +174,8 @@ void weapon_switch( int targ )
if (Options.chunks_autopickup || you.species == SP_VAMPIRE)
autopickup();
+
+ you.turn_is_over = true;
}
// Look for a butchering implement. If fallback is true,
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index e91c6b9296..7176807ae0 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -262,10 +262,12 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
&& (!auto_wield || !is_valid_item(you.inv[item_slot]) || !good_swap))
{
if (!auto_wield)
+ {
item_slot = prompt_invent_item(
"Wield which item (- for none, * to show all)?",
MT_INVLIST, OSEL_WIELD,
true, true, true, '-', NULL, OPER_WIELD);
+ }
else
item_slot = PROMPT_GOT_SPECIAL;
}
@@ -281,7 +283,7 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
return (true);
}
- // now we really change weapons (most likely, at least)
+ // Now we really change weapons! (Most likely, at least...)
if (you.duration[DUR_SURE_BLADE])
{
mpr("The bond with your blade fades away.");
@@ -294,7 +296,7 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages)
{
if (you.equip[EQ_WEAPON] != -1)
{
- // can we safely unwield this item?
+ // Can we safely unwield this item?
if (has_warning_inscription(you.inv[you.equip[EQ_WEAPON]], OPER_WIELD))
{
std::string prompt = "Really unwield ";
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index d4ff6e63fa..ff35d4dab1 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -2279,7 +2279,7 @@ bool can_autopickup()
static void _do_autopickup()
{
//David Loewenstern 6/99
- int n_did_pickup = 0;
+ int n_did_pickup = 0;
int n_tried_pickup = 0;
will_autopickup = false;
@@ -2300,22 +2300,24 @@ static void _do_autopickup()
if (item_needs_autopickup(mitm[o]))
{
int num_to_take = mitm[o].quantity;
- if ( Options.autopickup_no_burden && item_mass(mitm[o]) != 0)
+ if (Options.autopickup_no_burden && item_mass(mitm[o]) != 0)
{
int num_can_take =
(carrying_capacity(you.burden_state) - you.burden) /
- item_mass(mitm[o]);
+ item_mass(mitm[o]);
- if ( num_can_take < num_to_take )
+ if (num_can_take < num_to_take)
{
if (!n_tried_pickup)
+ {
mpr("You can't pick everything up without burdening "
"yourself.");
+ }
n_tried_pickup++;
num_to_take = num_can_take;
}
- if ( num_can_take == 0 )
+ if (num_can_take == 0)
{
o = next;
continue;
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 1a8d813618..d89a16e0fd 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1261,12 +1261,20 @@ flight_type mons_flies(const monsters *mon)
: FL_NONE);
}
-bool mons_amphibious(int mc)
+bool mons_class_amphibious(int mc)
{
return mons_class_flag(mc, M_AMPHIBIOUS);
}
-// This nice routine we keep in exactly the way it was-
+bool mons_amphibious(const monsters *mon)
+{
+ const int type = mons_is_zombified(mon) ? mons_zombie_base(mon)
+ : mon->type;
+
+ return (mons_class_amphibious(type));
+}
+
+// This nice routine we keep in exactly the way it was.
int hit_points(int hit_dice, int min_hp, int rand_hp)
{
int hrolled = 0;
@@ -2816,7 +2824,7 @@ bool monsters::floundering() const
// Can't use monster_habitable_grid because that'll return true
// for non-water monsters in shallow water.
&& mons_habitat(this) != HT_WATER
- && !mons_amphibious(type)
+ && !mons_amphibious(this)
&& !mons_flies(this));
}
@@ -2841,6 +2849,7 @@ bool monsters::can_drown() const
{
// Mummies can fall apart in water; ghouls, vampires, and demons can
// drown in water/lava.
+ // Other undead just "sink like a rock", to be never seen again.
return (!mons_res_asphyx(this)
|| mons_genus(type) == MONS_MUMMY
|| mons_genus(type) == MONS_GHOUL
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index e20fa68c02..b5bc41741b 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -397,7 +397,8 @@ bool give_monster_proper_name(monsters *mon, bool orcs_only = true);
flight_type mons_class_flies(int mc);
flight_type mons_flies(const monsters *mon);
-bool mons_amphibious(int mc);
+bool mons_class_amphibious(int mc);
+bool mons_amphibious(const monsters *mon);
// last updated XXmay2000 {dlb}
/* ***********************************************************************
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 260cc4b573..e5f46985b6 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -135,7 +135,7 @@ bool monster_habitable_grid(int monster_class,
}
// Amphibious critters are happy in water or on land.
- if (mons_amphibious(monster_class)
+ if (mons_class_amphibious(monster_class)
&& (preferred_habitat == DNGN_FLOOR
&& grid_compatible(DNGN_DEEP_WATER, actual_grid)
|| preferred_habitat == DNGN_DEEP_WATER
@@ -2523,11 +2523,8 @@ std::vector<coord_def> monster_pathfind::calc_waypoints()
return path;
dungeon_feature_type can_move;
- if (mons_amphibious(mons_is_zombified(mons) ? mons->base_monster
- : mons->type))
- {
+ if (mons_amphibious(mons))
can_move = DNGN_DEEP_WATER;
- }
else
can_move = DNGN_SHALLOW_WATER;
@@ -2621,7 +2618,7 @@ int monster_pathfind::travel_cost(coord_def npos)
// Travelling through water, entering or leaving water is more expensive
// for non-amphibious monsters, so they'll avoid it where possible.
// Only tested for shallow water since they can't enter deep water anywa.
- if (!airborne && !mons_amphibious(montype)
+ if (!airborne && !mons_class_amphibious(montype)
&& (grd(pos) == DNGN_SHALLOW_WATER || grd(npos) == DNGN_SHALLOW_WATER))
{
return 2;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index c1431bea59..8aeb15df70 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -2325,20 +2325,21 @@ static bool _choose_random_patrol_target_grid(monsters *mon)
// If a monster can see but not directly reach the player, and then fails to
// find a path to get him, mark all surrounding (in a radius of 2) monsters
-// of the same species as also being unable to find a path, so we won't need
-// to calculate again.
+// of the same (or greater) movement restrictions as also being unable to
+// find a path, so we won't need to calculate again.
// Should there be a direct path to the player for a monster thus marked, it
-// will still be able to come nearer (and the mark will be cleared).
-static void _mark_species_members_player_unreachable(monsters *mon)
+// will still be able to come nearer (and the mark will then be cleared).
+static void _mark_neighbours_player_unreachable(monsters *mon)
{
- // Highly intelligent monsters are capable of pathfinding and don't
- // need their neighbour's advice.
- if (mons_intel(mon->type) > I_NORMAL)
+ // Highly intelligent monsters are perfectly capable of pathfinding
+ // and don't need their neighbour's advice.
+ const int intel = mons_intel(mon->type);
+ if (intel > I_NORMAL)
return;
- // We won't be able to find pack members of human unique monsters.
- if (mons_is_unique(mon->type) && mons_species(mon->type) == MONS_HUMAN)
- return;
+ bool flies = mons_flies(mon);
+ bool amphibious = mons_amphibious(mon);
+ habitat_type habit = mons_habitat(mon);
int x, y;
monsters *m;
@@ -2364,15 +2365,22 @@ static void _mark_species_members_player_unreachable(monsters *mon)
m = &menv[mgrd[x][y]];
- // Only mark target for monsters of same species.
- // Restrict to same _type_ for humans (by far the most
- // versatile species).
- if (mon->type != m->type
- && (mon->type == MONS_HUMAN
- || mons_species(mon->type) != mons_species(m->type)))
- {
+ // Don't restrict smarter monsters as they might find a path
+ // a dumber monster wouldn't.
+ if (mons_intel(m->type) > intel)
+ continue;
+
+ // Monsters of differing habitats might prefer different routes.
+ if (mons_habitat(m) != habit)
+ continue;
+
+ // A flying monster has an advantage over a non-flying one.
+ if (!flies && mons_flies(m))
+ continue;
+
+ // Same for a swimming one, around water.
+ if (you.water_in_sight && !amphibious && mons_amphibious(m))
continue;
- }
if (m->travel_target == MTRAV_NONE)
m->travel_target = MTRAV_UNREACHABLE;
@@ -2424,14 +2432,8 @@ static void _handle_behaviour(monsters *mon)
return;
}
- dungeon_feature_type can_move;
- if (mons_amphibious(mons_is_zombified(mon) ?
- mon->base_monster : mon->type))
- {
- can_move = DNGN_DEEP_WATER;
- }
- else
- can_move = DNGN_SHALLOW_WATER;
+ const dungeon_feature_type can_move =
+ (mons_amphibious(mon)) ? DNGN_DEEP_WATER : DNGN_SHALLOW_WATER;
// Validate current target exists.
if (mon->foe != MHITNOT && mon->foe != MHITYOU
@@ -2543,7 +2545,7 @@ static void _handle_behaviour(monsters *mon)
{
foe_x = you.x_pos;
foe_y = you.y_pos;
- proxFoe = proxPlayer; // take invis into account
+ proxFoe = proxPlayer; // Take invis into account.
}
else
{
@@ -2683,9 +2685,41 @@ static void _handle_behaviour(monsters *mon)
// Monster can see foe: continue 'tracking'
// by updating target x,y.
- if (mon->foe == MHITYOU)
+ if (mon->foe == MHITYOU && proxPlayer)
{
- if (proxPlayer && !trans_wall_block)
+ bool potentially_blocking = trans_wall_block;
+
+ // Smart monsters that can fire through walls won't use
+ // pathfinding.
+ if (potentially_blocking && mons_intel(mon->type) >= I_NORMAL
+ && mons_has_los_ability(mon->type))
+ {
+ potentially_blocking = false;
+ }
+ else
+ {
+ // Flying monsters don't see water/lava as obstacle.
+ // Also don't use pathfinding if the monster can shoot
+ // across the blocking terrain, and is smart enough to
+ // realize that.
+ if (!potentially_blocking && !mons_flies(mon)
+ && (mons_intel(mon->type) < I_NORMAL
+ || !mons_has_ranged_spell(mon)
+ && !mons_has_ranged_attack(mon)))
+ {
+ const habitat_type habit = mons_habitat(mon);
+ if (you.lava_in_sight && habit != HT_LAVA
+ || you.water_in_sight && habit != HT_WATER
+ && !mons_amphibious(mon))
+ {
+ potentially_blocking = true;
+ }
+ }
+ }
+
+ if (!potentially_blocking
+ || grid_see_grid(mon->x, mon->y, you.x_pos, you.y_pos,
+ can_move))
{
if (mon->travel_target != MTRAV_PATROL
&& mon->travel_target != MTRAV_NONE)
@@ -2695,9 +2729,8 @@ static void _handle_behaviour(monsters *mon)
mon->travel_target = MTRAV_NONE;
}
}
- else if (proxPlayer && trans_wall_block
- && (mon->travel_target != MTRAV_UNREACHABLE
- || one_chance_in(12)))
+ else if (mon->travel_target != MTRAV_UNREACHABLE
+ || one_chance_in(12))
{
#ifdef DEBUG_PATHFIND
mprf("%s: Player out of reach! What now?",
@@ -2711,8 +2744,8 @@ static void _handle_behaviour(monsters *mon)
#endif
int len = mon->travel_path.size();
coord_def targ = mon->travel_path[len - 1];
- if (grid_see_grid(targ.x, targ.y, you.x_pos, you.y_pos)
- && !trans_wall_blocking(targ.x, targ.y))
+ if (grid_see_grid(targ.x, targ.y, you.x_pos, you.y_pos,
+ can_move))
{
#ifdef DEBUG_PATHFIND
mpr("Target still valid?");
@@ -2817,7 +2850,8 @@ static void _handle_behaviour(monsters *mon)
mpr("No path found!");
#endif
mon->travel_target = MTRAV_UNREACHABLE;
- _mark_species_members_player_unreachable(mon);
+ // Pass information on to nearby monsters.
+ _mark_neighbours_player_unreachable(mon);
}
}
else
@@ -2826,6 +2860,7 @@ static void _handle_behaviour(monsters *mon)
mpr("No path found!");
#endif
mon->travel_target = MTRAV_UNREACHABLE;
+ _mark_neighbours_player_unreachable(mon);
}
}
}
@@ -6496,7 +6531,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
// Bounds check - don't consider moving out of grid!
if (!inside_level_bounds(targ_x, targ_y))
- return false;
+ return (false);
// Non-friendly and non-good neutral monsters won't enter sanctuaries.
if (!mons_wont_attack(monster)
@@ -6542,26 +6577,26 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
if (targ_x <= 7 || targ_x >= (GXM - 8)
|| targ_y <= 7 || targ_y >= (GYM - 8))
{
- return false;
+ return (false);
}
// Don't burrow at an angle (legacy behaviour).
if (count_x != 0 && count_y != 0)
- return false;
+ return (false);
}
else if (!monster->can_pass_through_feat(target_grid)
|| (no_water && target_grid >= DNGN_DEEP_WATER
&& target_grid <= DNGN_WATER_STUCK))
{
- return false;
+ return (false);
}
else if (!_habitat_okay( monster, target_grid ))
{
- return false;
+ return (false);
}
if (monster->type == MONS_WANDERING_MUSHROOM && see_grid(targ_x, targ_y))
- return false;
+ return (false);
// Water elementals avoid fire and heat.
if (monster->type == MONS_WATER_ELEMENTAL
@@ -6569,7 +6604,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
|| targ_cloud_type == CLOUD_FIRE
|| targ_cloud_type == CLOUD_STEAM))
{
- return false;
+ return (false);
}
// Fire elementals avoid water and cold
@@ -6577,7 +6612,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
&& (grid_is_watery(target_grid)
|| targ_cloud_type == CLOUD_COLD))
{
- return false;
+ return (false);
}
// Submerged water creatures avoid the shallows where
@@ -6591,7 +6626,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
&& grd[monster->x][monster->y] == DNGN_DEEP_WATER
&& monster->hit_points < (monster->max_hit_points * 3) / 4)
{
- return false;
+ return (false);
}
// Smacking the player is always a good move if we're
@@ -6606,9 +6641,9 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
if (just_check)
{
if (targ_x == monster->x && targ_y == monster->y)
- return true;
+ return (true);
- return false; // blocks square
+ return (false); // blocks square
}
const int thismonster = monster_index(monster),
@@ -6619,7 +6654,7 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
&& targmonster != MHITYOU
&& !_mons_can_displace(monster, &menv[targmonster]))
{
- return false;
+ return (false);
}
}
@@ -6631,21 +6666,21 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
&& targ_x == you.x_pos
&& targ_y == you.y_pos)
{
- return false;
+ return (false);
}
// Wandering through a trap is OK if we're pretty healthy,
// really stupid, or immune to the trap.
const int which_trap = trap_at_xy(targ_x,targ_y);
if (which_trap >= 0 && !_is_trap_safe(monster, targ_x, targ_y, just_check))
- return false;
+ return (false);
if (targ_cloud_num != EMPTY_CLOUD)
{
if (curr_cloud_num != EMPTY_CLOUD
&& targ_cloud_type == curr_cloud_type)
{
- return true;
+ return (true);
}
switch (targ_cloud_type)
@@ -6656,61 +6691,61 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x,
case CLOUD_FIRE:
if (mons_res_fire(monster) > 1)
- return true;
+ return (true);
if (monster->hit_points >= 15 + random2avg(46, 5))
- return true;
+ return (true);
break;
case CLOUD_STINK:
if (mons_res_poison(monster) > 0)
- return true;
+ return (true);
if (1 + random2(5) < monster->hit_dice)
- return true;
+ return (true);
if (monster->hit_points >= random2avg(19, 2))
- return true;
+ return (true);
break;
case CLOUD_COLD:
if (mons_res_cold(monster) > 1)
- return true;
+ return (true);
if (monster->hit_points >= 15 + random2avg(46, 5))
- return true;
+ return (true);
break;
case CLOUD_POISON:
if (mons_res_poison(monster) > 0)
- return true;
+ return (true);
if (monster->hit_points >= random2avg(37, 4))
- return true;
+ return (true);
break;
case CLOUD_GREY_SMOKE:
// This isn't harmful, but dumb critters might think so.
if (mons_intel(monster->type) > I_ANIMAL || coinflip())
- return true;
+ return (true);
if (mons_res_fire(monster) > 0)
- return true;
+ return (true);
if (monster->hit_points >= random2avg(19, 2))
- return true;
+ return (true);
break;
default:
- return true; // harmless clouds
+ return (true); // harmless clouds
}
// If we get here, the cloud is potentially harmful.
// Exceedingly dumb creatures will still wander in.
if (mons_intel(monster->type) != I_PLANT)
- return false;
+ return (false);
}
// If we end up here the monster can safely move.
- return true;
+ return (true);
}
static bool _monster_move(monsters *monster)
@@ -6725,7 +6760,7 @@ static bool _monster_move(monsters *monster)
if (monster->type == MONS_TRAPDOOR_SPIDER)
{
if(monster->has_ench(ENCH_SUBMERGED))
- return false;
+ return (false);
// Trapdoor spiders hide if they can't see their target.
bool can_see;
@@ -6743,7 +6778,7 @@ static bool _monster_move(monsters *monster)
{
monster->add_ench(ENCH_SUBMERGED);
monster->behaviour = BEH_LURK;
- return false;
+ return (false);
}
}
@@ -6784,16 +6819,16 @@ static bool _monster_move(monsters *monster)
return _do_move_monster(monster, mmov_x, mmov_y);
}
}
- return false;
+ return (false);
}
// Let's not even bother with this if mmov_x and mmov_y are zero.
if (mmov_x == 0 && mmov_y == 0)
- return false;
+ return (false);
if (mons_flies(monster) != FL_NONE
|| habitat != HT_LAND
- || mons_amphibious(monster->type))
+ || mons_amphibious(monster))
{
okmove = DNGN_MINMOVE;
}
@@ -6836,13 +6871,13 @@ static bool _monster_move(monsters *monster)
if (mons_itemuse(monster->base_monster) >= MONUSE_OPEN_DOORS)
{
_mons_open_door(monster, newpos);
- return true;
+ return (true);
}
}
else if (mons_itemuse(monster->type) >= MONUSE_OPEN_DOORS)
{
_mons_open_door(monster, newpos);
- return true;
+ return (true);
}
} // endif - secret/closed doors
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index d83e4b0e1d..dac568679c 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -5421,6 +5421,8 @@ void player::init()
banished_by.clear();
entering_level = false;
+ lava_in_sight = false;
+ water_in_sight = false;
transit_stair = DNGN_UNSEEN;
berserk_penalty = 0;
diff --git a/crawl-ref/source/spl-data.h b/crawl-ref/source/spl-data.h
index 4c13af9f20..453cb7154c 100644
--- a/crawl-ref/source/spl-data.h
+++ b/crawl-ref/source/spl-data.h
@@ -1462,7 +1462,7 @@
SPELL_POISON_AMMUNITION, "Poison Ammunition",
SPTYP_ENCHANTMENT | SPTYP_POISON,
SPFLAG_NONE,
- 4, // jmf: SPTYP_TRANSMIGRATION vs SPTYP_ENCHANTMENT?
+ 4,
0,
NULL,
false,
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index caa83181df..dc0932e8d5 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -996,6 +996,9 @@ static void tag_construct_you(writer &th)
marshallShort(th, you.transit_stair);
marshallByte(th, you.entering_level);
+ // lava_in_sight and water_in_sight don't need to be saved as they can
+ // be recalculated on game start
+
// List of currently beholding monsters (usually empty).
marshallByte(th, you.beheld_by.size());
for (unsigned int k = 0; k < you.beheld_by.size(); k++)
@@ -1383,6 +1386,9 @@ static void tag_read_you(reader &th, char minorVersion)
you.transit_stair = static_cast<dungeon_feature_type>(unmarshallShort(th));
you.entering_level = unmarshallByte(th);
+ // These two need not be saved.
+ you.lava_in_sight = false;
+ you.water_in_sight = false;
// List of currently beholding monsters (usually empty).
count_c = unmarshallByte(th);
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 905fe0e967..61d2bb6821 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -1281,7 +1281,7 @@ bool check_awaken(monsters* monster)
&& you.special_wield != SPWLD_SHADOW
&& !mons_wont_attack(monster)
&& !mons_class_flag(monster->type, M_NO_EXP_GAIN)
- // if invisible, training happens much more rarely
+ // If invisible, training happens much more rarely.
&& (!unnatural_stealthy && one_chance_in(25) || one_chance_in(100)))
{
exercise(SK_STEALTH, 1);