summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
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
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')
-rw-r--r--crawl-ref/source/beam.cc17
-rw-r--r--crawl-ref/source/monstuff.cc43
-rw-r--r--crawl-ref/source/traps.cc3
3 files changed, 35 insertions, 28 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index a49f943d84..9e8d112083 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -5257,11 +5257,21 @@ static bool _nasty_beam(monsters *mon, const bolt &beam)
return (true);
// Now for some non-hurtful enchantments.
+ if (beam.flavour == BEAM_DIGGING)
+ return (false);
+
+ // haste/healing/invisibility
+ if (_nice_beam(mon, beam))
+ return (false);
// No charming holy beings!
if (beam.flavour == BEAM_CHARM)
return (mons_is_holy(mon));
+ // Friendly and good neutral monsters don't mind being teleported.
+ if (beam.flavour == BEAM_TELEPORT)
+ return (!mons_wont_attack(mon));
+
// degeneration / sleep / enslave soul
if (beam.flavour == BEAM_DEGENERATE || beam.flavour == BEAM_SLEEP
|| beam.flavour == BEAM_ENSLAVE_SOUL)
@@ -5284,13 +5294,6 @@ static bool _nasty_beam(monsters *mon, const bolt &beam)
if (beam.flavour == BEAM_ENSLAVE_DEMON)
return (mons_holiness(mon) == MH_DEMONIC);
- // haste/healing/invisibility
- if (beam.flavour == BEAM_HASTE || beam.flavour == BEAM_HEALING
- || beam.flavour == BEAM_INVISIBILITY)
- {
- return (false);
- }
-
// everything else is considered nasty by everyone
return (true);
}
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))
{
diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc
index c30381da63..dc27ad8df8 100644
--- a/crawl-ref/source/traps.cc
+++ b/crawl-ref/source/traps.cc
@@ -152,7 +152,6 @@ bool trap_def::is_known(const actor* act) const
if (act->atype() == ACT_MONSTER)
{
const monsters* monster = dynamic_cast<const monsters*>(act);
- const bool mechanical = (this->category() == DNGN_TRAP_MECHANICAL);
const int intel = mons_intel(monster);
// Smarter trap handling for intelligent monsters
@@ -163,7 +162,7 @@ bool trap_def::is_known(const actor* act) const
// * very intelligent monsters can be assumed to have a high T&D
// skill (or have memorised part of the dungeon layout ;) )
- rc = (intel >= I_NORMAL && mechanical
+ rc = (intel >= I_NORMAL
&& (mons_is_native_in_branch(monster)
|| mons_wont_attack(monster) && player_knows
|| intel >= I_HIGH && one_chance_in(3)));