Пример #1
0
 void JustDied(Unit* Killer)
 {
     Creature *pOtherBoss = GetOtherBoss();
     if (pOtherBoss)
     {
         pOtherBoss->SetHealth(0);
         pOtherBoss->setDeathState(JUST_DIED);
         pOtherBoss->SetFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
         CAST_AI(boss_twinemperorsAI, pOtherBoss->AI())->DontYellWhenDead = true;
     }
     if (!DontYellWhenDead)                              // I hope AI is not threaded
         DoPlaySoundToSet(m_creature, IAmVeklor() ? SOUND_VL_DEATH : SOUND_VN_DEATH);
 }
Пример #2
0
        void JustDied(Unit* killer)
        {
            Creature* deathcharger = me->FindNearestCreature(28782, 30);
            if (!deathcharger)
                return;

            if (killer->GetTypeId() == TYPEID_PLAYER && deathcharger->GetTypeId() == TYPEID_UNIT && deathcharger->IsVehicle())
            {
                deathcharger->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                deathcharger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                deathcharger->setFaction(2096);
            }
        }
Пример #3
0
        void MoveInLineOfSight(Unit* pWho)
        {
            if(!pWho)
                return;
            if(Phase == IDLE && pWho->isTargetableForAttack() && me->IsHostileTo(pWho) && me->IsWithinDistInMap(pWho, 20))
            {
                Phase = INTRO;
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

                pTrall = me->SummonCreature(CREATURE_TRALL, 685.569f, 615.103f, 435.396f, 6.23544f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                if(pTrall) {
                    pTrall->SetReactState(REACT_PASSIVE);
                    pTrall->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }

                pGarrosh = me->SummonCreature(CREATURE_GARROSH, 685.7f, 621.134f, 435.396f, 6.259f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                if(pGarrosh) {
                    pGarrosh->SetReactState(REACT_PASSIVE);
                    pGarrosh->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }

                pKing = me->SummonCreature(CREATURE_KING, 807.724f, 617.9f, 435.396f, 3.18416f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                if(pKing) {
                    pKing->SetReactState(REACT_PASSIVE);
                    pKing->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                pLady = me->SummonCreature(CREATURE_LADY, 807.401f, 613.667f, 435.397f, 3.0585f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                if(pLady) {
                    pLady->SetReactState(REACT_PASSIVE);
                    pLady->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }

                pHighlord = me->SummonCreature(CREATURE_HIGHLORD, 746.482f, 556.857f, 435.396f, 1.5898f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000);
                if(pHighlord) {
                    pHighlord->SetReactState(REACT_PASSIVE);
                    pHighlord->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
            }
        }
StatusTeleport::StatusTeleport(const Id & owner, const D3DXVECTOR3 & loc)
: CreatureStatus(CRESTATUS_TELEPORT, owner), m_bFading(true), m_dest(loc)
{
	TimeInit(&m_delay, TELE_DELAY);

	Creature *pCre = (Creature *)IDPageQuery(m_owner);

	if(pCre)
	{
		pCre->SetFlag(CRE_FLAG_INVUL, true);

		OBJSetToLast(pCre->GetOBJ());
	}
}
Пример #5
0
        void Update(uint32 diff)
        {
            if (GetData(TYPE_CROWN) == IN_PROGRESS)
            {
                if (spawnCrazedTimer <= diff)
                {
                    if (Creature* hummel = instance->GetCreature(hummelGUID))
                        hummel->AI()->DoAction(ACTION_SPAWN_CRAZED);
                    spawnCrazedTimer = urand(2000, 5000);
                }
                else
                    spawnCrazedTimer -= diff;
            }

            if (GetData(TYPE_FENRUS) != DONE)
                return;

            Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID);
            Creature* summon = NULL;

            if (!pArchmage || !pArchmage->isAlive())
                return;

            if (uiPhase)
            {
                if (uiTimer <= diff)
                {
                    switch (uiPhase)
                    {
                        case 1:
                            summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000);
                            summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                            summon->SetReactState(REACT_DEFENSIVE);
                            summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true);
                            DoScriptText(SAY_ARCHMAGE, summon);
                            uiTimer = 2000;
                            uiPhase = 2;
                            break;
                        case 2:
                            pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            uiPhase = 0;
                            break;

                    }
                } else uiTimer -= diff;
            }
        }
Пример #6
0
        void MoveInLineOfSight(Unit* who)
        {
            if (!who)
                return;

            if (Phase == IDLE && who->isTargetableForAttack() && me->IsHostileTo(who) && me->IsWithinDistInMap(who, 20.0))
            {
                Phase = INTRO;
                me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);

                if (Trall = me->SummonCreature(NPC_TRALL, 685.569f, 615.103f, 435.396f, 6.23544f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000))
                {
                    Trall->SetReactState(REACT_PASSIVE);
                    Trall->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                if (Garrosh = me->SummonCreature(NPC_GARROSH, 685.7f, 621.134f, 435.396f, 6.259f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000))
                {
                    Garrosh->SetReactState(REACT_PASSIVE);
                    Garrosh->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                if (King = me->SummonCreature(NPC_KING, 807.724f, 617.9f, 435.396f, 3.18416f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000))
                {
                    King->SetReactState(REACT_PASSIVE);
                    King->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                if (Lady = me->SummonCreature(NPC_LADY, 807.401f, 613.667f, 435.397f, 3.0585f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000))
                {
                    Lady->SetReactState(REACT_PASSIVE);
                    Lady->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
                if (Highlord = me->SummonCreature(NPC_HIGHLORD, 746.482f, 556.857f, 435.396f, 1.5898f, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000))
                {
                    Highlord->SetReactState(REACT_PASSIVE);
                    Highlord->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                }
            }
        }
Пример #7
0
    void SetRuffies(uint64 guid, bool bAttack, bool bReset)
    {
        Creature* pCreature = (Creature*)Unit::GetUnit(*m_creature, guid);

        if (!pCreature)
            return;

        if (bReset)
        {
            if (!pCreature->IsInEvadeMode() && pCreature->isAlive())
                pCreature->AI()->EnterEvadeMode();

            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_8);
            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_9);
        }
        else
        {
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_8);
            pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_UNK_9);

            if (!pCreature->isAlive())
                return;

            pCreature->SetStandState(UNIT_STAND_STATE_STAND);

            if (bAttack)
            {
                if (Unit* pUnit = Unit::GetUnit(*m_creature, m_uiPlayerGUID))
                {
                    if (pUnit->isAlive())
                        pCreature->AI()->AttackStart(pUnit);
                }
            }
        }
    }
StatusTeleport::StatusTeleport(const Id & owner, const char *targetName) 
: CreatureStatus(CRESTATUS_TELEPORT, owner), m_bFading(true), m_bGO(false)
{
	if(g_world)
	{
		g_world->TargetGet(targetName, m_dest);

		TimeInit(&m_delay, TELE_DELAY);
	}

	Creature *pCre = (Creature *)IDPageQuery(m_owner);

	if(pCre)
		pCre->SetFlag(CRE_FLAG_INVUL, true);
}
Пример #9
0
 void SpawnAdds()
 {
     Creature *pCreature = NULL;
     for (uint8 i = 0; i < 4; ++i)
     {
         pCreature = me->SummonCreature(SpiritInfo[i].entry, SpiritInfo[i].x, SpiritInfo[i].y, SpiritInfo[i].z, SpiritInfo[i].orient, TEMPSUMMON_DEAD_DESPAWN, 0);
         if (pCreature)
         {
             pCreature->CastSpell(pCreature, SPELL_SPIRIT_AURA, true);
             pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
             pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
             SpiritGUID[i] = pCreature->GetGUID();
         }
     }
 }
Пример #10
0
StatusInvulnerable::StatusInvulnerable(const Id & owner, double delay)
: CreatureStatus(CRESTATUS_INVULNERABLE, owner), m_bFading(true)
{
	TimeInit(&m_fadeDelay, INVUL_DELAY);
	TimeInit(&m_invulDelay, delay);

	Creature *pCre = (Creature *)IDPageQuery(m_owner);

	if(pCre)
	{
		pCre->SetFlag(CRE_FLAG_INVUL, true);

		OBJSetToLast(pCre->GetOBJ());
	}
}
Пример #11
0
 void SpawnMojo()
 {
     Creature *pCreature = NULL;
     for (uint8 i = 0; i < 5; ++i)
     {
         pCreature = me->SummonCreature(CREATURE_MOJO, SpawnLoc[i], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 1*IN_MILLISECONDS);
         if (pCreature)
         {
             MojoGUID[i] = pCreature->GetGUID();
             pCreature->SetVisible(true);
             pCreature->SetReactState(REACT_PASSIVE);
             pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         }
     }
 }
Пример #12
0
    void JustDidDialogueStep(int32 iEntry) override
    {
        switch (iEntry)
        {
            case NPC_WINDSOR_MOUNT:
            {
                if (Creature* pWindsor = m_creature->GetMap()->GetCreature(m_windsorGuid))
                {
                    pWindsor->Unmount();
                    m_creature->SummonCreature(NPC_WINDSOR_MOUNT, pWindsor->GetPositionX() - 1.0f, pWindsor->GetPositionY() + 1.0f, pWindsor->GetPositionZ(), pWindsor->GetOrientation(), TEMPSUMMON_TIMED_DESPAWN, 30000);
                }
                break;
            }
            case SAY_DISMOUNT:
            {
                if (Creature* pHorse = m_creature->GetMap()->GetCreature(m_horseGuid))
                {
                    pHorse->SetWalk(false);
                    pHorse->GetMotionMaster()->MovePoint(1, aWindsorSpawnLoc[0], aWindsorSpawnLoc[1], aWindsorSpawnLoc[2]);
                }
                break;
            }
            case QUEST_STORMWIND_RENDEZVOUS:
            {
                Creature* pWindsor = m_creature->GetMap()->GetCreature(m_windsorGuid);
                Player* pPlayer = GetPlayerForEscort();
                if (!pWindsor || !pPlayer)
                    break;

                pWindsor->SetFacingToObject(pPlayer);
                break;
            }
            case QUEST_THE_GREAT_MASQUERADE:
            {
                Creature* pWindsor = m_creature->GetMap()->GetCreature(m_windsorGuid);
                Player* pPlayer = GetPlayerForEscort();
                if (!pWindsor || !pPlayer)
                    break;

                DoScriptText(SAY_WELCOME, pWindsor, pPlayer);
                // Allow players to finish quest and also finish the escort
                pWindsor->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);
                SetEscortPaused(false);
                break;
            }
        }
    }
Пример #13
0
		void Update(uint32 uiDiff) {
			if (GetData(TYPE_FENRUS) != DONE)
				return;

			Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID);
			Creature* pSummon = NULL;

			if (!pArchmage || !pArchmage->isAlive())
				return;

			if (uiPhase) {
				if (uiTimer <= uiDiff) {
					switch (uiPhase) {
					case 1:
						pSummon = pArchmage->SummonCreature(
								pArchmage->GetEntry(), SpawnLocation[4],
								TEMPSUMMON_TIMED_DESPAWN, 10000);
						pSummon->SetFlag(UNIT_FIELD_FLAGS,
								UNIT_FLAG_OOC_NOT_ATTACKABLE);
						pSummon->SetReactState(REACT_DEFENSIVE);
						pSummon->CastSpell(pSummon, SPELL_ASHCROMBE_TELEPORT,
								true);
						DoScriptText(SAY_ARCHMAGE, pSummon);
						uiTimer = 2000;
						uiPhase = 2;
						break;
					case 2:
						pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER,
								SpawnLocation[0],
								TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
						pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER,
								SpawnLocation[1],
								TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
						pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER,
								SpawnLocation[2],
								TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
						pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER,
								SpawnLocation[3],
								TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
						uiPhase = 0;
						break;
					}
				} else
					uiTimer -= uiDiff;
			}
		}
