mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
possible fix for http://bugs.vcmi.eu/view.php?id=2612
This commit is contained in:
parent
f8bf2c3746
commit
931656f24a
@ -56,8 +56,8 @@ AttackPossibility AttackPossibility::evaluate(const BattleAttackInfo &AttackInfo
|
||||
//TODO other damage related to attack (eg. fire shield and other abilities)
|
||||
|
||||
//Limit damages by total stack health
|
||||
vstd::amin(ap.damageDealt, enemy->count * enemy->MaxHealth() - (enemy->MaxHealth() - enemy->firstHPleft));
|
||||
vstd::amin(ap.damageReceived, attacker->count * attacker->MaxHealth() - (attacker->MaxHealth() - attacker->firstHPleft));
|
||||
vstd::amin(ap.damageDealt, enemy->totalHealth());
|
||||
vstd::amin(ap.damageReceived, attacker->totalHealth());
|
||||
|
||||
return ap;
|
||||
}
|
||||
|
@ -1012,7 +1012,7 @@ const CGHeroInstance * CStack::getMyHero() const
|
||||
|
||||
ui32 CStack::totalHealth() const
|
||||
{
|
||||
return (MaxHealth() * (count-1)) + firstHPleft;
|
||||
return ((count > 0) ? MaxHealth() * (count-1) : 0) + firstHPleft;//do not hide possible invalid firstHPleft for dead stack
|
||||
}
|
||||
|
||||
std::string CStack::nodeName() const
|
||||
@ -1032,10 +1032,8 @@ std::string CStack::nodeName() const
|
||||
|
||||
std::pair<int,int> CStack::countKilledByAttack(int damageReceived) const
|
||||
{
|
||||
int killedCount = 0;
|
||||
int newRemainingHP = 0;
|
||||
|
||||
killedCount = damageReceived / MaxHealth();
|
||||
int killedCount = damageReceived / MaxHealth();
|
||||
unsigned damageFirst = damageReceived % MaxHealth();
|
||||
|
||||
if (damageReceived && vstd::contains(state, EBattleStackState::CLONED)) // block ability should not kill clone (0 damage)
|
||||
@ -1055,6 +1053,9 @@ std::pair<int,int> CStack::countKilledByAttack(int damageReceived) const
|
||||
}
|
||||
}
|
||||
|
||||
if(killedCount == count)
|
||||
newRemainingHP = 0;
|
||||
|
||||
return std::make_pair(killedCount, newRemainingHP);
|
||||
}
|
||||
|
||||
|
@ -1610,9 +1610,12 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs(CGameState *gs)
|
||||
bool resurrected = !changedStack->alive(); //indicates if stack is resurrected or just healed
|
||||
if(resurrected)
|
||||
{
|
||||
if(changedStack->count > 0 || changedStack->firstHPleft > 0)
|
||||
logGlobal->warn("Dead stack %s with positive total HP", changedStack->nodeName(), changedStack->totalHealth());
|
||||
|
||||
changedStack->state.insert(EBattleStackState::ALIVE);
|
||||
}
|
||||
//int missingHPfirst = changedStack->MaxHealth() - changedStack->firstHPleft;
|
||||
|
||||
int res = std::min(elem.healedHP / changedStack->MaxHealth() , changedStack->baseAmount - changedStack->count);
|
||||
changedStack->count += res;
|
||||
if(elem.lowLevelResurrection)
|
||||
|
@ -394,9 +394,9 @@ ESpellCastProblem::ESpellCastProblem HypnotizeMechanics::isImmuneByStack(const I
|
||||
if(nullptr != caster)
|
||||
{
|
||||
//TODO: what with other creatures casting hypnotize, Faerie Dragons style?
|
||||
ui64 subjectHealth = (obj->count - 1) * obj->MaxHealth() + obj->firstHPleft;
|
||||
ui32 subjectHealth = obj->totalHealth();
|
||||
//apply 'damage' bonus for hypnotize, including hero specialty
|
||||
ui64 maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj);
|
||||
ui32 maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj);
|
||||
if (subjectHealth > maxHealth)
|
||||
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user