aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/AI/SmartScripts
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-03-08 13:31:57 +0100
committerShauren <shauren.trinity@gmail.com>2015-03-08 13:31:57 +0100
commit0ba2e0d5ee416a2daf89d53877984fb0cf27ca9b (patch)
tree0cb086bb038bf7d3164b9c25dab9ecd1bf93cad6 /src/server/game/AI/SmartScripts
parent9ffeb58d094ddba9bffb33a79b33ade9af9f5c00 (diff)
Core/Spells: Implemented multiple spell power costs
Diffstat (limited to 'src/server/game/AI/SmartScripts')
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp
index 797abc201dc..108e5cedd09 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -491,12 +491,32 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
bool _allowMove = false;
SpellInfo const* spellInfo = sSpellMgr->AssertSpellInfo(e.action.cast.spell);
- int32 mana = me->GetPower(POWER_MANA);
+ std::vector<SpellInfo::CostData> costs = spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask());
+ bool hasPower = true;
+ for (SpellInfo::CostData const& cost : costs)
+ {
+ if (cost.Power == POWER_HEALTH)
+ {
+ if (me->GetHealth() <= cost.Amount)
+ {
+ hasPower = false;
+ break;
+ }
+ }
+ else
+ {
+ if (me->GetPower(cost.Power) < cost.Amount)
+ {
+ hasPower = false;
+ break;
+ }
+ }
+
+ }
if (me->GetDistance(*itr) > spellInfo->GetMaxRange(true) ||
me->GetDistance(*itr) < spellInfo->GetMinRange(true) ||
- !me->IsWithinLOSInMap(*itr) ||
- mana < spellInfo->CalcPowerCost(me, spellInfo->GetSchoolMask()))
+ !me->IsWithinLOSInMap(*itr) || !hasPower)
_allowMove = true;
ENSURE_AI(SmartAI, me->AI())->SetCombatMove(_allowMove);