From f69fd28fe0dd4aceeb21f186101a2236f7d89740 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sat, 24 Jan 2015 10:13:32 -0500 Subject: XEEN: Fixes for hit points calculations --- engines/xeen/party.cpp | 33 +++++++++++++++++---------------- engines/xeen/party.h | 2 +- engines/xeen/resources.cpp | 6 +++--- 3 files changed, 21 insertions(+), 20 deletions(-) (limited to 'engines') diff --git a/engines/xeen/party.cpp b/engines/xeen/party.cpp index 791a19ff4f..2822e41769 100644 --- a/engines/xeen/party.cpp +++ b/engines/xeen/party.cpp @@ -166,7 +166,7 @@ int Character::getAge(bool ignoreTemp) const { int Character::getMaxHP() const { int hp = BASE_HP_BY_CLASS[_class]; - hp += statBonus(getStat(ENDURANCE, false)); + hp += statBonus(getStat(ENDURANCE)); hp += RACE_HP_BONUSES[_race]; if (_skills[BODYBUILDER]) ++hp; @@ -176,10 +176,7 @@ int Character::getMaxHP() const { hp *= getCurrentLevel(); hp += itemScan(7); - if (hp < 0) - hp = 0; - - return hp; + return MAX(hp, 0); } int Character::getMaxSP() const { @@ -204,7 +201,7 @@ int Character::getMaxSP() const { for (;;) { // Get the base number of spell points - result = statBonus(getStat(attrib, false)); + result = statBonus(getStat(attrib)); result += RACE_SP_BONUSES[_race][attrib - 1]; if (_skills[skill]) @@ -240,7 +237,7 @@ int Character::getMaxSP() const { /** * Get the effective value of a given stat for the character */ -int Character::getStat(Attribute attrib, bool applyMod) const { +int Character::getStat(Attribute attrib, bool baseOnly) const { AttributePair attr; int mode = 0; @@ -277,32 +274,36 @@ int Character::getStat(Attribute attrib, bool applyMod) const { if (mode < 2) { int age = getAge(false); int ageIndex = 0; - while (AGE_RANGES[ageIndex] < age) + while (AGE_RANGES[ageIndex] <= age) ++ageIndex; attr._permanent += AGE_RANGES_ADJUST[mode][ageIndex]; } - if (applyMod) { + + attr._permanent += itemScan((int)attrib); + + if (!baseOnly) { attr._permanent += conditionMod(attrib); attr._permanent += attr._temporary; } - return (attr._permanent >= 1) ? attr._permanent : 0; + return MAX(attr._permanent, 0); } int Character::statBonus(int statValue) const { - for (int idx = 0; STAT_VALUES[idx] <= statValue; ++idx) - return STAT_BONUSES[idx]; + int idx; + for (idx = 0; STAT_VALUES[idx] <= statValue; ++idx) + ; - return 0; + return STAT_BONUSES[idx]; } bool Character::charSavingThrow(DamageType attackType) const { int v, vMax; if (attackType == DT_PHYSICAL) { - v = statBonus(getStat(LUCK, false)) + getCurrentLevel(); + v = statBonus(getStat(LUCK)) + getCurrentLevel(); vMax = v + 20; } else { switch (attackType) { @@ -378,7 +379,7 @@ bool Character::hasAward(int awardId) const { int Character::getArmorClass(bool baseOnly) const { Party &party = *Party::_vm->_party; - int result = statBonus(getStat(SPEED, false)) + itemScan(9); + int result = statBonus(getStat(SPEED)) + itemScan(9); if (!baseOnly) result += (party._blessedActive ? 1 : 0) + _ACTemp; @@ -762,7 +763,7 @@ void Party::changeTime(int numMinutes) { if (!player._conditions[DEAD] && !player._conditions[STONED] && !player._conditions[ERADICATED]) { for (int statNum = 0; statNum < TOTAL_STATS; ++statNum) { - int statVal = player.getStat((Attribute)statNum, false); + int statVal = player.getStat((Attribute)statNum); if (statVal < 1) player._conditions[DEAD] = 1; } diff --git a/engines/xeen/party.h b/engines/xeen/party.h index f56190982d..dc87e88bd8 100644 --- a/engines/xeen/party.h +++ b/engines/xeen/party.h @@ -146,7 +146,7 @@ public: int getMaxSP() const; - int getStat(Attribute attrib, bool applyMod) const; + int getStat(Attribute attrib, bool baseOnly = false) const; int statBonus(int statValue) const; diff --git a/engines/xeen/resources.cpp b/engines/xeen/resources.cpp index 993bf2f546..556544d4e4 100644 --- a/engines/xeen/resources.cpp +++ b/engines/xeen/resources.cpp @@ -508,12 +508,12 @@ const int AGE_RANGES_ADJUST[2][10] = { }; const int STAT_VALUES[24] = { - 11, 13, 15, 17, 19, 21, 25, 30, 35, 40, 50, 75, - 100, 125, 150, 175, 200, 225, 250, 65535 + 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 25, 30, 35, 40, + 50, 75, 100, 125, 150, 175, 200, 225, 250, 65535 }; const int STAT_BONUSES[24] = { - 251, 252, 253, 254, 255, 0, 1, 2, 3, 4, 5, 6, + -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 20 }; -- cgit v1.2.3