X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2Fstates%2FPerformAttacks.cpp;h=8550318d05cf83942cafb5619ea2a647869a98ce;hb=7263bddbde91d555decd58f043f6b43f54ba2b00;hp=2a8f3a53b697a4aecb3e5270c4e7c65d4be69ff9;hpb=c0068263474818f39e704eee12f753c0419f7708;p=l2e.git diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 2a8f3a5..8550318 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -33,12 +33,13 @@ namespace battle { void PerformAttacks::EnterState(Application &c, SDL_Surface *screen) { ctrl = &c; - battle->WriteOrder(order); + battle->CalculateAttackOrder(); numberAnimation.reserve(battle->MaxMonsters() > battle->NumHeroes() + 1 ? battle->MaxMonsters() : battle->NumHeroes() + 1); numberPosition.reserve(numberAnimation.size()); } void PerformAttacks::ExitState(Application &c, SDL_Surface *screen) { + battle->ClearAllAttacks(); ctrl = 0; } @@ -60,20 +61,22 @@ void PerformAttacks::HandleEvents(const Input &input) { CheckAnimations(); if (HasAnimationsRunning()) return; ResetAnimation(); - AdvanceCursor(); - if (Finished()) { - battle->ClearAllAttacks(); + battle->ApplyDamage(); + battle->NextAttack(); + if (battle->AttacksFinished()) { ctrl->PopState(); return; } - if (order[cursor].isMonster) { - const Monster &monster(battle->MonsterAt(order[cursor].index)); + battle->CalculateDamage(); + + if (battle->CurrentAttack().isMonster) { + Monster &monster(battle->MonsterAt(battle->CurrentAttack().index)); titleBarText = monster.Name(); - moveAnimation = 0; + moveAnimation = monster.AttackAnimation(); } else { - Hero &hero(battle->HeroAt(order[cursor].index)); - const AttackChoice &ac(battle->AttackChoiceAt(order[cursor].index)); + Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); + const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index)); switch (ac.GetType()) { case AttackChoice::SWORD: @@ -86,13 +89,22 @@ void PerformAttacks::HandleEvents(const Input &input) { } moveAnimation = hero.AttackAnimation(); - numberAnimation.push_back(NumberAnimation(15, battle->Res().numberAnimationPrototype, battle->Res().bigNumberSprite)); if (ac.Selection().TargetsEnemies()) { - numberPosition.push_back( - battle->MonsterPositions()[ac.Selection().SingleSelection()]); + 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 { - numberPosition.push_back( - battle->HeroesPositions()[ac.Selection().SingleSelection()]); + 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]); + } + } } break; case AttackChoice::MAGIC: @@ -176,18 +188,6 @@ void PerformAttacks::ResetAnimation() { numberPosition.clear(); } -void PerformAttacks::AdvanceCursor() { - ++cursor; - while (cursor < int(order.size())) { - if (order[cursor].isMonster) { - if (battle->MonsterAt(order[cursor].index).Health() > 0) break; - } else { - if (battle->HeroAt(order[cursor].index).Health() > 0) break; - } - ++cursor; - } -} - void PerformAttacks::UpdateWorld(float deltaT) { @@ -227,8 +227,8 @@ 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 (order[cursor].isMonster) return; // no monsters for now - const TargetSelection &ts(battle->AttackChoiceAt(order[cursor].index).Selection()); + if (battle->CurrentAttack().isMonster) return; // no monsters for now + const TargetSelection &ts(battle->AttackChoiceAt(battle->CurrentAttack().index).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)) {