Jump to content

[patch] Dash fix - disable Dash when not in Cat Form.


Auntie Mangos

Recommended Posts

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

Disables druid cat form Dash ability when not in cat form

For which repository revision was the patch created?

8480+

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

The bug is reported on getmangos.eu: here, here, and here.

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

Me - Dr Bobaz

Patch:

In SpellAuras.cpp

@@ -2942,10 +2942,12 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
    }

    // adding/removing linked auras
    // add/remove the shapeshift aura's boosts
    HandleShapeshiftBoosts(apply);
+	//update speed to enable/disable dash modifier
+	m_target->UpdateSpeed(MOVE_RUN, true);

    if(m_target->GetTypeId() == TYPEID_PLAYER)
        ((Player*)m_target)->InitDataForForm();
}

In Unit.h

@@ -1373,10 +1373,11 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        void ApplyAuraProcTriggerDamage(Aura* aura, bool apply);

        int32 GetTotalAuraModifier(AuraType auratype) const;
        float GetTotalAuraMultiplier(AuraType auratype) const;
        int32 GetMaxPositiveAuraModifier(AuraType auratype) const;
+		int32 GetOneBeforeMaxPositiveAuraModifier(AuraType auratype) const;
        int32 GetMaxNegativeAuraModifier(AuraType auratype) const;

        int32 GetTotalAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;
        float GetTotalAuraMultiplierByMiscMask(AuraType auratype, uint32 misc_mask) const;
        int32 GetMaxPositiveAuraModifierByMiscMask(AuraType auratype, uint32 misc_mask) const;

In Unit.cpp

@@ -3264,11 +3264,27 @@ int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const
        if ((*i)->GetModifier()->m_amount > modifier)
            modifier = (*i)->GetModifier()->m_amount;

    return modifier;
}
+int32 Unit::GetOneBeforeMaxPositiveAuraModifier(AuraType auratype) const
+{
+    int32 modifier = 0;
+	int32 modifier2 = 0;
+
+    AuraList const& mTotalAuraList = GetAurasByType(auratype);
+    for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i)
+        if ((*i)->GetModifier()->m_amount > modifier)
+		{
+			modifier = (*i)->GetModifier()->m_amount;
+			for(AuraList::const_iterator j = mTotalAuraList.begin();j != mTotalAuraList.end(); ++j)
+				if((j != i) && ((*j)->GetModifier()->m_amount > modifier2) && ((*j)->GetModifier()->m_amount <= modifier))
+					modifier2 = (*j)->GetModifier()->m_amount;
+		}

+    return modifier2;
+}
int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const
{
    int32 modifier = 0;

    AuraList const& mTotalAuraList = GetAurasByType(auratype);
@@ -9652,10 +9668,25 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
        default:
            sLog.outError("Unit::UpdateSpeed: Unsupported move type (%d)", mtype);
            return;
    }

+	//dash check
+	AuraList const& mSpeed = GetAurasByType(SPELL_AURA_MOD_INCREASE_SPEED);
+	if(m_form != FORM_CAT && mtype == MOVE_RUN)
+		for(AuraList::const_iterator i = mSpeed.begin(); i != mSpeed.end(); ++i)
+		{
+			if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && (*i)->GetSpellProto()->SpellIconID == 959)
+			{
+				if(main_speed_mod > (*i)->GetModifier()->m_amount)
+					break;
+				else 
+					main_speed_mod = GetOneBeforeMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SPEED);
+			}	
+		}
+	//dash check end
+
    float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus;
    // now we ready for speed calculation
    float speed  = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus;

    switch(mtype)

And, an alternate version of modifications in Unit.cpp, where I eliminated the loop-in-the-loop situation, and probably it is more effictient way to do it. Only the OneBefore... function is changed:

