X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FBattleState.cpp;h=649470e894dd20e9db70c690a02d39cc938c15ac;hb=8967f42789c619df6e5874f5c6a9ea4b6b6c33db;hp=720d70802c161b22a0cc451fd6db89d419713538;hpb=c68b073db752dcdcf8c900efba7d8a5da091751c;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 720d708..649470e 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -190,10 +190,9 @@ void BattleState::CalculateAttackOrder() { } for (vector::size_type i(0), end(monsters.size()); i < end; ++i) { attackOrder.push_back(Order(i, true)); + MonsterAt(i).GetAttackChoice() = AttackChoice(this); } std::sort(attackOrder.begin(), attackOrder.end(), OrderCompare(this)); - - monsterAttacks.resize(monsters.size(), AttackChoice(this)); } void BattleState::NextAttack() { @@ -218,7 +217,7 @@ bool BattleState::AttacksFinished() const { } void BattleState::CalculateDamage() { - AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : HeroAt(CurrentAttack().index).GetAttackChoice()); + AttackChoice &ac(CurrentAttack().isMonster ? MonsterAt(CurrentAttack().index).GetAttackChoice() : HeroAt(CurrentAttack().index).GetAttackChoice()); if (ac.GetType() == AttackChoice::DEFEND) return; if (CurrentAttack().isMonster) { @@ -294,7 +293,7 @@ Uint16 BattleState::CalculateDamage(const Stats &attacker, const Stats &defender void BattleState::ApplyDamage() { if (attackCursor < 0) return; - AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : HeroAt(CurrentAttack().index).GetAttackChoice()); + AttackChoice &ac(CurrentAttack().isMonster ? MonsterAt(CurrentAttack().index).GetAttackChoice() : HeroAt(CurrentAttack().index).GetAttackChoice()); TargetSelection &ts(ac.Selection()); if (ts.TargetsEnemies()) { for (int i(0); i < MaxMonsters(); ++i) { @@ -319,7 +318,7 @@ void BattleState::ApplyDamage() { AttackChoice &BattleState::CurrentAttackAttackChoice() { if (CurrentAttack().isMonster) { - return monsterAttacks[CurrentAttack().index]; + return MonsterAt(CurrentAttack().index).GetAttackChoice(); } else { return HeroAt(CurrentAttack().index).GetAttackChoice(); } @@ -328,11 +327,13 @@ AttackChoice &BattleState::CurrentAttackAttackChoice() { void BattleState::ClearAllAttacks() { attackCursor = -1; activeHero = -1; - for (int i(0); i < numHeroes; ++i) { - heroes[i].GetAttackChoice() = AttackChoice(this); + for (int i(0); i < NumHeroes(); ++i) { + HeroAt(i).GetAttackChoice() = AttackChoice(this); + } + for (int i(0); i < MaxMonsters(); ++i) { + MonsterAt(i).GetAttackChoice() = AttackChoice(this); } attackOrder.clear(); - monsterAttacks.clear(); }