mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-05 15:05:40 +02:00
Use hero battle victory and failure animations
This commit is contained in:
parent
270e1b75ce
commit
891eb5771a
@ -138,11 +138,6 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
|
|||||||
dest(_dest), attackedStack(defender), attackingStack(attacker)
|
dest(_dest), attackedStack(defender), attackingStack(attacker)
|
||||||
{
|
{
|
||||||
assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
|
assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
|
||||||
bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT)
|
|
||||||
&& owner->getCurrentPlayerInterface()->cb->battleHexToWallPart(_dest) >= 0;
|
|
||||||
|
|
||||||
assert(attackedStack || isCatapultAttack);
|
|
||||||
UNUSED(isCatapultAttack);
|
|
||||||
attackingStackPosBeforeReturn = attackingStack->position;
|
attackingStackPosBeforeReturn = attackingStack->position;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1069,12 +1069,27 @@ void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attacked
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
waitForAnims();
|
waitForAnims();
|
||||||
int targets = 0, killed = 0, damage = 0;
|
|
||||||
for (auto & attackedInfo : attackedInfos)
|
std::array<int, 2> killedBySide = {0, 0};
|
||||||
|
|
||||||
|
int targets = 0, damage = 0;
|
||||||
|
for(const StackAttackedInfo & attackedInfo : attackedInfos)
|
||||||
{
|
{
|
||||||
++targets;
|
++targets;
|
||||||
killed += attackedInfo.amountKilled;
|
|
||||||
damage += attackedInfo.dmg;
|
damage += attackedInfo.dmg;
|
||||||
|
|
||||||
|
ui8 side = attackedInfo.defender->side;
|
||||||
|
killedBySide.at(side) += attackedInfo.amountKilled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int killed = killedBySide[0] + killedBySide[1];
|
||||||
|
|
||||||
|
for(ui8 side = 0; side < 2; side++)
|
||||||
|
{
|
||||||
|
if(killedBySide.at(side) > killedBySide.at(1-side))
|
||||||
|
setHeroAnimation(side, 2);
|
||||||
|
else if(killedBySide.at(side) < killedBySide.at(1-side))
|
||||||
|
setHeroAnimation(side, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto & attackedInfo : attackedInfos)
|
for (auto & attackedInfo : attackedInfos)
|
||||||
@ -1398,6 +1413,14 @@ CBattleInterface::PossibleActions CBattleInterface::getCasterAction(const CSpell
|
|||||||
return spellSelMode;
|
return spellSelMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CBattleInterface::setHeroAnimation(ui8 side, int phase)
|
||||||
|
{
|
||||||
|
if(side == BattleSide::ATTACKER)
|
||||||
|
attackingHero->setPhase(phase);
|
||||||
|
else
|
||||||
|
defendingHero->setPhase(phase);
|
||||||
|
}
|
||||||
|
|
||||||
void CBattleInterface::castThisSpell(SpellID spellID)
|
void CBattleInterface::castThisSpell(SpellID spellID)
|
||||||
{
|
{
|
||||||
auto ba = new BattleAction();
|
auto ba = new BattleAction();
|
||||||
@ -1781,13 +1804,8 @@ void CBattleInterface::endAction(const BattleAction* action)
|
|||||||
{
|
{
|
||||||
const CStack *stack = curInt->cb->battleGetStackByID(action->stackNumber);
|
const CStack *stack = curInt->cb->battleGetStackByID(action->stackNumber);
|
||||||
|
|
||||||
if (action->actionType == Battle::HERO_SPELL)
|
if(action->actionType == Battle::HERO_SPELL)
|
||||||
{
|
setHeroAnimation(action->side, 0);
|
||||||
if (action->side)
|
|
||||||
defendingHero->setPhase(0);
|
|
||||||
else
|
|
||||||
attackingHero->setPhase(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stack && action->actionType == Battle::WALK &&
|
if (stack && action->actionType == Battle::WALK &&
|
||||||
!creAnims[action->stackNumber]->isIdle()) //walk or walk & attack
|
!creAnims[action->stackNumber]->isIdle()) //walk or walk & attack
|
||||||
@ -1935,14 +1953,12 @@ void CBattleInterface::startAction(const BattleAction* action)
|
|||||||
|
|
||||||
redraw(); // redraw after deactivation, including proper handling of hovered hexes
|
redraw(); // redraw after deactivation, including proper handling of hovered hexes
|
||||||
|
|
||||||
if (action->actionType == Battle::HERO_SPELL) //when hero casts spell
|
if(action->actionType == Battle::HERO_SPELL) //when hero casts spell
|
||||||
{
|
{
|
||||||
if (action->side)
|
setHeroAnimation(action->side, 4);
|
||||||
defendingHero->setPhase(4);
|
|
||||||
else
|
|
||||||
attackingHero->setPhase(4);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stack)
|
if (!stack)
|
||||||
{
|
{
|
||||||
logGlobal->error("Something wrong with stackNumber in actionStarted. Stack number: %d", action->stackNumber);
|
logGlobal->error("Something wrong with stackNumber in actionStarted. Stack number: %d", action->stackNumber);
|
||||||
|
@ -265,6 +265,8 @@ private:
|
|||||||
/** End of battle screen blitting methods */
|
/** End of battle screen blitting methods */
|
||||||
|
|
||||||
PossibleActions getCasterAction(const CSpell *spell, const ISpellCaster *caster, ECastingMode::ECastingMode mode) const;
|
PossibleActions getCasterAction(const CSpell *spell, const ISpellCaster *caster, ECastingMode::ECastingMode mode) const;
|
||||||
|
|
||||||
|
void setHeroAnimation(ui8 side, int phase);
|
||||||
public:
|
public:
|
||||||
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
static CondSh<bool> animsAreDisplayed; //for waiting with the end of battle for end of anims
|
||||||
static CondSh<BattleAction *> givenCommand; //data != nullptr if we have i.e. moved current unit
|
static CondSh<BattleAction *> givenCommand; //data != nullptr if we have i.e. moved current unit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user