]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/states/PerformAttacks.cpp
added melee animation of monsters
[l2e.git] / src / battle / states / PerformAttacks.cpp
index 9a81e00ccc1b062970761497a2287de524f7c5da..10fb8bb11294c6f0f517d1def1efd528cbd86cbb 100644 (file)
@@ -39,6 +39,7 @@ void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) {
 }
 
 void PerformAttacks::ExitState(Application &c, SDL_Surface *screen) {
+       battle->ClearAllAttacks();
        ctrl = 0;
 }
 
@@ -63,7 +64,6 @@ void PerformAttacks::HandleEvents(const Input &input) {
        battle->ApplyDamage();
        battle->NextAttack();
        if (battle->AttacksFinished()) {
-               battle->ClearAllAttacks();
                ctrl->PopState();
                return;
        }
@@ -71,9 +71,11 @@ void PerformAttacks::HandleEvents(const Input &input) {
        battle->CalculateDamage();
 
        if (battle->CurrentAttack().isMonster) {
-               const Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
+               Monster &monster(battle->MonsterAt(battle->CurrentAttack().index));
                titleBarText = monster.Name();
-               moveAnimation = 0;
+               moveAnimation = monster.AttackAnimation();
+               targetAnimation = monster.MeleeAnimation();
+               // TODO: add number animations
        } else {
                Hero &hero(battle->HeroAt(battle->CurrentAttack().index));
                const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));
@@ -227,8 +229,7 @@ void PerformAttacks::RenderNumbers(SDL_Surface *screen, const Vector<int> &offse
 
 void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector<int> &offset) const {
        if (!targetAnimation || !targetAnimation->Running()) return;
-       if (battle->CurrentAttack().isMonster) return; // no monsters for now
-       const TargetSelection &ts(battle->AttackChoiceAt(battle->CurrentAttack().index).Selection());
+       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)) {