Пример #14
0
    void WaypointReached(uint32 i)
    {
        Player* player = GetPlayerForEscort();

        if (!player)
            return;

        if (IsWalking && !m_creature->IsWalking())
            m_creature->SetWalk(true);

        switch (i)
        {
        case 0:
            SetVariables();
            break;
        case 3:
            if (!yeller_spawned)
            {
                Creature *yeller = m_creature->SummonCreature(DEFIAS_RAIDER, THUG_SPAWN_X, THUG_SPAWN_Y, THUG_SPAWN_Z, THUG_SPAWN_O, TEMPSUMMON_TIMED_DESPAWN, 3000);
                yeller->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                yeller->Yell(SAY_KILL_HER, LANG_UNIVERSAL, 0);
                yeller_spawned = true;
            }
            break;
        case 5:
            real_event_started = true;
            NextEvent();
            break;
        case 6:
            IsWalking = true;
            break;
        case 11:
            if (thug_wave > 3)
            {
                player->CompleteQuest(QUEST_PROTECT_DAPHNE);
            }
            if (player && player->GetTypeId() == TYPEID_PLAYER)
                ((Player*)player)->GroupEventHappens(QUEST_PROTECT_DAPHNE,m_creature);

            m_creature->GetMotionMaster()->MovementExpired();
            m_creature->GetMotionMaster()->MoveTargetedHome();
            SetVariables();
            break;
        }
    }
Пример #15
0
        void JustDied(Unit* killer)
        {
            Creature* deathcharger = me->FindNearestCreature(28782, 30);
            if (!deathcharger)
                return;

            if (killer->GetTypeId() == TYPEID_PLAYER && deathcharger->GetTypeId() == TYPEID_UNIT && deathcharger->IsVehicle())
            {
                deathcharger->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
                deathcharger->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                deathcharger->setFaction(2096);
                me->ExitVehicle();
                CAST_PLR(killer)->GroupEventHappens(12687, me);
                if (CAST_PLR(killer)->HasAura(REALM_OF_SHADOWS))
                    killer->RemoveAurasDueToSpell(REALM_OF_SHADOWS);
                me->DespawnOrUnsummon();
            }
        }
Пример #16
0
        void Update(uint32 uiDiff)
        {
            if (GetData(TYPE_FENRUS) != DONE)
                return;

            Creature* pArchmage = instance->GetCreature(uiArchmageArugalGUID);

            if (!pArchmage || !pArchmage->IsAlive())
                return;

            if (uiPhase)
            {
                if (uiTimer <= uiDiff)
                {
                    switch (uiPhase)
                    {
                        case 1:
                        {
                                  Creature* summon = pArchmage->SummonCreature(pArchmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000);
                                  summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                                  summon->SetReactState(REACT_DEFENSIVE);
                                  summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true);
                                  summon->AI()->Talk(SAY_ARCHMAGE);
                                  uiTimer = 2000;
                                  uiPhase = 2;
                                  break;
                        }
                        case 2:
                        {
                                  pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                                  pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                                  pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                                  pArchmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                                  uiPhase = 0;
                                  break;
                        }

                    }
                }
                else uiTimer -= uiDiff;
            }
        }
