summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-14 00:32:22 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-03-14 00:32:22 +0000
commitd686480e6613e1eed62238edc19d51ad7ccddc82 (patch)
treeb40c3b8cc5af144c49edfc7600b588c3a644fffe
parentd7711166c771976bf2f668e04229539c1028ba06 (diff)
downloadcrawl-ref-d686480e6613e1eed62238edc19d51ad7ccddc82.tar.gz
crawl-ref-d686480e6613e1eed62238edc19d51ad7ccddc82.zip
Really fix monster speed handling, so that enslaved intact souls can
have their speed properly overridden. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9457 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/describe.cc3
-rw-r--r--crawl-ref/source/mon-util.cc20
-rw-r--r--crawl-ref/source/mon-util.h5
-rw-r--r--crawl-ref/source/monplace.cc7
4 files changed, 20 insertions, 15 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 527e11dce0..3e61fce6f1 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -2683,8 +2683,7 @@ static std::string _monster_stat_description(const monsters& mon)
result << pronoun << " can sense the presence of invisible creatures.$";
// Unusual monster speed.
- const int speed = mons_class_is_zombified(mon.type) ?
- mons_class_zombie_speed(mon.base_monster) : mons_class_speed(mon.type);
+ const int speed = mons_base_speed(&mon);
if (speed != 10)
{
result << pronoun << " is ";
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 113d8a6973..5d062487d8 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1584,14 +1584,11 @@ int exper_value(const monsters *monster)
// These four are the original arguments.
const int mclass = monster->type;
- const int zclass = monster->base_monster;
const int mHD = monster->hit_dice;
const int maxhp = monster->max_hit_points;
// These are some values we care about.
- const int speed =
- mons_is_zombified(monster) ? mons_class_zombie_speed(zclass)
- : mons_class_speed(mclass);
+ const int speed = mons_base_speed(monster);
const int modifier = _mons_exp_mod(mclass);
const int item_usage = mons_itemuse(monster);
@@ -2302,15 +2299,24 @@ static int _mons_exp_mod(int mc)
return (smc->exp_mod);
}
-int mons_class_speed(int mc)
+int mons_class_base_speed(int mc)
{
ASSERT(smc);
return (smc->speed);
}
-int mons_class_zombie_speed(int mc)
+int mons_class_zombie_base_speed(int zombie_base_mc)
{
- return (std::max(3, _base_speed(mc) - 2));
+ return (std::max(3, _base_speed(zombie_base_mc) - 2));
+}
+
+int mons_base_speed(const monsters *mon)
+{
+ if (mons_enslaved_intact_soul(mon))
+ return (mons_class_base_speed(mons_zombie_base(mon)));
+
+ return (mons_is_zombified(mon) ? mons_class_zombie_base_speed(mons_zombie_base(mon))
+ : mons_class_base_speed(mon->type));
}
mon_intel_type mons_class_intel(int mc)
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index 0454c7fc83..92eacdaf3b 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -624,8 +624,9 @@ int mons_weight(int mc);
/* ***********************************************************************
* called from: monplace mon-util
* *********************************************************************** */
-int mons_class_speed(int mc);
-int mons_class_zombie_speed(int mc);
+int mons_class_base_speed(int mc);
+int mons_class_zombie_base_speed(int zombie_base_mc);
+int mons_base_speed(const monsters *mon);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index bdb50f3380..b112896d4b 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -763,7 +763,7 @@ int place_monster(mgen_data mg, bool force_pos)
// For some cases disallow monsters on stairs.
if (mons_class_is_stationary(mg.cls)
|| (pval == 2 // Stairs occupied by player.
- && (mons_class_speed(mg.cls) == 0
+ && (mons_class_base_speed(mg.cls) == 0
|| grd(mg.pos) == DNGN_LAVA
|| grd(mg.pos) == DNGN_DEEP_WATER)))
{
@@ -830,8 +830,7 @@ int place_monster(mgen_data mg, bool force_pos)
case PROX_NEAR_STAIRS:
if (pval == 2) // player on stairs
{
- // 0 speed monsters can't shove player out of their way.
- if (mons_class_speed(mg.cls) == 0)
+ if (mons_class_base_speed(mg.cls) == 0)
{
proxOK = false;
break;
@@ -1387,7 +1386,7 @@ static void _define_zombie(int mid, monster_type ztype, monster_type cs,
menv[mid].ev -= 5;
menv[mid].ev = std::max(0, menv[mid].ev);
- menv[mid].speed = mons_class_zombie_speed(menv[mid].base_monster);
+ menv[mid].speed = mons_class_zombie_base_speed(menv[mid].base_monster);
// Now override type with the required type.
if (cs == MONS_ZOMBIE_SMALL || cs == MONS_ZOMBIE_LARGE)