All pastes #1444524 Raw Copy code Copy link Edit

Stuff

public diff v1 · immutable
#1444524 ·published 2009-06-02 06:46 UTC
rendered paste body
diff --git a/src/game/Pet.cpp b/src/game/Pet.cppindex a85f2d7..6fcb9e5 100644--- a/src/game/Pet.cpp+++ b/src/game/Pet.cpp@@ -1312,15 +1312,27 @@ bool Pet::addSpell(uint32 spell_id,ActiveStates active /*= ACT_DECIDE*/, PetSpel     newspell.state = state;     newspell.type = type; -    if(active == ACT_DECIDE)                                //active was not used before, so we save it's autocast/passive state here+    switch (active)     {-        if(IsPassiveSpell(spell_id))-            newspell.active = ACT_PASSIVE;-        else-            newspell.active = ACT_DISABLED;+        case ACT_DECIDE:+            if (IsPassiveSpell(spell_id) || !IsPetAutoCastableSpell(spell_id))+                newspell.active = ACT_PASSIVE;+            else+                newspell.active = ACT_DISABLED;+            break;++        case ACT_DISABLED:+        case ACT_ENABLED:+            if (!IsPetAutoCastableSpell(spell_id))+                newspell.active = ACT_PASSIVE;+            else+                newspell.active = active;+            break;++        default:+            newspell.active = active;+            break;     }-    else-        newspell.active = active;      // talent: unlearn all other talent ranks (high and low)     if(TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id))@@ -1677,6 +1689,9 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)     if(IsPassiveSpell(spellid))         return; +    if (!IsPetAutoCastableSpell(spellid))+        return;+     PetSpellMap::iterator itr = m_spells.find(spellid);      int i;diff --git a/src/game/SharedDefines.h b/src/game/SharedDefines.hindex 893a6ad..1b3eca9 100644--- a/src/game/SharedDefines.h+++ b/src/game/SharedDefines.h@@ -261,7 +261,7 @@ enum ItemQualities #define SPELL_ATTR_EX_UNK14                       0x00004000            // 14 #define SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY    0x00008000            // 15 remove auras on immunity #define SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE 0x00010000            // 16 unaffected by school immunity-#define SPELL_ATTR_EX_UNK17                       0x00020000            // 17+#define SPELL_ATTR_EX_PET_NOT_AUTOCASTABLE        0x00020000            // 17 not autocastable by pets? #define SPELL_ATTR_EX_UNK18                       0x00040000            // 18 #define SPELL_ATTR_EX_UNK19                       0x00080000            // 19 #define SPELL_ATTR_EX_REQ_COMBO_POINTS1           0x00100000            // 20 Req combo points on targetdiff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cppindex 5ae4bd9..88516cb 100644--- a/src/game/SpellMgr.cpp+++ b/src/game/SpellMgr.cpp@@ -98,6 +98,30 @@ bool IsPassiveSpell(uint32 spellId)     return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; } +bool IsPetAutoCastableSpell(uint32 spellId)+{+    // obtain spell info+    SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId);+    if (!spellInfo)+        return false;++    // class-based check+    if (spellInfo->SpellFamilyName == SPELLFAMILY_WARLOCK)+    {+        // family-based check+        if ((spellInfo->SpellFamilyFlags & SPELLFAMILYFLAG_WARLOCK_PET_SPELLS) ||+            (spellInfo->SpellFamilyFlags2 & SPELLFAMILYFLAG_WARLOCK_PET_SPELLS2))+        {+            // this is pet spell, verify autocastability+            if (spellInfo->AttributesEx & SPELL_ATTR_EX_PET_NOT_AUTOCASTABLE)+                return false;+        }+    }++    // default is autocastable+    return true;+}+ bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) {     SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1);diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.hindex a6d238e..bd538ab 100644--- a/src/game/SpellMgr.h+++ b/src/game/SpellMgr.h@@ -76,6 +76,10 @@ enum SpellFamilyNames #define SPELLFAMILYFLAG_ROGUE__FINISHING_MOVE   UI64LIT(0x9003E0000)  #define SPELLFAMILYFLAG_PALADIN_SEALS           UI64LIT(0x26000C000A000000)++#define SPELLFAMILYFLAG_WARLOCK_PET_SPELLS      UI64LIT(0x0350000042803000)+#define SPELLFAMILYFLAG_WARLOCK_PET_SPELLS2     UI64LIT(0x00000400)+ // Spell clasification enum SpellSpecific {@@ -150,6 +154,7 @@ int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, ui bool IsSingleFromSpellSpecificPerCaster(SpellSpecific spellSpec1,SpellSpecific spellSpec2); bool IsSingleFromSpellSpecificRanksPerTarget(SpellSpecific spellId_spec, SpellSpecific i_spellId_spec); bool IsPassiveSpell(uint32 spellId);+bool IsPetAutoCastableSpell(uint32 spellId);  inline bool IsPassiveSpellStackableWithRanks(SpellEntry const* spellProto) {diff --git a/src/game/Unit.cpp b/src/game/Unit.cppindex e1a46f1..d290274 100644--- a/src/game/Unit.cpp+++ b/src/game/Unit.cpp@@ -10391,7 +10391,7 @@ void CharmInfo::InitCharmCreateSpells()             }              if(onlyselfcast || !IsPositiveSpell(spellId))   //only self cast and spells versus enemies are autocastable-                newstate = ACT_DISABLED;+                newstate = IsPetAutoCastableSpell(spellId) ? ACT_DISABLED : ACT_PASSIVE; // not all such spells are autocastable             else                 newstate = ACT_PASSIVE; @@ -10422,7 +10422,27 @@ bool CharmInfo::AddSpellToActionBar(uint32 spell_id, ActiveStates newstate)     {         if (!PetActionBar[i].SpellOrAction && PetActionBar[i].IsActionBarForSpell())         {-            SetActionBar(i,spell_id,newstate == ACT_DECIDE ? ACT_DISABLED : newstate);+            switch (newstate)+            {+                case ACT_DECIDE:+                case ACT_DISABLED:+                    if (IsPetAutoCastableSpell(spell_id))+                        SetActionBar(i,spell_id,ACT_DISABLED);+                    else+                        SetActionBar(i,spell_id,ACT_PASSIVE);+                    break;++                case ACT_ENABLED:+                    if (IsPetAutoCastableSpell(spell_id))+                        SetActionBar(i,spell_id,newstate);+                    else+                        SetActionBar(i,spell_id,ACT_PASSIVE);+                    break;++                default:+                    SetActionBar(i,spell_id,newstate);+                    break;+            }             return true;         }     }@@ -10453,6 +10473,9 @@ void CharmInfo::ToggleCreatureAutocast(uint32 spellid, bool apply)     if(IsPassiveSpell(spellid))         return; +    if (!IsPetAutoCastableSpell(spellid))+        return;+     for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x)     {         if(spellid == m_charmspells[x].spellId)@@ -10506,6 +10529,9 @@ void CharmInfo::BuildActionBar( WorldPacket* data )  void CharmInfo::SetSpellAutocast( uint32 spell_id, bool state ) {+    if (!IsPetAutoCastableSpell(spell_id))+        return;+     for(int i = 0; i < MAX_UNIT_ACTION_BAR_INDEX; ++i)     {         if(spell_id == PetActionBar[i].SpellOrAction && PetActionBar[i].IsActionBarForSpell())