summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-28 15:38:23 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-28 15:38:23 +0000
commit77482d829e77d44e438eeb5f43f898a7693c038b (patch)
tree8376d956696e1741d69419ba1a36679097c69ddc
parent583a087da1a61c5dbb919f78019c7b8d1b02b206 (diff)
downloadcrawl-ref-77482d829e77d44e438eeb5f43f898a7693c038b.tar.gz
crawl-ref-77482d829e77d44e438eeb5f43f898a7693c038b.zip
[1837663] Fixed monsters' raise dead using player's LOS.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2920 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/abl-show.cc2
-rw-r--r--crawl-ref/source/externs.h16
-rw-r--r--crawl-ref/source/it_use3.cc2
-rw-r--r--crawl-ref/source/monstuff.cc3
-rw-r--r--crawl-ref/source/mstuff2.cc3
-rw-r--r--crawl-ref/source/spells2.cc42
-rw-r--r--crawl-ref/source/spells2.h3
-rw-r--r--crawl-ref/source/spl-cast.cc2
-rw-r--r--crawl-ref/source/view.cc53
-rw-r--r--crawl-ref/source/view.h26
10 files changed, 81 insertions, 71 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 3892ceb210..1e41abedc1 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1430,7 +1430,7 @@ static bool do_ability(const ability_def& abil)
case ABIL_YRED_ANIMATE_DEAD:
mpr("You call on the dead to walk for you...");
- animate_dead( 1 + you.skills[SK_INVOCATIONS], BEH_FRIENDLY,
+ animate_dead( &you, 1 + you.skills[SK_INVOCATIONS], BEH_FRIENDLY,
you.pet_target, 1 );
exercise(SK_INVOCATIONS, 2 + random2(4));
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 248be30cda..8f0ae5144a 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1276,6 +1276,8 @@ private:
};
typedef FixedArray<dungeon_feature_type, GXM, GYM> feature_grid;
+typedef FixedArray<unsigned, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>
+ env_show_grid;
struct crawl_environment
{
@@ -1294,15 +1296,15 @@ public:
FixedArray< map_cell, GXM, GYM > map; // discovered terrain
- FixedArray<unsigned, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>
- show; // view window char
- FixedArray<unsigned short, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>
- show_col; // view window colour
-
+ // Glyphs of squares that are in LOS.
+ env_show_grid show;
+
// What would be visible, if all of the translucent wall were
// made opaque.
- FixedArray<unsigned, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>
- no_trans_show;
+ env_show_grid no_trans_show;
+
+ FixedArray<unsigned short, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>
+ show_col; // view window colour
FixedVector< cloud_struct, MAX_CLOUDS > cloud; // cloud list
unsigned char cloud_no;
diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc
index 126bdcdfb4..7b1f4fba04 100644
--- a/crawl-ref/source/it_use3.cc
+++ b/crawl-ref/source/it_use3.cc
@@ -199,7 +199,7 @@ void special_wielded()
case SPWLD_ZONGULDROK:
if (one_chance_in(5))
{
- animate_dead( 1 + random2(3), BEH_HOSTILE, MHITYOU, 1 );
+ animate_dead( &you, 1 + random2(3), BEH_HOSTILE, MHITYOU, 1 );
did_god_conduct( DID_NECROMANCY, 1 );
}
break;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 72dd128dec..928f05e50a 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -3760,7 +3760,8 @@ static bool handle_spell( monsters *monster, bolt & beem )
// Try to animate dead: if nothing rises, pretend we didn't cast it
if (spell_cast == SPELL_ANIMATE_DEAD
- && !animate_dead( 100, SAME_ATTITUDE(monster), monster->foe, 0 ))
+ && !animate_dead( monster, 100, SAME_ATTITUDE(monster),
+ monster->foe, 0 ))
{
return (false);
}
diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc
index a47b520a8d..d78a833819 100644
--- a/crawl-ref/source/mstuff2.cc
+++ b/crawl-ref/source/mstuff2.cc
@@ -611,7 +611,8 @@ void mons_cast(monsters *monster, bolt &pbolt, spell_type spell_cast)
case SPELL_ANIMATE_DEAD:
// see special handling in monstuff::handle_spell {dlb}
- animate_dead( 5 + random2(5), SAME_ATTITUDE(monster), monster->foe, 1 );
+ animate_dead( monster, 5 + random2(5), SAME_ATTITUDE(monster),
+ monster->foe, 1 );
return;
case SPELL_CALL_IMP: // class 5 demons
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index db0be3cd39..df26d89eee 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -297,17 +297,17 @@ int corpse_rot(int power)
return 0;
} // end corpse_rot()
-int animate_dead( int power, beh_type corps_beh, int corps_hit, int actual )
+int animate_dead( actor *caster, int power, beh_type corps_beh,
+ int corps_hit, int actual )
{
UNUSED( power );
+ static env_show_grid losgrid;
- int adx = 0;
- int ady = 0;
-
- int minx = you.x_pos - 6;
- int maxx = you.x_pos + 7;
- int miny = you.y_pos - 6;
- int maxy = you.y_pos + 7;
+ const coord_def c(caster->pos());
+ int minx = c.x - 6;
+ int maxx = c.x + 7;
+ int miny = c.y - 6;
+ int maxy = c.y + 7;
int xinc = 1;
int yinc = 1;
@@ -315,27 +315,33 @@ int animate_dead( int power, beh_type corps_beh, int corps_hit, int actual )
if (coinflip())
{
- minx = you.x_pos + 6;
- maxx = you.x_pos - 7;
+ minx = c.x + 6;
+ maxx = c.x - 7;
xinc = -1;
}
if (coinflip())
{
- miny = you.y_pos + 6;
- maxy = you.y_pos - 7;
+ miny = c.y + 6;
+ maxy = c.y - 7;
yinc = -1;
}
- for (adx = minx; adx != maxx; adx += xinc)
+ if (caster != &you)
+ losight(losgrid, grd, c.x, c.y, true);
+
+ env_show_grid &los(caster == &you? env.no_trans_show : losgrid);
+
+ coord_def a;
+ for (a.x = minx; a.x != maxx; a.x += xinc)
{
- for (ady = miny; ady != maxy; ady += yinc)
+ for (a.y = miny; a.y != maxy; a.y += yinc)
{
- if (see_grid_no_trans(adx, ady))
+ if (in_bounds(a) && see_grid(los, c, a))
{
- if (igrd[adx][ady] != NON_ITEM)
+ if (igrd(a) != NON_ITEM)
{
- int objl = igrd[adx][ady];
+ int objl = igrd(a);
int hrg = 0;
// This searches all the items on the ground for a corpse
@@ -344,7 +350,7 @@ int animate_dead( int power, beh_type corps_beh, int corps_hit, int actual )
if (is_animatable_corpse(mitm[objl])
&& !is_being_butchered(mitm[objl]))
{
- number_raised += raise_corpse(objl, adx, ady,
+ number_raised += raise_corpse(objl, a.x, a.y,
corps_beh, corps_hit, actual);
break;
}
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index 57de63e987..213c542d0c 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -37,7 +37,8 @@ int animate_a_corpse(int axps, int ayps, beh_type corps_beh,
/* ***********************************************************************
* called from: ability - it_use3 - monstuff - mstuff2 - spell
* *********************************************************************** */
-int animate_dead(int power, beh_type corps_beh, int corps_hit, int actual);
+int animate_dead(actor *caster, int power, beh_type corps_beh,
+ int corps_hit, int actual);
// last updated 24may2000 {dlb}
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 3685534fe2..e4d05849c6 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -1316,7 +1316,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail )
case SPELL_ANIMATE_DEAD:
mpr("You call on the dead to walk for you.");
- animate_dead(powc + 1, BEH_FRIENDLY, you.pet_target, 1);
+ animate_dead(&you, powc + 1, BEH_FRIENDLY, you.pet_target, 1);
break;
case SPELL_PAIN:
diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc
index 121d9ca833..fbdf5cab3b 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -2265,8 +2265,8 @@ int num_feats_between(int sourcex, int sourcey, int targetx, int targety,
// IMPROVEMENTS:
// Smoke will now only block LOS after two cells of smoke. This is
// done by updating with a second array.
-void losight(FixedArray < unsigned int, 19, 19 > &sh,
- FixedArray < dungeon_feature_type, 80, 70 > &gr, int x_p, int y_p,
+void losight(env_show_grid &sh,
+ feature_grid &gr, int x_p, int y_p,
bool clear_walls_block)
{
raycast();
@@ -3302,51 +3302,40 @@ bool mons_near(const monsters *monster, unsigned int foe)
return (false);
} // end mons_near()
-// answers the question: "Is a grid within character's line of sight?"
-bool see_grid( int grx, int gry )
+bool see_grid( const env_show_grid &show,
+ const coord_def &c,
+ const coord_def &pos )
{
- // rare case: can player see self? (of course!)
- if (grx == you.x_pos && gry == you.y_pos)
+ if (c == pos)
return (true);
- // check env.show array
- if (grid_distance( grx, gry, you.x_pos, you.y_pos ) < 9)
+ const coord_def ip = pos - c;
+ if (ip.rdist() < ENV_SHOW_OFFSET)
{
- const int ex = grx - you.x_pos + 9;
- const int ey = gry - you.y_pos + 9;
-
- if (env.show[ex][ey])
+ const coord_def sp(ip + coord_def(ENV_SHOW_OFFSET, ENV_SHOW_OFFSET));
+ if (show(sp))
return (true);
}
-
return (false);
-} // end see_grid()
+}
+
+// answers the question: "Is a grid within character's line of sight?"
+bool see_grid( const coord_def &p )
+{
+ return see_grid(env.show, you.pos(), p);
+}
// answers the question: "Would a grid be within character's line of sight,
// even if all translucent/clear walls were made opaque?"
-bool see_grid_no_trans( int grx, int gry )
+bool see_grid_no_trans( const coord_def &p )
{
- // rare case: can player see self? (of course!)
- if (grx == you.x_pos && gry == you.y_pos)
- return (true);
-
- // check no_trans_show array
- if (grid_distance( grx, gry, you.x_pos, you.y_pos ) < 9)
- {
- const int ex = grx - you.x_pos + 9;
- const int ey = gry - you.y_pos + 9;
-
- if (env.no_trans_show[ex][ey])
- return (true);
- }
-
- return (false);
+ return see_grid(env.no_trans_show, you.pos(), p);
}
// Is the grid visible, but a translucent wall is in the way?
-bool trans_wall_blocking( int grx, int gry )
+bool trans_wall_blocking( const coord_def &p )
{
- return see_grid(grx, gry) && !see_grid_no_trans(grx, gry);
+ return see_grid(p) && !see_grid_no_trans(p);
}
static const unsigned table[ NUM_CSET ][ NUM_DCHAR_TYPES ] =
diff --git a/crawl-ref/source/view.h b/crawl-ref/source/view.h
index f51d6fcd7b..931746f980 100644
--- a/crawl-ref/source/view.h
+++ b/crawl-ref/source/view.h
@@ -100,8 +100,7 @@ void find_features(const std::vector<coord_def>& features,
/* ***********************************************************************
* called from: direct - monstufff - view
* *********************************************************************** */
-void losight(FixedArray<unsigned int, ENV_SHOW_DIAMETER, ENV_SHOW_DIAMETER>& sh,
- FixedArray<dungeon_feature_type, GXM, GYM>& gr,
+void losight(env_show_grid &sh, feature_grid &gr,
int x_p, int y_p, bool clear_walls_block = false);
@@ -190,16 +189,27 @@ void add_feature_override(const std::string &text);
void clear_cset_overrides();
void add_cset_override(char_set_type set, const std::string &overrides);
-bool see_grid( int grx, int gry );
-inline bool see_grid(const coord_def &p) { return see_grid(p.x, p.y); }
+bool see_grid( const env_show_grid &show,
+ const coord_def &c,
+ const coord_def &pos );
+bool see_grid(const coord_def &p);
+bool see_grid_no_trans( const coord_def &p );
+bool trans_wall_blocking( const coord_def &p );
-bool see_grid_no_trans( int grx, int gry );
-inline bool see_grid_no_trans(const coord_def &p)
+inline bool see_grid( int grx, int gry )
{
- return see_grid_no_trans(p.x, p.y);
+ return see_grid(coord_def(grx, gry));
}
-bool trans_wall_blocking( int grx, int gry );
+inline bool see_grid_no_trans(int x, int y)
+{
+ return see_grid_no_trans(coord_def(x, y));
+}
+
+inline bool trans_wall_blocking(int x, int y)
+{
+ return trans_wall_blocking(coord_def(x, y));
+}
std::string screenshot(bool fullscreen = false);