Changeset 145

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

[svn] Add function GameObject::CastSpell?. Used for hunter's trap and so.
Use original caster instead caster to check spell hit result.
Let spell triggers have the same faction as the summoner.
Fix the bug that trigger creatures attack enemy. (no need use civilian extra flag in the future, 128 is enough)
Fix shadow step.

Original author: megamage
Date: 2008-11-02 00:59:44-05:00

Location:
trunk
Files:
1 added
7 modified

Legend:

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

    r102 r145  
    3838    void Initialize() 
    3939    { 
    40         (new CreatureAIFactory<NullCreatureAI>("NullAI"))->RegisterSelf(); 
     40        (new CreatureAIFactory<NullCreatureAI>("NullCreatureAI"))->RegisterSelf(); 
    4141        (new CreatureAIFactory<AggressorAI>("AggressorAI"))->RegisterSelf(); 
    4242        (new CreatureAIFactory<ReactorAI>("ReactorAI"))->RegisterSelf(); 
  • trunk/src/game/GameObject.cpp

    r120 r145  
    342342                if (ok) 
    343343                { 
    344                     Unit *caster =  owner ? owner : ok; 
    345  
    346                     caster->CastSpell(ok, goInfo->trap.spellId, true); 
     344                    //Unit *caster =  owner ? owner : ok; 
     345 
     346                    //caster->CastSpell(ok, goInfo->trap.spellId, true); 
     347                    CastSpell(ok, goInfo->trap.spellId); 
    347348                    m_cooldownTime = time(NULL) + 4;        // 4 seconds 
    348349 
     
    12641265    spell->prepare(&targets); 
    12651266} 
     1267 
     1268void GameObject::CastSpell(Unit* target, uint32 spell) 
     1269{ 
     1270    //summon world trigger 
     1271    Creature *trigger = SummonCreature(12999, GetPositionX(), GetPositionY(), GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 1); 
     1272    if(!trigger) return; 
     1273 
     1274    Unit *owner = GetOwner(); 
     1275    if(owner) trigger->setFaction(owner->getFaction()); 
     1276    else trigger->setFaction(14); 
     1277    trigger->SetVisibility(VISIBILITY_OFF); //should this be true? 
     1278    trigger->CastSpell(target, spell, true, 0, 0, owner->GetGUID()); 
     1279} 
  • trunk/src/game/GameObject.h

    r102 r145  
    573573 
    574574        GridReference<GameObject> &GetGridRef() { return m_gridRef; } 
     575 
     576        void CastSpell(Unit *target, uint32 spell); 
    575577    protected: 
    576578        uint32      m_charges;                              // Spell charges for GAMEOBJECT_TYPE_SPELLCASTER (22) 
  • trunk/src/game/Object.cpp

    r141 r145  
    14841484 
    14851485    if(pCreature->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER && pCreature->m_spells[0]) 
     1486    { 
     1487        if(GetTypeId() == TYPEID_UNIT || GetTypeId() == TYPEID_PLAYER) 
     1488            pCreature->setFaction(((Unit*)this)->getFaction()); 
    14861489        pCreature->CastSpell(pCreature, pCreature->m_spells[0], true, 0, 0, GetGUID()); 
     1490    } 
    14871491 
    14881492    //return the creature therewith the summoner has access to it 
  • trunk/src/game/Spell.cpp

    r142 r145  
    9595} 
    9696 
    97 void SpellCastTargets::setDestination(float x, float y, float z, bool send, uint32 mapId) 
     97void SpellCastTargets::setDestination(float x, float y, float z, bool send, int32 mapId) 
    9898{ 
    9999    m_destX = x; 
     
    103103    if(send) 
    104104        m_targetMask |= TARGET_FLAG_DEST_LOCATION; 
    105     if(mapId) 
     105    if(mapId >= 0) 
    106106        m_mapId = mapId; 
    107107} 
     
    416416        std::list<Unit*> tmpUnitMap; 
    417417 
    418         // Note: this hack with search required until GO casting not implemented 
    419         // environment damage spells already have around enemies targeting but this not help in case not existed GO casting support 
    420         // currently each enemy selected explicitly and self cast damage 
    421         if(m_spellInfo->EffectImplicitTargetA[i] == TARGET_ALL_AROUND_CASTER 
    422             && m_spellInfo->EffectImplicitTargetB[i]==TARGET_ALL_ENEMY_IN_AREA  
    423             && m_spellInfo->Effect[i]==SPELL_EFFECT_ENVIRONMENTAL_DAMAGE) 
    424         { 
    425             tmpUnitMap.push_back(m_targets.getUnitTarget()); 
    426         } 
    427         else 
    428         { 
    429             SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); 
    430             SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); 
    431         } 
     418        SetTargetMap(i,m_spellInfo->EffectImplicitTargetA[i],tmpUnitMap); 
     419        SetTargetMap(i,m_spellInfo->EffectImplicitTargetB[i],tmpUnitMap); 
    432420 
    433421        if(m_targets.HasDest()) 
     
    717705 
    718706    // Calculate hit result 
    719     target.missCondition = m_caster->SpellHitResult(pVictim, m_spellInfo, m_canReflect); 
     707    if(m_originalCaster) 
     708        target.missCondition = m_originalCaster->SpellHitResult(pVictim, m_spellInfo, m_canReflect); 
     709    else 
     710        target.missCondition = SPELL_MISS_NONE; 
    720711    if (target.missCondition == SPELL_MISS_NONE) 
    721712        ++m_countOfHit; 
     
    14551446                    || m_spellInfo->Effect[1] == SPELL_EFFECT_TELEPORT_UNITS 
    14561447                    || 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); 
     1448                    m_targets.setDestination(st->target_X, st->target_Y, st->target_Z, true, (int32)st->target_mapId); 
    14581449                else if(st->target_mapId == m_caster->GetMapId()) 
    14591450                    m_targets.setDestination(st->target_X, st->target_Y, st->target_Z); 
  • trunk/src/game/Spell.h

    r142 r145  
    112112            //m_srcZ = target.m_srcZ; 
    113113 
    114             m_mapId = 0; 
     114            m_mapId = -1; 
    115115            m_destX = target.m_destX; 
    116116            m_destY = target.m_destY; 
     
    128128        Unit *getUnitTarget() const { return m_unitTarget; } 
    129129        void setUnitTarget(Unit *target); 
    130         void setDestination(float x, float y, float z, bool send = true, uint32 mapId = 0); 
     130        void setDestination(float x, float y, float z, bool send = true, int32 mapId = -1); 
    131131        void setDestination(Unit *target, bool send = true); 
    132132 
     
    156156 
    157157        float m_srcX, m_srcY, m_srcZ; 
    158         uint32 m_mapId; 
     158        int32 m_mapId; 
    159159        float m_destX, m_destY, m_destZ; 
    160160        bool m_hasDest; 
  • trunk/src/game/SpellEffects.cpp

    r144 r145  
    19791979    } 
    19801980    // Init dest coordinates 
    1981     uint32 mapid = m_targets.m_mapId; 
     1981    int32 mapid = m_targets.m_mapId; 
     1982    if(mapid < 0) mapid = (int32)unitTarget->GetMapId(); 
    19821983    float x = m_targets.m_destX; 
    19831984    float y = m_targets.m_destY;