summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/monstuff.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-10 22:16:48 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-10 22:16:48 +0000
commita29e9c332e7c3711a5fc1d04c6c807f52a708132 (patch)
treedfc925d4286836ad35fd1e43216a466109cad196 /crawl-ref/source/monstuff.cc
parent88f7778a5f2236d69075b9b428fec91089e9e1ab (diff)
downloadcrawl-ref-a29e9c332e7c3711a5fc1d04c6c807f52a708132.tar.gz
crawl-ref-a29e9c332e7c3711a5fc1d04c6c807f52a708132.zip
In heal_monster(), add an upper limit to HP growth.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4181 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/monstuff.cc')
-rw-r--r--crawl-ref/source/monstuff.cc26
1 files changed, 18 insertions, 8 deletions
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 0cb9f1deb7..c2be5c31cc 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -6553,20 +6553,30 @@ bool heal_monster(monsters * patient, int health_boost,
return (false);
else if (!permit_growth && patient->hit_points == patient->max_hit_points)
return (false);
- else
- {
- patient->hit_points += health_boost;
- if (patient->hit_points > patient->max_hit_points)
+ patient->hit_points += health_boost;
+
+ bool success = true;
+
+ if (patient->hit_points > patient->max_hit_points)
+ {
+ if (permit_growth)
{
- if (permit_growth)
- patient->max_hit_points++;
+ const monsterentry* m = get_monster_data(patient->type);
+ const unsigned maxhp =
+ m->hpdice[0] * (m->hpdice[1] + m->hpdice[2]) + m->hpdice[3];
- patient->hit_points = patient->max_hit_points;
+ // Limit HP growth.
+ if (random2(3 * maxhp) > 2 * patient->max_hit_points)
+ patient->max_hit_points++;
+ else
+ success = false;
}
+
+ patient->hit_points = patient->max_hit_points;
}
- return (true);
+ return (success);
} // end heal_monster()
static spell_type _map_wand_to_mspell(int wand_type)