X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=36b7b1630d41477fa23ba7055ed629ee39078a8c;hb=4c3d420d8fc933d334def034f5d76ba23934479d;hp=8550318d05cf83942cafb5619ea2a647869a98ce;hpb=7263bddbde91d555decd58f043f6b43f54ba2b00;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 8550318..36b7b16 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -74,6 +74,8 @@ void PerformAttacks::HandleEvents(const Input &input) { Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); titleBarText = monster.Name(); moveAnimation = monster.AttackAnimation(); + targetAnimation = monster.MeleeAnimation(); + AddNumberAnimations(battle->MonsterAttackChoiceAt(battle->CurrentAttack().index).Selection()); } else { Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index)); @@ -88,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(); @@ -136,7 +121,7 @@ void PerformAttacks::HandleEvents(const Input &input) { } } - if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(1500); + if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(850); if (moveAnimation) moveAnimation->Start(*this); if (targetAnimation) { targetAnimationTimer = GraphicsTimers().StartCountdown(150); @@ -145,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); @@ -227,8 +240,7 @@ void PerformAttacks::RenderNumbers(SDL_Surface *screen, const Vector &offse void PerformAttacks::RenderTargetAnimation(SDL_Surface *screen, const geometry::Vector &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 > &positions(ts.TargetsHeroes() ? battle->HeroesPositions() : battle->MonsterPositions()); for (vector >::size_type i(0), end(positions.size()); i < end; ++i) { if (ts.IsSelected(i)) {