aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-13 18:29:38 -0600
committermegamage <none@none>2009-03-13 18:29:38 -0600
commit969eab7be482954253311eae33fddd3ccb4b59d3 (patch)
treea36db7e738513cd2e735800f56301bbc864a5814 /src
parentc3d14c82419ca06bae620df9560133cd16b4caed (diff)
[7451] Implement correct work SPELL_AURA_PERIODIC_MANA_LEECH for percent mana cost spells. Author: VladimirMangos
This is fix work of spell 3034 and 5138. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/SpellAuras.cpp29
1 files changed, 20 insertions, 9 deletions
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 92323d1c2e8..d69762d49a5 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -5737,6 +5737,15 @@ void Aura::PeriodicTick()
}
case SPELL_AURA_PERIODIC_MANA_LEECH:
{
+ if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
+ return;
+
+ Powers power = Powers(m_modifier.m_miscvalue);
+
+ // power type might have changed between aura applying and tick (druid's shapeshift)
+ if(m_target->getPowerType() != power)
+ return;
+
Unit *pCaster = GetCaster();
if(!pCaster)
return;
@@ -5755,18 +5764,20 @@ void Aura::PeriodicTick()
// ignore non positive values (can be result apply spellmods to aura damage
uint32 pdamage = m_modifier.m_amount > 0 ? m_modifier.m_amount : 0;
+ // Special case: draining x% of mana (up to a maximum of 2*x% of the caster's maximum mana)
+ // It's mana percent cost spells, m_modifier.m_amount is percent drain from target
+ if (m_spellProto->ManaCostPercentage)
+ {
+ // max value
+ uint32 maxmana = pCaster->GetMaxPower(power) * pdamage * 2 / 100;
+ pdamage = m_target->GetMaxPower(power) * pdamage / 100;
+ if(pdamage > maxmana)
+ pdamage = maxmana;
+ }
+
sLog.outDetail("PeriodicTick: %u (TypeId: %u) power leech of %u (TypeId: %u) for %u dmg inflicted by %u",
GUID_LOPART(GetCasterGUID()), GuidHigh2TypeId(GUID_HIPART(GetCasterGUID())), m_target->GetGUIDLow(), m_target->GetTypeId(), pdamage, GetId());
- if(m_modifier.m_miscvalue < 0 || m_modifier.m_miscvalue >= MAX_POWERS)
- break;
-
- Powers power = Powers(m_modifier.m_miscvalue);
-
- // power type might have changed between aura applying and tick (druid's shapeshift)
- if(m_target->getPowerType() != power)
- break;
-
int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
//Viper sting and Drain Life take mana % amount from target, but not bigger than amount*2 of caster mana