All pastes #958879 Raw Edit

macman

public diff v1 · immutable
#958879 ·published 2008-03-26 23:50 UTC
rendered paste body
Index: src/game/SpellAuras.cpp===================================================================--- src/game/SpellAuras.cpp	(revision 5483)+++ src/game/SpellAuras.cpp	(working copy)@@ -3457,6 +3457,12 @@         return;     } +    //save current and max HP and MP before applying aura+    uint32 curHPValue = m_target->GetHealth();+    uint32 maxHPValue = m_target->GetMaxHealth();+    uint32 curMPValue = m_target->GetPower(POWER_MANA);+    uint32 maxMPValue = m_target->GetMaxPower(POWER_MANA);+     for (int32 i = STAT_STRENGTH; i < MAX_STATS; i++)     {         if(m_modifier.m_miscvalue == i || m_modifier.m_miscvalue == -1)@@ -3469,6 +3475,20 @@             }         }     }+    +    //recalculate current HP/MP after applying aura modifications+    if ((m_modifier.m_miscvalue == STAT_STAMINA || m_modifier.m_miscvalue == -1) && (maxHPValue > 0) && (m_target->GetTypeId() == TYPEID_PLAYER))+    {+        // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed+        uint32 newHPValue = (m_target->GetMaxHealth() * curHPValue) / maxHPValue;+        m_target->SetHealth(newHPValue);+    }+    if ((m_modifier.m_miscvalue == STAT_INTELLECT || m_modifier.m_miscvalue == -1) && (maxMPValue > 0) && (m_target->GetTypeId() == TYPEID_PLAYER))+    {+        uint32 newMPValue = (m_target->GetMaxPower(POWER_MANA) * curMPValue) / maxMPValue;+        m_target->SetPower(POWER_MANA, newMPValue);+    }+     }  void Aura::HandleAuraModResistenceOfIntellectPercent(bool apply, bool Real)