Пример #17
0
        void Reset()
        {
            me->RemoveAllAuras();

            uiHolyFireTimer     = urand(9000,12000);
            uiHolySmiteTimer    = urand(5000,7000);
            uiRenewTimer        = urand(2000,5000);

            uiResetTimer        = 7000;

            bHealth = false;
            bDone = false;
    		
            if (Creature* pMemory = Unit::GetCreature(*me, MemoryGUID))
                if (pMemory->IsAlive())
                    pMemory->RemoveFromWorld();

            Map* pMap = me->GetMap();
            if (hasBeenInCombat && pMap && pMap->IsDungeon())
            {
                Map::PlayerList const &players = pMap->GetPlayers();
                for (Map::PlayerList::const_iterator itr = players.begin(); itr != players.end(); ++itr)
                {
                    if(itr->GetSource() && itr->GetSource()->IsAlive() && !itr->GetSource()->IsGameMaster())
                       return; //se almeno un player ¡§¡§ vivo, esce						
                }
    			 
                if(pInstance)
                {
                   GameObject* GO = GameObject::GetGameObject(*me, pInstance->GetData64(DATA_MAIN_GATE1));
                   if(GO)
                      pInstance->HandleGameObject(GO->GetGUID(),true);
                   Creature* announcer = pMap->GetCreature(pInstance->GetData64(DATA_ANNOUNCER));
                   pInstance->SetData(DATA_ARGENT_SOLDIER_DEFEATED,0);
                   announcer->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                }

                me->RemoveFromWorld();
                //ResetEncounter();
            }

        }
Пример #18
0
    void SummonDoomfire(Unit* pTarget)
    {
        Creature* Doomfire = DoSpawnCreature(CREATURE_DOOMFIRE_TARGETING, float(rand() % 30), float(rand() % 30), 0, 0, TEMPSUMMON_TIMED_DESPAWN, 30000);
        if (Doomfire)
        {
            ((mob_doomfire_targettingAI*)Doomfire->AI())->ArchimondeGUID = me->GetGUID();
            Doomfire->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            // Give Doomfire a taste of everyone in the threatlist = more targets to chase.
            ThreatContainer::StorageType::const_iterator itr;
            for (itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr)
                Doomfire->AddThreat(Unit::GetUnit(*me, (*itr)->getUnitGuid()), 1.0f);
            Doomfire->setFaction(me->getFaction());
            DoCast(Doomfire, SPELL_DOOMFIRE_SPAWN);
            Doomfire->CastSpell(Doomfire, SPELL_DOOMFIRE_VISUAL, true);
            if (pTarget)
                Doomfire->AI()->AttackStart(pTarget);

            if (rand() % 2 == 0)
                DoScriptText(SAY_DOOMFIRE1, me);
            else
                DoScriptText(SAY_DOOMFIRE2, me);
        }
    }
Пример #19
0
    void DoSpawnPortal()
    {
        if (Creature* pMedivh = instance->GetCreature(m_uiMedivhGUID))
        {
            int tmp = rand()%(4-1);

            if (tmp >= m_uiCurrentRiftId)
                ++tmp;

            debug_log("DS: Instance Dark Portal: Creating Time Rift at locationId %i (old locationId was %u).", tmp, m_uiCurrentRiftId);

            m_uiCurrentRiftId = tmp;

            Creature* pTemp = pMedivh->SummonCreature(NPC_TIME_RIFT,
                PortalLocation[tmp][0],PortalLocation[tmp][1],PortalLocation[tmp][2],PortalLocation[tmp][3],
                TEMPSUMMON_CORPSE_DESPAWN,0);

            if (pTemp)
            {
                pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                pTemp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

                if (Creature* pBoss = SummonedPortalBoss(pTemp))
                {
                    if (pBoss->GetEntry() == NPC_AEONUS)
                    {
                        pBoss->AddThreat(pMedivh);
                    }
                    else
                    {
                        pBoss->AddThreat(pTemp);
                        pTemp->CastSpell(pBoss,SPELL_RIFT_CHANNEL,false);
                    }
                }
            }
        }
    }
        void Update(uint32 Diff)
        {
            if (GetData(TYPE_FENRUS) != DONE)
                return;

            Creature* archmage = instance->GetCreature(ArchmageArugalGUID);
            Creature* summon = NULL;

            if (!archmage || !archmage->isAlive())
                return;

            if (Phase)
            {
                if (Timer <= Diff)
                {
                    switch (Phase)
                    {
                        case 1:
                            summon = archmage->SummonCreature(archmage->GetEntry(), SpawnLocation[4], TEMPSUMMON_TIMED_DESPAWN, 10000);
                            summon->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                            summon->SetReactState(REACT_DEFENSIVE);
                            summon->CastSpell(summon, SPELL_ASHCROMBE_TELEPORT, true);
                            DoScriptText(SAY_ARCHMAGE, summon);
                            Timer = 2000;
                            Phase = 2;
                            break;
                        case 2:
                            archmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            archmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[1], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            archmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[2], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            archmage->SummonCreature(NPC_ARUGAL_VOIDWALKER, SpawnLocation[3], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 60000);
                            Phase = 0;
                            break;
                    }
                } else Timer -= Diff;
            }
        }
Пример #21
0
bool GossipHello_npc_colonel_jules(Player* pPlayer, Creature* pCreature)
{
    // quest already completed
    if (pPlayer->GetQuestStatus(QUEST_ID_EXORCISM) == QUEST_STATUS_COMPLETE)
    {
        pPlayer->SEND_GOSSIP_MENU(TEXT_ID_CLEANSED, pCreature->GetObjectGuid());
        return true;
    }
    // quest active but not complete
    else if (pPlayer->IsCurrentQuest(QUEST_ID_EXORCISM, 1))
    {
        Creature* pAnchorite = GetClosestCreatureWithEntry(pCreature, NPC_ANCHORITE_BARADA, 15.0f);
        if (!pAnchorite)
            return true;

        if (npc_anchorite_baradaAI* pAnchoriteAI = dynamic_cast<npc_anchorite_baradaAI*>(pAnchorite->AI()))
        {
            // event complete - give credit and reset
            if (pAnchoriteAI->IsExorcismComplete())
            {
                // kill credit
                pPlayer->RewardPlayerAndGroupAtEvent(pCreature->GetEntry(), pCreature);

                // reset Anchorite and Colonel
                pAnchorite->AI()->EnterEvadeMode();
                pCreature->AI()->EnterEvadeMode();

                pAnchorite->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                pPlayer->SEND_GOSSIP_MENU(TEXT_ID_CLEANSED, pCreature->GetObjectGuid());
                return true;
            }
        }
    }

    pPlayer->SEND_GOSSIP_MENU(TEXT_ID_POSSESSED, pCreature->GetObjectGuid());
    return true;
}
        void JustDied(Unit* killer)
        {
            if (!ghost && instance)
            {
                Unit* skarvald = Unit::GetUnit(*me, instance->GetData64(DATA_SKARVALD));
                if (skarvald)
                {
                    if (skarvald->isDead())
                    {
                        DoScriptText(YELL_DALRONN_SKA_DIED, me);
						if(IsHeroic()){
						Map* map = me->GetMap();
						Map::PlayerList const &PlayerList = map->GetPlayers();
						for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr)
						if (Player* player = itr->getSource())
							 player->AddItem(ITEM_EMBLEM_OF_HEROISM,1);
						}
                        if (instance)
                            instance->SetData(DATA_SKARVALD_DALRONN_EVENT, DONE);
                    }
                    else
                    {
                        DoScriptText(YELL_DALRONN_DAL_DIEDFIRST, me);

                        me->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
                        //DoCast(me, SPELL_SUMMON_DALRONN_GHOST, true);
                        Creature* temp = me->SummonCreature(MOB_DALRONN_GHOST, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN, 5000);
                        if (temp)
                        {
                            temp->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            temp->AI()->AttackStart(killer);
                        }
                    }
                }
            }
        }
