]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.cpp
moved monster's position to Monster
[l2e.git] / src / battle / states / PerformAttacks.cpp
index 05227e6e4065f512aef1af9bb7cabfd053076bb2..44831791d2c749695cc83716d099178c6f552f67 100644 (file)
@@ -77,10 +77,10 @@ void PerformAttacks::HandleEvents(const Input &input) {
                targetAnimation = AnimationRunner(monster.MeleeAnimation());
                moveAnimation = AnimationRunner(monster.AttackAnimation());
                monster.SetAnimation(moveAnimation);
-               AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection());
+               AddNumberAnimations(battle->MonsterAt(battle->CurrentAttack().index).GetAttackChoice().Selection());
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
-               const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
+               const AttackChoice &ac(battle->HeroAt(battle->CurrentAttack().index).GetAttackChoice());
 
                switch (ac.GetType()) {
                        case AttackChoice::SWORD:
@@ -145,11 +145,11 @@ void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) {
                        if (ts.IsBad(i)) {
                                numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
                                numberPosition.push_back(
-                                               battle->MonsterPositions()[i]);
+                                               battle->MonsterAt(i).Position());
                        } else if (ts.IsGood(i)) {
                                numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
                                numberPosition.push_back(
-                                               battle->MonsterPositions()[i]);
+                                               battle->MonsterAt(i).Position());
                        }
                }
        } else {
@@ -157,11 +157,11 @@ void PerformAttacks::AddNumberAnimations(const TargetSelection &ts) {
                        if (ts.IsBad(i)) {
                                numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite));
                                numberPosition.push_back(
-                                               battle->HeroesPositions()[i]);
+                                               battle->HeroAt(i).Position());
                        } else if (ts.IsGood(i)) {
                                numberAnimation.push_back(NumberAnimation(ts.GetAmount(i), battle->Res().numberAnimationPrototype, battle->Res().greenNumberSprite));
                                numberPosition.push_back(
-                                               battle->HeroesPositions()[i]);
+                                               battle->HeroAt(i).Position());
                        }
                }
        }
@@ -251,10 +251,17 @@ void PerformAttacks::RenderNumbers(SDL_Surface *screen, const Vector<int> &offse
 void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
        if (!targetAnimation.Valid() || !targetAnimation.Running()) return;
        const TargetSelection &ts(battle->CurrentAttackAttackChoice().Selection());
-       const vector<Point<int> > &positions(ts.TargetsHeroes() ? battle->HeroesPositions() : battle->MonsterPositions());
-       for (vector<Point<int> >::size_type i(0), end(positions.size()); i < end; ++i) {
-               if (ts.IsSelected(i)) {
-                       targetAnimation.DrawCenter(screen, positions[i] + offset);
+       if (ts.TargetsHeroes()) {
+               for (vector<Point<int> >::size_type i(0), end(battle->NumHeroes()); i < end; ++i) {
+                       if (ts.IsSelected(i)) {
+                               targetAnimation.DrawCenter(screen, battle->HeroAt(i).Position() + offset);
+                       }
+               }
+       } else {
+               for (vector<Point<int> >::size_type i(0), end(battle->MaxMonsters()); i < end; ++i) {
+                       if (ts.IsSelected(i)) {
+                               targetAnimation.DrawCenter(screen, battle->MonsterAt(i).Position() + offset);
+                       }
                }
        }
 }