Jump to content

[patch]Tricks of the Trade, Misdirection


Auntie Mangos

Recommended Posts

I have make over-worked my patch. I need no "#include map.h".

My Revision:10410

Patchfile http://paste2.org/p/973358

@ascent: you get a compile error, if you not include map.h, in this line of code "GetMap()->GetUnit(m_misdirectionTargetGUID)"

Also in my patch a hack for Vigilance. If someone know a better resolution of Vigilance, post it.But the effect of taunt should be good.

DELETE  FROM spell_proc_event WHERE entry =(50720);
INSERT INTO
spell_proc_event (entry, SchoolMask, SpellFamilyName, SpellFamilyMaskA0, SpellFamilyMaskA1, SpellFamilyMaskA2, SpellFamilyMaskB0, SpellFamilyMaskB1, SpellFamilyMaskB2, SpellFamilyMaskC0, SpellFamilyMaskC1, SpellFamilyMaskC2, procFlags, procEx, CustomChance, Cooldown)
VALUES
(50720,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0);

Link to comment
Share on other sites

no, because the if befor:

       if (pVictim->HasAura(50720))  //hack for Vigilance
      {
              if (Unit* caster = (pVictim->GetAura(50720,EFFECT_INDEX_0))->GetCaster())

AND

you have the aura 50720 because, you are in prochandling of 50725 (sry for my bad english, i hope you unterstand me)

                 case 50725:                                                                             //Vigilance -> Remove SpellCooldown of Taunt
                              {
                                     if (m_caster->GetTypeId() != TYPEID_PLAYER)
                                              return;


                                      if(Unit* caster = (m_caster->GetAura(50720,EFFECT_INDEX_0))->GetCaster())

Link to comment
Share on other sites

You can just use this to avoid including additional files:

Unit *GetMisdirectionTarget();

in header

Unit * Unit::GetMisdirectionTarget()

{

return m_misdirectionTargetGUID ? ObjectAccessor::GetUnit(*this, m_misdirectionTargetGUID) : NULL;

}

in CPP

I have been using this for ages as I wrote :P - never crashed (no need of adding IsInWorld() )

Link to comment
Share on other sites

In past i also think that only way use additional fields (small possible improvment: place its to threat system objects instead Unit directly)

But look: Misdirection (34477) have 1300 effect + 4 dummy aura AND have Misdirection (35079) with dummy aura

Same: Tricks of the Trade (57934) have same structure and 59628

Same: Only Vigilance (59665) not have helper spell (at least if check by name) but have Vigilance (50720) that triggred 50725

So possible this spell linking let implement feature in more expected way... i will look.

Link to comment
Share on other sites

here my version of this patch(some hacks removed)

diff --git a/src/game/Spell.h b/src/game/Spell.h
index 1e00179..30fe344 100644
--- a/src/game/Spell.h
+++ b/src/game/Spell.h
@@ -336,6 +336,7 @@ class Spell
        void EffectTitanGrip(SpellEffectIndex eff_idx);
        void EffectEnchantItemPrismatic(SpellEffectIndex eff_idx);
        void EffectPlayMusic(SpellEffectIndex eff_idx);
+        void EffectRedirectThreat(SpellEffectIndex eff_idx);
        void EffectSpecCount(SpellEffectIndex eff_idx);
        void EffectActivateSpec(SpellEffectIndex eff_idx);

diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index b9b9fdf..e32fd17 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -2233,6 +2233,13 @@ void Aura::HandleAuraDummy(bool apply, bool Real)

                return;
            }
+            case 35079: //Misdirection
+            case 59628: //Tricks of Trade
+            {
+                if(Unit * caster = GetCaster())
+                    caster->SetThreatRedirectionTarget(NULL, 0);
+                return;
+            }
            case 58600:                                     // Restricted Flight Area
            {
                AreaTableEntry const* area = GetAreaEntryByAreaID(target->GetAreaId());
diff --git a/src/game/SpellEffects.cpp b/src/game/SpellEffects.cpp
index d93272a..708269c 100644
--- a/src/game/SpellEffects.cpp
+++ b/src/game/SpellEffects.cpp
@@ -192,7 +192,7 @@ pEffect SpellEffects[TOTAL_SPELL_EFFECTS]=
    &Spell::EffectProspecting,                              //127 SPELL_EFFECT_PROSPECTING              Prospecting spell
    &Spell::EffectApplyAreaAura,                            //128 SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
    &Spell::EffectApplyAreaAura,                            //129 SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
-    &Spell::EffectNULL,                                     //130 SPELL_EFFECT_REDIRECT_THREAT
+    &Spell::EffectRedirectThreat,                           //130 SPELL_EFFECT_REDIRECT_THREAT
    &Spell::EffectUnused,                                   //131 SPELL_EFFECT_131                      used in some test spells
    &Spell::EffectPlayMusic,                                //132 SPELL_EFFECT_PLAY_MUSIC               sound id in misc value (SoundEntries.dbc)
    &Spell::EffectUnlearnSpecialization,                    //133 SPELL_EFFECT_UNLEARN_SPECIALIZATION   unlearn profession specialization
@@ -8348,6 +8348,17 @@ void Spell::EffectRestoreItemCharges( SpellEffectIndex eff_idx )
    item->RestoreCharges();
}

+void Spell::EffectRedirectThreat(SpellEffectIndex eff_idx)
+{
+    if(!unitTarget)
+    return;
+    
+    m_caster->SetThreatRedirectionTarget(unitTarget->GetGUID(), (uint32)damage); 
+
+
+
+}
+
void Spell::EffectTeachTaxiNode( SpellEffectIndex eff_idx )
{
    if (unitTarget->GetTypeId() != TYPEID_PLAYER)

diff --git a/src/game/ThreatManager.cpp b/src/game/ThreatManager.cpp
index 61689ea..e9f91a7 100644
--- a/src/game/ThreatManager.cpp
+++ b/src/game/ThreatManager.cpp
@@ -392,6 +392,14 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho

    float threat = ThreatCalcHelper::calcThreat(pVictim, iOwner, pThreat, crit, schoolMask, pThreatSpell);

+    if( pVictim->GetThreatRedirectionPercent() && threat > 0.0f )
+    {
+        float redirectedThreat = threat * pVictim->GetThreatRedirectionPercent() / 100;
+        threat -= redirectedThreat;
+        if(Unit *unit = pVictim->GetMisdirectionTarget())
+            iThreatContainer.addThreat(unit, redirectedThreat);
+    }
+
    HostileReference* ref = iThreatContainer.addThreat(pVictim, threat);
    // Ref is online
    if (ref)
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index a5ff098..6fb5d9b 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -240,6 +240,9 @@ Unit::Unit()

    m_charmInfo = NULL;

+    m_ThreatRedirectionPercent = 0;
+    m_misdirectionTargetGUID = 0;
+
    // remove aurastates allowing special moves
    for(int i=0; i < MAX_REACTIVE; ++i)
        m_reactiveTimer[i] = 0;
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 191a0a9..981ddcf 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1891,6 +1891,14 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        void AddPetAura(PetAura const* petSpell);
        void RemovePetAura(PetAura const* petSpell);

+        void SetThreatRedirectionTarget(uint64 guid, uint32 pct)
+        {
+            m_misdirectionTargetGUID = guid;
+            m_ThreatRedirectionPercent = pct;
+        }
+        uint32 GetThreatRedirectionPercent() { return m_ThreatRedirectionPercent; }
+        Unit *GetMisdirectionTarget();
+
        // Movement info
        MovementInfo m_movementInfo;

@@ -1971,6 +1979,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
        ComboPointHolderSet m_ComboPointHolders;

        GuardianPetList m_guardianPets;
+        uint32 m_ThreatRedirectionPercent;
+        uint64 m_misdirectionTargetGUID;

        uint64 m_TotemSlot[MAX_TOTEM_SLOT];
};

@@ -2187,6 +2187,19 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
                }
                break;
            }