Пример #23
0
    void MoveInLineOfSight(Unit* /*who*/)
    {
        if (!GridSearcherSucceeded)
        {
            FindChannelers();

            if (Channelers.size() >= 6)
            {
                GridSearcherSucceeded = true;

                for (std::set<uint64>::iterator itr = Channelers.begin(); itr != Channelers.end(); ++itr)
                {
                    Creature* Channeler = (Unit::GetCreature(*me, *itr));
                    if (Channeler)
                    {
                        if (Channeler->isDead())
                        {
                            Channeler->RemoveCorpse();
                            Channeler->Respawn();
                            Channeler->InterruptNonMeleeSpells(true);
                            Channeler->RemoveAurasDueToSpell(SPELL_SHADE_SOUL_CHANNEL);
                        }

                        if (Channeler->IsAlive())
                        {
                            Channeler->CastSpell(me, SPELL_SHADE_SOUL_CHANNEL, true);
                            Channeler->CastSpell(me, SPELL_SHADE_SOUL_CHANNEL_2, true);
                            Channeler->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            Channeler->SetFacingToObject(me);
                        }
                    }
                }
            }
            else error_log("SD2 ERROR: No Channelers are stored in the list. This encounter will not work properly");
        }
    }
Пример #24
0
    void UpdateAI(const uint32 uiDiff)
    {
        if (!pInstance)
            return;

        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        switch (getStage())
        {
            case 0: //PHASE 1 PHYSICAL REALM
                timedCast(SPELL_FLAME_BREATH, uiDiff);
                timedCast(SPELL_FIERY_COMBUSTION, uiDiff);
                timedCast(SPELL_METEOR, uiDiff);
                if (m_creature->GetHealthPercent() < 75.0f) setStage(1);
                break;

            case 1: // Switch to phase 2
                m_creature->AttackStop();
                m_creature->InterruptNonMeleeSpells(true);
                DoScriptText(-1666108,m_creature);
                pInstance->SetData(TYPE_HALION_EVENT, NOT_STARTED);
                SetCombatMovement(false);
                StartMovement(0);
                {
                    Creature* pControl = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_HALION_CONTROL));
                    if (!pControl)
                        pControl = m_creature->SummonCreature(NPC_HALION_CONTROL, SpawnLoc[0].x, SpawnLoc[0].y, SpawnLoc[0].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 1000);
                    else if (!pControl->isAlive())
                        pControl->Respawn();
                    pControl->SetActiveObjectState(true);
                    pControl->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    m_creature->SetInCombatWith(pControl);
                    pControl->SetInCombatWith(m_creature);
                }
                setStage(2);
                break;

            case 2:
                if (MovementStarted) return;
                doCast(SPELL_SUMMON_TWILIGHT_PORTAL);
                setStage(3);
                if (GameObject* pGoPortal = pInstance->instance->GetGameObject(pInstance->GetData64(GO_HALION_PORTAL_1)))
                      pGoPortal->SetPhaseMask(31,true);
                if (GameObject* pGoRing = pInstance->instance->GetGameObject(pInstance->GetData64(GO_FLAME_RING)))
                      pGoRing->SetPhaseMask(65535,true);
                break;

            case 3:
                if (m_creature->IsNonMeleeSpellCasted(false)) return;
                m_creature->SetActiveObjectState(true);
                doCast(SPELL_START_PHASE2);
                setStage(4);
                break;

            case 4:
                if (!m_creature->IsNonMeleeSpellCasted(false))
                {
                    if (Creature* pControl = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_HALION_CONTROL)))
                    {
                        m_creature->SetInCombatWith(pControl);
                        pControl->SetInCombatWith(m_creature);
                    }
                    Creature* pTwilight = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_HALION_TWILIGHT));
                    if (!pTwilight)
                        pTwilight = m_creature->SummonCreature(NPC_HALION_TWILIGHT, SpawnLoc[0].x, SpawnLoc[0].y, SpawnLoc[0].z, 0, TEMPSUMMON_MANUAL_DESPAWN, 1000);
                    else if (!pTwilight->isAlive())
                        pTwilight->Respawn();
                    pTwilight->SetCreatorGUID(0);
                    m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    setStage(5);
                }
                break;

            case 5: // HALION awaiting end battle in TWILIGHT REALM
                if (pInstance->GetData(TYPE_HALION_EVENT) == IN_PROGRESS)
                    {
//                        pInstance->SetData(TYPE_HALION_EVENT, SPECIAL);
                        doRemove(SPELL_START_PHASE2);
                        if (Creature* pControl = m_creature->GetMap()->GetCreature(pInstance->GetData64(NPC_HALION_CONTROL)))
                        {
                            m_creature->SetInCombatWith(pControl);
                            pControl->SetInCombatWith(m_creature);
                        }
                        m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        m_creature->SetHealth(m_creature->GetMaxHealth()/2);
                        m_creature->SetInCombatWithZone();
                        setStage(6);
                    }
                return;

            case 6: // Switch to phase 3
