X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=6c318aaf04138e86c627a94429dcdec23e260911;hb=8456b7dac2051bfd2b507a39854c1428eb4d91cd;hp=dd0e0df1cd0a27de4102081e4b8a6e470e945f01;hpb=8f6a2452408f4ae35396cd7008a6fab0ecb03a46;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index dd0e0df..6c318aa 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -7,6 +7,7 @@ #include "PerformAttacks.h" +#include "../AttackAnimation.h" #include "../BattleState.h" #include "../Hero.h" #include "../Monster.h" @@ -57,6 +58,7 @@ void PerformAttacks::Resize(int width, int height) { void PerformAttacks::HandleEvents(const Input &input) { + if (attackAnimation) attackAnimation->Update(); CheckNumberAnimation(); if (HasAnimationsRunning()) return; ResetAnimation(); @@ -77,8 +79,19 @@ void PerformAttacks::HandleEvents(const Input &input) { switch (ac.GetType()) { case AttackChoice::SWORD: - titleBarText = hero.HasWeapon() ? hero.Weapon()->Name() : "Melee attack!"; - moveAnimation = hero.AttackAnimation(); + if (hero.HasWeapon()) { + titleBarText = hero.Weapon()->Name(); + moveAnimation = hero.AttackAnimation(); + } else { + titleBarText = "Melee attack!"; + if (hero.MeleeAnimation()) { + moveAnimation = 0; + attackAnimation = hero.MeleeAnimation(); + } else { + moveAnimation = hero.AttackAnimation(); + attackAnimation = 0; + } + } numberAnimation.push_back(NumberAnimation(15, battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); if (ac.Selection().TargetsEnemies()) { numberPosition.push_back( @@ -119,11 +132,15 @@ void PerformAttacks::HandleEvents(const Input &input) { if (titleBarText) titleBarTimer = GraphicsTimers().StartCountdown(1500); if (moveAnimation) moveAnimation->Start(*this); + if (attackAnimation) attackAnimation->Start(battle, this); } void PerformAttacks::CheckNumberAnimation() { if (moveAnimation && moveAnimation->Running()) return; - if (!moveAnimation || moveAnimation->JustFinished()) { + if (attackAnimation && !attackAnimation->Finished()) return; + if (moveAnimation || attackAnimation) { + moveAnimation = 0; + attackAnimation = 0; for (vector::iterator i(numberAnimation.begin()), end(numberAnimation.end()); i != end; ++i) { i->Start(*this); } @@ -145,6 +162,7 @@ bool PerformAttacks::HasAnimationsRunning() const { void PerformAttacks::ResetAnimation() { if (moveAnimation) moveAnimation->Stop(); + if (attackAnimation) attackAnimation = 0; titleBarTimer.Clear(); numberAnimation.clear(); numberPosition.clear(); @@ -175,6 +193,7 @@ void PerformAttacks::Render(SDL_Surface *screen) { battle->RenderSmallHeroTags(screen, offset); RenderTitleBar(screen, offset); RenderNumbers(screen, offset); + if (attackAnimation) attackAnimation->Render(screen, offset); } void PerformAttacks::RenderTitleBar(SDL_Surface *screen, const Vector &offset) {