void UpdateAI(const uint32 uiDiff) { if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) { if (!m_pInstance) return; if (m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS) return; if (!m_bSummonedIntro) { m_bSummonedIntro = true; SummonIntroStart(); // Cast channel visual, doesn't channel find out why m_creature->CastSpell(m_creature, SPELL_CHANNEL_VISUAL, true); } if (m_uiPhase1Timer < uiDiff) { if(m_creature->HasAura(SPELL_CHANNEL_VISUAL)) m_creature->RemoveAurasDueToSpell(SPELL_CHANNEL_VISUAL); // Remove all non-combat or already moving intro adds DespawnIntroCreaturesNonCombat(); m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); SetCombatMovement(true); m_creature->GetMotionMaster()->MoveChase(m_creature->getVictim()); DoScriptText(EMOTE_PHASE2, m_creature); switch (urand(0, 2)) { case 0: DoScriptText(SAY_AGGRO1, m_creature); break; case 1: DoScriptText(SAY_AGGRO2, m_creature); break; case 2: DoScriptText(SAY_AGGRO3, m_creature); break; } } else { if (m_uiSoldierTimer < uiDiff) { if (SendRandomSoldierToCenter()) m_uiSoldierTimer = 2000; } else m_uiSoldierTimer -= uiDiff; if (m_uiUndeadTimer < uiDiff) { if (SendRandomUndeadToCenter()) m_uiUndeadTimer = 10000; } else m_uiUndeadTimer -= uiDiff; m_uiPhase1Timer -= uiDiff; } return; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (m_uiFrostBoltTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BOLT); m_uiFrostBoltTimer = urand(1000, 60000); } else m_uiFrostBoltTimer -= uiDiff; if (m_uiFrostBoltNovaTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BOLT_NOVA); m_uiFrostBoltNovaTimer = 15000; } else m_uiFrostBoltNovaTimer -= uiDiff; if (m_uiChainsTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAINS_OF_KELTHUZAD); DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature); m_uiChainsTimer = urand(30000, 60000); } else m_uiChainsTimer -= uiDiff; if (m_uiManaDetonationTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_MANA_DETONATION); if (urand(0, 1)) DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature); m_uiManaDetonationTimer = 20000; } else m_uiManaDetonationTimer -= uiDiff; if (m_uiShadowFissureTimer < uiDiff) { CastShadowFissure(); if (urand(0, 1)) DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature); m_uiShadowFissureTimer = 10000; } else m_uiShadowFissureTimer -= uiDiff; if (m_uiFrostBlastTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BLAST); if (urand(0, 1)) DoScriptText(SAY_FROST_BLAST, m_creature); m_uiFrostBlastTimer = urand(30000, 60000); } else m_uiFrostBlastTimer -= uiDiff; //start phase 3 when we are 40% health if (!m_bIsPhase3 && m_creature->GetHealthPercent() < 40.0f) { m_bIsPhase3 = true; DoScriptText(SAY_REQUEST_AID, m_creature); //here Lich King should respond to KelThuzad but I don't know which creature to make talk //so for now just make Kelthuzad says it. DoScriptText(SAY_ANSWER_REQUEST, m_creature); } if (m_bIsPhase3 && m_uiGuardiansCount < m_uiGuardiansCountMax) { if (m_uiGuardiansTimer < uiDiff) { //Summon a Guardian of Icecrown in a random alcove SummonGuardian(); //5 seconds until summoning next guardian m_uiGuardiansTimer = 5000; } else m_uiGuardiansTimer -= uiDiff; } if (m_bIsPhase3 && m_uiGuardiansCount > 0) { if (m_uiCheckShackleTimer < uiDiff) { CheckShackle(); m_uiCheckShackleTimer = 2000; } else m_uiCheckShackleTimer -= uiDiff; } DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 uiDiff) { if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) { if (!m_pInstance) return; if (m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS) return; if (!m_bSummonedIntro) { m_bSummonedIntro = true; SummonIntroStart(); } if (m_uiPhase1Timer < uiDiff) { m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); float fx, fy, fz; m_pInstance->GetChamberCenterCoords(fx, fy, fz); m_creature->GetMotionMaster()->MovePoint(0, fx, fy, fz); DoScriptText(EMOTE_PHASE2, m_creature); return; } else { if (m_uiSoldierTimer < uiDiff) { if (SendRandomSoldierToCenter()) m_uiSoldierTimer = 2000; } else m_uiSoldierTimer -= uiDiff; if (m_uiUndeadTimer < uiDiff) { if (SendRandomUndeadToCenter()) m_uiUndeadTimer = 10000; } else m_uiUndeadTimer -= uiDiff; m_uiPhase1Timer -= uiDiff; } return; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (m_uiFrostBoltTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BOLT); m_uiFrostBoltTimer = urand(1000, 60000); } else m_uiFrostBoltTimer -= uiDiff; if (m_uiFrostBoltNovaTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BOLT_NOVA); m_uiFrostBoltNovaTimer = 15000; } else m_uiFrostBoltNovaTimer -= uiDiff; if (m_uiChainsTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_CHAINS_OF_KELTHUZAD); DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature); m_uiChainsTimer = urand(30000, 60000); } else m_uiChainsTimer -= uiDiff; if (m_uiManaDetonationTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_MANA_DETONATION); if (urand(0, 1)) DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature); m_uiManaDetonationTimer = 20000; } else m_uiManaDetonationTimer -= uiDiff; if (m_uiShadowFissureTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_SHADOW_FISSURE); if (urand(0, 1)) DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature); m_uiShadowFissureTimer = 25000; } else m_uiShadowFissureTimer -= uiDiff; if (m_uiFrostBlastTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), SPELL_FROST_BLAST); if (urand(0, 1)) DoScriptText(SAY_FROST_BLAST, m_creature); m_uiFrostBlastTimer = urand(30000, 60000); } else m_uiFrostBlastTimer -= uiDiff; //start phase 3 when we are 40% health if (!m_bIsPhase3 && m_creature->GetHealthPercent() < 40.0f) { m_bIsPhase3 = true; DoScriptText(SAY_REQUEST_AID, m_creature); //here Lich King should respond to KelThuzad but I don't know which creature to make talk //so for now just make Kelthuzad says it. DoScriptText(SAY_ANSWER_REQUEST, m_creature); } if (m_bIsPhase3 && m_uiGuardiansCount < m_uiGuardiansCountMax) { if (m_uiGuardiansTimer < uiDiff) { //Summon a Guardian of Icecrown in a random alcove SummonGuardian(); //5 seconds until summoning next guardian m_uiGuardiansTimer = 5000; } else m_uiGuardiansTimer -= uiDiff; } DoMeleeAttackIfReady(); }
void UpdateAI(const uint32 uiDiff) { if (m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE)) { if (!m_pInstance) return; if (m_pInstance->GetData(TYPE_KELTHUZAD) != IN_PROGRESS) return; if (!m_bSummonedIntro) { m_bSummonedIntro = true; SummonIntroStart(); } if (m_uiPhase1Timer < uiDiff) { m_creature->SetInCombatWithZone(); if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) { if (m_pInstance) m_pInstance->SetData(TYPE_KELTHUZAD, FAIL); Reset(); return; } m_creature->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); DoScriptText(EMOTE_PHASE2, m_creature); return; } else { if (m_uiSoldierTimer < uiDiff) { if (SendRandomSoldierToCenter()) m_uiSoldierTimer = 3000; } else m_uiSoldierTimer -= uiDiff; if (m_uiUndeadTimer < uiDiff) { if (SendRandomUndeadToCenter()) m_uiUndeadTimer = 13000; } else m_uiUndeadTimer -= uiDiff; m_uiPhase1Timer -= uiDiff; } return; } if (!m_creature->SelectHostileTarget() || !m_creature->getVictim()) return; if (m_uiFrostBoltTimer < uiDiff) { DoCastSpellIfCan(m_creature->getVictim(), m_bIsRegularMode ? SPELL_FROST_BOLT : SPELL_FROST_BOLT_H); m_uiFrostBoltTimer = urand(2000, 30000); } else m_uiFrostBoltTimer -= uiDiff; if (m_uiFrostBoltNovaTimer < uiDiff) { DoCastSpellIfCan(m_creature, m_bIsRegularMode ? SPELL_FROST_BOLT_NOVA : SPELL_FROST_BOLT_NOVA_H); m_uiFrostBoltNovaTimer = 15000; } else m_uiFrostBoltNovaTimer -= uiDiff; if (!m_bIsRegularMode) if (m_uiChainsTimer < uiDiff) { m_lChainsTargets.clear(); if (SpellEntry* TempSpell = (SpellEntry*)GetSpellStore()->LookupEntry(SPELL_CHAINS_OF_KELTHUZAD_TARGET)) { TempSpell->EffectApplyAuraName[0]=SPELL_AURA_MOD_CHARM; uint8 uiChainsTargetsCount = 0; for (uint8 i=0; i<25; ++i) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 1)) { if (pTarget->GetTypeId() == TYPEID_PLAYER && !pTarget->HasAura(SPELL_CHAINS_OF_KELTHUZAD_TARGET, EFFECT_INDEX_0)) { m_creature->InterruptNonMeleeSpells(false); m_creature->CastCustomSpell(pTarget, TempSpell, NULL, NULL, NULL, true); ((Player*)pTarget)->SetClientControl(pTarget, 0); m_lChainsTargets.insert(pTarget); ++uiChainsTargetsCount; } if (uiChainsTargetsCount>=3) break; } } m_uiChainsEndTimer = 20000; m_uiChainsTargetsCastTimer = 3500; DoResetThreat(); } //DoCastSpellIfCan(pTarget, SPELL_CHAINS_OF_KELTHUZAD); DoScriptText(urand(0, 1) ? SAY_CHAIN1 : SAY_CHAIN2, m_creature); m_uiChainsTimer = urand(60000, 90000); } else m_uiChainsTimer -= uiDiff; if (!m_lChainsTargets.empty()) { if (m_uiChainsTargetsCastTimer < uiDiff) { for (std::set<Unit*>::iterator itr = m_lChainsTargets.begin(); itr != m_lChainsTargets.end(); ++itr) { if (*itr) { int32 amount = 150000; (*itr)->CastCustomSpell(m_creature, 36983, &amount, NULL, NULL, false); } } m_uiChainsTargetsCastTimer = 4500; } else m_uiChainsTargetsCastTimer -= uiDiff; if (m_uiChainsEndTimer < uiDiff) { for(std::set<Unit*>::iterator itr = m_lChainsTargets.begin(); itr != m_lChainsTargets.end(); ++itr) { if (*itr) { ((Player*)(*itr))->SetClientControl(*itr, 1); } } m_lChainsTargets.clear(); } else m_uiChainsEndTimer -= uiDiff; } if (m_uiManaDetonationTimer < uiDiff) { Unit* pTarget = NULL; Map *map = m_creature->GetMap(); if (map && map->IsDungeon()) { std::set<Unit*> lManaDetonationTargets; Map::PlayerList const &PlayerList = map->GetPlayers(); if (!PlayerList.isEmpty()) for (Map::PlayerList::const_iterator itr = PlayerList.begin(); itr != PlayerList.end(); ++itr) { uint8 uiTargetClass = ((Unit*)itr->getSource())->getClass(); if (!itr->getSource()->isGameMaster() && itr->getSource()->isAlive() && uiTargetClass!=CLASS_WARRIOR && uiTargetClass!=CLASS_ROGUE && uiTargetClass!=CLASS_DEATH_KNIGHT) { lManaDetonationTargets.insert(itr->getSource()); } } std::set<Unit*>::iterator itr = lManaDetonationTargets.begin(); advance(itr, urand(0, lManaDetonationTargets.size()-1)); pTarget = *itr; } if (pTarget) { m_creature->InterruptNonMeleeSpells(false); DoCastSpellIfCan(pTarget, SPELL_MANA_DETONATION); } if (urand(0, 1)) DoScriptText(SAY_SPECIAL1_MANA_DET, m_creature); m_uiManaDetonationTimer = urand(30000, 60000); } else m_uiManaDetonationTimer -= uiDiff; if (m_uiShadowFissureTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0)) { m_creature->InterruptNonMeleeSpells(false); DoCastSpellIfCan(pTarget, SPELL_SHADOW_FISSURE); } if (urand(0, 1)) DoScriptText(SAY_SPECIAL3_MANA_DET, m_creature); m_uiShadowFissureTimer = urand (15000, 40000); } else m_uiShadowFissureTimer -= uiDiff; if (m_uiFrostBlastTimer < uiDiff) { if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, m_bIsRegularMode ? 1 : 0)) { m_creature->InterruptNonMeleeSpells(false); DoCastSpellIfCan(pTarget, SPELL_FROST_BLAST); } if (urand(0, 1)) DoScriptText(SAY_FROST_BLAST, m_creature); m_uiFrostBlastTimer = urand(45000, 50000); } else m_uiFrostBlastTimer -= uiDiff; //start phase 3 when we are 45% health if (!m_bIsPhase3 && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 45.0f) { m_bIsPhase3 = true; DoScriptText(SAY_REQUEST_AID, m_creature); //here Lich King should respond to KelThuzad but I don't know which creature to make talk //so for now just make Kelthuzad says it. DoScriptText(SAY_ANSWER_REQUEST, m_creature); } if (m_bIsPhase3 && m_uiGuardiansCount < m_uiGuardiansCountMax) { if (m_uiGuardiansTimer < uiDiff) { //Summon a Guardian of Icecrown in a random alcove SummonGuardian(); //5 seconds until summoning next guardian m_uiGuardiansTimer = 5000; } else m_uiGuardiansTimer -= uiDiff; } DoMeleeAttackIfReady(); }