//                doCast(SPELL_TWILIGHT_DIVISION);
                DoScriptText(-1666109,m_creature);
                pInstance->SetData(TYPE_HALION_EVENT, SPECIAL);
                setStage(7);
                break;

            case 7:
                if (m_creature->IsNonMeleeSpellCasted(false)) return;
                if (m_creature->getVictim()->GetTypeId() != TYPEID_PLAYER) return;
                SetCombatMovement(true);
                m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim());
                setStage(8);
                break;

            case 8: //PHASE 3 BOTH REALMS
                timedCast(SPELL_FLAME_BREATH, uiDiff);
                timedCast(SPELL_FIERY_COMBUSTION, uiDiff);
                timedCast(SPELL_METEOR, uiDiff);
                break;

            default:
                break;
        }

        timedCast(SPELL_BERSERK, uiDiff);

        DoMeleeAttackIfReady();

    }
    void UpdateAI(const uint32 diff)
    {
        //Sounds OOC, Kiljaeden Orders
        if(!m_creature->getVictim())
        {
            if(m_uiKJOrdersTimer < diff)
            {
		        switch (rand()%5)
		        {
			        case 0: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT1); break;
			        case 1: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT2); break;
			        case 2: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT3); break;
                    case 3: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT4); break;
                    case 4: DoPlaySoundToSet(m_creature, SAY_KJ_OFFCOMBAT5); break;
		        }
                m_uiKJOrdersTimer = 30000;
            }else m_uiKJOrdersTimer -= diff;
        }

        /*//Rebirth After Phase1
		if(pInstance && pInstance->GetData(DATA_KILJAEDEN) == IN_PROGRESS)
        {
            m_creature->setFaction(14);
            m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            //pInstance->SetData(DATA_KILJAEDEN_EVENT, IN_PROGRESS);
            //pInstance->SetData(DATA_DECIVER, NOT_STARTED); 
        }*/

        if(!m_creature->SelectHostileTarget() || !m_creature->getVictim())
               return;

		//dragon cast blue shield
        for(uint8 i=0; i<4; ++i)
        {
            if(Unit* Dragon = Unit::GetUnit(*m_creature, DragonGUID[i]))
                if(Dragon && Dragon->HasAura(SPELL_SHIELD_OF_BLUE))
                {
                    m_uiCancelShieldTimer = 5000;
                    std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
                    for(std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
                    {
                        Unit *TargetedPlayer = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());  
                        if (TargetedPlayer && TargetedPlayer->GetTypeId() == TYPEID_PLAYER && TargetedPlayer->IsWithinDistInMap(Dragon, 10) && !TargetedPlayer->HasAura(AURA_BLUESHIELD))
                            TargetedPlayer->CastSpell(TargetedPlayer,AURA_BLUESHIELD,true);
                    }
                }
        }

		//stop blue shield
        if(m_uiCancelShieldTimer < diff)
        {
            std::list<HostileReference *> t_list = m_creature->getThreatManager().getThreatList();
            for(std::list<HostileReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
            {
                Unit *ShieldedPlayer1 = Unit::GetUnit(*m_creature, (*itr)->getUnitGuid());
                if (ShieldedPlayer1 && ShieldedPlayer1->GetTypeId() == TYPEID_PLAYER && ShieldedPlayer1->HasAura(AURA_BLUESHIELD))
                {
                    ShieldedPlayer1->RemoveAurasDueToSpell(AURA_BLUESHIELD);
                } 
            }
            m_uiCancelShieldTimer = 300000;
        }else m_uiCancelShieldTimer -= diff;

        //Kalecgos and Anvena Event
        if((m_uiKalecgosAnvenaTimer < diff) && m_bIsAnvena)
        {
            switch(m_uiKalecgosAnvenaCount)
            {
                case 0:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_AWAKEN); m_uiKalecgosAnvenaTimer = 5000; break;
                case 1:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_IMPRISONED); m_uiKalecgosAnvenaTimer = 3000; break;
                case 2:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_LETGO); m_uiKalecgosAnvenaTimer = 6000; break;
                case 5:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_LOST); m_uiKalecgosAnvenaTimer = 4000; break;
                case 4:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_FOCUS); m_uiKalecgosAnvenaTimer = 8000; break;
                case 3:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_KALEC); m_uiKalecgosAnvenaTimer = 5000; break;
                case 6:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_FATE); m_uiKalecgosAnvenaTimer = 5000; break;
                case 7:
                DoPlaySoundToSet(m_creature, SAY_ANVEENA_GOODBYE); 
                m_creature->CastSpell(m_creature, SPELL_SACRIFICE_OF_ANVEENA, false);
                m_uiKalecgosAnvenaTimer = 5000;
                break;
                case 9:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_GOODBYE); ; m_bIsAnvena = false; break;
                case 8:
                DoPlaySoundToSet(m_creature, SAY_KALECGOS_ENCOURAGE); m_uiKalecgosAnvenaTimer = 14000; break;         
            }
            ++m_uiKalecgosAnvenaCount;
        } m_uiKalecgosAnvenaTimer -= diff;

        //Kalecgos Event working
        if((m_uiKalecgosTimer < diff) && !m_bIsKalecgosSpawned)
        {
            DoPlaySoundToSet(m_creature, SAY_KALECGOS_JOIN);
            Kalecgos = m_creature->SummonCreature(ID_KALECGOS, m_creature->GetPositionX()-25, m_creature->GetPositionY()-25, m_creature->GetPositionZ()+10, 0.686f, TEMPSUMMON_TIMED_DESPAWN, 600000);
            Kalecgos->setFaction(35);
            //Kalecgos need to start shhooting arcane bolt into Kiljaeden
            //Dragon->AI()->AttackStart(m_creature);
            m_bIsKalecgosSpawned = true;
        }m_uiKalecgosTimer -= diff;

        //Shield Orb At Start each phases working
       /* if(m_uiShieldOrbTimer < diff && !m_bPhase5)
        {
            uint8 l=1;
            if(m_bPhase3)
                l=2;
            if(m_bPhase4)
                l=3;
            for(uint8 k=0; k<l; ++k)
            {
                Creature* ShieldOrb = m_creature->SummonCreature(ID_SHIELDORB, m_creature->GetPositionX()+urand(1,15), m_creature->GetPositionY()+urand(1,15), m_creature->GetPositionZ()+15, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 15000);
                if(ShieldOrb)
                    ShieldOrb->AI()->AttackStart(m_creature->getVictim()); 
            }
            
            m_uiShieldOrbTimer = 50000; 
        }else m_uiShieldOrbTimer -= diff;*/

        //Sinister Reflects Attack Spell Timer
        if(m_uiSinnisterCastTimer < diff)
        {
            uint8 m_uiSinisterCount = 4;
            /*if(m_bPhase3)
                m_uiSinisterCount = 4;
            if(m_bPhase4)
                m_uiSinisterCount = 8;
            if(m_bPhase5)
                m_uiSinisterCount = 12;*/
            for(uint8 i=0; i<m_uiSinisterCount; ++i)
			{
                if(Unit* Sinister = Unit::GetUnit(*m_creature, m_uiSinisterGUID[i][0]))
				{
					if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
						Sinister->CastSpell(target, m_uiSinisterGUID[i][1], true);
				}
			}
            m_uiSinnisterCastTimer = 8000;
        }else m_uiSinnisterCastTimer -= diff;

        //Phase4
		//armageddon 
        if((m_uiAramageddonTimer < diff) && m_bPhase4)
        {
            uint8 h=3;
            if(m_bPhase5)
                h=5;
            if(!m_bPhase5 && m_bDarknessOfSoulsCasting)
                h=0;
            
            for(uint8 i=0; i<h; ++i)
            {
                if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
                    Creature* Armagedon = m_creature->SummonCreature(ID_ARMAGEDON, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 15000);
            }
            m_uiAramageddonTimer = 14000;
        }else m_uiAramageddonTimer -= diff;

        if((m_uiShadowSpikeEndsTimer < diff) && m_bShadowSpikeEnds && m_bPhase3)
        {
            if(Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0))
            {
                cShadowSpike = m_creature->SummonCreature(ID_SHADOWSPIKE, target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 6000);
                cShadowSpike->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                cShadowSpike->setFaction(14);

                //target->CastSpell(target, SPELL_SHADOWSPIKE_EXP, false);
            }
            ++m_uiSpikesCount;
            if(m_uiSpikesCount > 9)
                m_bShadowSpikeEnds = false;
            m_uiShadowSpikeEndsTimer = 3000;
        }else m_uiShadowSpikeEndsTimer -= diff;

        if(m_bShadowSpikeEnds)
            return;

        if(m_uiDarknessExplosionTimer < diff && m_bDarknessOfSoulsCasting)
        {
            m_creature->CastSpell(m_creature->getVictim(), SPELL_DARKNESS_EXPLOSION, true);
            m_bDarknessOfSoulsCasting = false;
            m_uiDarknessExplosionTimer = 600000;
            m_uiDarknessOfSoulsTimer = 45000;
            if(m_bPhase5)
                m_uiDarknessOfSoulsTimer = 25000;
        }else m_uiDarknessExplosionTimer -= diff;

        if(m_bDarknessOfSoulsCasting)
            return;

		// darkness of a thousand souls from phase 3 on
        if(m_uiDarknessOfSoulsTimer < diff && m_bPhase3)
        {
            switch (rand()%3)
		        {
			        case 0: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS1); break;
			        case 1: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS2); break;
			        case 2: DoPlaySoundToSet(m_creature, SAY_KJ_DARKNESS3); break;
		        }
            m_creature->CastSpell(m_creature, SPELL_DARKNESS_OF_SOULS, true);
            m_bDarknessOfSoulsCasting = true;
            m_uiDarknessExplosionTimer = 8500;
        }else m_uiDarknessOfSoulsTimer -= diff;

        // After Each Phase Dragons Are Spawned
        if((m_uiOrbTimer < diff) && !m_bBoolOrb)
        {
            for(uint8 i=0; i<4; ++i)
                DragonGUID[i] = 0;

            switch (rand()%4)
		        {
			        case 0: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY1); break;
			        case 1: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY2); break;
			        case 2: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY3); break;
                    case 3: DoPlaySoundToSet(m_creature, SAY_KALEC_ORB_READY4); break;
		        }
            uint8 m_uiMaxDragons = 1;
            if(m_bPhase5)
                m_uiMaxDragons = 4;
            for(uint8 i=0; i<m_uiMaxDragons; ++i)
            {
                Creature* Dragon = m_creature->SummonCreature(ID_DRAGON, m_creature->GetPositionX()+urand(5,20), m_creature->GetPositionY()+urand(5,20), m_creature->GetPositionZ(), 0, TEMPSUMMON_CORPSE_DESPAWN, 20000);
                DragonGUID[i] = Dragon->GetGUID();
            }
            m_bBoolOrb = true;
        }else m_uiOrbTimer -= diff;

        //FireBloom Damage WorkArround
        if (m_uiFireBloomCheck < diff)
        {
            if(m_uiFireBloomCount < 10)
                for(uint8 i=0; i<5; ++i)
                {
                    if(Unit* FireTarget = Unit::GetUnit(*m_creature, m_uiFireBloomTarget[i]))
                        FireTarget->CastSpell(FireTarget, SPELL_FIREBLOOM_EFF, true);
                }
            ++m_uiFireBloomCount;
            m_uiFireBloomCheck = 2000;
        }else m_uiFireBloomCheck -= diff;

        //Phase 3 init
        if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 85) && !m_bPhase3)
        {      
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE3);
            if(Unit* victim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) 
                if (victim && (victim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)victim),0,4);
			m_creature->MonsterYell("entering phase 3",LANG_UNIVERSAL,0);

            m_uiSinnisterCastTimer     = 10000;
            m_uiShadowSpikeTimer       = 30000;
            m_uiFlameDartTimer         = 40000;
            m_uiDarknessOfSoulsTimer   = 45000;
            m_bShadowSpikeEnds         = false;
            m_bDarknessOfSoulsCasting  = false;
            m_bPhase3 = true;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
        }

		//phase 4 init
        if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 55) && !m_bPhase4)
        {
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE4);
            if(Unit* victim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) 
                if (victim && (victim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)victim),4,8);
			m_creature->MonsterYell("entering phase 4",LANG_UNIVERSAL,0);

            m_uiAramageddonTimer       = 2000;  //100% ok
            m_bPhase4 = true;
            m_uiDarknessOfSoulsTimer   = 45000;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
        }

		//phase 5 init
        if(((m_creature->GetHealth()*100 / m_creature->GetMaxHealth()) <= 25) && !m_bPhase5)
        {
            DoPlaySoundToSet(m_creature, SAY_KJ_PHASE5);
            if(Unit* victim = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM,0)) 
                if (victim && (victim->GetTypeId() == TYPEID_PLAYER))
                    Sinister(((Player*)victim),8,12);
			m_creature->MonsterYell("entering phase 5",LANG_UNIVERSAL,0);
            m_uiShadowSpikeTimer = 1000;
            m_uiDarknessOfSoulsTimer   = 45000;
            m_bPhase5 = true;
            //DragonsTimer
            m_uiOrbTimer = 35000;
            m_bBoolOrb = false;
            //Kalecgos and Anvena Event
            m_uiKalecgosAnvenaTimer = 20000;
            m_bIsAnvena = true;
            m_uiKalecgosAnvenaCount = 0;

            Creature* Anveena = m_creature->SummonCreature(ID_ANVEENA, m_creature->GetPositionX()+urand(20,30), m_creature->GetPositionY()+urand(20,30), m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 120000);
            Anveena->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            Anveena->setFaction(35);
        }

        //spells used from phase 3 on
        if(m_bPhase3)
        {
			if(m_uiShadowSpikeTimer < diff)
            {
                DoCast(m_creature->getVictim(), SPELL_SHADOWSPIKE);

                m_bShadowSpikeEnds         = true;
                m_uiShadowSpikeEndsTimer    = 500;
                m_uiSpikesCount             = 0;
                m_uiShadowSpikeTimer        = 90000;
            }else m_uiShadowSpikeTimer -= diff;

			//flame dart
            if(m_uiFlameDartTimer < diff )
            {
                DoCast(m_creature->getVictim(), SPELL_FLAMEDARTS);
                m_uiFlameDartTimer = 33000;
            }else m_uiFlameDartTimer -= diff;
        }

        //Phase2
		// legion lightning all phases
        if(m_uiLegionLightingTimer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_LEGION_LIGHTING);
            m_uiLegionLightingTimer = 11000;
        }else m_uiLegionLightingTimer -= diff;

		// fire bloom all phases
        if(m_uiFireBloomTimer < diff)
        {
            for(uint8 i=0; i<5; ++i)
            {
                Unit* target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
                m_uiFireBloomTarget[i] = target->GetGUID();
                m_uiFireBloomCount = 0;
                //DoCast(target, SPELL_FIREBLOOM, true);
            }
            m_uiFireBloomTimer = 25000;
        }else m_uiFireBloomTimer -= diff;

		// soul flay all phases
        if(m_uiSoulFlayTimer < diff)
        {
            DoCast(m_creature->getVictim(), SPELL_SOULFLAY);
            m_uiSoulFlayTimer = 7000;
        }else m_uiSoulFlayTimer -= diff;

        DoMeleeAttackIfReady();
    }