+            case SPELLFAMILY_ROGUE:
+            {
+        switch(GetId())
+                {
+               case 59628:                            //Tricks of the trade
+            {
+                if(Unit *mistdir = target->GetMisdirectionTarget())
+                    target->CastSpell(mistdir,57933,true);//Apply 6 sec buff on misdirect target   (15% damage bonus)
+                break;
+            }
+        }
+                break;
+            }
        }
    }
    // AT REMOVE


@@ -10963,3 +10966,8 @@ void Unit::SheduleAINotify(uint32 delay)
    RelocationNotifyEvent *notify = new RelocationNotifyEvent(*this);
    m_Events.AddEvent(notify, m_Events.CalculateTime(delay));
}
+
+Unit* Unit::GetMisdirectionTarget()
+{
+ return m_misdirectionTargetGUID ? ObjectAccessor::GetUnit(*this, m_misdirectionTargetGUID) : NULL; 
+}

diff --git a/src/game/UnitAuraProcHandler.cpp b/src/game/UnitAuraProcHandler.cpp
index 76dc284..717e4e8 100644
--- a/src/game/UnitAuraProcHandler.cpp
+++ b/src/game/UnitAuraProcHandler.cpp
@@ -1671,6 +1671,12 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura
                    triggered_spell_id = 32747;
                    break;
                }
+        case 57934:                            //Tricks of the trade
+        {            
+                //triggered_spell_id = 59628;//Apply 6 sec buff on self
+            CastSpell(target, 59628, false);
+            return SPELL_AURA_PROC_OK;        
+                }
            }
            // Cut to the Chase
            if (dummySpell->SpellIconID == 2909)
@@ -1773,6 +1779,12 @@ SpellAuraProcResult Unit::HandleDummyAuraProc(Unit *pVictim, uint32 damage, Aura
            {
                pVictim->CastSpell(pVictim, 57894, true, NULL, NULL, GetGUID());
                return SPELL_AURA_PROC_OK;
+            }    
+        else if(dummySpell->Id == 34477)                            //Misdirect
+        {            
+            //Apply 6 sec buff on self
+        CastSpell(target, 35079, false);
+        return SPELL_AURA_PROC_OK;        
            }
            break;
        }

Link to comment
Share on other sites

+                    if (m_removeMode == AURA_REMOVE_BY_EXPIRE)
+                        pCaster->SetThreatRedirectionTarget(NULL, 0);

not good way check: player can cancel buff and by above code will still have redirection. Proper check: != AURA_REMOVE_BY_DEFAULT

as i think. last used for explicit aura removes

[added]

With this fix in [10466] added reset code for all spells base at Toinan67 patch code. Thank you,

Link to comment
Share on other sites

in fact i plan use in next commit from your patch only proc event code. Other or applied in alt. form or not related to redirection.

[added]Last part of redirection spells functionality added into [10467]. Triggering code added base at tester20 patch. Thank you :)

Sorry for strange author name i use in commit. I not understand how this happens. ^^

Please, if you want, post missing functionality patches for topic spell in thread, for other redirection spell please create own threads.

About additional buffs casting: do it in effect/aura code is bads style and will not excepted without real reason do in like way.

In most cases liek spells must be casted in Spell:cast (look existed examples) if casted spell duration not releated from main spell

Or spell must be casted SpellAuraHolder::HandleSpellSpecificBoosts if applied by spell aura must be removed at main spell aura remove (1), or if spell must be casted at last main spell aura remove.

Link to comment
Share on other sites

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