From 0ba2e0d5ee416a2daf89d53877984fb0cf27ca9b Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 8 Mar 2015 13:31:57 +0100 Subject: Core/Spells: Implemented multiple spell power costs --- src/server/game/AI/SmartScripts/SmartScript.cpp | 26 ++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src/server/game/AI/SmartScripts') 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 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); -- cgit v1.2.3