Пример #26
0
        void UpdateAI(const uint32 diff)
        {
            if (Intro && !Done)
            {
                if (AggroTimer <= diff)
                {
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    DoScriptText(SAY_AGGRO, me);
                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_NONE);
                    Done = true;
                    if (AggroTargetGUID)
                    {
                        Unit* pUnit = Unit::GetUnit((*me), AggroTargetGUID);
                        if (pUnit)
                            AttackStart(pUnit);

                        DoZoneInCombat();
                    }
                    else
                    {
                        EnterEvadeMode();
                        return;
                    }
                } else AggroTimer -= diff;
            }

            if (!UpdateVictim() || !Done)
                return;

            if (SummonShadowsTimer <= diff)
            {
                //MindControlGhost();

                for (uint8 i = 0; i < 2; ++i)
                {
                    Creature* Shadow = NULL;
                    float X = CalculateRandomLocation(me->GetPositionX(), 10);
                    Shadow = me->SummonCreature(CREATURE_SHADOWY_CONSTRUCT, X, me->GetPositionY(), me->GetPositionZ(), 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 0);
                    if (Shadow)
                    {
                        Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                        if (!pTarget)
                            pTarget = me->getVictim();

                        if (pTarget)
                            Shadow->AI()->AttackStart(pTarget);
                    }
                }
                SummonShadowsTimer = 60000;
            } else SummonShadowsTimer -= diff;

            if (SummonDoomBlossomTimer <= diff)
            {
                if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                {
                    float X = CalculateRandomLocation(pTarget->GetPositionX(), 20);
                    float Y = CalculateRandomLocation(pTarget->GetPositionY(), 20);
                    float Z = pTarget->GetPositionZ();
                    Z = me->GetMap()->GetHeight(X, Y, Z);
                    Creature* DoomBlossom = me->SummonCreature(CREATURE_DOOM_BLOSSOM, X, Y, Z, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 20000);
                    if (DoomBlossom)
                    {
                        DoomBlossom->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        DoomBlossom->setFaction(me->getFaction());
                        DoomBlossom->AddThreat(pTarget, 1.0f);
                        CAST_AI(mob_doom_blossom::mob_doom_blossomAI, DoomBlossom->AI())->SetTeronGUID(me->GetGUID());
                        pTarget->CombatStart(DoomBlossom);
                        SetThreatList(DoomBlossom);
                        SummonDoomBlossomTimer = 35000;
                    }
                }
            } else SummonDoomBlossomTimer -= diff;

            if (IncinerateTimer <= diff)
            {
                Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);
                if (!pTarget)
                    pTarget = me->getVictim();

                if (pTarget)
                {
                    DoScriptText(RAND(SAY_SPECIAL1, SAY_SPECIAL2), me);
                    DoCast(pTarget, SPELL_INCINERATE);
                    IncinerateTimer = 20000 + rand()%31 * 1000;
                }
            } else IncinerateTimer -= diff;

            if (CrushingShadowsTimer <= diff)
            {
                Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                if (pTarget && pTarget->isAlive())
                    DoCast(pTarget, SPELL_CRUSHING_SHADOWS);
                CrushingShadowsTimer = 10000 + rand()%16 * 1000;
            } else CrushingShadowsTimer -= diff;

            /*** NOTE FOR FUTURE DEV: UNCOMMENT BELOW ONLY IF MIND CONTROL IS FULLY IMPLEMENTED **/
            /*if (ShadowOfDeathTimer <= diff)
            {
                Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 1);

                if (!pTarget)
                   pTarget = me->getVictim();

                if (pTarget && pTarget->isAlive() && pTarget->GetTypeId() == TYPEID_PLAYER)
                {
                    DoCast(pTarget, SPELL_SHADOW_OF_DEATH);
                    GhostGUID = pTarget->GetGUID();
                    ShadowOfDeathTimer = 30000;
                    SummonShadowsTimer = 53000; // Make it VERY close but slightly less so that we can check if the aura is still on the player
                }
            } else ShadowOfDeathTimer -= diff;*/

            if (RandomYellTimer <= diff)
            {
                DoScriptText(RAND(SAY_SPELL1, SAY_SPELL2), me);
                RandomYellTimer = 50000 + rand()%51 * 1000;
            } else RandomYellTimer -= diff;

            if (!me->HasAura(SPELL_BERSERK))
            {
                if (EnrageTimer <= diff)
            {
                DoCast(me, SPELL_BERSERK);
                DoScriptText(SAY_ENRAGE, me);
            } else EnrageTimer -= diff;
            }

            DoMeleeAttackIfReady();
        }
