Changeset 264

Show
Ignore:
Timestamp:
11/21/08 08:48:41 (17 years ago)
Author:
yumileroy
Message:

*Re-commit some reverted patch: aura stacking check. By QAston.

Original author: megamage
Date: 2008-11-20 18:13:10-06:00

Location:
trunk/src/game
Files:
3 modified

Legend:

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

    r253 r264  
    100100} 
    101101 
    102 bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 
     102/*bool IsNoStackAuraDueToAura(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 
    103103{ 
    104104    SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); 
     
    114114 
    115115    return true; 
    116 } 
     116}*/ 
    117117 
    118118int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2) 
     
    245245        case SPELL_CURSE: 
    246246        case SPELL_ASPECT: 
     247        case SPELL_POSITIVE_SHOUT: 
     248        case SPELL_JUDGEMENT: 
     249        case SPELL_WARLOCK_CORRUPTION: 
     250            return spellSpec1==spellSpec2; 
     251        default: 
     252            return false; 
     253    } 
     254} 
     255 
     256bool IsSingleFromSpellSpecificPerTarget(uint32 spellSpec1,uint32 spellSpec2) 
     257{ 
     258    switch(spellSpec1) 
     259    { 
    247260        case SPELL_TRACKER: 
    248261        case SPELL_WARLOCK_ARMOR: 
     
    250263        case SPELL_ELEMENTAL_SHIELD: 
    251264        case SPELL_MAGE_POLYMORPH: 
    252         case SPELL_POSITIVE_SHOUT: 
    253         case SPELL_JUDGEMENT: 
    254         case SPELL_WARLOCK_CORRUPTION: 
    255265            return spellSpec1==spellSpec2; 
    256266        case SPELL_BATTLE_ELIXIR: 
     
    10311041} 
    10321042 
    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; 
     1043bool SpellMgr::IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2, bool sameCaster) const 
     1044{ 
     1045    //if(spellId_1 == spellId_2) // auras due to the same spell 
     1046    //    return false; 
    10371047 
    10381048    SpellEntry const *spellInfo_1 = sSpellStore.LookupEntry(spellId_1); 
     
    10421052        return false; 
    10431053 
     1054    SpellSpecific spellId_spec_1 = GetSpellSpecific(spellId_1); 
     1055    SpellSpecific spellId_spec_2 = GetSpellSpecific(spellId_2); 
     1056    if (spellId_spec_1 && spellId_spec_2) 
     1057        if (IsSingleFromSpellSpecificPerTarget(spellId_spec_1, spellId_spec_2) 
     1058            ||(IsSingleFromSpellSpecificPerCaster(spellId_spec_1, spellId_spec_2) && sameCaster)) 
     1059            return true; 
     1060 
    10441061    if(spellInfo_1->SpellFamilyName != spellInfo_2->SpellFamilyName) 
    10451062        return false; 
    10461063 
    1047     if(!spellInfo_1->SpellFamilyName) // generic spells 
     1064    // generic spells 
     1065    if(!spellInfo_1->SpellFamilyName) 
    10481066    { 
    10491067        if(!spellInfo_1->SpellIconID  
     
    10511069            return false; 
    10521070    } 
    1053     else if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 
    1054         return false; 
     1071 
     1072    // if both elixirs are not battle/guardian/potions/flasks then always stack 
     1073    else if(spellInfo_1->SpellFamilyName == SPELLFAMILY_POTION) 
     1074    { 
     1075        if(spellId_spec_1 || spellId_spec_2)) 
     1076            return false; 
     1077    } 
     1078 
     1079    // check for class spells 
     1080    else 
     1081    { 
     1082        if (spellInfo_1->SpellFamilyFlags != spellInfo_2->SpellFamilyFlags) 
     1083            return false; 
     1084    } 
    10551085 
    10561086    for(uint32 i = 0; i < 3; ++i) 
     1087    { 
    10571088        if(spellInfo_1->Effect[i] != spellInfo_2->Effect[i] 
    1058             || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i]) 
    1059             return false; 
     1089            || spellInfo_1->EffectApplyAuraName[i] != spellInfo_2->EffectApplyAuraName[i] 
     1090            || spellInfo_1->EffectMiscValue[i] != spellInfo_2->EffectMiscValue[i]) // paladin resist aura 
     1091            return false; // need itemtype check? need an example to add that check 
     1092 
     1093        if(spellInfo_1->EffectApplyAuraName[i] // both spell has the same auras 
     1094            && !sameCaster 
     1095            && spellInfo_1->Effect[i] != SPELL_EFFECT_APPLY_AREA_AURA_PARTY) // not area auras (shaman totem) 
     1096            // a better check may be effect == SPELL_EFFECT_APPLY_AURA 
     1097        { 
     1098            switch(spellInfo_1->EffectApplyAuraName[i]) 
     1099            { 
     1100                // DOT or HOT from different casters will stack 
     1101                case SPELL_AURA_PERIODIC_DAMAGE: 
     1102                case SPELL_AURA_PERIODIC_HEAL: 
     1103                case SPELL_AURA_PERIODIC_TRIGGER_SPELL: 
     1104                case SPELL_AURA_PERIODIC_ENERGIZE: 
     1105                case SPELL_AURA_PERIODIC_MANA_LEECH: 
     1106                case SPELL_AURA_PERIODIC_LEECH: 
     1107                    return false; 
     1108                default: 
     1109                    break; 
     1110            } 
     1111        } 
     1112    } 
    10601113 
    10611114    return true; 
  • trunk/src/game/SpellMgr.h

    r253 r264  
    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) 
     
    301301 
    302302int32 CompareAuraRanks(uint32 spellId_1, uint32 effIndex_1, uint32 spellId_2, uint32 effIndex_2); 
    303 bool IsSingleFromSpellSpecificPerCaster(uint32 spellSpec1,uint32 spellSpec2); 
     303bool 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 sameCaster) const; 
    772773 
    773774        SpellEntry const* SelectAuraRankForPlayerLevel(SpellEntry const* spellInfo, uint32 playerLevel) const; 
  • trunk/src/game/Unit.cpp

    r257 r264  
    38963896        if(!is_triggered_by_spell) 
    38973897        { 
    3898             SpellSpecific i_spellId_spec = GetSpellSpecific(i_spellId); 
    3899  
    3900             bool is_sspc = IsSingleFromSpellSpecificPerCaster(spellId_spec,i_spellId_spec); 
    3901  
    3902             if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() ) 
    3903             { 
    3904                 // cannot remove higher rank 
    3905                 if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 
    3906                     if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 
    3907                         return false; 
     3898            bool sameCaster = Aur->GetCasterGUID() == (*i).second->GetCasterGUID(); 
     3899            if( spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId, sameCaster) ) 
     3900            { 
     3901                //some spells should be not removed by lower rank of them 
     3902                // what is this spell? 
     3903                if (!sameCaster 
     3904                    &&(spellProto->Effect[effIndex]==SPELL_EFFECT_APPLY_AREA_AURA_PARTY) 
     3905                    &&(spellProto->DurationIndex==21) 
     3906                    &&(spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId)) 
     3907                    &&(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)) 
     3908                    return false; 
    39083909 
    39093910                // Its a parent aura (create this aura in ApplyModifier) 
     
    39193920                else 
    39203921                    next =  m_Auras.begin(); 
    3921             } 
    3922             else if( !is_sspc && spellmgr.IsNoStackSpellDueToSpell(spellId, i_spellId) ) 
    3923             { 
    3924                 // Its a parent aura (create this aura in ApplyModifier) 
    3925                 if ((*i).second->IsInUse()) 
    3926                 { 
    3927                     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()); 
    3928                     continue; 
    3929                 } 
    3930                 RemoveAurasDueToSpell(i_spellId); 
    3931  
    3932                 if( m_Auras.empty() ) 
    3933                     break; 
    3934                 else 
    3935                     next =  m_Auras.begin(); 
    3936             } 
    3937             // Potions stack aura by aura (elixirs/flask already checked) 
    3938             else if( spellProto->SpellFamilyName == SPELLFAMILY_POTION && i_spellProto->SpellFamilyName == SPELLFAMILY_POTION ) 
    3939             { 
    3940                 if (IsNoStackAuraDueToAura(spellId, effIndex, i_spellId, i_effIndex)) 
    3941                 { 
    3942                     if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0) 
    3943                         return false;                       // cannot remove higher rank 
    3944  
    3945                     // Its a parent aura (create this aura in ApplyModifier) 
    3946                     if ((*i).second->IsInUse()) 
    3947                     { 
    3948                         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()); 
    3949                         continue; 
    3950                     } 
    3951                     RemoveAura(i); 
    3952                     next = i; 
    3953                 } 
    39543922            } 
    39553923        }