mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-25 21:38:59 +02:00
Fix spellcaster animations
This commit is contained in:
parent
f247a98373
commit
3c037ed620
@ -75,7 +75,7 @@ std::vector<CBattleAnimation *> & CBattleAnimation::pendingAnimations()
|
||||
return owner->stacksController->currentAnimations;
|
||||
}
|
||||
|
||||
std::shared_ptr<CCreatureAnimation> CBattleAnimation::stackAnimation(const CStack * stack)
|
||||
std::shared_ptr<CCreatureAnimation> CBattleAnimation::stackAnimation(const CStack * stack) const
|
||||
{
|
||||
return owner->stacksController->stackAnimation[stack->ID];
|
||||
}
|
||||
@ -169,7 +169,7 @@ bool CAttackAnimation::checkInitialConditions()
|
||||
return CBattleAnimation::checkInitialConditions();
|
||||
}
|
||||
|
||||
const CCreature * CAttackAnimation::getCreature()
|
||||
const CCreature * CAttackAnimation::getCreature() const
|
||||
{
|
||||
if (attackingStack->getCreature()->idNumber == CreatureID::ARROW_TOWERS)
|
||||
return owner->siegeController->getTurretCreature();
|
||||
@ -817,15 +817,13 @@ void CRangedAttackAnimation::nextFrame()
|
||||
|
||||
if (!projectileEmitted)
|
||||
{
|
||||
const CCreature *shooterInfo = getCreature();
|
||||
|
||||
logAnim->info("Ranged attack executing, %d / %d / %d",
|
||||
stackAnimation(attackingStack)->getCurrentFrame(),
|
||||
shooterInfo->animation.attackClimaxFrame,
|
||||
getAttackClimaxFrame(),
|
||||
stackAnimation(attackingStack)->framesInGroup(group));
|
||||
|
||||
// emit projectile once animation playback reached "climax" frame
|
||||
if ( stackAnimation(attackingStack)->getCurrentFrame() >= shooterInfo->animation.attackClimaxFrame )
|
||||
if ( stackAnimation(attackingStack)->getCurrentFrame() >= getAttackClimaxFrame() )
|
||||
{
|
||||
emitProjectile();
|
||||
stackAnimation(attackingStack)->pause();
|
||||
@ -860,6 +858,12 @@ void CShootingAnimation::createProjectile(const Point & from, const Point & dest
|
||||
owner->projectilesController->createProjectile(attackingStack, attackedStack, from, dest);
|
||||
}
|
||||
|
||||
uint32_t CShootingAnimation::getAttackClimaxFrame() const
|
||||
{
|
||||
const CCreature *shooterInfo = getCreature();
|
||||
return shooterInfo->animation.attackClimaxFrame;
|
||||
}
|
||||
|
||||
CCreatureAnim::EAnimType CShootingAnimation::getUpwardsGroup() const
|
||||
{
|
||||
return CCreatureAnim::SHOOT_UP;
|
||||
@ -969,6 +973,16 @@ void CCastAnimation::createProjectile(const Point & from, const Point & dest) co
|
||||
owner->projectilesController->createSpellProjectile(attackingStack, attackedStack, from, dest, spell);
|
||||
}
|
||||
|
||||
uint32_t CCastAnimation::getAttackClimaxFrame() const
|
||||
{
|
||||
//FIXME: allow defining this parameter in config file, separately from attackClimaxFrame of missile attacks
|
||||
uint32_t maxFrames = stackAnimation(attackingStack)->framesInGroup(group);
|
||||
|
||||
if (maxFrames > 2)
|
||||
return maxFrames - 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
CPointEffectAnimation::CPointEffectAnimation(CBattleInterface * _owner, soundBase::soundID sound, std::string animationName, int effects):
|
||||
CBattleAnimation(_owner),
|
||||
animation(std::make_shared<CAnimation>(animationName)),
|
||||
|
@ -34,7 +34,7 @@ protected:
|
||||
bool initialized;
|
||||
|
||||
std::vector<CBattleAnimation *> & pendingAnimations();
|
||||
std::shared_ptr<CCreatureAnimation> stackAnimation(const CStack * stack);
|
||||
std::shared_ptr<CCreatureAnimation> stackAnimation(const CStack * stack) const;
|
||||
bool stackFacingRight(const CStack * stack);
|
||||
void setStackFacingRight(const CStack * stack, bool facingRight);
|
||||
|
||||
@ -78,7 +78,7 @@ protected:
|
||||
const CStack *attackingStack;
|
||||
int attackingStackPosBeforeReturn; //for stacks with return_after_strike feature
|
||||
|
||||
const CCreature * getCreature();
|
||||
const CCreature * getCreature() const;
|
||||
public:
|
||||
void nextFrame() override;
|
||||
bool checkInitialConditions();
|
||||
@ -210,6 +210,7 @@ protected:
|
||||
virtual CCreatureAnim::EAnimType getDownwardsGroup() const = 0;
|
||||
|
||||
virtual void createProjectile(const Point & from, const Point & dest) const = 0;
|
||||
virtual uint32_t getAttackClimaxFrame() const = 0;
|
||||
|
||||
public:
|
||||
CRangedAttackAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
@ -227,6 +228,7 @@ class CShootingAnimation : public CRangedAttackAnimation
|
||||
CCreatureAnim::EAnimType getDownwardsGroup() const override;
|
||||
|
||||
void createProjectile(const Point & from, const Point & dest) const override;
|
||||
uint32_t getAttackClimaxFrame() const override;
|
||||
|
||||
public:
|
||||
CShootingAnimation(CBattleInterface * _owner, const CStack * attacker, BattleHex dest, const CStack * defender);
|
||||
@ -257,6 +259,7 @@ class CCastAnimation : public CRangedAttackAnimation
|
||||
CCreatureAnim::EAnimType getDownwardsGroup() const override;
|
||||
|
||||
void createProjectile(const Point & from, const Point & dest) const override;
|
||||
uint32_t getAttackClimaxFrame() const override;
|
||||
|
||||
public:
|
||||
CCastAnimation(CBattleInterface * owner_, const CStack * attacker, BattleHex dest_, const CStack * defender, const CSpell * spell);
|
||||
|
Loading…
x
Reference in New Issue
Block a user