Changeset 131

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

[svn] Fix broken spell target 38 (script target).
Implement linked spells, but will not enable it before testing.

Original author: megamage
Date: 2008-10-29 14:19:31-05:00

Location:
trunk/src/game
Files:
4 modified

Legend:

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

    r122 r131  
    923923    if(m_caster->GetTypeId() == TYPEID_UNIT && ((Creature*)m_caster)->AI()) 
    924924        ((Creature*)m_caster)->AI()->SpellHitTarget(unit, m_spellInfo); 
     925 
     926    if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 1)) 
     927    { 
     928        if(spell_triggered > 0) 
     929            m_caster->CastSpell(unit, spell_triggered, true); 
     930        else 
     931            unit->RemoveAurasDueToSpell(-spell_triggered); 
     932    } 
    925933} 
    926934 
     
    12871295        radius = GetSpellMaxRange(sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex)); 
    12881296 
     1297    uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; 
     1298    uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; 
    12891299    if(m_originalCaster) 
     1300    { 
    12901301        if(Player* modOwner = m_originalCaster->GetSpellModOwner()) 
     1302        { 
    12911303            modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RADIUS, radius,this); 
    1292  
    1293     uint32 EffectChainTarget = m_spellInfo->EffectChainTarget[i]; 
    1294     if(m_originalCaster) 
    1295         if(Player* modOwner = m_originalCaster->GetSpellModOwner()) 
    12961304            modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, EffectChainTarget, this); 
    1297  
    1298     uint32 unMaxTargets = m_spellInfo->MaxAffectedTargets; 
     1305        } 
     1306    } 
     1307 
    12991308    switch(cur) 
    13001309    { 
     
    15521561                    m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ()); 
    15531562            } 
     1563            else 
     1564            { 
     1565                if(creatureScriptTarget) 
     1566                    TagUnitMap.push_back(creatureScriptTarget); 
     1567                else if(goScriptTarget) 
     1568                    AddGOTarget(goScriptTarget, i); 
     1569            } 
    15541570        }break; 
    1555  
    15561571 
    15571572        // dummy 
     
    21762191            } 
    21772192        } 
     2193    } 
     2194 
     2195    if(int32 spell_triggered = spellmgr.GetSpellLinked(m_spellInfo->Id, 0)) 
     2196    { 
     2197        if(spell_triggered > 0) 
     2198            m_caster->CastSpell(m_targets.getUnitTarget() ? m_targets.getUnitTarget() : m_caster, spell_triggered, true); 
     2199        else 
     2200            m_caster->RemoveAurasDueToSpell(-spell_triggered); 
    21782201    } 
    21792202 
  • trunk/src/game/SpellMgr.cpp

    r122 r131  
    20522052    uint32 count = 0; 
    20532053 
    2054     //                                                0       1 
    2055     QueryResult *result = WorldDatabase.Query("SELECT spell0, spell1 FROM spell_linked_spell"); 
     2054    //                                                0              1             2 
     2055    QueryResult *result = WorldDatabase.Query("SELECT spell_trigger, spell_effect, type FROM spell_linked_spell"); 
    20562056    if( !result ) 
    20572057    { 
     
    20592059        bar.step(); 
    20602060        sLog.outString(); 
    2061         sLog.outString( ">> Loaded %u spell pet auras", count ); 
     2061        sLog.outString( ">> Loaded %u linked spells", count ); 
    20622062        return; 
    20632063    } 
     
    20712071        bar.step(); 
    20722072 
    2073         uint16 spell = fields[0].GetUInt16(); 
    2074         uint16 pet = fields[1].GetUInt16(); 
    2075         uint16 aura = fields[2].GetUInt16(); 
    2076  
    2077         SpellPetAuraMap::iterator itr = mSpellPetAuraMap.find(spell); 
    2078         if(itr != mSpellPetAuraMap.end()) 
    2079         { 
    2080             itr->second.AddAura(pet, aura); 
    2081         } 
    2082         else 
    2083         { 
    2084             SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell); 
    2085             if (!spellInfo) 
    2086             { 
    2087                 sLog.outErrorDb("Spell %u listed in `spell_pet_auras` does not exist", spell); 
    2088                 continue; 
    2089             } 
    2090             int i = 0; 
    2091             for(; i < 3; ++i) 
    2092                 if((spellInfo->Effect[i] == SPELL_EFFECT_APPLY_AURA && 
    2093                     spellInfo->EffectApplyAuraName[i] == SPELL_AURA_DUMMY) || 
    2094                     spellInfo->Effect[i] == SPELL_EFFECT_DUMMY) 
    2095                     break; 
    2096  
    2097             if(i == 3) 
    2098             { 
    2099                 sLog.outError("Spell %u listed in `spell_pet_auras` does not have dummy aura or dummy effect", spell); 
    2100                 continue; 
    2101             } 
    2102  
    2103             SpellEntry const* spellInfo2 = sSpellStore.LookupEntry(aura); 
    2104             if (!spellInfo2) 
    2105             { 
    2106                 sLog.outErrorDb("Aura %u listed in `spell_pet_auras` does not exist", aura); 
    2107                 continue; 
    2108             } 
    2109  
    2110             PetAura pa(pet, aura, spellInfo->EffectImplicitTargetA[i] == TARGET_PET, spellInfo->EffectBasePoints[i] + spellInfo->EffectBaseDice[i]); 
    2111             mSpellPetAuraMap[spell] = pa; 
    2112         } 
     2073        int32 trigger = fields[0].GetInt32(); 
     2074        int32 effect = fields[1].GetInt32(); 
     2075        int32 type = fields[2].GetInt32(); 
     2076 
     2077        SpellEntry const* spellInfo = sSpellStore.LookupEntry(abs(trigger)); 
     2078        if (!spellInfo) 
     2079        { 
     2080            sLog.outErrorDb("Spell %u listed in `spell_linked_spell` does not exist", abs(trigger)); 
     2081            continue; 
     2082        } 
     2083        spellInfo = sSpellStore.LookupEntry(abs(effect)); 
     2084        if (!spellInfo) 
     2085        { 
     2086            sLog.outErrorDb("Spell %u listed in `spell_linked_spell` does not exist", abs(effect)); 
     2087            continue; 
     2088        } 
     2089 
     2090        SpellLinkedSpell linkedSpell; 
     2091        linkedSpell.spell = effect; 
     2092        linkedSpell.type = type; 
     2093        mSpellLinkedMap[trigger] = linkedSpell; 
    21132094 
    21142095        ++count; 
     
    21182099 
    21192100    sLog.outString(); 
    2120     sLog.outString( ">> Loaded %u spell pet auras", count ); 
     2101    sLog.outString( ">> Loaded %u linked spells", count ); 
    21212102} 
    21222103 
  • trunk/src/game/SpellMgr.h

    r122 r131  
    649649typedef std::map<uint32, SpellExtraAttribute> SpellExtraAttrMap; 
    650650 
    651 typedef std::map<int32, int32> SpellLinkedMap; 
     651struct SpellLinkedSpell 
     652{ 
     653    int32 spell; 
     654    uint32 type; 
     655}; 
     656typedef std::map<int32, SpellLinkedSpell> SpellLinkedMap; 
    652657 
    653658class SpellMgr 
     
    858863        } 
    859864 
    860         int32 GetSpellLinked(int32 spell_id) const 
     865        int32 GetSpellLinked(int32 spell_id, uint32 type) const 
    861866        { 
    862867            SpellLinkedMap::const_iterator itr = mSpellLinkedMap.find(spell_id); 
    863868            if(itr != mSpellLinkedMap.end()) 
    864                 return itr->second; 
     869                return itr->second.type == type ? itr->second.spell : 0; 
    865870            else 
    866871                return 0; 
  • trunk/src/game/Unit.cpp

    r120 r131  
    41634163            if(caster->GetTypeId()==TYPEID_UNIT && ((Creature*)caster)->isTotem() && ((Totem*)caster)->GetTotemType()==TOTEM_STATUE) 
    41644164                statue = ((Totem*)caster); 
     4165 
     4166 
     4167    if(int32 spell_triggered = spellmgr.GetSpellLinked(-(int32)Aur->GetSpellProto()->Id, 0)) 
     4168    { 
     4169        if(spell_triggered > 0) 
     4170        { 
     4171            if(Unit* caster = Aur->GetCaster()) 
     4172                CastSpell(this, spell_triggered, true, 0, 0, caster->GetGUID()); 
     4173        } 
     4174        else 
     4175            RemoveAurasDueToSpell(-spell_triggered); 
     4176    } 
    41654177 
    41664178    sLog.outDebug("Aura %u now is remove mode %d",Aur->GetModifier()->m_auraname, mode);