]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.cpp
added numbers animation for monsters' attacks
[l2e.git] / src / battle / states / PerformAttacks.cpp
index 10fb8bb11294c6f0f517d1def1efd528cbd86cbb..238849b3f5da06638e04925fe5311d246e6a7783 100644 (file)
@@ -75,7 +75,7 @@ void PerformAttacks::HandleEvents(const Input &input) {
                titleBarText = monster.Name();
                moveAnimation = monster.AttackAnimation();
                targetAnimation = monster.MeleeAnimation();
-               // TODO: add number animations
+               AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection());
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
                const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
@@ -90,24 +90,7 @@ void PerformAttacks::HandleEvents(const Input &input) {
                                        targetAnimation = hero.MeleeAnimation();
                                }
                                moveAnimation = hero.AttackAnimation();
-
-                               if (ac.Selection().TargetsEnemies()) {
-                                       for (int i(0); i < battle->MaxMonsters(); ++i) {
-                                               if (ac.Selection().IsSelected(i)) {
-                                                       numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
-                                                       numberPosition.push_back(
-                                                                       battle->MonsterPositions()[i]);
-                                               }
-                                       }
-                               } else {
-                                       for (int i(0); i < battle->NumHeroes(); ++i) {
-                                               if (ac.Selection().IsSelected(i)) {
-                                                       numberAnimation.push_back(NumberAnimation(ac.Selection().GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
-                                                       numberPosition.push_back(
-                                                                       battle->HeroesPositions()[i]);
-                                               }
-                                       }
-                               }
+                               AddNumberAnimations(ac.Selection());
                                break;
                        case AttackChoice::MAGIC:
                                titleBarText = ac.GetSpell()->Name();
@@ -147,6 +130,34 @@ void PerformAttacks::HandleEvents(const Input &input) {
        }
 }
 
+void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) {
+       if (ts.TargetsEnemies()) {
+               for (int i(0); i < battle->MaxMonsters(); ++i) {
+                       if (ts.IsBad(i)) {
+                               numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
+                               numberPosition.push_back(
+                                               battle->MonsterPositions()[i]);
+                       } else if (ts.IsGood(i)) {
+                               numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
+                               numberPosition.push_back(
+                                               battle->MonsterPositions()[i]);
+                       }
+               }
+       } else {
+               for (int i(0); i < battle->NumHeroes(); ++i) {
+                       if (ts.IsBad(i)) {
+                               numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
+                               numberPosition.push_back(
+                                               battle->HeroesPositions()[i]);
+                       } else if (ts.IsGood(i)) {
+                               numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
+                               numberPosition.push_back(
+                                               battle->HeroesPositions()[i]);
+                       }
+               }
+       }
+}
+
 void PerformAttacks::CheckAnimations() {
        if (targetAnimation && targetAnimationTimer.JustHit()) {
                targetAnimation->Start(*this);