예제 #1
0
 void JustReachedHome() override
 {
     if (m_pInstance)
     {
         if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE)
             m_pInstance->SetData(TYPE_GRAND_CHAMPIONS, FAIL);
     }
 }
예제 #2
0
    void Aggro(Unit* pWho) override
    {
        if (m_pInstance)
        {
            if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE)
                m_pInstance->SetData(TYPE_GRAND_CHAMPIONS, IN_PROGRESS);

            m_pInstance->DoSetChamptionsInCombat(pWho);
        }
    }
예제 #3
0
    void DamageTaken(Unit* /*pDealer*/, uint32& uiDamage) override
    {
        if (uiDamage >= m_creature->GetHealth())
        {
            uiDamage = 0;

            if (m_bDefeated)
                return;

            if (m_pInstance)
            {
                // second part of the champions challenge
                if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE)
                {
                    m_creature->SetStandState(UNIT_STAND_STATE_KNEEL);
                    m_creature->SetHealth(1);

                    // no movement
                    SetCombatMovement(false);
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();

                    // check if the other champions are wounded and set instance data
                    if (m_pInstance->IsArenaChallengeComplete(TYPE_GRAND_CHAMPIONS))
                        m_pInstance->SetData(TYPE_GRAND_CHAMPIONS, DONE);
                }
                // first part of the champions challenge (arena encounter)
                else
                {
                    // unmount
                    if (Creature* pMount = (Creature*)m_creature->GetTransportInfo()->GetTransport())
                    {
                        pMount->RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
                        pMount->ForcedDespawn();
                    }

                    m_creature->SetStandState(UNIT_STAND_STATE_DEAD);
                    m_creature->SetHealth(1);

                    // no movement
                    SetCombatMovement(false);
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();

                    m_uiDefeatedTimer = 15000;
                }
            }

            m_bDefeated = true;
        }
    }
예제 #4
0
    void Reset() override
    {
        if (m_pInstance)
        {
            if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE)
                m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE);
            else
                DoCastSpellIfCan(m_creature, SPELL_DEFEND_DUMMY, CAST_TRIGGERED);
        }

        m_uiShieldBreakerTimer  = urand(3000, 5000);
        m_uiChargeTimer         = urand(1000, 3000);
        m_uiDefeatedTimer       = 0;
        m_uiResetThreatTimer    = urand(5000, 15000);

        m_bDefeated             = false;
    }
예제 #5
0
    void MovementInform(uint32 uiMotionType, uint32 uiPointId) override
    {
        if (uiMotionType != POINT_MOTION_TYPE || !m_pInstance)
            return;

        switch (uiPointId)
        {
            case POINT_ID_MOUNT:
            {
                // mount the closest vehicle and start attacking
                uint32 uiMountEntry = m_pInstance->GetMountEntryForChampion();

                // search for the vehicle again, just in case the previous one was taken
                Creature* pMount = m_creature->GetMap()->GetCreature(m_newMountGuid);
                if (pMount->HasAura(SPELL_RIDE_ARGENT_VEHICLE))
                    pMount = GetClosestCreatureWithEntry(m_creature, uiMountEntry, 60.0f);

                // if we don't have any mount send an error
                if (!pMount)
                {
                    script_error_log("Instance Trial of the Champion: ERROR Failed to get a mount replacement for champion %u.", m_creature->GetEntry());
                    return;
                }

                DoCastSpellIfCan(pMount, SPELL_RIDE_ARGENT_VEHICLE, CAST_TRIGGERED);

                if (m_creature->getVictim())
                    pMount->AI()->AttackStart(m_creature->getVictim());

                m_bDefeated = false;
                break;
            }
            case POINT_ID_EXIT:
                // mark the first part as complete if required
                if (m_pInstance->GetData(TYPE_GRAND_CHAMPIONS) != DONE)
                    m_pInstance->SetData(TYPE_ARENA_CHALLENGE, DONE);

                m_creature->ForcedDespawn();
                break;
        }
    }
예제 #6
0
    void UpdateAI(const uint32 uiDiff) override
    {
        // Return since we have no target
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
            return;

        // timer for other champions check
        if (m_uiDefeatedTimer)
        {
            if (m_uiDefeatedTimer <= uiDiff)
            {
                DoUseNearbyMountIfCan();
                m_uiDefeatedTimer = 0;
            }
            else
                m_uiDefeatedTimer -= uiDiff;
        }

        // no combat after defeated
        if (m_bDefeated)
            return;

        if (!m_pInstance)
            return;

        // arena battle - on vehicles
        if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == IN_PROGRESS)
        {
            if (m_uiShieldBreakerTimer < uiDiff)
            {
                if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHIELD_BREAKER) == CAST_OK)
                    m_uiShieldBreakerTimer = urand(2000, 4000);
            }
            else
                m_uiShieldBreakerTimer -= uiDiff;

            if (m_uiChargeTimer)
            {
                if (m_uiChargeTimer <= uiDiff)
                {
                    if (DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHARGE) == CAST_OK)
                    {
                        if (m_creature->GetTransportInfo() && m_creature->GetTransportInfo()->IsOnVehicle())
                        {
                            if (Creature* pMount = (Creature*)m_creature->GetTransportInfo()->GetTransport())
                                SendAIEvent(AI_EVENT_CUSTOM_A, m_creature->getVictim(), pMount);
                        }
                        m_uiChargeTimer = 0;
                    }
                }
                else
                    m_uiChargeTimer -= uiDiff;
            }
        }
        // arena challenge complete - start normal battle
        else if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE)
        {
            // Call specific virtual function
            if (!UpdateChampionAI(uiDiff))
                return;

            // Change target
            if (m_uiResetThreatTimer < uiDiff)
            {
                if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1))
                {
                    DoResetThreat();
                    AttackStart(pTarget);
                    m_uiResetThreatTimer = urand(5000, 15000);
                }
            }
            else
                m_uiResetThreatTimer -= uiDiff;

            DoMeleeAttackIfReady();
        }
    }
 void JustReachedHome() override
 {
     if (m_pInstance && m_pInstance->GetData(TYPE_ARGENT_CHAMPION) != DONE)
         m_pInstance->SetData(TYPE_ARGENT_CHAMPION, FAIL);
 }