From: Daniel Karbach Date: Sun, 19 Aug 2012 20:10:07 +0000 (+0200) Subject: run monsters' attack animation X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=591ecc2d7ecb0b41144be9b64c09801ac0a28131;p=l2e.git run monsters' attack animation --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 7ea17d8..b934039 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -420,7 +420,14 @@ void BattleState::RenderBackground(SDL_Surface *screen, const Vector &offse void BattleState::RenderMonsters(SDL_Surface *screen, const Vector &offset) { for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { if (MonsterPositionOccupied(i)) { - monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); + // TODO: better solution for running animations + if (monsters[i].AttackAnimation() && monsters[i].AttackAnimation()->Running()) { + monsters[i].AttackAnimation()->DrawCenter(screen, monsterPositions[i] + offset); + } else if (monsters[i].SpellAnimation() && monsters[i].SpellAnimation()->Running()) { + monsters[i].SpellAnimation()->DrawCenter(screen, monsterPositions[i] + offset); + } else { + monsters[i].Sprite()->DrawCenter(screen, monsterPositions[i] + offset); + } } } } diff --git a/src/battle/states/PerformAttacks.cpp b/src/battle/states/PerformAttacks.cpp index 9a81e00..86d7a7c 100644 --- a/src/battle/states/PerformAttacks.cpp +++ b/src/battle/states/PerformAttacks.cpp @@ -71,9 +71,9 @@ 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(); } else { Hero &hero(battle->HeroAt(battle->CurrentAttack().index)); const AttackChoice &ac(battle->AttackChoiceAt(battle->CurrentAttack().index));