]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
moved monsters' attack choices to Monster
[l2e.git] / src / battle / BattleState.cpp
index 50121049651fc4b0a4deacb7c40554dcdc21400a..649470e894dd20e9db70c690a02d39cc938c15ac 100644 (file)
@@ -190,10 +190,9 @@ void BattleState::CalculateAttackOrder() {
        }
        for (vector<Monster>::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] : AttackChoiceAt(CurrentAttack().index));
+       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] : AttackChoiceAt(CurrentAttack().index));
+       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,20 +318,22 @@ void BattleState::ApplyDamage() {
 
 AttackChoice &BattleState::CurrentAttackAttackChoice() {
        if (CurrentAttack().isMonster) {
-               return monsterAttacks[CurrentAttack().index];
+               return MonsterAt(CurrentAttack().index).GetAttackChoice();
        } else {
-               return AttackChoiceAt(CurrentAttack().index);
+               return HeroAt(CurrentAttack().index).GetAttackChoice();
        }
 }
 
 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();
 }