Jump to content

[fix] Hunger for Blood


Guest Lukyn

Recommended Posts

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

Due to changes in Hunger for Blood spell in 3.1.3, it's application requires "bleeding effect" on the rogue target.

"Bleeding effect" is represented by "AuraState = 18" enumerated as AURA_STATE_UNKNOWN18 in recent revision.

First this patch modifies AuraState on rougue's target to expected value, when any aura with bleed mechanic is applied.

Second it adds HasAuraMechanic(...) method to Unit class to recognize if there is an aura on unit with respective mechanic (bleed in this case).

This feature is used for correct removal of AuraState::AURA_STATE_BLEEDING when there is nothing on unit causing bleeding.

And finally it handles correct application of Hunger for Blood aura to the caster (while it is presented as Dummy effect, instead of Apply Aura: Mod Dmg % as in previous WoW versions).

For which repository revision was the patch created?

revision 8254

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.

by myself

diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index a1879af..bdb30ab 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -897,7 +897,7 @@ enum AuraState
    AURA_STATE_SWIFTMEND                    = 15,           //   T |
    AURA_STATE_DEADLY_POISON                = 16,           //   T |
    AURA_STATE_ENRAGE                       = 17,           // C   |
-    //AURA_STATE_UNKNOWN18                  = 18,           // C  t|
+    AURA_STATE_BLEEDING                     = 18,           //   T |
    //AURA_STATE_UNKNOWN19                  = 19,           //     | not used
    //AURA_STATE_UNKNOWN20                  = 20,           //  c  | only (45317 Suicide)
    //AURA_STATE_UNKNOWN21                  = 21,           //     | not used
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index b5c6d6f..eb61628 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1153,6 +1153,10 @@ void Aura::_RemoveAura()
                ((Player*)caster)->SendCooldownEvent(GetSpellProto());
        }
    }
+
+        //if target has bleeding flag, but aura removes bleeding efect and no other aura with mechanics: bleeding remains, then remove flag
+        if (m_spellProto->Mechanic == MECHANIC_BLEED && m_target->HasAuraState(AURA_STATE_BLEEDING) && !m_target->HasAuraMechanic(MECHANIC_BLEED))
+                m_target->ModifyAuraState(AURA_STATE_BLEEDING, false);
}

void Aura::SendAuraUpdate(bool remove)
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 7a6ed0c..a2f900f 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1478,6 +1478,29 @@ void Spell::EffectDummy(uint32 i)
        case SPELLFAMILY_ROGUE:
            switch(m_spellInfo->Id )
            {
+                                case 51662:                                                        //hunger for blood
+                                {
+                                        //only for player
+                                        if (m_caster->GetTypeId() != TYPEID_PLAYER)
+                                                return;
+
+                                        //new aura should be added to caster
+                                        Aura* aura = CreateAura(m_spellInfo, i, NULL, m_caster, m_caster);
+                                        if (aura)
+                                        {
+                                                //correct aura mod a values
+                                                aura->SetModifier(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE, m_spellInfo->CalculateSimpleValue(i), 0, SPELL_SCHOOL_MASK_NORMAL);
+                                                aura->SetPositive();
+                                                aura->SetIsSingleTarget(true);
+                                                aura->SetRemoveMode(AURA_REMOVE_BY_CANCEL);
+                                                //correct duration (3.1.3)
+                                                aura->SetAuraMaxDuration(60 * IN_MILISECONDS);
+                                                aura->SetAuraDuration(60 * IN_MILISECONDS);
+                                                //final add aura to caster
+                                                m_caster->AddAura(aura);
+                                        }
+                                        return;
+                                }
                case 5938:                                  // Shiv
                {
                    if(m_caster->GetTypeId() != TYPEID_PLAYER)
@@ -2392,6 +2415,11 @@ void Spell::EffectApplyAura(uint32 i)
    if(!Aur)
        return;

+        //bleeding effect has to be added for those spells with Mechanics: bleeding
+        //(purpose: Hunger for Blood fix - 3.1.3)
+        if (m_spellInfo->Mechanic == MECHANIC_BLEED)
+                unitTarget->ModifyAuraState(AURA_STATE_BLEEDING, true);
+
    // Prayer of Mending (jump animation), we need formal caster instead original for correct animation
    if( m_spellInfo->SpellFamilyName == SPELLFAMILY_PRIEST && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x00002000000000)))
        m_caster->CastSpell(unitTarget, 41637, true, NULL, Aur, m_originalCasterGUID);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 9f37a13..0e4a122 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -7457,6 +7457,21 @@ void Unit::CombatStopWithPets(bool includingCast)
            guardian->CombatStop(includingCast);
}

+bool Unit::HasAuraMechanic(Mechanics mechanic) const
+{
+        for (AuraMap::const_iterator it = m_Auras.begin(); it != m_Auras.end(); ++it)
+        {
+                Aura* aura = it->second;
+                if (aura)
+                {
+                        const SpellEntry* spellEntry = aura->GetSpellProto();
+                        if (spellEntry && spellEntry->Mechanic == mechanic)
+                                        return true;
+                }
+        }
+        return false;
+}
+
bool Unit::isAttackingPlayer() const
{
    if(hasUnitState(UNIT_STAT_ATTACK_PLAYER))
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 386f518..15cbc23 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1195,6 +1195,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject

        Pet* CreateTamedPetFrom(Creature* creatureTarget,uint32 spell_id = 0);

+                bool HasAuraMechanic(Mechanics mechanic) const;
+
        bool AddAura(Aura *aur);

        void RemoveAura(Aura* aura);

download link for patch file

Link to comment
Share on other sites

  • 2 weeks later...
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index dbe2269..5dfe6dd 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -897,7 +897,7 @@ enum AuraState
    AURA_STATE_SWIFTMEND                    = 15,           //   T |
    AURA_STATE_DEADLY_POISON                = 16,           //   T |
    AURA_STATE_ENRAGE                       = 17,           // C   |
-    //AURA_STATE_UNKNOWN18                  = 18,           // C  t|
+    AURA_STATE_MECHANIC_BLEED               = 18,           // C  t|
    //AURA_STATE_UNKNOWN19                  = 19,           //     | not used
    //AURA_STATE_UNKNOWN20                  = 20,           //  c  | only (45317 Suicide)
    //AURA_STATE_UNKNOWN21                  = 21,           //     | not used
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 21e0270..b641c5e 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1011,6 +1011,10 @@ void Aura::_AddAura()
            // Enrage aura state
            if(m_spellProto->Dispel == DISPEL_ENRAGE)
                m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
+      
+           // Mechanic bleed aura state
+           if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
+               m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, true);
        }
    }
}
@@ -1125,6 +1129,11 @@ void Aura::_RemoveAura()
                    removeState = AURA_STATE_FAERIE_FIRE;   // Sting (hunter versions)

        }
