1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-26 22:57:00 +02:00

Removed CStack::totalHealth()

This commit is contained in:
AlexVinS 2017-07-09 20:23:51 +03:00
parent 44fc0cb57b
commit ea3502ed60
5 changed files with 6 additions and 12 deletions

View File

@ -589,11 +589,6 @@ const CGHeroInstance * CStack::getMyHero() const
return nullptr; return nullptr;
} }
ui32 CStack::totalHealth() const
{
return health.available();//do not hide possible invalid firstHPleft for dead stack
}
std::string CStack::nodeName() const std::string CStack::nodeName() const
{ {
std::ostringstream oss; std::ostringstream oss;

View File

@ -186,7 +186,6 @@ public:
si32 magicResistance() const override; //include aura of resistance si32 magicResistance() const override; //include aura of resistance
std::vector<si32> activeSpells() const; //returns vector of active spell IDs sorted by time of cast std::vector<si32> activeSpells() const; //returns vector of active spell IDs sorted by time of cast
const CGHeroInstance * getMyHero() const; //if stack belongs to hero (directly or was by him summoned) returns hero, nullptr otherwise const CGHeroInstance * getMyHero() const; //if stack belongs to hero (directly or was by him summoned) returns hero, nullptr otherwise
ui32 totalHealth() const; // total health for all creatures in stack;
static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, BattleHex attackerPos = BattleHex::INVALID, BattleHex defenderPos = BattleHex::INVALID); static bool isMeleeAttackPossible(const CStack * attacker, const CStack * defender, BattleHex attackerPos = BattleHex::INVALID, BattleHex defenderPos = BattleHex::INVALID);

View File

@ -1640,8 +1640,8 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs(CGameState *gs)
bool resurrected = !changedStack->alive(); //indicates if stack is resurrected or just healed bool resurrected = !changedStack->alive(); //indicates if stack is resurrected or just healed
if(resurrected) if(resurrected)
{ {
if(changedStack->getCount() > 0 || changedStack->getFirstHPleft() > 0) if(auto totalHealth = changedStack->health.available())
logGlobal->warn("Dead stack %s with positive total HP %d", changedStack->nodeName(), changedStack->totalHealth()); logGlobal->warn("Dead stack %s with positive total HP %d", changedStack->nodeName(), totalHealth);
changedStack->state.insert(EBattleStackState::ALIVE); changedStack->state.insert(EBattleStackState::ALIVE);
} }

View File

@ -442,10 +442,10 @@ ESpellCastProblem::ESpellCastProblem HypnotizeMechanics::isImmuneByStack(const I
if(nullptr != caster) if(nullptr != caster)
{ {
//TODO: what with other creatures casting hypnotize, Faerie Dragons style? //TODO: what with other creatures casting hypnotize, Faerie Dragons style?
ui32 subjectHealth = obj->totalHealth(); int64_t subjectHealth = obj->health.available();
//apply 'damage' bonus for hypnotize, including hero specialty //apply 'damage' bonus for hypnotize, including hero specialty
ui32 maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj); int64_t maxHealth = caster->getSpellBonus(owner, owner->calculateRawEffectValue(caster->getEffectLevel(owner), caster->getEffectPower(owner)), obj);
if (subjectHealth > maxHealth) if(subjectHealth > maxHealth)
return ESpellCastProblem::STACK_IMMUNE_TO_SPELL; return ESpellCastProblem::STACK_IMMUNE_TO_SPELL;
} }
return DefaultSpellMechanics::isImmuneByStack(caster, obj); return DefaultSpellMechanics::isImmuneByStack(caster, obj);

View File

@ -1014,7 +1014,7 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons
bsa2.flags |= BattleStackAttacked::EFFECT; //FIXME: play animation upon efreet and not attacker bsa2.flags |= BattleStackAttacked::EFFECT; //FIXME: play animation upon efreet and not attacker
bsa2.effect = 11; bsa2.effect = 11;
bsa2.damageAmount = (std::min<si32>(def->totalHealth(), bsa.damageAmount) * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense bsa2.damageAmount = (std::min<int64_t>(def->health.available(), bsa.damageAmount) * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense
att->prepareAttacked(bsa2, getRandomGenerator()); att->prepareAttacked(bsa2, getRandomGenerator());
bat.bsa.push_back(bsa2); bat.bsa.push_back(bsa2);
} }