From 44d7fbb36c55859117824fe25a298afbe437221b Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 6 Jul 2008 20:14:35 +0000 Subject: Fix 1870427: Max hp misreported if frail and rotted. Fix 2002931: feature_item_brand not working No, it's not the important bugs, but at least these are bugs I can reproduce. :P git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6433 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/player.cc | 49 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'crawl-ref/source/player.cc') diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 4ded8c08f8..252bbe152c 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4876,6 +4876,55 @@ void set_mp(int new_amount, bool max_too) you.redraw_magic_points = true; } +// If trans is true, being berserk and/or transformed is taken into account +// here. Else, the base hp is calculated. If rotted is true, calculate the +// real max hp you'd have if the rotting was cured. +int get_real_hp(bool trans, bool rotted) +{ + int hitp; + + hitp = (you.base_hp - 5000) + (you.base_hp2 - 5000); + hitp += (you.experience_level * you.skills[SK_FIGHTING]) / 5; + + // Being berserk makes you resistant to damage. I don't know why. + if (trans && you.duration[DUR_BERSERKER]) + { + hitp *= 15; + hitp /= 10; + } + + if (trans) + { + // Some transformations give you extra hp. + switch (you.attribute[ATTR_TRANSFORMATION]) + { + case TRAN_STATUE: + hitp *= 15; + hitp /= 10; + break; + case TRAN_ICE_BEAST: + hitp *= 12; + hitp /= 10; + break; + case TRAN_DRAGON: + hitp *= 16; + hitp /= 10; + break; + } + } + + if (rotted) + hitp += player_rotted(); + + // Frail and robust mutations, and divine robustness. + hitp *= (10 + player_mutation_level(MUT_ROBUST) + + you.attribute[ATTR_DIVINE_ROBUSTNESS] + - player_mutation_level(MUT_FRAIL)); + hitp /= 10; + + return (hitp); +} + static int _get_contamination_level() { const int glow = you.magic_contamination; -- cgit v1.2.3-54-g00ecf