aboutsummaryrefslogtreecommitdiff
path: root/src/game/Spell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/Spell.cpp')
-rw-r--r--src/game/Spell.cpp72
1 files changed, 2 insertions, 70 deletions
diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 090749b32db..8f47a8252d4 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -2621,8 +2621,8 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect* triggeredByAura
}
}
- // Fill cost data
- m_powerCost = CalculatePowerCost();
+ // Fill cost data (not use power for item casts
+ m_powerCost = m_CastItem ? 0 : CalculatePowerCost(m_spellInfo, m_caster, m_spellSchoolMask);
SpellCastResult result = CheckCast(true);
if(result != SPELL_CAST_OK && !IsAutoRepeat()) //always cast autorepeat dummy for triggering
@@ -5348,74 +5348,6 @@ SpellCastResult Spell::CheckRange(bool strict)
return SPELL_CAST_OK;
}
-int32 Spell::CalculatePowerCost()
-{
- // item cast not used power
- if(m_CastItem)
- return 0;
-
- // Spell drain all exist power on cast (Only paladin lay of Hands)
- if (m_spellInfo->AttributesEx & SPELL_ATTR_EX_DRAIN_ALL_POWER)
- {
- // If power type - health drain all
- if (m_spellInfo->powerType == POWER_HEALTH)
- return m_caster->GetHealth();
- // Else drain all power
- if (m_spellInfo->powerType < MAX_POWERS)
- return m_caster->GetPower(Powers(m_spellInfo->powerType));
- sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id);
- return 0;
- }
-
- // Base powerCost
- int32 powerCost = m_spellInfo->manaCost;
- // PCT cost from total amount
- if (m_spellInfo->ManaCostPercentage)
- {
- switch (m_spellInfo->powerType)
- {
- // health as power used
- case POWER_HEALTH:
- powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateHealth() / 100;
- break;
- case POWER_MANA:
- powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetCreateMana() / 100;
- break;
- case POWER_RAGE:
- case POWER_FOCUS:
- case POWER_ENERGY:
- case POWER_HAPPINESS:
- powerCost += m_spellInfo->ManaCostPercentage * m_caster->GetMaxPower(Powers(m_spellInfo->powerType)) / 100;
- break;
- case POWER_RUNE:
- case POWER_RUNIC_POWER:
- sLog.outDebug("Spell::CalculateManaCost: Not implemented yet!");
- break;
- default:
- sLog.outError("Spell::CalculateManaCost: Unknown power type '%d' in spell %d", m_spellInfo->powerType, m_spellInfo->Id);
- return 0;
- }
- }
- SpellSchools school = GetFirstSchoolInMask(m_spellSchoolMask);
- // Flat mod from caster auras by spell school
- powerCost += m_caster->GetInt32Value(UNIT_FIELD_POWER_COST_MODIFIER + school);
- // Shiv - costs 20 + weaponSpeed*10 energy (apply only to non-triggered spell with energy cost)
- if ( m_spellInfo->AttributesEx4 & SPELL_ATTR_EX4_SPELL_VS_EXTEND_COST )
- powerCost += m_caster->GetAttackTime(OFF_ATTACK)/100;
- // Apply cost mod by spell
- if(Player* modOwner = m_caster->GetSpellModOwner())
- modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_COST, powerCost, this);
-
- if(m_spellInfo->Attributes & SPELL_ATTR_LEVEL_DAMAGE_CALCULATION)
- powerCost = int32(powerCost/ (1.117f* m_spellInfo->spellLevel / m_caster->getLevel() -0.1327f));
-
- // PCT mod from user auras by school
- powerCost = int32(powerCost * (1.0f+m_caster->GetFloatValue(UNIT_FIELD_POWER_COST_MULTIPLIER+school)));
- if (powerCost < 0)
- powerCost = 0;
- return powerCost;
-}
-
SpellCastResult Spell::CheckPower()
{
// item cast not used power