All pastes #955055 Raw Edit

macman

public diff v1 · immutable
#955055 ·published 2008-03-24 09:36 UTC
rendered paste body
Index: src/game/SpellAuras.cpp===================================================================--- src/game/SpellAuras.cpp	(revision 5472)+++ 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)@@ -3467,6 +3473,20 @@                 ((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)+            {+                //this doesn't work as i expected, i'm not sure why+                //m_target->SetHealth(m_target->GetHealth() * (100.0 + float(m_modifier.m_amount))/100.0);+               +                // newHP = (curHP / maxHP) * newMaxHP = (newMaxHP * curHP) / maxHP -> which is better because no int -> double -> int conversion is needed+                uint32 newHPValue = (maxHPValue==0) ? 0 : ((m_target->GetMaxHealth() * curHPValue) / maxHPValue);+                m_target->SetHealth(newHPValue);+            }+            if (m_modifier.m_miscvalue == STAT_INTELLECT || m_modifier.m_miscvalue == -1)+            {+                uint32 newMPValue = (maxMPValue==0) ? 0 : ((m_target->GetMaxPower(POWER_MANA) * curMPValue) / maxMPValue);+                m_target->SetPower(POWER_MANA, newMPValue);+            }         }     } }