1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-25 21:38:59 +02:00

CGameHandler::applyBattleEffects: improve Fire Shield support

Now damage is limited to total health of defending stack and clone have no file shield damage. In same time damage calculation is likely remain incorrect.
This commit is contained in:
Arseniy Shestakov 2016-03-14 15:28:17 +03:00
parent 4240ecad01
commit 2e70d29479
3 changed files with 12 additions and 2 deletions

@ -988,6 +988,11 @@ const CGHeroInstance * CStack::getMyHero() const
return nullptr;
}
ui32 CStack::totalHelth() const
{
return (MaxHealth() * (count-1)) + firstHPleft;
}
std::string CStack::nodeName() const
{
std::ostringstream oss;

@ -206,6 +206,7 @@ public:
static void stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse);
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
ui32 totalHelth() const; // total health for all creatures in stack;
static inline Bonus featureGenerator(Bonus::BonusType type, si16 subtype, si32 value, ui16 turnsRemain, si32 additionalInfo = 0, Bonus::LimitEffect limit = Bonus::NO_LIMIT)
{

@ -900,15 +900,19 @@ void CGameHandler::applyBattleEffects(BattleAttack &bat, const CStack *att, cons
bat.bsa.push_back(bsa); //add this stack to the list of victims after drain life has been calculated
//fire shield handling
if(!bat.shot() && def->hasBonusOfType(Bonus::FIRE_SHIELD) && !att->hasBonusOfType (Bonus::FIRE_IMMUNITY))
if(!bat.shot() && !vstd::contains(def->state, EBattleStackState::CLONED) &&
def->hasBonusOfType(Bonus::FIRE_SHIELD) && !att->hasBonusOfType(Bonus::FIRE_IMMUNITY))
{
// TODO: Fire sheild damage should be calculated separately after BattleAttack applied.
// Currently it's looks like attacking stack damage itself with defenders fire shield.
// So no separate message on spell damge in log and expirience calculation is likely wrong too.
BattleStackAttacked bsa2;
bsa2.stackAttacked = att->ID; //invert
bsa2.attackerID = def->ID;
bsa2.flags |= BattleStackAttacked::EFFECT; //FIXME: play animation upon efreet and not attacker
bsa2.effect = 11;
bsa2.damageAmount = (bsa.damageAmount * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense
bsa2.damageAmount = (std::min(def->totalHelth(), bsa.damageAmount) * def->valOfBonuses(Bonus::FIRE_SHIELD)) / 100; //TODO: scale with attack/defense
att->prepareAttacked(bsa2, gameState()->getRandomGenerator());
bat.bsa.push_back(bsa2);
}