From a1e06aa2176df2436fd8c3837ac9395757ce08a4 Mon Sep 17 00:00:00 2001 From: AlexVinS Date: Wed, 16 Sep 2015 10:08:40 +0300 Subject: [PATCH] Unify LIFE_DRAIN and Tent healing with magic healing --- lib/BattleState.cpp | 2 +- server/CGameHandler.cpp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/BattleState.cpp b/lib/BattleState.cpp index 5af3cd14c..b92770850 100644 --- a/lib/BattleState.cpp +++ b/lib/BattleState.cpp @@ -1178,7 +1178,7 @@ ui32 CStack::calculateHealedHealthPoints(ui32 toHeal, const bool resurrect) cons return 0; } - return std::min(toHeal, MaxHealth() - firstHPleft + (resurrect ? baseAmount * MaxHealth() : 0)); + return std::min(toHeal, MaxHealth() - firstHPleft + (resurrect ? (baseAmount - count) * MaxHealth() : 0)); } ui8 CStack::getSpellSchoolLevel(const CSpell * spell, int * outSelectedSchool) const diff --git a/server/CGameHandler.cpp b/server/CGameHandler.cpp index 2a44fe769..082a49a41 100644 --- a/server/CGameHandler.cpp +++ b/server/CGameHandler.cpp @@ -845,14 +845,13 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons if (att->hasBonusOfType(Bonus::LIFE_DRAIN) && def->isLiving()) { StacksHealedOrResurrected shi; - shi.lifeDrain = (ui8)true; - shi.tentHealing = (ui8)false; + shi.lifeDrain = true; + shi.tentHealing = false; shi.drainedFrom = def->ID; StacksHealedOrResurrected::HealInfo hi; hi.stackID = att->ID; - hi.healedHP = std::min (bsa.damageAmount * att->valOfBonuses (Bonus::LIFE_DRAIN) / 100, - att->MaxHealth() - att->firstHPleft + att->MaxHealth() * (att->baseAmount - att->count) ); + hi.healedHP = att->calculateHealedHealthPoints(bsa.damageAmount * att->valOfBonuses (Bonus::LIFE_DRAIN) / 100, true); hi.lowLevelResurrection = false; shi.healedStacks.push_back(hi); @@ -3771,14 +3770,17 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) const CStack *healer = gs->curB->battleGetStackByID(ba.stackNumber), *destStack = gs->curB->battleGetStackByPos(ba.destinationTile); + ui32 healed = 0; + if(healer == nullptr || destStack == nullptr || !healer->hasBonusOfType(Bonus::HEALER)) { complain("There is either no healer, no destination, or healer cannot heal :P"); } - int maxHealable = destStack->MaxHealth() - destStack->firstHPleft; - int maxiumHeal = healer->count * std::max(10, attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::FIRST_AID)); - - int healed = std::min(maxHealable, maxiumHeal); + else + { + ui32 maxiumHeal = healer->count * std::max(10, attackingHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::FIRST_AID)); + healed = destStack->calculateHealedHealthPoints(maxiumHeal, false); + } if(healed == 0) { @@ -3799,8 +3801,6 @@ bool CGameHandler::makeBattleAction( BattleAction &ba ) shr.healedStacks.push_back(hi); sendAndApply(&shr); } - - sendAndApply(&end_action); break; }