summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-13 13:56:45 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-13 13:56:45 +0000
commitd2a1017761869d23760a73a30e51903e872da28a (patch)
tree5e103a79e9b78236a955d9510c90ace143daff86 /crawl-ref/source/monstuff.cc
parent7a66364b0a9a5ee83119698e5d84b8293d3b3b62 (diff)
downloadcrawl-ref-d2a1017761869d23760a73a30e51903e872da28a.tar.gz
crawl-ref-d2a1017761869d23760a73a30e51903e872da28a.zip
FR 2046572: Don't anger allies by teleporting them. (Maybe enslaved monsters
should be exempted from that, but for now they're not.) Make *all* allies (including zombies) avoid Zot traps known to the player, but don't let them avoid unknown ones (unless native, or highly intelligent, as usual.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7444 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc43
1 files changed, 24 insertions, 19 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index cc73d8a844..f2259451ef 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -6535,15 +6535,21 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where,
{
const int intel = mons_intel(monster);
- // Dumb monsters don't care at all.
- if (intel == I_PLANT)
- return (true);
-
const trap_def *ptrap = find_trap(where);
if (!ptrap)
return (true);
const trap_def& trap = *ptrap;
+ const bool player_knows_trap = (trap.is_known(&you));
+
+ // No friendly monsters will ever enter a Zot trap you know.
+ if (player_knows_trap && mons_friendly(monster) && trap.type == TRAP_ZOT)
+ return (false);
+
+ // Dumb monsters don't care at all.
+ if (intel == I_PLANT)
+ return (true);
+
if (trap.type == TRAP_SHAFT && monster->will_trigger_shaft())
{
if ((mons_is_fleeing(monster) || mons_is_pacified(monster))
@@ -6554,11 +6560,9 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where,
return (false);
}
- // Monsters are not afraid of non-mechanical traps. XXX: If we add
- // any non-mechanical traps that can damage monsters, we must add
- // checks for them here.
+ // Hostile monsters are not afraid of non-mechanical traps.
+ // Allies will try to avoid teleportation and zot traps.
const bool mechanical = (trap.category() == DNGN_TRAP_MECHANICAL);
- const bool player_knows_trap = (trap.is_known(&you));
if (trap.is_known(monster))
{
@@ -6581,10 +6585,9 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where,
// hostile terrain or other traps rather than walls.
// What we do is check whether the squares with the relative
// positions (-1,0)/(+1,0) or (0,-1)/(0,+1) form a "corridor"
- // (relative to the _current_ monster position rather than the
- // trap one).
+ // (relative to the _trap_ position rather than the monster one).
// If they don't, the trap square is marked as "unsafe" (because
- // there's good alternative move for the monster to take),
+ // there's a good alternative move for the monster to take),
// otherwise the decision will be made according to later tests
// (monster hp, trap type, ...)
// If a monster still gets stuck in a corridor it will usually be
@@ -6618,7 +6621,10 @@ static bool _is_trap_safe(const monsters *monster, const coord_def& where,
// Friendly and good neutral monsters don't enjoy Zot trap perks;
// handle accordingly.
if (mons_wont_attack(monster))
- return (mechanical ? mons_flies(monster) : trap.type != TRAP_ZOT);
+ {
+ return (mechanical ? mons_flies(monster)
+ : !trap.is_known(monster) || trap.type != TRAP_ZOT);
+ }
else
return (!mechanical || mons_flies(monster));
}
@@ -6733,13 +6739,13 @@ static bool _mon_can_move_to_pos(const monsters *monster,
const int targ_cloud_num = env.cgrid(targ);
const int targ_cloud_type =
- targ_cloud_num == EMPTY_CLOUD ? CLOUD_NONE
- : env.cloud[targ_cloud_num].type;
+ (targ_cloud_num == EMPTY_CLOUD) ? CLOUD_NONE
+ : env.cloud[targ_cloud_num].type;
const int curr_cloud_num = env.cgrid(monster->pos());
const int curr_cloud_type =
- curr_cloud_num == EMPTY_CLOUD ? CLOUD_NONE
- : env.cloud[curr_cloud_num].type;
+ (curr_cloud_num == EMPTY_CLOUD) ? CLOUD_NONE
+ : env.cloud[curr_cloud_num].type;
if (monster->type == MONS_BORING_BEETLE
&& (target_grid == DNGN_ROCK_WALL
@@ -7007,7 +7013,7 @@ static bool _monster_move(monsters *monster)
const int targ_y = monster->pos().y + count_y - 1;
// Bounds check - don't consider moving out of grid!
- if (targ_x < 0 || targ_x >= GXM || targ_y < 0 || targ_y >= GYM)
+ if (!in_bounds(targ_x, targ_y))
{
good_move[count_x][count_y] = false;
continue;
@@ -7027,8 +7033,7 @@ static bool _monster_move(monsters *monster)
// Normal/smart monsters know about secret doors
// (they _live_ in the dungeon!)
if (grd(newpos) == DNGN_CLOSED_DOOR
- || grd(newpos) == DNGN_SECRET_DOOR
- && mons_intel(monster) >= I_NORMAL)
+ || grd(newpos) == DNGN_SECRET_DOOR && mons_intel(monster) >= I_NORMAL)
{
if (mons_is_zombified(monster))
{