From: Daniel Karbach Date: Mon, 20 Aug 2012 20:46:42 +0000 (+0200) Subject: collecting exp/gold reward in battle state X-Git-Url: https://git.localhorst.tv/?a=commitdiff_plain;h=9a273798937710928304fdcc5e33a78c6f8b48be;p=l2e.git collecting exp/gold reward in battle state --- diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index 84d1a49..5547bbf 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -375,9 +375,13 @@ void BattleState::ApplyDamage() { TargetSelection &ts(ac.Selection()); if (ts.TargetsEnemies()) { for (int i(0); i < MaxMonsters(); ++i) { + Monster &monster(MonsterAt(i)); if (ts.IsBad(i)) { - MonsterAt(i).SubtractHealth(ts.GetAmount(i)); - // TODO: collect reward if dead + monster.SubtractHealth(ts.GetAmount(i)); + if (monster.Health() == 0) { + expReward += monster.ExpReward(); + goldReward += monster.GoldReward(); + } } } } else { diff --git a/src/battle/BattleState.h b/src/battle/BattleState.h index a10ff7e..9f30fb5 100644 --- a/src/battle/BattleState.h +++ b/src/battle/BattleState.h @@ -58,6 +58,8 @@ public: , numHeroes(0) , activeHero(-1) , attackCursor(-1) + , expReward(0) + , goldReward(0) , ranAway(false) { assert(background && res); } public: @@ -190,6 +192,8 @@ private: int numHeroes; int activeHero; int attackCursor; + int expReward; + int goldReward; bool ranAway; };