Пример #27
0
        void UpdateAI(const uint32 diff)
        {
            if (EventInProgress) {
                Player* pWarrior = NULL;

                if (PlayerGUID)
                    pWarrior = Unit::GetPlayer(*me, PlayerGUID);

                if (!pWarrior)
                    return;

                if (!pWarrior->isAlive() && pWarrior->GetQuestStatus(1719) == QUEST_STATUS_INCOMPLETE) {
                    EventInProgress = false;
                    DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, me);
                    pWarrior->FailQuest(1719);

                    for (uint8 i = 0; i < 6; ++i)
                    {
                        if (AffrayChallenger[i])
                        {
                            Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[i]);
                            if (pCreature) {
                                if (pCreature->isAlive())
                                {
                                    pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
                                    pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                    pCreature->setDeathState(JUST_DIED);
                                }
                            }
                        }
                        AffrayChallenger[i] = 0;
                        Challenger_down[i] = false;
                    }

                    if (BigWill)
                    {
                        Creature* pCreature = Unit::GetCreature((*me), BigWill);
                        if (pCreature) {
                            if (pCreature->isAlive()) {
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
                                pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pCreature->setDeathState(JUST_DIED);
                            }
                        }
                    }
                    BigWill = 0;
                }

                if (!EventGrate && EventInProgress)
                {
                    float x, y, z;
                    pWarrior->GetPosition(x, y, z);

                    if (x >= -1684 && x <= -1674 && y >= -4334 && y <= -4324) {
                        pWarrior->AreaExploredOrEventHappens(1719);
                        DoScriptText(SAY_TWIGGY_FLATHEAD_BEGIN, me);

                        for (uint8 i = 0; i < 6; ++i)
                        {
                            Creature* pCreature = me->SummonCreature(NPC_AFFRAY_CHALLENGER, AffrayChallengerLoc[i][0], AffrayChallengerLoc[i][1], AffrayChallengerLoc[i][2], AffrayChallengerLoc[i][3], TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 600000);
                            if (!pCreature)
                                continue;
                            pCreature->setFaction(35);
                            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                            pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                            pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                            AffrayChallenger[i] = pCreature->GetGUID();
                        }
                        Wave_Timer = 5000;
                        Challenger_checker = 1000;
                        EventGrate = true;
                    }
                }
                else if (EventInProgress)
                {
                    if (Challenger_checker <= diff)
                    {
                        for (uint8 i = 0; i < 6; ++i)
                        {
                            if (AffrayChallenger[i])
                            {
                                Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[i]);
                                if ((!pCreature || (!pCreature->isAlive())) && !Challenger_down[i])
                                {
                                    DoScriptText(SAY_TWIGGY_FLATHEAD_DOWN, me);
                                    Challenger_down[i] = true;
                                }
                            }
                        }
                        Challenger_checker = 1000;
                    } else Challenger_checker -= diff;

                    if (Wave_Timer <= diff)
                    {
                        if (AffrayChallenger[Wave] && Wave < 6 && !EventBigWill)
                        {
                            DoScriptText(SAY_TWIGGY_FLATHEAD_FRAY, me);
                            Creature* pCreature = Unit::GetCreature((*me), AffrayChallenger[Wave]);
                            if (pCreature && (pCreature->isAlive()))
                            {
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                                pCreature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                                pCreature->HandleEmoteCommand(EMOTE_ONESHOT_ROAR);
                                pCreature->setFaction(14);
                                pCreature->AI()->AttackStart(pWarrior);
                                ++Wave;
                                Wave_Timer = 20000;
                            }
                        }
                        else if (Wave >= 6 && !EventBigWill) {
                            if (Creature* pCreature = me->SummonCreature(NPC_BIG_WILL, -1722, -4341, 6.12f, 6.26f, TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 480000))
                            {
                                BigWill = pCreature->GetGUID();
                                //pCreature->GetMotionMaster()->MovePoint(0, -1693, -4343, 4.32f);
                                //pCreature->GetMotionMaster()->MovePoint(1, -1684, -4333, 2.78f);
                                pCreature->GetMotionMaster()->MovePoint(2, -1682, -4329, 2.79f);
                                pCreature->HandleEmoteCommand(EMOTE_STATE_READYUNARMED);
                                EventBigWill = true;
                                Wave_Timer = 1000;
                            }
                        }
                        else if (Wave >= 6 && EventBigWill && BigWill)
                        {
                            Creature* pCreature = Unit::GetCreature((*me), BigWill);
                            if (!pCreature || !pCreature->isAlive())
                            {
                                DoScriptText(SAY_TWIGGY_FLATHEAD_OVER, me);
                                EventInProgress = false;
                                EventBigWill = false;
                                EventGrate = false;
                                PlayerGUID = 0;
                                Wave = 0;
                            }
                        }
                    } else Wave_Timer -= diff;
                }
            }
        }
