Changeset 153

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

[svn] Add class SummonList? in script to despawn summons. Update Zul'jin script for test.

Original author: megamage
Date: 2008-11-03 10:16:06-06:00

Location:
trunk/src/bindings/scripts
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/bindings/scripts/include/sc_creature.cpp

    r130 r153  
    1515    uint8 Effects;                                          // set of enum SelectEffect 
    1616} *SpellSummary; 
     17 
     18void SummonList::Despawn(Creature *summon) 
     19{ 
     20    uint64 guid = summon->GetGUID(); 
     21    for(iterator i = begin(); i != end(); ++i) 
     22    { 
     23        if(*i == guid) 
     24        { 
     25            erase(i); 
     26            return; 
     27        } 
     28    } 
     29} 
     30 
     31void SummonList::DespawnEntry(uint32 entry) 
     32{ 
     33    for(iterator i = begin(); i != end(); ++i) 
     34    { 
     35        if(Creature *summon = (Creature*)Unit::GetUnit(*m_creature, *i)) 
     36        { 
     37            if(summon->GetEntry() == entry) 
     38            { 
     39                summon->setDeathState(JUST_DIED); 
     40                summon->RemoveCorpse(); 
     41                i = erase(i); 
     42                --i; 
     43            } 
     44        } 
     45        else 
     46        { 
     47            i = erase(i); 
     48            --i; 
     49        } 
     50    } 
     51} 
     52 
     53void SummonList::DespawnAll() 
     54{ 
     55    for(iterator i = begin(); i != end(); ++i) 
     56    { 
     57        if(Creature *summon = (Creature*)Unit::GetUnit(*m_creature, *i)) 
     58        { 
     59            summon->setDeathState(JUST_DIED); 
     60            summon->RemoveCorpse(); 
     61        } 
     62    } 
     63    clear(); 
     64} 
    1765 
    1866bool ScriptedAI::IsVisible(Unit* who) const 
  • trunk/src/bindings/scripts/include/sc_creature.h

    r130 r153  
    1111#include "CreatureAI.h" 
    1212#include "Creature.h" 
     13 
     14class SummonList : std::list<uint64> 
     15{ 
     16public: 
     17    SummonList(Creature* creature) : m_creature(creature) {} 
     18    void Summon(Creature *summon) {push_back(summon->GetGUID());} 
     19    void Despawn(Creature *summon); 
     20    void DespawnEntry(uint32 entry); 
     21    void DespawnAll(); 
     22private: 
     23    Creature *m_creature; 
     24}; 
    1325 
    1426struct TRINITY_DLL_DECL ScriptedAI : public CreatureAI 
  • trunk/src/bindings/scripts/scripts/zone/zulaman/boss_zuljin.cpp

    r117 r153  
    2323#include "precompiled.h" 
    2424#include "def_zulaman.h" 
    25 //#include "spell.h" 
    2625 
    2726//Speech 
     
    143142struct TRINITY_DLL_DECL boss_zuljinAI : public ScriptedAI 
    144143{ 
    145     boss_zuljinAI(Creature *c) : ScriptedAI(c) 
     144    boss_zuljinAI(Creature *c) : ScriptedAI(c), Summons(m_creature) 
    146145    { 
    147146        pInstance = ((ScriptedInstance*)c->GetInstanceData()); 
    148         // wait for core patch be accepted 
    149         SpellEntry *TempSpell = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_CLAW_RAGE_DAMAGE); 
    150         if(TempSpell) 
    151         { 
    152             //if(TempSpell->DmgClass != SPELL_DAMAGE_CLASS_MELEE) 
    153             //    TempSpell->DmgClass = SPELL_DAMAGE_CLASS_MELEE; 
    154             if(TempSpell->EffectApplyAuraName[2] != SPELL_AURA_MOD_STUN) 
    155                 TempSpell->EffectApplyAuraName[2] = SPELL_AURA_MOD_STUN; 
    156         } 
    157147        Reset(); 
    158148    } 
     
    184174    uint32 Pillar_Of_Fire_Timer; 
    185175 
     176    SummonList Summons; 
     177 
    186178    void Reset() 
    187179    { 
     
    214206        TankGUID = 0;         
    215207 
    216         DespawnAdds(); 
    217         DespawnSummons(CREATURE_FEATHER_VORTEX); 
    218         DespawnSummons(CREATURE_COLUMN_OF_FIRE); 
     208        Summons.DespawnAll(); 
    219209 
    220210        m_creature->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_DISPLAY, 47174); 
     
    261251        DoYell(YELL_DEATH, LANG_UNIVERSAL, NULL); 
    262252        DoPlaySoundToSet(m_creature, SOUND_DEATH); 
    263         DespawnSummons(CREATURE_COLUMN_OF_FIRE); 
     253        Summons.DespawnEntry(CREATURE_COLUMN_OF_FIRE); 
    264254 
    265255        if(Unit *Temp = Unit::GetUnit(*m_creature, SpiritGUID[3])) 
     
    329319    } 
    330320 
    331     void DespawnSummons(uint32 entry) 
    332     { 
    333         std::list<Creature*> templist; 
    334         float x, y, z; 
    335         m_creature->GetPosition(x, y, z); 
    336  
    337         { 
    338             CellPair pair(Trinity::ComputeCellPair(x, y)); 
    339             Cell cell(pair); 
    340             cell.data.Part.reserved = ALL_DISTRICT; 
    341             cell.SetNoCreate(); 
    342  
    343             Trinity::AllCreaturesOfEntryInRange check(m_creature, entry, 100); 
    344             Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange> searcher(templist, check); 
    345  
    346             TypeContainerVisitor<Trinity::CreatureListSearcher<Trinity::AllCreaturesOfEntryInRange>, GridTypeMapContainer> cSearcher(searcher); 
    347  
    348             CellLock<GridReadGuard> cell_lock(cell, pair); 
    349             cell_lock->Visit(cell_lock, cSearcher, *(m_creature->GetMap())); 
    350         } 
    351  
    352         for(std::list<Creature*>::iterator i = templist.begin(); i != templist.end(); ++i) 
    353         { 
    354             (*i)->SetVisibility(VISIBILITY_OFF); 
    355             (*i)->setDeathState(JUST_DIED); 
    356         } 
     321    void JustSummoned(Creature *summon) 
     322    { 
     323        Summons.Summon(summon); 
     324    } 
     325 
     326    void SummonedCreatureDespawn(Creature *summon) 
     327    { 
     328        Summons.Despawn(summon); 
    357329    } 
    358330 
     
    405377            { 
    406378                m_creature->RemoveAurasDueToSpell(SPELL_ENERGY_STORM); 
    407                 DespawnSummons(CREATURE_FEATHER_VORTEX); 
     379                Summons.DespawnEntry(CREATURE_FEATHER_VORTEX); 
    408380                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); 
    409381            }