summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-24 17:28:46 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-24 17:28:46 +0000
commit6df89800353b16e265eebf447d8b898469cd7bc8 (patch)
treefb20abdbf5b483a9a5f257b9dcdec7b03d338a08 /crawl-ref/source
parente63d0ce25374303ed7a08f0993eecb7d509b5eac (diff)
downloadcrawl-ref-6df89800353b16e265eebf447d8b898469cd7bc8.tar.gz
crawl-ref-6df89800353b16e265eebf447d8b898469cd7bc8.zip
Add priest promotion-re;ated fixes. Rename monsters::change_type() to
monsters::upgrade_type(), as it's more accurate, allow it to adjust HD as well as HP, and do the latter when promoting to a priest, to make sure that it ends up with the proper HD. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3860 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/externs.h4
-rw-r--r--crawl-ref/source/mgrow.cc12
-rw-r--r--crawl-ref/source/mgrow.h2
-rw-r--r--crawl-ref/source/religion.cc2
4 files changed, 14 insertions, 6 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 89aa78bb2b..315a12f01f 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1202,7 +1202,7 @@ public:
int stat_hp() const { return hit_points; }
int stat_maxhp() const { return max_hit_points; }
-
+
int shield_bonus() const;
int shield_block_penalty() const;
void shield_block_succeeded();
@@ -1213,7 +1213,7 @@ public:
// Hacks, with a capital H.
void fix_speed();
void check_speed();
- void change_type(monster_type after, bool adjust_hp);
+ void upgrade_type(monster_type after, bool adjust_hd, bool adjust_hp);
std::string describe_enchantments() const;
diff --git a/crawl-ref/source/mgrow.cc b/crawl-ref/source/mgrow.cc
index 3d3a59185d..9a7f518dcb 100644
--- a/crawl-ref/source/mgrow.cc
+++ b/crawl-ref/source/mgrow.cc
@@ -98,7 +98,8 @@ static const monster_level_up *monster_level_up_target(
return (NULL);
}
-void monsters::change_type(monster_type after, bool adjust_hp)
+void monsters::upgrade_type(monster_type after, bool adjust_hd,
+ bool adjust_hp)
{
const monsterentry *orig = get_monster_data(type);
// Ta-da!
@@ -118,6 +119,13 @@ void monsters::change_type(monster_type after, bool adjust_hp)
ac += m->AC - orig->AC;
ev += m->ev - orig->ev;
+ if (adjust_hd)
+ {
+ const int minhd = dummy.hit_dice;
+ if (hit_dice < minhd)
+ hit_dice += minhd - hit_dice;
+ }
+
if (adjust_hp)
{
const int minhp = dummy.max_hit_points;
@@ -135,7 +143,7 @@ bool monsters::level_up_change()
if (const monster_level_up *lup =
monster_level_up_target(static_cast<monster_type>(type), hit_dice))
{
- change_type(lup->after, lup->adjust_hp);
+ upgrade_type(lup->after, false, lup->adjust_hp);
return (true);
}
return (false);
diff --git a/crawl-ref/source/mgrow.h b/crawl-ref/source/mgrow.h
index 047e1ed821..36ddfb8000 100644
--- a/crawl-ref/source/mgrow.h
+++ b/crawl-ref/source/mgrow.h
@@ -19,7 +19,7 @@ struct monster_level_up
monster_type before, after;
int chance; // Chance in 1000 of the monster growing up,
// defaults to 1000.
-
+
bool adjust_hp; // If hp post growing up is less than minimum, adjust it.
monster_level_up(monster_type _before, monster_type _after,
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index a4aeb10da9..d188504969 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -772,7 +772,7 @@ static bool blessing_priesthood(monsters* mon)
// Turn an ordinary monster into a priestly monster, using a
// function normally used when going up an experience level.
// This is a hack, but there seems to be no better way for now.
- mon->change_type(priest_type, true);
+ mon->upgrade_type(priest_type, true, true);
return true;
}