@@ -3264,11 +3264,33 @@ int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const
        if ((*i)->GetModifier()->m_amount > modifier)
            modifier = (*i)->GetModifier()->m_amount;

    return modifier;
}
+int32 Unit::GetOneBeforeMaxPositiveAuraModifier(AuraType auratype) const
+{
+    int32 modifier = 0, modifier2 = 0, l = 0, ind = 0;

+    AuraList const& mTotalAuraList = GetAurasByType(auratype);
+    for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i)
+	{
+        if ((*i)->GetModifier()->m_amount > modifier)
+		{
+			modifier = (*i)->GetModifier()->m_amount;
+			ind = l;
+		}
+		++l;
+	}
+	l = 0;
+	for(AuraList::const_iterator i = mTotalAuraList.begin();i != mTotalAuraList.end(); ++i)
+	{
+		if(((*i)->GetModifier()->m_amount > modifier2 && l != ind))
+			modifier2 = (*i)->GetModifier()->m_amount;
+		++l;
+	}	
+    return modifier2;
+}
int32 Unit::GetMaxNegativeAuraModifier(AuraType auratype) const
{
    int32 modifier = 0;

    AuraList const& mTotalAuraList = GetAurasByType(auratype);
@@ -9652,10 +9674,25 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
        default:
            sLog.outError("Unit::UpdateSpeed: Unsupported move type (%d)", mtype);
            return;
    }

+	//dash check
+	AuraList const& mSpeed = GetAurasByType(SPELL_AURA_MOD_INCREASE_SPEED);
+	if(m_form != FORM_CAT && mtype == MOVE_RUN)
+		for(AuraList::const_iterator i = mSpeed.begin(); i != mSpeed.end(); ++i)
+		{
+			if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && (*i)->GetSpellProto()->SpellIconID == 959)
+			{
+				if(main_speed_mod > (*i)->GetModifier()->m_amount)
+					break;
+				else 
+					main_speed_mod = GetOneBeforeMaxPositiveAuraModifier(SPELL_AURA_MOD_INCREASE_SPEED);
+			}	
+		}
+	//dash check end
+
    float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus;
    // now we ready for speed calculation
    float speed  = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus;

    switch(mtype)

I'm also thinking of using the second function as GetMaxPositive, with modifier2 returned as reference, and performing second loop only if function is triggerd with parameter. But it will create a unnecesary condition check every time the function is triggerd. So maybe separate function is a better idea?

Link to comment
Share on other sites

  • 39 years later...

i use this and works fine too

diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 321c18d..95a7841 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2774,6 +2774,8 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
    // add/remove the shapeshift aura's boosts
    HandleShapeshiftBoosts(apply);

+    m_target->UpdateSpeed(MOVE_RUN, true);
+
    if(m_target->GetTypeId() == TYPEID_PLAYER)
        ((Player*)m_target)->InitDataForForm();
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 2db68f7..0213a02 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -9264,6 +9264,21 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
            return;
    }

+    // Remove Druid Dash bonus if not in Cat Form
+    if (m_form != FORM_CAT)
+    {
+        AuraList const& speed_increase_auras = GetAurasByType(SPELL_AURA_MOD_INCREASE_SPEED);
+        for(AuraList::const_iterator itr = speed_increase_auras.begin(); itr != speed_increase_auras.end(); ++itr)
+        {
+            const SpellEntry* aura_proto = (*itr)->GetSpellProto();
+            if (aura_proto->SpellFamilyName == SPELLFAMILY_DRUID && aura_proto->SpellIconID == 959)
+            {
+                main_speed_mod -= (*itr)->GetModifier()->m_amount;
+                break;
+            }
+        }
+    }
+
    float bonus = non_stack_bonus > stack_bonus ? non_stack_bonus : stack_bonus;
    // now we ready for speed calculation
    float speed  = main_speed_mod ? bonus*(100.0f + main_speed_mod)/100.0f : bonus;

Link to comment
Share on other sites

This one won't work, if you have other aura that increases speed. For example, if you use Dash level 3, which increases speed by 70% and feral build with feral swiftness talent (increases speed by 30% while in cat form), after removing dash, your speed will be 170-70=100% instead of 130%.

And that whill be every time, when caster has an other aura that increases run speed.

So, it is a bug, and not work fine.

