]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.cpp
added capsule attack/animation handling
[l2e.git] / src / battle / states / PerformAttacks.cpp
index fac7cdf855aa42a4c8422f38e5ebd715afd52608..43414eb89a60d86e7964ad2f63861da7818f5b8e 100644 (file)
@@ -67,13 +67,20 @@ void PerformAttacks::HandleEvents(const Input &input) {
 
        battle->CalculateDamage();
 
-       if (battle->CurrentAttack().isMonster) {
+       if (battle->CurrentAttack().IsMonster()) {
                Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
                titleBarText = monster.Name();
                targetAnimation = AnimationRunner(monster.MeleeAnimation());
                moveAnimation = AnimationRunner(monster.AttackAnimation());
                monster.SetAnimation(moveAnimation);
                AddNumberAnimations(battle->MonsterAt(battle->CurrentAttack().index).GetAttackChoice().Selection());
+       } else if (battle->CurrentAttack().IsCapsule()) {
+               Capsule &capsule(battle->GetCapsule());
+               titleBarText = capsule.Name();
+               targetAnimation = AnimationRunner(capsule.MeleeAnimation());
+               moveAnimation = AnimationRunner(capsule.AttackAnimation());
+               capsule.SetAnimation(moveAnimation);
+               AddNumberAnimations(capsule.GetAttackChoice().Selection());
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
                const AttackChoice &ac(battle->HeroAt(battle->CurrentAttack().index).GetAttackChoice());
@@ -122,10 +129,12 @@ void PerformAttacks::HandleEvents(const Input &input) {
        if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(850);
        if (moveAnimation.Valid()) {
                moveAnimation.Start(*this);
-               if (battle->CurrentAttack().isMonster) {
+               if (battle->CurrentAttack().IsMonster()) {
                        battle->MonsterAt(battle->CurrentAttack().index).SetAnimation(moveAnimation);
-               } else {
+               } else if (battle->CurrentAttack().IsHero()) {
                        battle->HeroAt(battle->CurrentAttack().index).SetAnimation(moveAnimation);
+               } else {
+                       battle->GetCapsule().SetAnimation(moveAnimation);
                }
        }
        if (targetAnimation.Valid()) {
@@ -195,7 +204,7 @@ bool PerformAttacks::HasAnimationsRunning() const {
 void PerformAttacks::ResetAnimation() {
        if (moveAnimation.Valid()) {
                moveAnimation.Clear();
-               if (!battle->CurrentAttack().isMonster) {
+               if (!battle->CurrentAttack().IsMonster()) {
                        battle->HeroAt(battle->CurrentAttack().index).GetAnimation().Clear();
                }
        }