Jump to content

[patch] Removespellbydamagetaken() Bug Fix


Auntie Mangos

Recommended Posts

RemoveSpellbyDamageTaken() should based on MECHANIC type rather than AURA type

Example:

Spell 20511: which is triggered by 5246. 20511 is stun aura, but it is fear MECHANIC. Someone play in official should know that it should be regarded as fear, not stun. Any damage should break this aura.

Spell 43150: this spell has a root aura but does not has a root mechanic. It is a damage spell and should stack debuff on target. It should not be removed due to damage taken.

Spell 43130: this spell has a root aura but has a ensnared mechanic. It also deal DOT damage to target. It should not be removed by the damage dealed by itself.

And there are many spells without any mechanic, such as 42716, 37450, they are only used to immobilize the target, and should not be removed by damage

Please see:

http://getmangos.eu/community/viewtopic.php?id=28636

Index: Unit.cpp
===================================================================
--- Unit.cpp                (revision 6412)
+++ Unit.cpp                (working copy)
@@ -430,18 +456,36 @@
}

/* Called by DealDamage for auras that have a chance to be dispelled on damage taken. */
-void Unit::RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage)
+void Unit::RemoveSpellbyDamageTaken(Mechanics mechanicsType, uint32 damage)
{
-                if(!HasAuraType(auraType))
-                                return;
+                //if(!HasAuraType(auraType))
+                //                return;

                // The chance to dispell an aura depends on the damage taken with respect to the casters level.
                uint32 max_dmg = getLevel() > 8 ? 25 * getLevel() - 150 : 50;
                float chance = float(damage) / max_dmg * 100.0f;
                if (roll_chance_f(chance))
-                                RemoveSpellsCausingAura(auraType);
+                                RemoveMechanicsCausingAura(mechanicsType);
}

+void Unit::RemoveMechanicsCausingAura(Mechanics mechanic)
+{
+                for(AuraMap::iterator iter = m_Auras.begin(), next; iter != m_Auras.end(); iter = next)
+                {
+                                next = iter;
+                                ++next;
+                                SpellEntry const *spell = sSpellStore.LookupEntry(iter->second->GetSpellProto()->Id);
+                                if(spell->Mechanic == mechanic || spell->EffectMechanic[iter->second->GetEffIndex()] == mechanic)
+                                {
+                                                RemoveAurasDueToSpell(spell->Id);
+                                                if(m_Auras.empty())
+                                                                break;
+                                                else
+                                                                next = m_Auras.begin();
+                                }
+                }
+}
+
uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const *spellProto, bool durabilityLoss)
{
                if (!pVictim->isAlive() || pVictim->isInFlight() || pVictim->GetTypeId() == TYPEID_UNIT && ((Creature*)pVictim)->IsInEvadeMode())
@@ -489,10 +533,10 @@
                                return 0;
                }

-                pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_FEAR, damage);
+                pVictim->RemoveSpellbyDamageTaken(MECHANIC_FEAR, damage);
                // root type spells do not dispell the root effect
                if(!spellProto || spellProto->Mechanic != MECHANIC_ROOT)
-                                pVictim->RemoveSpellbyDamageTaken(SPELL_AURA_MOD_ROOT, damage);
+                                pVictim->RemoveSpellbyDamageTaken(MECHANIC_ROOT, damage);

                if(pVictim->GetTypeId() != TYPEID_PLAYER)
                {
Index: Unit.h
===================================================================
--- Unit.h                (revision 6412)
+++ Unit.h                (working copy)
@@ -879,7 +880,8 @@

                                bool isFrozen() const;

-                                void RemoveSpellbyDamageTaken(AuraType auraType, uint32 damage);
+                                void RemoveSpellbyDamageTaken(Mechanics mechanicsType, uint32 damage);
+                                void RemoveMechanicsCausingAura(Mechanics mechanicsType);

                                bool isTargetableForAttack() const;
                                virtual bool IsInWater() const;

Link to comment
Share on other sites

  • 38 years later...
  • 2 years later...
Guest
This topic is now closed to further replies.
×
×
  • 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