My patch instead, works fine in that matter. If dash is the highest speed modification aura, it takes the second in line highest speed modification aura, and if dash isn't the highest - it does nothing, as it should be.

Link to comment
Share on other sites

Thank you, thenecromancer, for the comment and suggestion. Honestly, I even didn't think about that method you suggested. I somehow imagined that it would be impossible, and just your post made me aware that it is good solution.

So, I re-post that patch.

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

Disables druid cat form Dash ability when not in cat form

For which repository revision was the patch created?

8480+

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

The bug is reported on getmangos.eu: here, here, and here.

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

Me - Dr Bobaz

Patch:

SpellAuras.cpp:

@@ -3013,13 +3013,14 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
                break;
        }
    }

    // adding/removing linked auras
+	//update speed to enable/disable dash modifier
+	m_target->UpdateSpeed(MOVE_RUN, true);
    // add/remove the shapeshift aura's boosts
    HandleShapeshiftBoosts(apply);
-
    if(m_target->GetTypeId() == TYPEID_PLAYER)
        ((Player*)m_target)->InitDataForForm();
}

void Aura::HandleAuraTransform(bool apply, bool Real)

and Unit.cpp:

@@ -9716,10 +9716,27 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced)
{
    int32 main_speed_mod  = 0;
    float stack_bonus     = 1.0f;
    float non_stack_bonus = 1.0f;

+	//dash check
+	if(getClass() == CLASS_DRUID && mtype == MOVE_RUN)
+	{
+	AuraList const& mSpeed = GetAurasByType(SPELL_AURA_MOD_INCREASE_SPEED);
+	for(AuraList::const_iterator i = mSpeed.begin(); i != mSpeed.end(); ++i)
+       {
+           if ((*i)->GetSpellProto()->SpellFamilyName == SPELLFAMILY_DRUID && (*i)->GetSpellProto()->SpellIconID == 959)
+           {
+			   if(m_form != FORM_CAT)
+				(*i)->SetModifier((*i)->GetModifier()->m_auraname, 0, (*i)->GetModifier()->periodictime, (*i)->GetModifier()->m_miscvalue);
+			   else
+				(*i)->SetModifier((*i)->GetModifier()->m_auraname, ((*i)->GetSpellProto()->EffectBasePoints[0]+1), (*i)->GetModifier()->periodictime, (*i)->GetModifier()->m_miscvalue);
+           } 
+       }
+	}
+	//dash check end
+
    switch(mtype)
    {
        case MOVE_WALK:
            return;
        case MOVE_RUN:

as before, I don't know why in highlight every [ and ] are represented by its symbols. it should be:

EffectBasePoints[0]+1

Link to comment
Share on other sites

Dunno if its faster/better but here is how i did it:

if( (*i)->GetSpellProto()->SpellIconID == 959 && ( GetTypeId() == TYPEID_PLAYER && ((Player*)(this))->m_form != FORM_CAT  ) )
           continue;

to

int32 Unit::GetMaxPositiveAuraModifier(AuraType auratype) const

in AuraList iterator

along with adding (like everyone else)

m_target->UpdateSpeed(MOVE_RUN, true);

to

void Aura::HandleAuraModShapeshift(bool apply, bool Real)

(sorry for lack of patch...)

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...
  • 2 months later...

on offi client is Displaying "Must be in Cat Form" and spell is not processed, so seems above solutions are incomplete :/

half fix i am using looks like this:

diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 24bdfaa..5ac1fc0 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -5170,6 +5170,14 @@ SpellCastResult Spell::CheckCast(bool strict)

                break;
            }
+            case SPELL_AURA_MOD_INCREASE_SPEED:
+            {
+                // Dash in Cat From check
+                if (m_spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && m_spellInfo->SpellIconID == 959)
+                    if ( m_caster->m_form != FORM_CAT)
+                        return SPELL_FAILED_ONLY_SHAPESHIFT;
+                break;
+            }
            default:
                break;
        }

still missing packet data for propper error display

Link to comment
Share on other sites

  • 3 weeks 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