All pastes #958862 Raw Edit

macman

public diff v1 · immutable
#958862 ·published 2008-03-26 23:37 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)@@ -3466,6 +3472,17 @@             {                 ((Player*)m_target)->ApplyPosStatPercentMod(Stats(i), m_modifier.m_amount, apply );                 ((Player*)m_target)->ApplyNegStatPercentMod(Stats(i), m_modifier.m_amount, apply );+                if ((m_modifier.m_miscvalue == STAT_STAMINA || m_modifier.m_miscvalue == -1) && (maxHPValue > 0))+                {+                    // 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))+                {+                    uint32 newMPValue = (m_target->GetMaxPower(POWER_MANA) * curMPValue) / maxMPValue;+                    m_target->SetPower(POWER_MANA, newMPValue);+                }             }         }     }