Jump to content

[patch][5694] Charges In Character Buffs


Guest DiSlord

Recommended Posts

Show charges in player buffs (example Lighting Shield or Inner Fire)

Base idea by TERRANZ

Code by me :)

Index: SpellAuras.cpp
===================================================================
--- SpellAuras.cpp        (revision 5688)
+++ SpellAuras.cpp        (working copy)
@@ -790,7 +790,7 @@

        // we can found aura in NULL_AURA_SLOT and then need store state instead check slot != NULL_AURA_SLOT
        bool samespell = false;
-
+        bool secondaura = false;
        uint8 slot = NULL_AURA_SLOT;

        for(uint8 i = 0; i < 3; i++)
@@ -802,6 +802,8 @@
                        if(itr->second->GetCasterGUID()==GetCasterGUID())
                        {
                                samespell = true;
+                                if (m_effIndex > itr->second->GetEffIndex())
+                                         secondaura = true;
                                slot = itr->second->GetAuraSlot();
                                break;
                        }
@@ -865,6 +867,9 @@
                                SetAuraFlag(slot, true);
                                SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));

+                                if (m_procCharges >= 1)                            // Add charge count (as aura stack count) for show in client
+                                        SetAuraApplication(slot, m_procCharges - 1);
+
                                // update for out of range group members
                                m_target->UpdateAuraForGroup(slot);
                        }
@@ -875,7 +880,9 @@
                else                                                                                                // use found slot
                {
                        SetAuraSlot( slot );
-                        UpdateSlotCounterAndDuration(true);
+                        // Not recalculate stack count for second aura of the same spell
+                        if (!secondaura)
+                                UpdateSlotCounterAndDuration(true);
                }

                // Update Seals information
@@ -935,6 +942,7 @@
                        if(itr->second->GetAuraSlot()==slot)
                        {
                                samespell = true;
+
                                break;
                        }
                }
@@ -949,6 +957,7 @@
                SetAuraFlag(slot, false);
                SetAuraLevel(slot,caster ? caster->getLevel() : sWorld.getConfig(CONFIG_MAX_PLAYER_LEVEL));

+                SetAuraApplication(slot, 0);
                // update for out of range group members
                m_target->UpdateAuraForGroup(slot);

@@ -1019,7 +1028,7 @@
        uint32 byte         = (slot % 4) * 8;
        uint32 val            = m_target->GetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index);
        val &= ~(0xFF << byte);
-        val |= (count << byte);
+        val |= ((uint8(count)) << byte);
        m_target->SetUInt32Value(UNIT_FIELD_AURAAPPLICATIONS + index, val);
}

@@ -3165,7 +3174,10 @@
                // some spell have charges by functionality not have its in spell data
                switch (m_spellId)
                {
-                        case 28200: m_procCharges = 6; break;                     // Ascendance (Talisman of Ascendance trinket
+                        case 28200:                                                 // Ascendance (Talisman of Ascendance trinket
+                                m_procCharges = 6; 
+                                UpdateAuraCharges(); 
+                                break;
                        default: break;
                }
        }
Index: SpellAuras.h
===================================================================
--- SpellAuras.h        (revision 5688)
+++ SpellAuras.h        (working copy)
@@ -239,6 +239,12 @@

                uint8 GetAuraSlot() const { return m_auraSlot; }
                void SetAuraSlot(uint8 slot) { m_auraSlot = slot; }
+                void UpdateAuraCharges()
+                {
+                        uint8 slot = GetAuraSlot();
+                        if (slot < MAX_AURAS && m_procCharges >= 1)
+                                SetAuraApplication(slot, m_procCharges - 1);
+                }

                bool IsPositive() { return m_positive; }
                void SetNegative() { m_positive = false; }
Index: Unit.cpp
===================================================================
--- Unit.cpp        (revision 5688)
+++ Unit.cpp        (working copy)
@@ -9499,6 +9499,22 @@
                                        break;
                                }
                        }
+                        // Update charge (aura can be removed by triggers)
+                        // Not validate aura on check (for speed)
+                        if(i->triggeredByAura->m_procCharges > 0)
+                        {
+                                // need found aura (can be dropped by triggers)
+                                AuraMap::const_iterator lower = GetAuras().lower_bound(i->triggeredByAura_SpellPair);
+                                AuraMap::const_iterator upper = GetAuras().upper_bound(i->triggeredByAura_SpellPair);
+                                for(AuraMap::const_iterator itr = lower; itr!= upper; ++itr)
+                                {
+                                        if(itr->second == i->triggeredByAura)
+                                        {
+                                                i->triggeredByAura->UpdateAuraCharges();
+                                                break;
+                                        }
+                                }
+                        }
                }

                // Safely remove auras with zero charges

http://pastebin.ca/994899

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use