Changeset 157 for trunk/src/game

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

[svn] Fix hunter's frozen trap, half duration when pvp.
Use vector to store linked spell information to support multiple effects.

Original author: megamage
Date: 2008-11-03 17:20:35-06:00

Location:
trunk/src/game
Files:
5 modified

Legend:

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

    r148 r157  
    10561056        ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); 
    10571057 
    1058     if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) 
    1059     { 
    1060         if(spell_triggered > 0) 
    1061             unit->CastSpell(unit, spell_triggered, true, 0, 0, m_caster->GetGUID()); 
    1062         else 
    1063             unit->RemoveAurasDueToSpell(-spell_triggered); 
     1058    if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id + 1000000)) 
     1059    { 
     1060        for(std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i) 
     1061        { 
     1062            if(spell_triggered < 0) 
     1063                unit->RemoveAurasDueToSpell(-(*i)); 
     1064            else 
     1065                unit->CastSpell(unit, *i, true, 0, 0, m_caster->GetGUID()); 
     1066        } 
    10641067    } 
    10651068} 
     
    22532256    } 
    22542257 
    2255     if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 0)) 
    2256     { 
    2257         if(spell_triggered > 0) 
    2258             m_caster->CastSpell(m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster, spell_triggered, true); 
    2259         else 
    2260             m_caster->RemoveAurasDueToSpell(-spell_triggered); 
     2258    if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id)) 
     2259    { 
     2260        for(std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i) 
     2261        { 
     2262            if(spell_triggered < 0) 
     2263                m_caster->RemoveAurasDueToSpell(-(*i)); 
     2264            else 
     2265                m_caster->CastSpell(m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster, *i, true); 
     2266        } 
    22612267    } 
    22622268 
  • trunk/src/game/SpellEffects.cpp

    r149 r157  
    21192119    // Now Reduce spell duration using data received at spell hit 
    21202120    int32 duration = Aur->GetAuraMaxDuration(); 
    2121     unitTarget->ApplyDiminishingToDuration(m_diminishGroup,duration,m_caster,m_diminishLevel); 
     2121    unitTarget->ApplyDiminishingToDuration(m_diminishGroup,duration,caster,m_diminishLevel); 
    21222122    Aur->setDiminishGroup(m_diminishGroup); 
    21232123 
  • trunk/src/game/SpellMgr.cpp

    r155 r157  
    20882088        } 
    20892089 
    2090         SpellLinkedSpell linkedSpell; 
    2091         linkedSpell.spell = effect; 
    2092         linkedSpell.type = type; 
    2093         mSpellLinkedMap[trigger] = linkedSpell; 
     2090        if(type) //we will find a better way when more types are needed 
     2091            trigger += 1000000; 
     2092        mSpellLinkedMap[trigger].push_back(effect); 
    20942093 
    20952094        ++count; 
  • trunk/src/game/SpellMgr.h

    r131 r157  
    649649typedef std::map<uint32, SpellExtraAttribute> SpellExtraAttrMap; 
    650650 
    651 struct SpellLinkedSpell 
    652 { 
    653     int32 spell; 
    654     uint32 type; 
    655 }; 
    656 typedef std::map<int32, SpellLinkedSpell> SpellLinkedMap; 
     651typedef std::map<int32, std::vector<int32> > SpellLinkedMap; 
    657652 
    658653class SpellMgr 
     
    863858        } 
    864859 
    865         int32 GetSpellLinked(int32 spell_id, uint32 type) const 
     860        const std::vector<int32> *GetSpellLinked(int32 spell_id) const 
    866861        { 
    867862            SpellLinkedMap::const_iterator itr = mSpellLinkedMap.find(spell_id); 
    868             if(itr != mSpellLinkedMap.end()) 
    869                 return itr->second.type == type ? itr->second.spell : 0; 
    870             else 
    871                 return 0; 
     863            return itr != mSpellLinkedMap.end() ? &(itr->second) : NULL; 
    872864        } 
    873865 
  • trunk/src/game/Unit.cpp

    r155 r157  
    41554155 
    41564156 
    4157     if(int32 spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id, 0)) 
    4158     { 
    4159         if(spell_triggered > 0) 
    4160         { 
    4161             if(Unit* caster = Aur->GetCaster()) 
    4162                 CastSpell(this, spell_triggered, true, 0, 0, caster->GetGUID()); 
    4163         } 
    4164         else 
    4165             RemoveAurasDueToSpell(-spell_triggered); 
     4157    if(const std::vector<int32> *spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id)) 
     4158    { 
     4159        for(std::vector<int32>::const_iterator i = spell_triggered->begin(); i != spell_triggered->end(); ++i) 
     4160        { 
     4161            if(spell_triggered < 0) 
     4162                RemoveAurasDueToSpell(-(*i)); 
     4163            else if(Unit* caster = Aur->GetCaster()) 
     4164                CastSpell(this, *i, true, 0, 0, caster->GetGUID()); 
     4165        } 
    41664166    } 
    41674167