+    
+        // Mechanic bleed aura state
+        if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
+            m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, false);
+
        // Remove state (but need check other auras for it)
        if (removeState)
        {
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 06718ce..c492f34 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1537,6 +1537,11 @@ void Spell::EffectDummy(uint32 i)
                    m_caster->CastSpell(m_caster, 45182, true);
                    return;
                }
+                case 51662:                                 // Hunger for Blood
+                {
+                    m_caster->CastSpell(m_caster, 63848, true);
+                    return;
+                }
            }
            break;
        case SPELLFAMILY_HUNTER:

Link to comment
Share on other sites

  • 1 month later...
diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.h
index dbe2269..5dfe6dd 100644
--- a/src/game/SharedDefines.h
+++ b/src/game/SharedDefines.h
@@ -897,7 +897,7 @@ enum AuraState
    AURA_STATE_SWIFTMEND                    = 15,           //   T |
    AURA_STATE_DEADLY_POISON                = 16,           //   T |
    AURA_STATE_ENRAGE                       = 17,           // C   |
-    //AURA_STATE_UNKNOWN18                  = 18,           // C  t|
+    AURA_STATE_MECHANIC_BLEED               = 18,           // C  t|
    //AURA_STATE_UNKNOWN19                  = 19,           //     | not used
    //AURA_STATE_UNKNOWN20                  = 20,           //  c  | only (45317 Suicide)
    //AURA_STATE_UNKNOWN21                  = 21,           //     | not used
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 21e0270..b641c5e 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -1011,6 +1011,10 @@ void Aura::_AddAura()
            // Enrage aura state
            if(m_spellProto->Dispel == DISPEL_ENRAGE)
                m_target->ModifyAuraState(AURA_STATE_ENRAGE, true);
+      
+           // Mechanic bleed aura state
+           if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
+               m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, true);
        }
    }
}
@@ -1125,6 +1129,11 @@ void Aura::_RemoveAura()
                    removeState = AURA_STATE_FAERIE_FIRE;   // Sting (hunter versions)

        }
+    
+        // Mechanic bleed aura state
+        if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
+            m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, false);
+
        // Remove state (but need check other auras for it)
        if (removeState)
        {
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index 06718ce..c492f34 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -1537,6 +1537,11 @@ void Spell::EffectDummy(uint32 i)
                    m_caster->CastSpell(m_caster, 45182, true);
                    return;
                }
+                case 51662:                                 // Hunger for Blood
+                {
+                    m_caster->CastSpell(m_caster, 63848, true);
+                    return;
+                }
            }
            break;
        case SPELLFAMILY_HUNTER:

works as should on 3.2, without any bugs

Link to comment
Share on other sites

Well.. if multiple Auras with MECHANIC_BLEED are on the target and one runs out, AURA_STATE_MECHANIC_BLEED is turned off.. regardless of the still active auras.

so

        // Mechanic bleed aura state
       if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
           m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, false);

should be more like

    // Mechanic bleed aura state
   if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))
   {
       bool found = false;
       Unit::AuraList const& mPerDmg = m_target->GetAurasByType(SPELL_AURA_PERIODIC_DAMAGE);
       for(Unit::AuraList::const_iterator i = mPerDmg.begin(); i != mPerDmg.end(); ++i)
       {
           if(GetAllSpellMechanicMask((*i)->m_spellProto) & (1 << MECHANIC_BLEED))
           {
               found = true;
               break;
           }
       }
       if(!found)
           m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, false);
   }

Link to comment
Share on other sites

  • 5 weeks later...
  • 2 weeks later...
  • 1 month later...

it's ok if i use it like this? i'm begginer with mangos that i ask :)

+ // Mechanic bleed aura state

+ if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))

+ m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, true);

// Mechanic bleed aura state

if (m_spellProto->Mechanic == MECHANIC_BLEED)

m_target->ModifyAuraState(AURA_STATE_MECHANIC_BLEED, true);

Link to comment
Share on other sites

for me

if(GetAllSpellMechanicMask(m_spellProto) & (1 << MECHANIC_BLEED))

didn't worked.

function GetAllSpellMechanicMask is:

inline uint32 GetAllSpellMechanicMask(SpellEntry const* spellInfo)

{

uint32 mask = 0;

if (spellInfo->Mechanic)

mask |= 1 << (spellInfo->Mechanic - 1);

for (int i=0; i< 3; ++i)

if (spellInfo->EffectMechanic)

mask |= 1 << (spellInfo->EffectMechanic-1);

return mask;

}

so i used if(GetAllSpellMechanicMask(m_spellProto) & (1 << (MECHANIC_BLEED - 1)))

it's ok like this? :)

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks 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