// 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(); } } }
void JustReachedHome() override { if (m_pInstance) { if (m_pInstance->GetData(TYPE_ARENA_CHALLENGE) == DONE) m_pInstance->SetData(TYPE_GRAND_CHAMPIONS, FAIL); } }
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); } }
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; } }
void JustReachedHome() override { if (m_pInstance) m_pInstance->SetData(TYPE_BLACK_KNIGHT, FAIL); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_OOC_NOT_ATTACKABLE); }
void JustDied(Unit* /*pKiller*/) override { if (m_pInstance) m_pInstance->SetData(TYPE_BLACK_KNIGHT, DONE); DoScriptText(SAY_DEATH, m_creature); DoCastSpellIfCan(m_creature, SPELL_KILL_CREDIT, CAST_TRIGGERED); }
void SpellHitTarget(Unit* pUnit, const SpellEntry* pSpellEntry) override { if (pUnit->GetTypeId() != TYPEID_PLAYER) return; // set achiev failed if (pSpellEntry->Id == SPELL_EXPLODE && m_pInstance) m_pInstance->SetHadWorseAchievFailed(); }
void MovementInform(uint32 uiMotionType, uint32 uiPointId) override { if (uiMotionType != POINT_MOTION_TYPE || !m_pInstance) return; switch (uiPointId) { case POINT_ID_CENTER: m_pInstance->MoveChampionToHome(m_creature); break; case POINT_ID_HOME: if (Creature* pCenterTrigger = m_pInstance->GetSingleCreatureFromStorage(NPC_WORLD_TRIGGER)) { m_creature->SetRespawnCoord(m_creature->GetPositionX(), m_creature->GetPositionY(), m_creature->GetPositionZ(), m_creature->GetAngle(pCenterTrigger)); m_creature->SetFacingToObject(pCenterTrigger); } m_pInstance->InformChampionReachHome(); break; } }
void SummonedMovementInform(Creature* pSummoned, uint32 uiMotionType, uint32 uiPointId) override { if (uiMotionType != POINT_MOTION_TYPE || uiPointId != POINT_ID_HOME || !m_pInstance) return; if (Creature* pCenterTrigger = m_pInstance->GetSingleCreatureFromStorage(NPC_WORLD_TRIGGER)) { pSummoned->SetRespawnCoord(pSummoned->GetPositionX(), pSummoned->GetPositionY(), pSummoned->GetPositionZ(), pSummoned->GetAngle(pCenterTrigger)); pSummoned->SetFacingToObject(pCenterTrigger); } }
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; } }
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; }
void DamageTaken(Unit* /*pDealer*/, uint32& uiDamage) override { if (uiDamage >= m_creature->GetHealth()) { uiDamage = 0; if (m_bDefeated) return; if (m_pInstance) m_pInstance->SetData(TYPE_ARGENT_CHAMPION, DONE); // Handle event completion DoHandleEventEnd(); m_creature->SetFactionTemporary(FACTION_CHAMPION_FRIENDLY, TEMPFACTION_NONE); EnterEvadeMode(); m_bDefeated = true; } }
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 Aggro(Unit* /*pWho*/) override { if (m_pInstance) DoCastSpellIfCan(m_creature, m_pInstance->GetPlayerTeam() == ALLIANCE ? SPELL_RAISE_DEAD_ARELAS : SPELL_RAISE_DEAD_JAEREN); }
void JustReachedHome() override { if (m_pInstance && m_pInstance->GetData(TYPE_ARGENT_CHAMPION) != DONE) m_pInstance->SetData(TYPE_ARGENT_CHAMPION, FAIL); }
void Aggro(Unit* /*pWho*/) override { if (m_pInstance) m_pInstance->SetData(TYPE_ARGENT_CHAMPION, IN_PROGRESS); }