void SummonList::DespawnAll(uint32 msTimeToDespawn) {
    while (!empty()) {
        Creature* summon = Unit::GetCreature(*me, *begin());
        if (!summon)
            erase(begin());
        else {
            erase(begin());
            if (TempSummon* summ = summon->ToTempSummon()) {
                summon->DestroyForNearbyPlayers();
                summ->UnSummon(msTimeToDespawn);
            } else
                summon->DespawnOrUnsummon(msTimeToDespawn);
        }
    }
}
void SummonList::DespawnAll()
{
    while(!empty())
    {
        Creature *summon = Unit::GetCreature(*m_creature, *begin());
        if (!summon)
            erase(begin());
        else
        {
            erase(begin());
            if (summon->isSummon())
            {
                summon->DestroyForNearbyPlayers();
                CAST_SUM(summon)->UnSummon();
            }
            else
                summon->DisappearAndDie();
        }
    }
}
Example #3
0
void SummonList::DespawnAll()
{
    while (!empty())
    {
        Creature* summon = Unit::GetCreature(*me, *begin());
        if (!summon)
            erase(begin());
        else
        {
            erase(begin());
            if (TempSummon* summ = summon->ToTempSummon())
            {
                summon->DestroyForNearbyPlayers();
                summ->UnSummon();
            }
            else
                summon->DisappearAndDie();
        }
    }
}
            void SetData(uint32 type, uint32 data)
            {
                switch (type)
                {
                    case DATA_MEATHOOK_EVENT:
                        _encounterState[0] = data;
                        break;
                    case DATA_SALRAMM_EVENT:
                        if(data == DONE)
                        {
                            DoUpdateWorldState(WORLDSTATE_WAVE_COUNT, 0);
                            if(ArthasNeedsTeleport())
                                if(Creature* arthas = instance->GetCreature(_arthasGUID))
                                    arthas->AI()->SetData(1, 0);
                        }
                        _encounterState[1] = data;
                        break;
                    case DATA_EPOCH_EVENT:
                        _encounterState[2] = data;
                        break;
                    case DATA_MAL_GANIS_EVENT:
                        _encounterState[3] = data;

                        switch (_encounterState[3])
                        {
                            case NOT_STARTED:
                                HandleGameObject(_malGanisGate2GUID, true);
                                break;
                            case IN_PROGRESS:
                                HandleGameObject(_malGanisGate2GUID, false);
                                break;
                            case DONE:
                                HandleGameObject(_exitGateGUID, true);
                                if (GameObject* go = instance->GetGameObject(_malGanisChestGUID))
								{
                                    go->RemoveFlag(GAMEOBJECT_FLAGS, GO_FLAG_INTERACT_COND);
									go->SetPhaseMask(1, true);
								}
                                instance->SummonCreature(NPC_CHROMIE_3, ChromieExitSummonPos);
                                Map::PlayerList const &players = instance->GetPlayers();
                                for(Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                                    itr->getSource()->KilledMonsterCredit(31006, 0);
                                break;
                        }
                        break;
                    case DATA_INFINITE_EVENT:
                        _encounterState[4] = data;
                        switch(data)
                        {
                            case DONE:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0);
                                //DoCompleteAchievement(ACHIEVEMENT_CULLING_TIME);
                                break;
                            case FAIL:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 0);
                                if(Creature* infinite = instance->GetCreature(_infiniteGUID))
                                    infinite->AI()->DoAction(0);
                                break;
                            case IN_PROGRESS:
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN_SHOW, 1);
                                DoUpdateWorldState(WORLDSTATE_TIME_GUARDIAN, 25);
								timerVisible = true;
                                instance->SummonCreature(NPC_INFINITE, InfiniteSummonPos);
                                break;
                        }
                        break;
                    case DATA_ARTHAS_EVENT:
                        if(data == FAIL)
                        {
                            if(Creature* deadArthas = instance->GetCreature(_arthasGUID))
                            {
                                deadArthas->DespawnOrUnsummon(10000);
                                int index;
                                if(_artasStepUi >= 83) // Before last run
                                    index = 2;
                                else if(_artasStepUi >= 60) // Before the council
                                    index = 1;
                                else // entrance of city
                                    index = 0;

                                if(Creature* newArthas = instance->SummonCreature(NPC_ARTHAS, ArthasSpawnPositions[index]))
                                    newArthas->AI()->SetData(0, (uint32)pow(2.0f, index));
                            }
                        }
                        break;
                    case DATA_CRATE_COUNT:
                        _crateCount = data;
						DoUpdateWorldState(WORLDSTATE_CRATES_REVEALED, _crateCount);
                        if (_crateCount == 5)
                        {
                            if (Creature* bunny = instance->GetCreature(_genericBunnyGUID))
                                bunny->CastSpell(bunny, SPELL_CRATES_CREDIT, true);

							// Summon Chromie and global whisper
                            if (Creature* chromie = instance->SummonCreature(NPC_CHROMIE_2, ChromieSummonPos))
                                if (!instance->GetPlayers().isEmpty())
                                    if (Player* player = instance->GetPlayers().getFirst()->getSource())
                                        sCreatureTextMgr->SendChat(chromie, SAY_CRATES_COMPLETED, player->GetGUID(), CHAT_MSG_ADDON, LANG_ADDON, TEXT_RANGE_ZONE);

							DoUpdateWorldState(WORLDSTATE_SHOW_CRATES, 0);

							if(Creature* crier = instance->GetCreature(_lordaeronCrierGUID))
								crier->YellToZone(-1595053, LANG_UNIVERSAL, 0);
						}
                        break;
                    case DATA_TRANSFORM_CITIZENS:
                        switch(data)
                        {
                            case SPECIAL: // Respawn Zombies
                                while(!_zombiesList.empty())
                                {
                                    Creature* summon = instance->GetCreature(*_zombiesList.begin());
                                    if(!summon)
                                        _zombiesList.erase(_zombiesList.begin());
                                    else
                                    {
                                        _zombiesList.erase(_zombiesList.begin());
                                        if(TempSummon* summ = summon->ToTempSummon())
                                        {
                                            summon->DestroyForNearbyPlayers();
                                            summ->UnSummon();
                                        }
                                        else
                                            summon->DisappearAndDie();
                                    }
                                }
                            case IN_PROGRESS: // Transform Citizens
                                for(std::list<uint64>::iterator itr = _citizensList.begin(); itr != _citizensList.end(); ++itr)
                                    if(Creature* citizen = instance->GetCreature((*itr)))
                                    {
                                        if(Creature* arthas = instance->GetCreature(GetData64(DATA_ARTHAS)))
                                            if(Creature* risenZombie = arthas->SummonCreature(NPC_ZOMBIE, citizen->GetPositionX(), citizen->GetPositionY(), citizen->GetPositionZ(), citizen->GetOrientation())) //, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 5000))
											{
                                                _zombiesList.push_back(risenZombie->GetGUID());
												risenZombie->SetRespawnTime(60);
												risenZombie->GetMotionMaster()->MoveRandom(10.0f);
											}
                                        citizen->SetPhaseMask(2, true);
                                    }
                                break;
                        }
                        break;
                    case DATA_ZOMBIEFEST:
                        if(!instance->IsHeroic() || GetData(DATA_ZOMBIEFEST) == DONE)
                            break;

                        switch(data)
                        {
                            case DONE:
                                //DoCompleteAchievement(ACHIEVEMENT_ZOMBIEFEST);
                                _zombieFest = data;
                                break;
                            case IN_PROGRESS:
                                _zombieFest = data;
                                break;
                            case FAIL:
                                _killedZombieCount = 0;
                                _zombieTimer = 60000;
                                _zombieFest = data;
                               DoStopTimedAchievement(ACHIEVEMENT_TIMED_TYPE_CREATURE, ACHIEVEMENT_ZOMBIEFEST);
                                break;
                            case SPECIAL:
                                _killedZombieCount++;
								DoUpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, 27737, 1);
                                if(_killedZombieCount == 1)
								{
                                    SetData(DATA_ZOMBIEFEST, IN_PROGRESS);
									DoStartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_CREATURE, ACHIEVEMENT_ZOMBIEFEST);
								}
                                else if(_killedZombieCount >= 100 && GetData(DATA_ZOMBIEFEST) == IN_PROGRESS)
                                    SetData(DATA_ZOMBIEFEST, DONE);
                                //else
                                //{
                                    //if(_killedZombieCount%10 == 0);
                                //}
                                break;
                        }
                        break;
                    case DATA_ARTHAS_STEP:
                        _artasStepUi = data;
                        return;
                    case DATA_SKIP:
                        _skipUi = data;
                }

                if (data == DONE)
                    SaveToDB();
            }