Jump to content

[Fix] Spellsteal


Guest MrLama

Recommended Posts

What bug does the patch fix? What features does the patch add?

Implements dispel resist to Spellsteal

For which repository revision was the patch created?

9235

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

---

Who has been writing this patch? Please include either forum user names or email addresses.

me ( but got idea from EffectDispel )

http://pastebin.com/m41d96d5d

diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 90c8577..a34df1a 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
-6834,29 +6834,33 @@ void Spell::EffectStealBeneficialBuff(uint32 i)
    // Ok if exist some buffs for dispel try dispel it
    if (!steal_list.empty())
    {
-        std::list < std::Pair<uint32,uint64> > success_list;
-        int32 list_size = steal_list.size();
+        std::list < std::Pair<uint32,uint64> > success_list;// (spell_id,casterGuid)
+        std::list < uint32 > fail_list;                     // spell_id
        // Dispell N = damage buffs (or while exist buffs for dispel)
-        for (int32 count=0; count < damage && list_size > 0; ++count)
+		for (int32 count=0; count < damage && !steal_list.empty(); ++count)
        {
            // Random select buff for dispel
-            Aura *aur = steal_list[urand(0, list_size-1)];
-            // Not use chance for steal
-            // TODO possible need do it
-            success_list.push_back( std::Pair<uint32,uint64>(aur->GetId(),aur->GetCasterGUID()));
+            std::vector<Aura*>::iterator steal_itr = steal_list.begin();
+            std::advance(steal_itr,urand(0, steal_list.size()-1));

-            // Remove buff from list for prevent doubles
-            for (std::vector<Aura *>::iterator j = steal_list.begin(); j != steal_list.end(); )
-            {
-                Aura *stealed = *j;
-                if (stealed->GetId() == aur->GetId() && stealed->GetCasterGUID() == aur->GetCasterGUID())
-                {
-                    j = steal_list.erase(j);
-                    --list_size;
-                }
-                else
-                    ++j;
-            }
+            Aura *aur = *steal_itr;
+			// remove entry from steal_list
+            steal_list.erase(steal_itr);
+
+            SpellEntry const* spellInfo = aur->GetSpellProto();
+            // Base dispel chance
+            int32 miss_chance = 0;
+            // Apply dispel mod from aura caster
+            if (Unit *caster = aur->GetCaster())
+			{
+				if ( Player* modOwner = caster->GetSpellModOwner() )
+                    modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_DISPEL_CHANCE, miss_chance, this);
+			}
+            // Try dispel
+            if (roll_chance_i(miss_chance))
+                fail_list.push_back(spellInfo->Id);
+            else
+                success_list.push_back(std::Pair<uint32,uint64>(aur->GetId(),aur->GetCasterGUID()));
        }
        // Really try steal and send log
        if (!success_list.empty())
-6877,6 +6881,18 @@ void Spell::EffectStealBeneficialBuff(uint32 i)
            }
            m_caster->SendMessageToSet(&data, true);
        }
+		// Send fail log to client
+        if (!fail_list.empty())
+        {
+            // Failed to steal
+            WorldPacket data(SMSG_DISPEL_FAILED, 8+8+4+4*fail_list.size());
+            data << uint64(m_caster->GetGUID());            // Caster GUID
+            data << uint64(unitTarget->GetGUID());          // Victim GUID
+            data << uint32(m_spellInfo->Id);                // Steal spell id
+            for (std::list< uint32 >::iterator j = fail_list.begin(); j != fail_list.end(); ++j)
+				data << uint32(*j);                         // Spell Id
+            m_caster->SendMessageToSet(&data, true);
+        }
    }
}

Link to comment
Share on other sites

  • 3 months later...
×
×
  • 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