From: Daniel Karbach Date: Sun, 19 Aug 2012 20:01:14 +0000 (+0200) Subject: added support for defend action in damage calculation X-Git-Url: http://git.localhorst.tv/?a=commitdiff_plain;h=7b73cc018371817cb29f658ac94e8863aa6e1656;hp=c6156f6b3dc88a97a78694a2652dfbc874fcc8e4;p=l2e.git added support for defend action in damage calculation --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index e72fbf9..7ea17d8 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -288,23 +288,26 @@ void BattleState::NextAttack() { } void BattleState::CalculateDamage() { + AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index)); + if (ac.GetType() == AttackChoice::DEFEND) return; + if (CurrentAttack().isMonster) { const Stats &attackerStats(MonsterAt(CurrentAttack().index).GetStats()); // TODO: run monster's attack script - monsterAttacks[CurrentAttack().index].SetType(AttackChoice::SWORD); - monsterAttacks[CurrentAttack().index].Selection().SelectSingle(); - monsterAttacks[CurrentAttack().index].Selection().SelectHeroes(); + ac.SetType(AttackChoice::SWORD); + ac.Selection().SelectSingle(); + ac.Selection().SelectHeroes(); for (int i(0); i < NumHeroes(); ++i) { if (HeroAt(i).Health() > 0) { const Stats &defenderStats(HeroAt(i).GetStats()); Uint16 damage(CalculateDamage(attackerStats, defenderStats)); - monsterAttacks[CurrentAttack().index].Selection().SetBad(0, damage); + ac.Selection().SetBad(0, damage); break; } } } else { const Stats &attackerStats(HeroAt(CurrentAttack().index).GetStats()); - TargetSelection &ts(AttackChoiceAt(CurrentAttack().index).Selection()); + TargetSelection &ts(ac.Selection()); bool hitSome(false); if (ts.TargetsEnemies()) { for (int i(0); i < MaxMonsters(); ++i) {