summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 06:53:52 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-29 06:53:52 +0000
commit8cffb32e8c61a88ce23b389c5d1e4255e21e59d9 (patch)
treefee921f947ec465a58a91b65fa53dc21ad8fbecd /crawl-ref
parentdcf9fc82a633b9541eae069e209088bcaa557cc8 (diff)
downloadcrawl-ref-8cffb32e8c61a88ce23b389c5d1e4255e21e59d9.tar.gz
crawl-ref-8cffb32e8c61a88ce23b389c5d1e4255e21e59d9.zip
Only place a newly created monster (summons) on a sanctuary square if it
is friendly. Only allow friendly and neutral-good monsters to blink or teleport onto a sanctuary square. Don't allow corpses on sanctuary squares to be rotted or animated. Restrict monster cantrip messages to self-buff types if the player is in sanctuary. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6211 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/monplace.cc4
-rw-r--r--crawl-ref/source/monstuff.cc9
-rw-r--r--crawl-ref/source/monstuff.h3
-rw-r--r--crawl-ref/source/mstuff2.cc36
-rw-r--r--crawl-ref/source/spells2.cc2
-rw-r--r--crawl-ref/source/spells3.cc3
6 files changed, 38 insertions, 19 deletions
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index ec18719873..d17b46d5e4 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -807,6 +807,7 @@ static int _place_monster_aux( const mgen_data &mg,
// Setup habitat and placement.
// If the space is occupied, try some neighbouring square instead.
if (first_band_member && in_bounds(mg.pos)
+ && (mg.behaviour == BEH_FRIENDLY || !is_sanctuary(mg.pos.x, mg.pos.y))
&& (force_pos || mgrd(mg.pos) == NON_MONSTER && mg.pos != you.pos()
&& monster_habitable_grid(htype, grd(mg.pos))))
{
@@ -833,6 +834,9 @@ static int _place_monster_aux( const mgen_data &mg,
if (!grid_compatible(grid_wanted, grd(fpos), true))
continue;
+ if (mg.behaviour != BEH_FRIENDLY && is_sanctuary(fpos.x, fpos.y))
+ continue;
+
// Don't generate monsters on top of teleport traps.
// (How do they get there?)
int trap = trap_at_xy(fpos.x, fpos.y);
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 2c9ddee6fd..c40052035e 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -1647,7 +1647,9 @@ bool monster_blink(monsters *monster)
losight(env.show, grd, monster->x, monster->y, true);
if (!random_near_space(monster->x, monster->y, nx, ny,
- false, true))
+ false, true,
+ !mons_friendly(monster)
+ && !mons_good_neutral(monster)))
{
return (false);
}
@@ -1675,7 +1677,7 @@ bool monster_blink(monsters *monster)
// allow_adjacent: allow target to be adjacent to origin.
// restrict_LOS: restrict target to be within PLAYER line of sight.
bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent,
- bool restrict_LOS)
+ bool restrict_LOS, bool forbid_sanctuary)
{
// This might involve ray tracing (via num_feats_between()), so
// cache results to avoid duplicating ray traces.
@@ -1718,7 +1720,8 @@ bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent,
|| grd[tx][ty] < DNGN_SHALLOW_WATER
|| mgrd[tx][ty] != NON_MONSTER
|| tx == you.x_pos && ty == you.y_pos
- || !allow_adjacent && distance(ox, oy, tx, ty) <= 2)
+ || !allow_adjacent && distance(ox, oy, tx, ty) <= 2
+ || forbid_sanctuary && is_sanctuary(tx, ty))
{
continue;
}
diff --git a/crawl-ref/source/monstuff.h b/crawl-ref/source/monstuff.h
index 5aee3f67e0..30fc17ecfc 100644
--- a/crawl-ref/source/monstuff.h
+++ b/crawl-ref/source/monstuff.h
@@ -125,7 +125,8 @@ bool monster_blink(monsters *monster);
* false, false
* *********************************************************************** */
bool random_near_space( int ox, int oy, int &tx, int &ty,
- bool allow_adjacent = false, bool restrict_LOS = true);
+ bool allow_adjacent = false, bool restrict_LOS = true,
+ bool forbid_sanctuary = false);
/* ***********************************************************************
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index 841a3ca89c..7e57b643e3 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -786,6 +786,8 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
case SPELL_CANTRIP:
{
const bool friendly = mons_friendly(monster);
+ const bool buff_only = !friendly && is_sanctuary(you.x_pos,
+ you.y_pos);
bool need_friendly_stub = false;
const msg_channel_type channel = (friendly) ? MSGCH_FRIEND_ENCHANT
: MSGCH_MONSTER_ENCHANT;
@@ -795,35 +797,35 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
// spells (ie orc priest) can be toned down a bit. -- bwr
//
// XXX: Needs expansion, and perhaps different priest/mage flavours.
- switch (random2(7))
+ switch (random2(buff_only ? 4 : 7))
{
case 0:
simple_monster_message(monster, " glows brightly for a moment.",
channel);
break;
case 1:
- if (friendly)
- need_friendly_stub = true;
- else
- mpr("You feel troubled.");
+ simple_monster_message(monster, " looks stronger.",
+ channel);
break;
case 2:
- if (friendly)
- need_friendly_stub = true;
- else
- mpr("You feel a wave of unholy energy pass over you.");
+ simple_monster_message(monster, " becomes somewhat translucent.",
+ channel);
break;
case 3:
- simple_monster_message(monster, " looks stronger.",
+ simple_monster_message(monster, "'s eyes start to glow.",
channel);
break;
case 4:
- simple_monster_message(monster, " becomes somewhat translucent.",
- channel);
+ if (friendly)
+ need_friendly_stub = true;
+ else
+ mpr("You feel troubled.");
break;
case 5:
- simple_monster_message(monster, "'s eyes start to glow.",
- channel);
+ if (friendly)
+ need_friendly_stub = true;
+ else
+ mpr("You feel a wave of unholy energy pass over you.");
break;
case 6:
default:
@@ -1012,6 +1014,12 @@ void monster_teleport(monsters *monster, bool instan, bool silent)
continue;
}
+ if (is_sanctuary(newx, newy) && !mons_friendly(monster)
+ && !mons_good_neutral(monster))
+ {
+ continue;
+ }
+
if (monster_habitable_grid(monster, grd[newx][newy]))
break;
}
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 7e078290c0..ec85a04ab2 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -267,7 +267,7 @@ int corpse_rot(int power)
for (adx = minx; adx != maxx; adx += xinc)
for (ady = miny; ady != maxy; ady += yinc)
{
- if (see_grid_no_trans(adx, ady))
+ if (see_grid_no_trans(adx, ady) && !is_sanctuary(adx, ady))
{
if (igrd[adx][ady] == NON_ITEM
|| env.cgrid[adx][ady] != EMPTY_CLOUD)
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 524cf1f790..bc1a5c8a5f 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -871,6 +871,9 @@ bool animate_a_corpse(const coord_def &a, corpse_type class_allowed,
god_type god, bool actual,
bool quiet)
{
+ if (is_sanctuary(a.x, a.y))
+ return (false);
+
bool success = false;
// Search all the items on the ground for a corpse.