Exemplo n.º 1
0
    // function that will make the champion to use the nearby available mount
    void DoUseNearbyMountIfCan()
    {
        if (!m_pInstance)
            return;

        // set instance data as special if first part is completed
        if (m_pInstance->IsArenaChallengeComplete(TYPE_ARENA_CHALLENGE))
            m_pInstance->SetData(TYPE_ARENA_CHALLENGE, SPECIAL);
        else
        {
            m_creature->SetStandState(UNIT_STAND_STATE_STAND);

            float fX, fY, fZ;
            uint32 uiMountEntry = m_pInstance->GetMountEntryForChampion();

            if (Creature* pMount = GetClosestCreatureWithEntry(m_creature, uiMountEntry, 60.0f))
            {
                pMount->GetContactPoint(m_creature, fX, fY, fZ);
                m_creature->SetWalk(true);
                m_creature->GetMotionMaster()->Clear();
                m_creature->GetMotionMaster()->MovePoint(POINT_ID_MOUNT, fX, fY, fZ);

                m_newMountGuid = pMount->GetObjectGuid();
            }
        }
    }
Exemplo n.º 2
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;
        }
    }