Пример #28
0
    void StartBossEncounter(uint8 uiBoss, bool bForceRespawn = true)
    {
        Creature* pBoss = NULL;

        switch(uiBoss)
        {
            case BOSS_MORAGG:
                HandleGameObject(uiMoraggCell,bForceRespawn);
                pBoss = instance->GetCreature(uiMoragg);
                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove1);
                break;
            case BOSS_EREKEM:
                HandleGameObject(uiErekemCell, bForceRespawn);
                HandleGameObject(uiErekemRightGuardCell, bForceRespawn);
                HandleGameObject(uiErekemLeftGuardCell, bForceRespawn);

                pBoss = instance->GetCreature(uiErekem);

                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove2);

                if (Creature* pGuard1 = instance->GetCreature(uiErekemGuard[0]))
                {
                    if (bForceRespawn)
                        pGuard1->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    else
                        pGuard1->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    pGuard1->GetMotionMaster()->MovePoint(0, BossStartMove21);
                }

                if (Creature* pGuard2 = instance->GetCreature(uiErekemGuard[1]))
                {
                    if (bForceRespawn)
                        pGuard2->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    else
                        pGuard2->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                    pGuard2->GetMotionMaster()->MovePoint(0, BossStartMove22);
                }
                break;
            case BOSS_ICHORON:
                HandleGameObject(uiIchoronCell,bForceRespawn);
                pBoss = instance->GetCreature(uiIchoron);
                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove3);
                break;
            case BOSS_LAVANTHOR:
                HandleGameObject(uiLavanthorCell,bForceRespawn);
                pBoss = instance->GetCreature(uiLavanthor);
                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove4);
                break;
            case BOSS_XEVOZZ:
                HandleGameObject(uiXevozzCell,bForceRespawn);
                pBoss = instance->GetCreature(uiXevozz);
                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove5);
                break;
            case BOSS_ZURAMAT:
                HandleGameObject(uiZuramatCell,bForceRespawn);
                pBoss = instance->GetCreature(uiZuramat);
                if (pBoss)
                    pBoss->GetMotionMaster()->MovePoint(0, BossStartMove6);
                break;
        }

        // generic boss state changes
        if (pBoss)
        {
            pBoss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
            pBoss->SetReactState(REACT_AGGRESSIVE);

            if (!bForceRespawn)
            {
                if (pBoss->isDead())
                {
                    // respawn but avoid to be looted again
                    pBoss->Respawn();
                    pBoss->RemoveLootMode(1);
                }
                pBoss->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE|UNIT_FLAG_NON_ATTACKABLE);
                uiWaveCount = 0;
            }
        }
    }
Пример #29
0
        void StartBossEncounter(uint8 uiBoss, bool bForceRespawn = true)
        {
            Creature* boss = nullptr;

            switch (uiBoss)
            {
                case BOSS_MORAGG:
                    HandleGameObject(GetObjectGuid(DATA_MORAGG_CELL), bForceRespawn);
                    boss = GetCreature(DATA_MORAGG);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove1);
                    break;
                case BOSS_EREKEM:
                    HandleGameObject(GetObjectGuid(DATA_EREKEM_CELL), bForceRespawn);
                    HandleGameObject(GetObjectGuid(DATA_EREKEM_LEFT_GUARD_CELL), bForceRespawn);
                    HandleGameObject(GetObjectGuid(DATA_EREKEM_RIGHT_GUARD_CELL), bForceRespawn);

                    boss = GetCreature(DATA_EREKEM);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove2);

                    if (Creature* pGuard1 = instance->GetCreature(uiErekemGuard[0]))
                    {
                        if (bForceRespawn)
                            pGuard1->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NON_ATTACKABLE);
                        else
                            pGuard1->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NON_ATTACKABLE);
                        pGuard1->GetMotionMaster()->MovePoint(0, BossStartMove21);
                    }

                    if (Creature* pGuard2 = instance->GetCreature(uiErekemGuard[1]))
                    {
                        if (bForceRespawn)
                            pGuard2->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NON_ATTACKABLE);
                        else
                            pGuard2->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC | UNIT_FLAG_NON_ATTACKABLE);
                        pGuard2->GetMotionMaster()->MovePoint(0, BossStartMove22);
                    }
                    break;
                case BOSS_ICHORON:
                    HandleGameObject(GetObjectGuid(DATA_ICHORON_CELL), bForceRespawn);
                    boss = GetCreature(DATA_ICHORON);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove3);
                    break;
                case BOSS_LAVANTHOR:
                    HandleGameObject(GetObjectGuid(DATA_LAVANTHOR_CELL), bForceRespawn);
                    boss = GetCreature(DATA_LAVANTHOR);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove4);
                    break;
                case BOSS_XEVOZZ:
                    HandleGameObject(GetObjectGuid(DATA_XEVOZZ_CELL), bForceRespawn);
                    boss = GetCreature(DATA_XEVOZZ);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove5);
                    break;
                case BOSS_ZURAMAT:
                    HandleGameObject(GetObjectGuid(DATA_ZURAMAT_CELL), bForceRespawn);
                    boss = GetCreature(DATA_ZURAMAT);
                    if (boss)
                        boss->GetMotionMaster()->MovePoint(0, BossStartMove6);
                    break;
            }

            // generic boss state changes
            if (boss)
            {
                boss->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_NON_ATTACKABLE);
                boss->SetReactState(REACT_AGGRESSIVE);

                if (!bForceRespawn)
                {
                    if (boss->isDead())
                    {
                        // respawn but avoid to be looted again
                        boss->Respawn();
                        boss->RemoveLootMode(1);
                    }
                    boss->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC|UNIT_FLAG_NON_ATTACKABLE);
                    uiWaveCount = 0;
                }
            }
        }
        void UpdateAI(const uint32 diff)
        {
            //Only if not incombat check if the event is started
            if (!me->isInCombat() && pInstance && pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                Unit *pTarget = Unit::GetUnit((*me), pInstance->GetData64(DATA_KARATHRESSEVENT_STARTER));

                if (pTarget)
                {
                    AttackStart(pTarget);
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
                return;

            //someone evaded!
            if (pInstance && !pInstance->GetData(DATA_KARATHRESSEVENT))
            {
                EnterEvadeMode();
                return;
            }

            //WaterBoltVolley_Timer
            if (WaterBoltVolley_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_WATER_BOLT_VOLLEY);
                WaterBoltVolley_Timer = 30000;
            } else WaterBoltVolley_Timer -= diff;

            //TidalSurge_Timer
            if (TidalSurge_Timer <= diff)
            {
                DoCast(me->getVictim(), SPELL_TIDAL_SURGE);
                // Hacky way to do it - won't trigger elseways
                me->getVictim()->CastSpell(me->getVictim(), SPELL_TIDAL_SURGE_FREEZE, true);
                TidalSurge_Timer = 15000+rand()%5000;
            } else TidalSurge_Timer -= diff;

            //Cyclone_Timer
            if (Cyclone_Timer <= diff)
            {
                //DoCast(me, SPELL_SUMMON_CYCLONE); // Doesn't work
                Cyclone_Timer = 30000+rand()%10000;
                Creature *Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000);
                if (Cyclone)
                {
                    CAST_CRE(Cyclone)->SetFloatValue(OBJECT_FIELD_SCALE_X, 3.0f);
                    Cyclone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    Cyclone->setFaction(me->getFaction());
                    Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true);
                    Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if (pTarget)
                    {
                        Cyclone->AI()->AttackStart(pTarget);
                    }
                }
            } else Cyclone_Timer -= diff;

            //Heal_Timer
            if (Heal_Timer <= diff)
            {
                // It can be cast on any of the mobs
                Unit *pUnit = NULL;

                while (pUnit == NULL || !pUnit->isAlive())
                {
                    pUnit = selectAdvisorUnit();
                }

                if (pUnit && pUnit->isAlive())
                    DoCast(pUnit, SPELL_HEAL);
                Heal_Timer = 60000;
            } else Heal_Timer -= diff;

            DoMeleeAttackIfReady();
        }