mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Simplified healed HP calculation
This commit is contained in:
parent
eb1753851e
commit
05e52993fd
@ -1170,6 +1170,17 @@ bool CStack::canBeHealed() const
|
|||||||
&& !hasBonusOfType(Bonus::SIEGE_WEAPON);
|
&& !hasBonusOfType(Bonus::SIEGE_WEAPON);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui32 CStack::calculateHealedHealthPoints(ui32 toHeal, const bool resurrect) const
|
||||||
|
{
|
||||||
|
if(!resurrect && !alive())
|
||||||
|
{
|
||||||
|
logGlobal->warnStream() <<"Attempt to heal corpse detected.";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::min<ui32>(toHeal, MaxHealth() - firstHPleft + (resurrect ? baseAmount * MaxHealth() : 0));
|
||||||
|
}
|
||||||
|
|
||||||
ui8 CStack::getSpellSchoolLevel(const CSpell * spell, int * outSelectedSchool) const
|
ui8 CStack::getSpellSchoolLevel(const CSpell * spell, int * outSelectedSchool) const
|
||||||
{
|
{
|
||||||
int skill = valOfBonuses(Selector::typeSubtype(Bonus::SPELLCASTER, spell->id));
|
int skill = valOfBonuses(Selector::typeSubtype(Bonus::SPELLCASTER, spell->id));
|
||||||
|
@ -203,6 +203,8 @@ public:
|
|||||||
bool waited(int turn = 0) const;
|
bool waited(int turn = 0) const;
|
||||||
bool canMove(int turn = 0) const; //if stack can move
|
bool canMove(int turn = 0) const; //if stack can move
|
||||||
bool canBeHealed() const; //for first aid tent - only harmed stacks that are not war machines
|
bool canBeHealed() const; //for first aid tent - only harmed stacks that are not war machines
|
||||||
|
///returns actual heal value based on internal state
|
||||||
|
ui32 calculateHealedHealthPoints(ui32 toHeal, const bool resurrect) const;
|
||||||
ui32 level() const;
|
ui32 level() const;
|
||||||
si32 magicResistance() const override; //include aura of resistance
|
si32 magicResistance() const override; //include aura of resistance
|
||||||
static void stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse);
|
static void stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse);
|
||||||
|
@ -517,10 +517,9 @@ ui32 DefaultSpellMechanics::calculateHealedHP(const CGHeroInstance* caster, cons
|
|||||||
else
|
else
|
||||||
healedHealth = spellPowerSkill * owner->power + levelPower; //???
|
healedHealth = spellPowerSkill * owner->power + levelPower; //???
|
||||||
healedHealth = caster->getSpellBonus(owner, healedHealth, stack);
|
healedHealth = caster->getSpellBonus(owner, healedHealth, stack);
|
||||||
return std::min<ui32>(healedHealth, stack->MaxHealth() - stack->firstHPleft + (owner->isRisingSpell() ? stack->baseAmount * stack->MaxHealth() : 0));
|
return stack->calculateHealedHealthPoints(healedHealth, owner->isRisingSpell());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env, BattleSpellCastParameters & parameters, SpellCastContext & ctx) const
|
||||||
{
|
{
|
||||||
int effectLevel = parameters.spellLvl;
|
int effectLevel = parameters.spellLvl;
|
||||||
@ -675,7 +674,10 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
if(unitSpellPower)
|
if(unitSpellPower)
|
||||||
hpGained = parameters.casterStack->count * unitSpellPower; //Archangel
|
hpGained = parameters.casterStack->count * unitSpellPower; //Archangel
|
||||||
else //Faerie Dragon-like effect - unused so far
|
else //Faerie Dragon-like effect - unused so far
|
||||||
|
{
|
||||||
parameters.usedSpellPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_SPELL_POWER) * parameters.casterStack->count / 100;
|
parameters.usedSpellPower = parameters.casterStack->valOfBonuses(Bonus::CREATURE_SPELL_POWER) * parameters.casterStack->count / 100;
|
||||||
|
hpGained = parameters.usedSpellPower * owner->power + owner->getPower(effectLevel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
StacksHealedOrResurrected shr;
|
StacksHealedOrResurrected shr;
|
||||||
shr.lifeDrain = false;
|
shr.lifeDrain = false;
|
||||||
@ -687,21 +689,11 @@ void DefaultSpellMechanics::applyBattleEffects(const SpellCastEnvironment * env,
|
|||||||
if (parameters.casterStack) //casted by creature
|
if (parameters.casterStack) //casted by creature
|
||||||
{
|
{
|
||||||
const bool resurrect = owner->isRisingSpell();
|
const bool resurrect = owner->isRisingSpell();
|
||||||
if (hpGained)
|
hi.healedHP = attackedCre->calculateHealedHealthPoints(hpGained, resurrect);
|
||||||
{
|
|
||||||
//archangel
|
|
||||||
hi.healedHP = std::min<ui32>(hpGained, attackedCre->MaxHealth() - attackedCre->firstHPleft + (resurrect ? attackedCre->baseAmount * attackedCre->MaxHealth() : 0));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//any typical spell (commander's cure or animate dead)
|
|
||||||
int healedHealth = parameters.usedSpellPower * owner->power + owner->getPower(effectLevel);
|
|
||||||
hi.healedHP = std::min<ui32>(healedHealth, attackedCre->MaxHealth() - attackedCre->firstHPleft + (resurrect ? attackedCre->baseAmount * attackedCre->MaxHealth() : 0));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
hi.healedHP = calculateHealedHP(parameters.casterHero, attackedCre, parameters.selectedStack); //Casted by hero
|
hi.healedHP = calculateHealedHP(parameters.casterHero, attackedCre, parameters.selectedStack); //Casted by hero
|
||||||
hi.lowLevelResurrection = (effectLevel <= 1) && (owner->id != SpellID::ANIMATE_DEAD);
|
hi.lowLevelResurrection = (effectLevel <= 1) && (owner->id == SpellID::RESURRECTION);
|
||||||
shr.healedStacks.push_back(hi);
|
shr.healedStacks.push_back(hi);
|
||||||
}
|
}
|
||||||
if(!shr.healedStacks.empty())
|
if(!shr.healedStacks.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user