Beispiel #1
0
void hyjalAI::SummonedCreatureJustDied(Creature* pSummoned)
{
    if (!pSummoned->IsWorldBoss())                          // Only do stuff when bosses die
        return;

    if (m_aBossGuid[0] == pSummoned->GetObjectGuid())
    {
        DoTalk(INCOMING);
        m_bIsFirstBossDead = true;
    }
    else if (m_aBossGuid[1] == pSummoned->GetObjectGuid())
    {
        DoTalk(SUCCESS);
        m_bIsSecondBossDead = true;
    }

    m_bIsEventInProgress = false;

    m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);

    // Reset world state for enemies to disable it
    m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);

    m_creature->SetActiveObjectState(false);
}
Beispiel #2
0
void hyjalAI::JustDied(Unit* /*pKiller*/)
{
    DoTalk(DEATH);
    m_creature->SetActiveObjectState(false);

    // TODO: in case they die during boss encounter, then what? despawn boss?
}
Beispiel #3
0
void hyjalAI::Aggro(Unit *who)
{
    for(uint8 i = 0; i < MAX_SPELL; ++i)
        if (m_aSpells[i].m_uiCooldown)
            m_uiSpellTimer[i] = m_aSpells[i].m_uiCooldown;

    DoTalk(ATTACKED);
}
Beispiel #4
0
void hyjalAI::StartEvent()
{
    if (!m_pInstance)
        return;

    DoTalk(BEGIN);

    m_bIsEventInProgress = true;
    m_bIsSummoningWaves = true;

    m_uiNextWaveTimer = 10000;
    m_uiCheckTimer = 5000;

    m_creature->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);

    m_pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
    m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
    m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 0);
}
Beispiel #5
0
void hyjalAI::UpdateAI(const uint32 uiDiff)
{
    if (!m_bIsEventInProgress)
        return;

    if (m_bIsSummoningWaves && m_pInstance)
    {
        if (m_uiWaveMoveTimer < uiDiff)
        {
            // Skip the master timer, and start next wave in 5. Clear the list, it should not be any here now.
            if (!m_pInstance->GetData(DATA_TRASH))
            {
                lWaveMobGUIDList.clear();
                m_uiNextWaveTimer = 5000;
            }

            if (!lWaveMobGUIDList.empty())
            {
                for(std::list<uint64>::iterator itr = lWaveMobGUIDList.begin(); itr != lWaveMobGUIDList.end(); ++itr)
                {
                    if (Creature* pTemp = m_pInstance->instance->GetCreature(*itr))
                    {
                        if (!pTemp->isAlive() || pTemp->getVictim())
                            continue;

                        pTemp->RemoveSplineFlag(SPLINEFLAG_WALKMODE);
                        pTemp->GetMotionMaster()->MovePoint(1, m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ());
                    }
                }
            }
            m_uiWaveMoveTimer = 10000;
        }
        else
            m_uiWaveMoveTimer -= uiDiff;

        if (m_uiNextWaveTimer < uiDiff)
            SummonNextWave();
        else
            m_uiNextWaveTimer -= uiDiff;
    }

    if (m_uiCheckTimer < uiDiff)
    {
        for(uint8 i = 0; i < 2; ++i)
        {
            if (m_uiBossGUID[i])
            {
                Creature* pBoss = m_creature->GetMap()->GetCreature(m_uiBossGUID[i]);

                if (pBoss && !pBoss->isAlive())
                {
                    if (m_uiBossGUID[i] == m_uiBossGUID[0])
                    {
                        DoTalk(INCOMING);
                        m_bIsFirstBossDead = true;
                    }
                    else if (m_uiBossGUID[i] == m_uiBossGUID[1])
                    {
                        DoTalk(SUCCESS);
                        m_bIsSecondBossDead = true;
                    }

                    m_bIsEventInProgress = false;
                    m_uiCheckTimer = 0;

                    m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);

                    m_uiBossGUID[i] = 0;

                    // Reset world state for enemies to disable it
                    m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 0);
                }
            }
        }

        m_uiCheckTimer = 5000;
    }
    else
        m_uiCheckTimer -= uiDiff;

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

    for(uint8 i = 0; i < MAX_SPELL; ++i)
    {
        if (m_aSpells[i].m_uiSpellId)
        {
            if (m_uiSpellTimer[i] < uiDiff)
            {
                if (m_creature->IsNonMeleeSpellCasted(false))
                    m_creature->InterruptNonMeleeSpells(false);

                Unit* pTarget = NULL;

                switch(m_aSpells[i].m_pType)
                {
                    case TARGETTYPE_SELF:   pTarget = m_creature; break;
                    case TARGETTYPE_RANDOM: pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0); break;
                    case TARGETTYPE_VICTIM: pTarget = m_creature->getVictim(); break;
                }

                if (pTarget)
                {
                    DoCastSpellIfCan(pTarget, m_aSpells[i].m_uiSpellId);
                    m_uiSpellTimer[i] = m_aSpells[i].m_uiCooldown;
                }
            }
            else
                m_uiSpellTimer[i] -= uiDiff;
        }
    }

    DoMeleeAttackIfReady();
}
Beispiel #6
0
void hyjalAI::JustDied(Unit* pKiller)
{
    DoTalk(DEATH);

    //TODO: in case they die during boss encounter, then what? despawn boss?
}
Beispiel #7
0
void hyjalAI::SummonNextWave()
{
    // 1 in 4 chance we give a rally yell. Not sure if the chance is offilike.
    if (!urand(0, 3))
        DoTalk(RALLY);

    if (!m_pInstance)
    {
        error_log(ERROR_INST_DATA);
        return;
    }

    sHyjalWave* pWaveData = m_uiBase ? &m_aHyjalWavesHorde[m_uiWaveCount] : &m_aHyjalWavesAlliance[m_uiWaveCount];

    if (!pWaveData)
    {
        error_log("SD2: hyjalAI not able to obtain wavedata for SummonNextWave.");
        return;
    }

    m_uiEnemyCount = m_pInstance->GetData(DATA_TRASH);

    for(uint8 i = 0; i < MAX_WAVE_MOB; ++i)
    {
        if (pWaveData->m_auiMobEntry[i])
            SpawnCreatureForWave(pWaveData->m_auiMobEntry[i]);
    }

    if (!pWaveData->m_bIsBoss)
    {
        uint32 stateValue = m_uiWaveCount+1;

        if (m_bIsFirstBossDead)
            stateValue -= MAX_WAVES;                        // Subtract 9 from it to give the proper wave number if we are greater than 8

        // Set world state to our current wave number
        m_pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, stateValue);
        // Enable world state
        m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1);

        m_pInstance->SetData(DATA_TRASH, m_uiEnemyCount);   // Send data for instance script to update count

        if (!m_bDebugMode)
            m_uiNextWaveTimer = pWaveData->m_uiWaveTimer;
        else
        {
            m_uiNextWaveTimer = 15000;
            debug_log("SD2: HyjalAI: debug mode is enabled. Next Wave in 15 seconds");
        }
    }
    else
    {
        // Set world state for waves to 0 to disable it.
        m_pInstance->DoUpdateWorldState(WORLD_STATE_WAVES, 0);
        m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMY, 1);

        // Set World State for enemies invading to 1.
        m_pInstance->DoUpdateWorldState(WORLD_STATE_ENEMYCOUNT, 1);

        m_bIsSummoningWaves = false;
    }

    m_uiWaveMoveTimer = 15000;
    m_uiCheckTimer = 5000;
    ++m_uiWaveCount;
}
void npc_reginald_windsorAI::UpdateAI(const uint32 uiDiff)
{
    // in case of idle / afk players
    if (m_uiDespawnTimer < uiDiff)
    {
        PokeRowe();
        m_creature->ForcedDespawn();
    }
    else
        m_uiDespawnTimer -= uiDiff;

    for (int i = 0; i < 6; i++)
    {
        if (GardeNeed[i] == true)
        {
            if (GardeTimer[i] < uiDiff)
            {
                if (Creature* pGarde = GetGuard(i))
                {
                    int Var = i + 7;
                    pGarde->SetFacingTo(WindsorEventMove[Var].o);
                    pGarde->SetStandState(UNIT_STAND_STATE_KNEEL);
                    GardeNeed[i] = false;
                }
            }
            else
                GardeTimer[i] -= uiDiff;
        }
    }
    if (Begin)
    {
        if (m_creature->GetDistance2d(WindsorDeplacement[0].x, WindsorDeplacement[0].y) < 2.0f)
        {
            Begin = false;
            m_creature->Unmount();
            m_creature->CastSpell(m_creature, SPELL_WINDSOR_DISMISS_HORSE, true);
            m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER);

            if (Creature* pMercutio = m_creature->FindNearestCreature(NPC_MERCUTIO, 10.0f))
            {
                pMercutio->SetSpeedRate(MOVE_WALK, 2.5f, true);
                pMercutio->setFaction(m_creature->getFaction());
                pMercutio->GetMotionMaster()->MovePoint(0, -9148.395508f, 371.322174f, 90.543655f);
                pMercutio->ForcedDespawn(12000);
                m_creature->SetFacingToObject(pMercutio);
                m_creature->MonsterSay("Yawww!");
                m_creature->HandleEmote(EMOTE_ONESHOT_ATTACKUNARMED);
            }

            m_creature->SetWalk(true);
            m_creature->SetSpeedRate(MOVE_WALK, 1.0f, true);
            GreetPlayer = true;
        }
    }

    if (!BeginQuest)
    {
        if (GreetPlayer)
        {
            if (Timer <= uiDiff)
            {
                Player* pPlayer = GetPlayer();
                if (pPlayer)
                {
                    m_creature->SetFacingToObject(pPlayer);
                    char sMessage[200];
                    sprintf(sMessage, "I knew you would come, %s. It is good to see you again, friend.", pPlayer->GetName());
                    m_creature->MonsterSay(sMessage);
                    m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
                }
                Timer = 5000;
                GreetPlayer = false;
            }
            else
                Timer -= uiDiff;
        }
        return;
    }

    if (Timer < uiDiff)
    {
        std::list<Creature*> DragListe;
        float X = 0.0f;
        float Y = 0.0f;
        uint32 eventGardId = 6;
        switch (Tick)
        {
        case 0:
            m_uiDespawnTimer = 20 * MINUTE*IN_MILLISECONDS;
            m_creature->SetFacingTo(0.659f);
            m_creature->MonsterYellToZone(NOST_TEXT(235));
            m_creature->HandleEmote(EMOTE_ONESHOT_SHOUT);
            Timer = 5000;
            break;
        case 1:
            for (int i = 0; i < 6; i++)
            {
                int Var = i + 1;
                Creature* pSummon = m_creature->SummonCreature(NPC_STORMWIND_CITY_GUARD,
                    WindsorEventMove[Var].x,
                    WindsorEventMove[Var].y,
                    WindsorEventMove[Var].z,
                    WindsorEventMove[Var].o, TEMPSUMMON_TIMED_DESPAWN, 240 * IN_MILLISECONDS);
                if (pSummon)
                {
                    GardesGUIDs[i] = pSummon->GetGUID();
                    pSummon->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                }
            }
            if (Creature* Onyxia = m_creature->SummonCreature(NPC_KATRANA_PRESTOR, -9075.6f, 466.11f, 120.383f, 6.27f, TEMPSUMMON_TIMED_DESPAWN, 10 * IN_MILLISECONDS))
            {
                Onyxia->SetDisplayId(11686);
                Onyxia->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                Onyxia->MonsterYellToZone(NOST_TEXT(WindsorTalk[IDSpeech]));
                IDSpeech++;
            }
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->GetMotionMaster()->MovePoint(0, WindsorEventMove[0].x, WindsorEventMove[0].y, WindsorEventMove[0].z);
                General->Unmount();
            }
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[1].x, WindsorDeplacement[1].y, WindsorDeplacement[1].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[1].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[1].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            break;
        case 2:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 3:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 4:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 5:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
                General->MonsterTextEmote("General Marcus Jonathan appears lost in contemplation.", nullptr);
            }
            Timer = 10000;
            break;
        case 6:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                DoTalk(General, false);
                General->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 7:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 8:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 10000;
            break;
        case 9:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                if (Creature* pGarde = GetGuard(0))
                    General->SetFacingToObject(pGarde);
                General->HandleEmote(EMOTE_ONESHOT_EXCLAMATION);
                DoTalk(General, false);
            }
            Timer = 4000;
            break;
        case 10:
            eventGardId = 0;
            break;
        case 11:
            eventGardId = 1;
            break;
        case 12:
            eventGardId = 2;
            break;
        case 13:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                if (Creature* pGarde = GetGuard(3))
                    General->SetFacingToObject(pGarde);
                General->HandleEmote(EMOTE_ONESHOT_EXCLAMATION);
                DoTalk(General, false);
            }
            Timer = 4000;
            break;
        case 14:
            eventGardId = 3;
            break;
        case 15:
            eventGardId = 4;
            break;
        case 16:
            eventGardId = 5;
            break;
        case 17:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->SetFacingToObject(m_creature);
                DoTalk(General, true);
                General->HandleEmote(EMOTE_ONESHOT_SHOUT);
            }
            Timer = 5000;
            break;
        case 18:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
                General->HandleEmote(EMOTE_ONESHOT_SALUTE);
            Timer = 5000;
            break;
        case 19:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
                DoTalk(General, false);
            Timer = 10000;
            break;
        case 20:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->GetMotionMaster()->MovePoint(0, WindsorEventMove[13].x, WindsorEventMove[13].y, WindsorEventMove[13].z);
                X = General->GetPositionX() - WindsorEventMove[13].x;
                Y = General->GetPositionY() - WindsorEventMove[13].y;
                Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            }
            else Timer = 1000;
            break;
        case 21:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->HandleEmote(EMOTE_STATE_KNEEL);
                General->SetFacingTo(WindsorEventMove[13].o);
                m_creature->SetFacingToObject(General);
                DoTalk(m_creature, false);
            }
            Timer = 10000;
            break;
        case 22:
            if (Creature* pGarde = GetGuard(0))
                m_creature->SetFacingToObject(pGarde);
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_POINT);
            Timer = 5000;
            break;
        case 25:
            NeedCheck = true;
            break;
        case 26:
            if (Creature* General = m_creature->FindNearestCreature(NPC_MARCUS_JONATHAN, 150.0f))
            {
                General->ForcedDespawn();
                General->Respawn();
            }
            break;
        case 40:
            m_uiDespawnTimer = 10 * MINUTE*IN_MILLISECONDS;
            BeginQuest = false;
            m_creature->SetUInt32Value(UNIT_NPC_FLAGS, 1);
            DoTalk(m_creature, false);
            break;
        case 47:
            DoTalk(m_creature, false);
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
            Timer = 10000;
            break;
        case 48:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                DoTalk(Bolvar, false);
            Timer = 500;
            break;
        case 49:
            if (Creature* Anduin = m_creature->FindNearestCreature(NPC_ANDUIN_WRYNN, 150.0f))
                Anduin->GetMotionMaster()->MovePoint(0, WindsorEventMove[14].x, WindsorEventMove[14].y, WindsorEventMove[14].z);
            Timer = 5000;
            break;
        case 50:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                m_creature->SetFacingToObject(Onyxia);
                DoTalk(m_creature, false);
                m_creature->HandleEmote(EMOTE_ONESHOT_POINT);
            }
            Timer = 10000;
            break;
        case 51:
        case 52:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                DoTalk(Onyxia, false);
                Onyxia->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            Timer = 10000;
            break;
        case 53:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 7000;
            break;
        case 54:
            m_creature->MonsterTextEmote("Reginald Windsor reaches into his pack and pulls out the encoded tablets.");
            Timer = 4000;
            break;
        case 55:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 6000;
            break;
        case 56:
            DoTalk(m_creature, false);
            m_creature->HandleEmote(EMOTE_ONESHOT_TALK);
            Timer = 4000;
            break;
        case 57:
            m_creature->MonsterTextEmote("Reginald Windsor reads from the tablets. Unknown, unheard sounds flow through your consciousness.");
            Timer = 2000;
            break;
        case 58:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                m_creature->CastSpell(Onyxia, SPELL_WINSOR_READ_TABLETS, false);
            Timer = 10000;
            break;
        case 59:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->CastSpell(Onyxia, SPELL_ONYXIA_TRANS, true);
                Onyxia->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.5f);
            }
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->MonsterTextEmote("Highlord Bolvar Fordragon gasps.");
            Timer = 2000;
            break;
        case 60:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                Bolvar->GetMotionMaster()->MovePoint(0, WindsorEventMove[15].x, WindsorEventMove[15].y, WindsorEventMove[15].z);
                X = Bolvar->GetPositionX() - WindsorEventMove[15].x;
                Y = Bolvar->GetPositionY() - WindsorEventMove[15].y;
                Timer = 1000 + sqrt((X * X) + (Y * Y)) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            }
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                DoTalk(Onyxia, false);
                Onyxia->HandleEmote(EMOTE_ONESHOT_TALK);
            }
            else Timer = 5000;
            break;
        case 61:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                    Bolvar->SetFacingToObject(Onyxia);
                DoTalk(Bolvar, true);
            }
            Timer = 1000;
            break;
        case 62:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->MonsterTextEmote("Lady Onyxia laughs.");
            Timer = 2000;
            break;
        case 63:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterSay("Yesss... Guards, come to your lord's aid!");
                int Var = 0;
                GetCreatureListWithEntryInGrid(DragListe, Onyxia, NPC_STORMWIND_ROYAL_GUARD, 25.0f);
                for (auto itr = DragListe.begin(); itr != DragListe.end(); ++itr)
                {
                    DragsGUIDs[Var] = (*itr)->GetGUID();
                    (*itr)->UpdateEntry(NPC_ONYXIA_ELITE_GUARD);
                    (*itr)->AIM_Initialize();
                    (*itr)->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                    if (!urand(0, 2))
                        (*itr)->MonsterTextEmote("Onyxia's Elite Guard hisses.");
                    Var++;
                }
            }
            Timer = 4000;
            break;
        case 64:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
                Onyxia->CastSpell(m_creature, SPELL_WINDSOR_DEATH, false);
            Timer = 1500;
            break;
        case 65:
            DoTalk(m_creature, false);
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterSay("Was this fated, Windsor? If it was death that you came for then the prophecy has been fulfilled. May your consciousness rot in the Twisting Nether. Finish the rest of these meddlesome insects, children. Bolvar, you have been a pleasurable puppet.");
                Onyxia->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PASSIVE);
                if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                {
                    int Var = 0;
                    while (DragsGUIDs[Var] && Var < 9)
                    {
                        Creature* crea = me->GetMap()->GetCreature(DragsGUIDs[Var]);
                        crea->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
                        crea->getThreatManager().addThreatDirectly(Bolvar, 5000.0f);
                        crea->SetTargetGuid(Bolvar->GetGUID());
                        Bolvar->AddThreat(crea);
                        Bolvar->SetInCombatWith(crea);
                        crea->SetInCombatWith(Bolvar);
                        Var++;
                    }
                }
            }
            Timer = 5000;
            break;
        case 66:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->MonsterYell("You have failed him, mortalsss... Farewell!");
                Onyxia->CastSpell(Onyxia, SPELL_PRESTOR_DESPAWNS, true);
            }
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
                Bolvar->MonsterTextEmote("Highlord Bolvar Fordragon's medallion shatters.");
            Timer = 1000;
            PhaseFinale = true;
            break;
        case 67:
            if (Creature* Onyxia = m_creature->FindNearestCreature(NPC_KATRANA_PRESTOR, 150.0f))
            {
                Onyxia->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER | UNIT_NPC_FLAG_GOSSIP);
                Onyxia->SetFloatValue(OBJECT_FIELD_SCALE_X, 1.0f);
                Onyxia->ForcedDespawn();
                Onyxia->SetRespawnDelay(7 * MINUTE);
                Onyxia->SetRespawnTime(7 * MINUTE);
            }
            Tick = 100; // come back when combat is done
            break;
        case 68:
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                DoTalk(Bolvar, false);
                DoTalk(m_creature, false);
                Bolvar->HandleEmote(EMOTE_ONESHOT_KNEEL);
            }
            Timer = 4500;
            break;
        case 69:
            SituationFinale();
            BeginQuest = false;
            m_creature->MonsterTextEmote("Reginald Windsor dies.");
            m_creature->CastSpell(m_creature, 5, true);
            break;
        }
        if (eventGardId < 6)
        {
            if (Creature* pGarde = GetGuard(eventGardId))
            {
                int Var = eventGardId + 7;
                pGarde->GetMotionMaster()->MovePoint(0, WindsorEventMove[Var].x, WindsorEventMove[Var].y, WindsorEventMove[Var].z);
                X = pGarde->GetPositionX() - WindsorEventMove[Var].x;
                Y = pGarde->GetPositionY() - WindsorEventMove[Var].y;
            }
            GardeTimer[eventGardId] = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
            GardeNeed[eventGardId] = true;
            Timer = 1000;
        }
        if (Tick > 23 && Tick < 40)
        {
            int Var = Tick - 21;
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[Var].x, WindsorDeplacement[Var].y, WindsorDeplacement[Var].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[Var].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[Var].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
        }
        else if (Tick > 41 && Tick < 46)
        {
            int Var = Tick - 22;
            m_creature->GetMotionMaster()->MovePoint(0, WindsorDeplacement[Var].x, WindsorDeplacement[Var].y, WindsorDeplacement[Var].z);
            X = m_creature->GetPositionX() - WindsorDeplacement[Var].x;
            Y = m_creature->GetPositionY() - WindsorDeplacement[Var].y;
            Timer = 1000 + sqrt(X * X + Y * Y) / (m_creature->GetSpeed(MOVE_WALK) * 0.001f);
        }
        else if (PhaseFinale == true)
        {
            if (Creature* Bolvar = m_creature->FindNearestCreature(NPC_BOLVAR_FORDRAGON, 150.0f))
            {
                if (!Bolvar->isInCombat())
                {
                    if (!CombatJustEnded)
                    {
                        Bolvar->SetWalk(true);
                        Bolvar->GetMotionMaster()->MovePoint(0, -8447.39f, 335.35f, 121.747f, 1.29f);
                        CombatJustEnded = true;
                        Timer = 5000;
                        Tick = 68;
                        return;
                    }
                }
            }
        }
        Tick++;
    }
    else
        Timer -= uiDiff;
}