Changeset 142

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

[svn] Fix teleport spells.
Fix cone spells.
Use interrupt_aura_flag to remove stealth/invisible/feign death auras.

Original author: megamage
Date: 2008-11-01 15:08:12-05:00

Location:
trunk/src/game
Files:
6 modified

Legend:

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

    r136 r142  
    1660416604 
    1660516605    // prevent stealth flight 
    16606     RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
     16606    RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); 
    1660716607 
    1660816608    WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4); 
  • trunk/src/game/Spell.cpp

    r141 r142  
    9595} 
    9696 
    97 void SpellCastTargets::setDestination(float x, float y, float z, bool send) 
     97void SpellCastTargets::setDestination(float x, float y, float z, bool send, uint32 mapId) 
    9898{ 
    9999    m_destX = x; 
     
    103103    if(send) 
    104104        m_targetMask |= TARGET_FLAG_DEST_LOCATION; 
     105    if(mapId) 
     106        m_mapId = mapId; 
    105107} 
    106108 
     
    10071009            //if(!IsPositiveSpell(m_spellInfo->Id)) 
    10081010            { 
    1009                 unit->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
     1011                //do not remove feign death 
     1012                unit->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH + AURA_INTERRUPT_FLAG_DAMAGE); 
    10101013            } 
    10111014        } 
     
    10131016        { 
    10141017            // for delayed spells ignore negative spells (after duel end) for friendly targets 
     1018            // TODO: this cause soul transfer bugged 
    10151019            if(m_spellInfo->speed > 0.0f && !IsPositiveSpell(m_spellInfo->Id)) 
    10161020            { 
     
    12501254void Spell::SearchAreaTarget(std::list<Unit*> &TagUnitMap, float radius, const uint32 &type, SpellTargets TargetType, uint32 entry) 
    12511255{ 
    1252     if(type == PUSH_DEST_CENTER && !m_targets.HasDest()) 
    1253     { 
    1254         sLog.outError( "SPELL: cannot find destination for spell ID %u\n", m_spellInfo->Id ); 
    1255         return; 
    1256     } 
    1257  
    1258     CellPair p(Trinity::ComputeCellPair(m_targets.m_destX, m_targets.m_destY)); 
     1256    float x, y; 
     1257    if(type == PUSH_DEST_CENTER) 
     1258    { 
     1259        if(!m_targets.HasDest()) 
     1260        { 
     1261            sLog.outError( "SPELL: cannot find destination for spell ID %u\n", m_spellInfo->Id ); 
     1262            return; 
     1263        } 
     1264        x = m_targets.m_destX; 
     1265        y = m_targets.m_destY; 
     1266    } 
     1267    else 
     1268    { 
     1269        x = m_caster->GetPositionX(); 
     1270        y = m_caster->GetPositionY(); 
     1271    } 
     1272 
     1273    CellPair p(Trinity::ComputeCellPair(x, y)); 
    12591274    Cell cell(p); 
    12601275    cell.data.Part.reserved = ALL_DISTRICT; 
     
    14361451            if(SpellTargetPosition const* st = spellmgr.GetSpellTargetPosition(m_spellInfo->Id)) 
    14371452            { 
    1438                 if (st->target_mapId == m_caster->GetMapId()) 
     1453                //TODO: fix this check 
     1454                if(m_spellInfo->Effect[0] == SPELL_EFFECT_TELEPORT_UNITS 
     1455                    || m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS 
     1456                    || m_spellInfo->Effect[2] == SPELL_EFFECT_TELEPORT_UNITS) 
     1457                    m_targets.setDestination(st->target_X, st->target_Y, st->target_Z, true, st->target_mapId); 
     1458                else if(st->target_mapId == m_caster->GetMapId()) 
    14391459                    m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); 
    14401460            } 
    14411461            else 
    14421462                sLog.outError( "SPELL: unknown target coordinates for spell ID %u\n", m_spellInfo->Id ); 
     1463            break; 
     1464        case TARGET_INNKEEPER_COORDINATES: 
     1465            if(m_caster->GetTypeId() == TYPEID_PLAYER) 
     1466                m_targets.setDestination(((Player*)m_caster)->m_homebindX,((Player*)m_caster)->m_homebindY,((Player*)m_caster)->m_homebindZ, true, ((Player*)m_caster)->m_homebindMapId); 
    14431467            break; 
    14441468 
     
    14811505        case TARGET_IN_FRONT_OF_CASTER: 
    14821506        case TARGET_UNIT_CONE_ENEMY_UNKNOWN: 
    1483         { 
    14841507            switch(spellmgr.GetSpellExtraAttr(m_spellInfo->Id, SPELL_EXTRA_ATTR_CONE_TYPE)) 
    14851508            { 
     
    14941517                    SearchAreaTarget(TagUnitMap, radius, PUSH_IN_LINE, SPELL_TARGETS_AOE_DAMAGE); 
    14951518                    break; 
    1496             } 
    1497         }break; 
     1519            }break; 
    14981520        case TARGET_UNIT_CONE_ALLY: 
    1499         { 
    15001521            SearchAreaTarget(TagUnitMap, radius, PUSH_IN_FRONT, SPELL_TARGETS_FRIENDLY); 
    1501         }break; 
     1522            break; 
    15021523 
    15031524        // nearby target 
     
    20002021        case TARGET_DEST_DEST_RANDOM: 
    20012022        { 
    2002             if(!(m_targets.m_targetMask & TARGET_FLAG_DEST_LOCATION)) 
     2023            if(!m_targets.HasDest()) 
    20032024            { 
    20042025                sLog.outError("SPELL: no destination for spell ID %u\n", m_spellInfo->Id); 
     
    20142035        }break; 
    20152036        case TARGET_SELF2: 
    2016             m_targets.m_hasDest = true; 
     2037            if(!m_targets.HasDest()) 
     2038            { 
     2039                sLog.outError("SPELL: no destination for spell ID %u\n", m_spellInfo->Id); 
     2040                break; 
     2041            } 
    20172042            break; 
    20182043        default: 
     
    21242149    if ( !m_IsTriggeredSpell && isSpellBreakStealth(m_spellInfo) ) 
    21252150    { 
    2126         m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
    2127         m_caster->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); 
     2151        m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); 
    21282152    } 
    21292153 
  • trunk/src/game/Spell.h

    r139 r142  
    112112            //m_srcZ = target.m_srcZ; 
    113113 
     114            m_mapId = 0; 
    114115            m_destX = target.m_destX; 
    115116            m_destY = target.m_destY; 
     
    127128        Unit *getUnitTarget() const { return m_unitTarget; } 
    128129        void setUnitTarget(Unit *target); 
    129         void setDestination(float x, float y, float z, bool send = true); 
     130        void setDestination(float x, float y, float z, bool send = true, uint32 mapId = 0); 
    130131        void setDestination(Unit *target, bool send = true); 
    131132 
     
    155156 
    156157        float m_srcX, m_srcY, m_srcZ; 
     158        uint32 m_mapId; 
    157159        float m_destX, m_destY, m_destZ; 
    158160        bool m_hasDest; 
     
    549551        float i_radius; 
    550552        SpellTargets i_TargetType; 
    551         Unit* i_originalCaster; 
     553        Unit* i_caster; 
    552554        uint32 i_entry; 
    553555 
     
    556558            : i_data(&data), i_spell(spell), i_push_type(type), i_radius(radius), i_TargetType(TargetType), i_entry(entry) 
    557559        { 
    558             i_originalCaster = spell.GetCaster(); 
     560            i_caster = spell.GetCaster(); 
    559561        } 
    560562 
     
    563565            assert(i_data); 
    564566 
    565             if(!i_originalCaster) 
     567            if(!i_caster) 
    566568                return; 
    567569 
     
    574576                { 
    575577                    case SPELL_TARGETS_FRIENDLY: 
    576                         if (!itr->getSource()->isTargetableForAttack() || !i_originalCaster->IsFriendlyTo( itr->getSource() )) 
     578                        if (!itr->getSource()->isTargetableForAttack() || !i_caster->IsFriendlyTo( itr->getSource() )) 
    577579                            continue; 
    578580                        break; 
     
    584586                            continue; 
    585587 
    586                         Unit* check = i_originalCaster->GetCharmerOrOwnerOrSelf(); 
     588                        Unit* check = i_caster->GetCharmerOrOwnerOrSelf(); 
    587589 
    588590                        if( check->GetTypeId()==TYPEID_PLAYER ) 
     
    608610                { 
    609611                    case PUSH_IN_FRONT: 
    610                         if(i_spell.GetCaster()->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
     612                        if(i_caster->isInFront((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
    611613                            i_data->push_back(itr->getSource()); 
    612614                        break; 
    613615                    case PUSH_IN_BACK: 
    614                         if(i_spell.GetCaster()->isInBack((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
     616                        if(i_caster->isInBack((Unit*)(itr->getSource()), i_radius, M_PI/3 )) 
    615617                            i_data->push_back(itr->getSource()); 
    616618                        break; 
    617619                    case PUSH_IN_LINE: 
    618                         if(i_spell.GetCaster()->isInLine((Unit*)(itr->getSource()), i_radius )) 
     620                        if(i_caster->isInLine((Unit*)(itr->getSource()), i_radius )) 
    619621                            i_data->push_back(itr->getSource()); 
    620622                        break; 
    621623                    case PUSH_SELF_CENTER: 
    622                         if(i_spell.GetCaster()->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) 
     624                        if(i_caster->IsWithinDistInMap((Unit*)(itr->getSource()), i_radius)) 
    623625                            i_data->push_back(itr->getSource()); 
    624626                        break; 
  • trunk/src/game/SpellEffects.cpp

    r141 r142  
    19721972        return; 
    19731973 
    1974     switch (m_spellInfo->EffectImplicitTargetB[i]) 
    1975     { 
    1976         case TARGET_INNKEEPER_COORDINATES: 
    1977         { 
    1978             // Only players can teleport to innkeeper 
    1979             if (unitTarget->GetTypeId() != TYPEID_PLAYER) 
    1980                 return; 
    1981  
    1982             ((Player*)unitTarget)->TeleportTo(((Player*)unitTarget)->m_homebindMapId,((Player*)unitTarget)->m_homebindX,((Player*)unitTarget)->m_homebindY,((Player*)unitTarget)->m_homebindZ,unitTarget->GetOrientation(),unitTarget==m_caster ? TELE_TO_SPELL : 0); 
    1983             return; 
    1984         } 
    1985         default: 
    1986         { 
    1987             // If not exist data for dest location - return 
    1988             if(!m_targets.HasDest()) 
    1989             { 
    1990                 sLog.outError( "Spell::EffectTeleportUnits - unknown EffectImplicitTargetB[%u] = %u for spell ID %u\n", i, m_spellInfo->EffectImplicitTargetB[i], m_spellInfo->Id ); 
    1991                 return; 
    1992             } 
    1993             // Init dest coordinates 
    1994             uint32 mapid = m_caster->GetMapId(); 
    1995             float x = m_targets.m_destX; 
    1996             float y = m_targets.m_destY; 
    1997             float z = m_targets.m_destZ; 
    1998             float orientation = unitTarget->GetOrientation(); 
    1999             // Teleport 
    2000             if(unitTarget->GetTypeId() == TYPEID_PLAYER) 
    2001                 ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); 
    2002             else 
    2003             { 
    2004                 MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); 
    2005                 WorldPacket data; 
    2006                 unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); 
    2007                 unitTarget->SendMessageToSet(&data, false); 
    2008             } 
    2009             return; 
    2010         } 
     1974    // If not exist data for dest location - return 
     1975    if(!m_targets.HasDest()) 
     1976    { 
     1977        sLog.outError( "Spell::EffectTeleportUnits - does not have destination for spell ID %u\n", m_spellInfo->Id ); 
     1978        return; 
     1979    } 
     1980    // Init dest coordinates 
     1981    uint32 mapid = m_targets.m_mapId; 
     1982    float x = m_targets.m_destX; 
     1983    float y = m_targets.m_destY; 
     1984    float z = m_targets.m_destZ; 
     1985    float orientation = unitTarget->GetOrientation(); 
     1986    sLog.outDebug("Spell::EffectTeleportUnits - teleport unit to %u %f %f %f\n", mapid, x, y, z); 
     1987    // Teleport 
     1988    if(unitTarget->GetTypeId() == TYPEID_PLAYER) 
     1989        ((Player*)unitTarget)->TeleportTo(mapid, x, y, z, orientation, TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET | (unitTarget==m_caster ? TELE_TO_SPELL : 0)); 
     1990    else 
     1991    { 
     1992        MapManager::Instance().GetMap(mapid, m_caster)->CreatureRelocation((Creature*)unitTarget, x, y, z, orientation); 
     1993        WorldPacket data; 
     1994        unitTarget->BuildTeleportAckMsg(&data, x, y, z, orientation); 
     1995        unitTarget->SendMessageToSet(&data, false); 
    20111996    } 
    20121997 
     
    34903475        { 
    34913476            // Reveal action + get attack 
    3492             m_caster->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
     3477            m_caster->RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); 
    34933478            if (((Creature*)unitTarget)->AI()) 
    34943479                ((Creature*)unitTarget)->AI()->AttackStart(m_caster); 
  • trunk/src/game/Unit.cpp

    r141 r142  
    455455} 
    456456 
     457void Unit::RemoveInterruptableAura(uint32 flag) 
     458{ 
     459    AuraList::iterator iter, next; 
     460    for (iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); iter = next) 
     461    { 
     462        next = iter; 
     463        ++next; 
     464 
     465        //sLog.outDetail("auraflag:%u flag:%u = %u",(*iter)->GetSpellProto()->AuraInterruptFlags,flag,(*iter)->GetSpellProto()->AuraInterruptFlags & flag); 
     466        if(*iter && ((*iter)->GetSpellProto()->AuraInterruptFlags & flag) == flag) 
     467        { 
     468            RemoveAurasDueToSpell((*iter)->GetId()); 
     469            if (!m_interruptableAuras.empty()) 
     470                next = m_interruptableAuras.begin(); 
     471            else 
     472                return; 
     473        } 
     474    } 
     475} 
     476 
    457477bool Unit::HasAuraType(AuraType auraType) const 
    458478{ 
     
    475495 
    476496    // remove affects from victim (including from 0 damage and DoTs) 
    477     if(pVictim != this) 
    478         pVictim->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
     497    //if(pVictim != this) 
     498    //    pVictim->RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
    479499 
    480500    // remove affects from attacker at any non-DoT damage (including 0 damage) 
    481501    if( damagetype != DOT) 
    482502    { 
    483         RemoveSpellsCausingAura(SPELL_AURA_MOD_STEALTH); 
    484         RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH); 
     503        RemoveInterruptableAura(AURA_INTERRUPT_FLAG_STEALTH); 
    485504 
    486505        if(pVictim->GetTypeId() == TYPEID_PLAYER && !pVictim->IsStandState() && !pVictim->hasUnitState(UNIT_STAT_STUNNED)) 
     
    37393758    { 
    37403759        m_modAuras[Aur->GetModifier()->m_auraname].push_back(Aur); 
     3760        if(Aur->GetSpellProto()->AuraInterruptFlags) 
     3761            m_interruptableAuras.push_back(Aur); 
    37413762    } 
    37423763 
     
    41114132    { 
    41124133        m_modAuras[(*i).second->GetModifier()->m_auraname].remove((*i).second); 
     4134        if((*i).second->GetSpellProto()->AuraInterruptFlags) 
     4135            m_interruptableAuras.remove((*i).second); 
    41134136    } 
    41144137 
  • trunk/src/game/Unit.h

    r141 r142  
    7272    AURA_INTERRUPT_FLAG_UNK12               = 0x00001000,   // 12   removed by attack? 
    7373    AURA_INTERRUPT_FLAG_UNK13               = 0x00002000,   // 13 
     74    AURA_INTERRUPT_FLAG_STEALTH             = 0x00003C00, 
    7475    AURA_INTERRUPT_FLAG_UNK14               = 0x00004000,   // 14 
    7576    AURA_INTERRUPT_FLAG_UNK15               = 0x00008000,   // 15   removed by casting a spell? 
     
    10041005 
    10051006        void RemoveSpellsCausingAura(AuraType auraType); 
     1007        void RemoveInterruptableAura(uint32 flag); 
    10061008        void RemoveRankAurasDueToSpell(uint32 spellId); 
    10071009        bool RemoveNoStackAurasDueToAura(Aura *Aur); 
     
    13011303 
    13021304        AuraList m_modAuras[TOTAL_AURAS]; 
     1305        AuraList m_interruptableAuras; 
    13031306        float m_auraModifiersGroup[UNIT_MOD_END][MODIFIER_TYPE_END]; 
    13041307        float m_weaponDamage[MAX_ATTACK][2];