Changeset 250 for trunk

Show
Ignore:
Timestamp:
11/19/08 13:50:41 (17 years ago)
Author:
yumileroy
Message:

*Update aura stacking check. By QAston.
*Update pet autocast check. By qubix.

Original author: megamage
Date: 2008-11-17 17:59:33-06:00

Location:
trunk/src/game
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Pet.cpp

    r218 r250  
    287287            ++iter; 
    288288            m_charmInfo->GetActionBarEntry(index)->SpellOrAction = atol((*iter).c_str()); 
     289            // patch for old data where some spells have ACT_DECIDE but should have ACT_CAST 
     290            // so overwrite old state  
     291            SpellEntry const *spellInfo = sSpellStore.LookupEntry(m_charmInfo->GetActionBarEntry(index)->SpellOrAction); 
     292            if (spellInfo && spellInfo->AttributesEx & SPELL_ATTR_EX_PET_NOT_AUTOCAST) 
     293                m_charmInfo->GetActionBarEntry(index)->Type = ACT_CAST; 
    289294        } 
    290295 
     
    12871292            Field *fields = result->Fetch(); 
    12881293 
    1289             addSpell(fields[0].GetUInt16(), fields[2].GetUInt16(), PETSPELL_UNCHANGED, fields[1].GetUInt16()); 
     1294            addSpell(fields[0].GetUInt16(), (ActiveStates)fields[2].GetUInt16(), PETSPELL_UNCHANGED, fields[1].GetUInt16()); 
    12901295        } 
    12911296        while( result->NextRow() ); 
     
    14181423} 
    14191424 
    1420 bool Pet::addSpell(uint16 spell_id, uint16 active, PetSpellState state, uint16 slot_id, PetSpellType type) 
     1425bool Pet::addSpell(uint16 spell_id, ActiveStates active, PetSpellState state, uint16 slot_id, PetSpellType type) 
    14211426{ 
    14221427    SpellEntry const *spellInfo = sSpellStore.LookupEntry(spell_id); 
     
    14341439        return false; 
    14351440    } 
     1441    // same spells don't have autocast option 
     1442    if (spellInfo->AttributesEx & SPELL_ATTR_EX_PET_NOT_AUTOCAST) 
     1443        active = ACT_CAST; 
    14361444 
    14371445    PetSpellMap::iterator itr = m_spells.find(spell_id); 
     
    15091517        CastSpell(this, spell_id, true); 
    15101518    else if(state == PETSPELL_NEW) 
    1511         m_charmInfo->AddSpellToAB(oldspell_id, spell_id); 
     1519        m_charmInfo->AddSpellToAB(oldspell_id, spell_id, active); 
    15121520 
    15131521    if(newspell->active == ACT_ENABLED) 
     
    16591667        return; 
    16601668 
    1661     if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 
     1669    /*if(const SpellEntry *tempSpell = GetSpellStore()->LookupEntry(spellid)) 
    16621670        if(tempSpell->EffectImplicitTargetA[0] != TARGET_ALL_AROUND_CASTER 
    16631671            && tempSpell->EffectImplicitTargetA[0] != TARGET_CHAIN_DAMAGE) 
    1664             return;     
     1672            return;    */ 
    16651673 
    16661674    PetSpellMap::const_iterator itr = m_spells.find((uint16)spellid); 
  • trunk/src/game/Pet.h

    r206 r250  
    213213        void _SaveSpells(); 
    214214 
    215         bool addSpell(uint16 spell_id,uint16 active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, uint16 slot_id=0xffff, PetSpellType type = PETSPELL_NORMAL); 
     215        bool addSpell(uint16 spell_id, ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, uint16 slot_id=0xffff, PetSpellType type = PETSPELL_NORMAL); 
    216216        bool learnSpell(uint16 spell_id); 
    217217        void removeSpell(uint16 spell_id); 
  • trunk/src/game/SharedDefines.h

    r230 r250  
    249249#define SPELL_ATTR_EX_DISPEL_AURAS_ON_IMMUNITY    0x00008000            // 15 remove auras on immunity 
    250250#define SPELL_ATTR_EX_UNAFFECTED_BY_SCHOOL_IMMUNE 0x00010000            // 16 unaffected by school immunity 
    251 #define SPELL_ATTR_EX_UNK17                       0x00020000            // 17 
     251#define SPELL_ATTR_EX_PET_NOT_AUTOCAST            0x00020000            // 17 
    252252#define SPELL_ATTR_EX_UNK18                       0x00040000            // 18 
    253253#define SPELL_ATTR_EX_UNK19                       0x00080000            // 19 
  • trunk/src/game/SpellMgr.cpp

    r236 r250  
    9999    return (spellInfo->Attributes & SPELL_ATTR_PASSIVE) != 0; 
    100100} 
    101  
     101/*not used for now so commented out 
    102102bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 
    103103{ 
     
    108108 
    109109    if (spellInfo_1->Effect[effIndex_1] != spellInfo_2->Effect[effIndex_2] || 
    110         spellInfo_1->EffectItemType[effIndex_1] != spellInfo_2->EffectItemType[effIndex_2] || 
    111110        spellInfo_1->EffectMiscValue[effIndex_1] != spellInfo_2->EffectMiscValue[effIndex_2] || 
    112111        spellInfo_1->EffectApplyAuraName[effIndex_1] != spellInfo_2->EffectApplyAuraName[effIndex_2]) 
     
    114113 
    115114    return true; 
    116 } 
     115}*/ 
    117116 
    118117int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 
     
    245244        case SPELL_CURSE: 
    246245        case SPELL_ASPECT: 
     246        case SPELL_POSITIVE_SHOUT: 
     247        case SPELL_JUDGEMENT: 
     248        case SPELL_WARLOCK_CORRUPTION: 
     249            return spellSpec1==spellSpec2; 
     250        default: 
     251            return false; 
     252    } 
     253} 
     254 
     255bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2) 
     256{ 
     257    switch(spellSpec1) 
     258    { 
    247259        case SPELL_TRACKER: 
    248260        case SPELL_WARLOCK_ARMOR: 
     
    250262        case SPELL_ELEMENTAL_SHIELD: 
    251263        case SPELL_MAGE_POLYMORPH: 
    252         case SPELL_POSITIVE_SHOUT: 
    253         case SPELL_JUDGEMENT: 
    254         case SPELL_WARLOCK_CORRUPTION: 
    255264            return spellSpec1==spellSpec2; 
    256265        case SPELL_BATTLE_ELIXIR: 
     
    10311040} 
    10321041 
    1033 bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const 
    1034 { 
    1035     if(spellId_1 == spellId_2) // auras due to the same spell 
    1036         return false; 
    1037  
     1042bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool isFromTheSameCaster ) const 
     1043{ 
    10381044    SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); 
    10391045    SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2); 
     
    10411047    if(!spellInfo_1 || !spellInfo_2) 
    10421048        return false; 
     1049 
     1050    SpellSpecific spellId_spec_1 = GetSpellSpecific(spellId_1); 
     1051    SpellSpecific spellId_spec_2 = GetSpellSpecific(spellId_2); 
     1052    if (spellId_spec_1 && spellId_spec_2) 
     1053        if (IsSingleFromSpellSpecificPerTarget(spellId_spec_1,spellId_spec_2) 
     1054            || (IsSingleFromSpellSpecificPerCaster(spellId_spec_1,spellId_spec_2) && isFromTheSameCaster)) 
     1055            return true; 
    10431056 
    10441057    if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) 
     
    10511064            return false; 
    10521065    } 
     1066 
     1067    //if both elixirs are not battle/guardian/potions/flasks then always stack 
     1068    else if ((spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) 
     1069        &&(spellId_spec_1 || spellId_spec_2)) 
     1070        return false; 
     1071 
    10531072    else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 
    10541073        return false; 
    10551074 
    10561075    for(uint32 i = 0; i < 3; ++i) 
    1057         if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i] 
    1058             || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) 
     1076    { 
     1077        if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i]) 
    10591078            return false; 
    1060  
     1079        if (spellInfo_1->EffectApplyAuraName[i] || spellInfo_2->EffectApplyAuraName[i]) 
     1080        { 
     1081            if(spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i] 
     1082                || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) 
     1083                    // need itemtype check? need to find an example 
     1084                return false; 
     1085            else if (!isFromTheSameCaster) 
     1086                switch(spellInfo_1->EffectApplyAuraName[i]) 
     1087                    { 
     1088                    //spells with these auras from different casters will stack 
     1089                        case SPELL_AURA_PERIODIC_DAMAGE: 
     1090                        case SPELL_AURA_PERIODIC_HEAL: 
     1091                        case SPELL_AURA_PERIODIC_TRIGGER_SPELL: 
     1092                        case SPELL_AURA_PERIODIC_ENERGIZE: 
     1093                        case SPELL_AURA_PERIODIC_MANA_LEECH: 
     1094                        case SPELL_AURA_PERIODIC_LEECH: 
     1095                        //exception for shaman positive totems with these auras 
     1096                        if ((spellInfo_1->SpellFamilyName != SPELLFAMILY_SHAMAN) 
     1097                            ||(spellInfo_1->Effect[i]!=SPELL_AURA_MOD_INCREASE_ENERGY)) 
     1098                            return false; 
     1099                        default: 
     1100                            break; 
     1101                    } 
     1102        } 
     1103    } 
    10611104    return true; 
    10621105} 
  • trunk/src/game/SpellMgr.h

    r229 r250  
    285285} 
    286286 
    287 bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 
     287//bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 
    288288 
    289289inline bool IsSealSpell(SpellEntry const *spellInfo) 
     
    302302int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 
    303303bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); 
     304bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2); 
    304305bool IsPassiveSpell(uint32 spellId); 
    305306 
     
    769770        bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const; 
    770771        static bool canStackSpellRanks(SpellEntry const *spellInfo); 
    771         bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const; 
     772        bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool isFromTheSameCaster ) const; 
    772773 
    773774        SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const; 
  • trunk/src/game/Unit.cpp

    r248 r250  
    38983898        if(!is_triggered_by_spell) 
    38993899        { 
    3900             SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); 
    3901  
    3902             bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); 
    3903  
    3904             if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) 
    3905             { 
    3906                 // cannot remove higher rank 
    3907                 if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 
    3908                     if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 
     3900            bool isFromSameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID(); 
     3901            if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, isFromSameCaster) ) 
     3902            { 
     3903                //some spells should be not removed by lower rank of them 
     3904                if (!isFromSameCaster 
     3905                    &&(spellProto->Effect[effIndex]==SPELL_AURA_MOD_INCREASE_ENERGY) 
     3906                    &&(spellProto->DurationIndex==21) 
     3907                    &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 
     3908                    &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)) 
    39093909                        return false; 
    39103910 
    3911                 // Its a parent aura (create this aura in ApplyModifier) 
     3911                //Its a parent aura (create this aura in ApplyModifier) 
    39123912                if ((*i).second->IsInUse()) 
    39133913                { 
     
    39213921                else 
    39223922                    next =  m_Auras.begin(); 
    3923             } 
    3924             else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) 
    3925             { 
    3926                 // Its a parent aura (create this aura in ApplyModifier) 
    3927                 if ((*i).second->IsInUse()) 
    3928                 { 
    3929                     sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); 
    3930                     continue; 
    3931                 } 
    3932                 RemoveAurasDueToSpell(i_spellId); 
    3933  
    3934                 if( m_Auras.empty() ) 
    3935                     break; 
    3936                 else 
    3937                     next =  m_Auras.begin(); 
    3938             } 
    3939             // Potions stack aura by aura (elixirs/flask already checked) 
    3940             else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) 
    3941             { 
    3942                 if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) 
    3943                 { 
    3944                     if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 
    3945                         return false;                       // cannot remove higher rank 
    3946  
    3947                     // Its a parent aura (create this aura in ApplyModifier) 
    3948                     if ((*i).second->IsInUse()) 
    3949                     { 
    3950                         sLog.outError("Aura (Spell %u Effect %u) is in process but attempt removed at aura (Spell %u Effect %u) adding, need add stack rule for Unit::RemoveNoStackAurasDueToAura", i->second->GetId(), i->second->GetEffIndex(),Aur->GetId(), Aur->GetEffIndex()); 
    3951                         continue; 
    3952                     } 
    3953                     RemoveAura(i); 
    3954                     next = i; 
    3955                 } 
    39563923            } 
    39573924        }