Changeset 110

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

[svn] Add SpellExtraInfoMap?. Currently support:
Limited-number-of-players spell; shared damage spell; target-in-line cone spell (e.g. dark glare).
Change angle of cone spells from 120 degree to 60 degree.

Original author: megamage
Date: 2008-10-25 15:46:52-05:00

Location:
trunk/src/game
Files:
8 modified

Legend:

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

    r108 r110  
    12271227        cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); 
    12281228    } 
    1229     TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, GridTypeMapContainer >  grid_object_notifier(notifier); 
    1230     cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); 
     1229    if(!spellmgr.GetSpellExtraInfo(m_spellInfo->Id, SPELL_EXTRA_INFO_MAX_TARGETS)) 
     1230    { 
     1231        TypeContainerVisitor<Trinity::SpellNotifierCreatureAndPlayer, GridTypeMapContainer >  grid_object_notifier(notifier); 
     1232        cell_lock->Visit(cell_lock, grid_object_notifier, *MapManager::Instance().GetMap(m_caster->GetMapId(), m_caster)); 
     1233    } 
    12311234} 
    12321235 
     
    13521355        case TARGET_ALL_AROUND_CASTER: 
    13531356        { 
     1357            if(!unMaxTargets) 
     1358                unMaxTargets = spellmgr.GetSpellExtraInfo(m_spellInfo->Id, SPELL_EXTRA_INFO_MAX_TARGETS); 
    13541359            m_caster->GetPosition(m_targets.m_destX, m_targets.m_destY, m_targets.m_destZ); 
    13551360        }break; 
     
    14141419        }break; 
    14151420        case TARGET_IN_FRONT_OF_CASTER: 
    1416         { 
    1417             bool inFront = m_spellInfo->SpellVisual != 3879; 
    1418             SearchAreaTarget(TagUnitMap, radius, inFront ? PUSH_IN_FRONT : PUSH_IN_BACK,SPELL_TARGETS_AOE_DAMAGE); 
     1421        case TARGET_UNIT_CONE_ENEMY_UNKNOWN: 
     1422        { 
     1423            switch(spellmgr.GetSpellExtraInfo(m_spellInfo->Id, SPELL_EXTRA_INFO_CONE_TYPE)) 
     1424            { 
     1425                default: 
     1426                case 0: 
     1427                    SearchAreaTarget(TagUnitMap, radius, PUSH_IN_FRONT, SPELL_TARGETS_AOE_DAMAGE); 
     1428                    break; 
     1429                case 1: 
     1430                    SearchAreaTarget(TagUnitMap, radius, PUSH_IN_BACK, SPELL_TARGETS_AOE_DAMAGE); 
     1431                    break; 
     1432                case 2: 
     1433                    SearchAreaTarget(TagUnitMap, radius, PUSH_IN_LINE, SPELL_TARGETS_AOE_DAMAGE); 
     1434                    break; 
     1435            } 
    14191436        }break; 
     1437        case TARGET_UNIT_CONE_ALLY: 
     1438        { 
     1439            SearchAreaTarget(TagUnitMap, radius, PUSH_IN_FRONT, SPELL_TARGETS_FRIENDLY); 
     1440        }break; 
     1441 
    14201442 
    14211443        // nearby target 
  • trunk/src/game/Spell.h

    r108 r110  
    7474    PUSH_IN_FRONT, 
    7575    PUSH_IN_BACK, 
     76    PUSH_IN_LINE, 
    7677    PUSH_SELF_CENTER, 
    7778    PUSH_DEST_CENTER, 
     
    603604                { 
    604605                    case PUSH_IN_FRONT: 
    605                         if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) 
     606                        if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
    606607                            i_data->push_back(itr->getSource()); 
    607608                        break; 
    608609                    case PUSH_IN_BACK: 
    609                         if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, 2*M_PI/3 )) 
     610                        if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
     611                            i_data->push_back(itr->getSource()); 
     612                        break; 
     613                    case PUSH_IN_LINE: 
     614                        if(i_spell.GetCaster()->isInLine((Unit*)(itr->getSource()), i_radius )) 
    610615                            i_data->push_back(itr->getSource()); 
    611616                        break; 
  • trunk/src/game/SpellEffects.cpp

    r106 r110  
    312312                } 
    313313 
     314                // Meteor like spells (divided damage to targets) 
     315                if(spellmgr.GetSpellExtraInfo(m_spellInfo->Id, SPELL_EXTRA_INFO_SHARE_DAMAGE)) 
     316                { 
     317                    uint32 count = 0; 
     318                    for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) 
     319                        if(ihit->effectMask & (1<<effect_idx)) 
     320                            ++count; 
     321 
     322                    damage /= count;                    // divide to all targets 
     323                } 
     324 
    314325                switch(m_spellInfo->Id)                     // better way to check unknown 
    315326                { 
    316                     // Meteor like spells (divided damage to targets) 
    317                     case 24340: case 26558: case 28884:     // Meteor 
    318                     case 36837: case 38903: case 41276:     // Meteor 
    319                     case 26789:                             // Shard of the Fallen Star 
    320                     case 31436:                             // Malevolent Cleave 
    321                     case 35181:                             // Dive Bomb 
    322                     case 40810: case 43267: case 43268:     // Saber Lash 
    323                     case 42384:                             // Brutal Swipe 
    324                     case 45150:                             // Meteor Slash 
    325                     { 
    326                         uint32 count = 0; 
    327                         for(std::list<TargetInfo>::iterator ihit= m_UniqueTargetInfo.begin();ihit != m_UniqueTargetInfo.end();++ihit) 
    328                             if(ihit->effectMask & (1<<effect_idx)) 
    329                                 ++count; 
    330  
    331                         damage /= count;                    // divide to all targets 
    332                         break; 
    333                     } 
    334327                    // percent from health with min 
    335328                    case 25599:                             // Thundercrash 
  • trunk/src/game/SpellMgr.cpp

    r108 r110  
    19691969} 
    19701970 
     1971// set data in core for now 
     1972void SpellMgr::LoadSpellExtraInfo() 
     1973{ 
     1974    SpellExtraInfo info; 
     1975    info.info[SPELL_EXTRA_INFO_CONE_TYPE] = 0; 
     1976    info.info[SPELL_EXTRA_INFO_MAX_TARGETS] = 0; 
     1977    info.info[SPELL_EXTRA_INFO_SHARE_DAMAGE] = 0; 
     1978 
     1979    info.info[SPELL_EXTRA_INFO_CONE_TYPE] = 1; 
     1980    SpellEntry const* tempSpell; 
     1981    for(uint32 i = 0; i < GetSpellStore()->GetNumRows(); ++i) 
     1982    { 
     1983        tempSpell = GetSpellStore()->LookupEntry(i); 
     1984        if(tempSpell && tempSpell->SpellVisual == 3879) 
     1985            mSpellExtraInfoMap[tempSpell->Id] = info; 
     1986    } 
     1987    info.info[SPELL_EXTRA_INFO_CONE_TYPE] = 2; 
     1988    mSpellExtraInfoMap[26029] = info; // dark glare 
     1989    mSpellExtraInfoMap[37433] = info; // spout 
     1990    mSpellExtraInfoMap[43140] = info; // flame breath 
     1991    mSpellExtraInfoMap[43215] = info; // flame breath 
     1992    info.info[SPELL_EXTRA_INFO_CONE_TYPE] = 0; 
     1993 
     1994    info.info[SPELL_EXTRA_INFO_SHARE_DAMAGE] = 1; 
     1995    for(uint32 i = 0; i < 46000; ++i) 
     1996    { 
     1997        switch(i) 
     1998        { 
     1999            case 24340: case 26558: case 28884:     // Meteor 
     2000            case 36837: case 38903: case 41276:     // Meteor 
     2001            case 26789:                             // Shard of the Fallen Star 
     2002            case 31436:                             // Malevolent Cleave 
     2003            case 35181:                             // Dive Bomb 
     2004            case 40810: case 43267: case 43268:     // Saber Lash 
     2005            case 42384:                             // Brutal Swipe 
     2006            case 45150:                             // Meteor Slash 
     2007                mSpellExtraInfoMap[i] = info; 
     2008                break; 
     2009            default: 
     2010                break; 
     2011        } 
     2012    } 
     2013    info.info[SPELL_EXTRA_INFO_SHARE_DAMAGE] = 0; 
     2014 
     2015    info.info[SPELL_EXTRA_INFO_MAX_TARGETS] = 1; 
     2016    for(uint32 i = 0; i < 46000; ++i) 
     2017    { 
     2018        switch(i) 
     2019        { 
     2020            case 44978: case 45001: case 45002:     // Wild Magic 
     2021            case 45004: case 45006: case 45010:     // Wild Magic 
     2022            case 31347: // Doom 
     2023            case 41635: // Prayer of Mending 
     2024                mSpellExtraInfoMap[i] = info; 
     2025                break; 
     2026            default: 
     2027                break; 
     2028        } 
     2029    } 
     2030    info.info[SPELL_EXTRA_INFO_MAX_TARGETS] = 3; 
     2031    mSpellExtraInfoMap[41376] = info;   //Spite 
     2032    info.info[SPELL_EXTRA_INFO_MAX_TARGETS] = 0; 
     2033} 
     2034 
    19712035/// Some checks for spells, to prevent adding depricated/broken spells for trainers, spell book, etc 
    19722036bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg) 
  • trunk/src/game/SpellMgr.h

    r102 r110  
    635635} 
    636636 
     637enum SpellExtraInfoType 
     638{ 
     639    SPELL_EXTRA_INFO_MAX_TARGETS, 
     640    SPELL_EXTRA_INFO_CONE_TYPE, 
     641    SPELL_EXTRA_INFO_SHARE_DAMAGE 
     642}; 
     643 
     644struct SpellExtraInfo 
     645{ 
     646    uint32 info[3]; 
     647}; 
     648 
     649typedef std::map<uint32, SpellExtraInfo> SpellExtraInfoMap; 
     650 
    637651class SpellMgr 
    638652{ 
     
    831845            else 
    832846                return NULL; 
     847        } 
     848 
     849        uint32 GetSpellExtraInfo(uint32 spell_id, uint32 type) const 
     850        { 
     851            SpellExtraInfoMap::const_iterator itr = mSpellExtraInfoMap.find(spell_id); 
     852            if(itr != mSpellExtraInfoMap.end()) 
     853                return itr->second.info[type]; 
     854            else 
     855                return 0; 
    833856        } 
    834857 
     
    849872        void LoadSkillLineAbilityMap(); 
    850873        void LoadSpellPetAuras(); 
     874        void LoadSpellExtraInfo(); 
    851875 
    852876    private: 
     
    862886        SkillLineAbilityMap mSkillLineAbilityMap; 
    863887        SpellPetAuraMap     mSpellPetAuraMap; 
     888        SpellExtraInfoMap   mSpellExtraInfoMap; 
    864889}; 
    865890 
  • trunk/src/game/Unit.cpp

    r102 r110  
    34473447{ 
    34483448    return IsWithinDistInMap(target, distance) && !HasInArc( 2 * M_PI - arc, target ); 
     3449} 
     3450 
     3451bool Unit::isInLine(Unit const* target, float distance) const 
     3452{ 
     3453    if(!HasInArc(M_PI, target) || !IsWithinDistInMap(target, distance)) return false; 
     3454    float width = (GetObjectSize() / 2 + target->GetObjectSize()) / 2; 
     3455    float angle = GetAngle(target); 
     3456    angle -= GetOrientation(); 
     3457    return abs(sin(angle)) * distance < width; 
    34493458} 
    34503459 
  • trunk/src/game/Unit.h

    r102 r110  
    10961096        void SetInFront(Unit const* target); 
    10971097        bool isInBack(Unit const* target, float distance, float arc = M_PI) const; 
     1098        bool isInLine(Unit const* target, float distance) const; 
    10981099 
    10991100        // Visibility system 
  • trunk/src/game/World.cpp

    r102 r110  
    10961096    spellmgr.LoadSpellPetAuras(); 
    10971097 
     1098    sLog.outString( "Loading spell extra infos...(TODO)" ); 
     1099    spellmgr.LoadSpellExtraInfo(); 
     1100 
    10981101    sLog.outString( "Loading player Create Info & Level Stats..." ); 
    10991102    objmgr.LoadPlayerInfo();