void UpdateAI(const uint32 diff) { if (TalkTimer) { if (!TalkSequence) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(); ++TalkSequence; } if (TalkTimer <= diff) { if (isFriendly) GoodEnding(); else BadEnding(); ++TalkSequence; } else TalkTimer -= diff; } else { if (bJustReset) { if (ResetTimer <= diff) { me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE|UNIT_FLAG_NOT_SELECTABLE); me->RemoveUnitMovementFlag(MOVEMENTFLAG_LEVITATING); me->SetVisible(true); me->SetStandState(UNIT_STAND_STATE_SLEEP); ResetTimer = 10000; bJustReset = false; } else ResetTimer -= diff; return; } if (!UpdateVictim()) return; if (CheckTimer <= diff) { if (me->GetDistance(CENTER_X, CENTER_Y, DRAGON_REALM_Z) >= 75) { me->AI()->EnterEvadeMode(); return; } if (HealthBelowPct(10) && !isEnraged) { if (Creature* Sath = Unit::GetCreature(*me, SathGUID)) Sath->AI()->DoAction(DO_ENRAGE); DoAction(DO_ENRAGE); } if (!isBanished && HealthBelowPct(1)) { if (Creature* Sath = Unit::GetCreature(*me, SathGUID)) { if (Sath->HasAura(SPELL_BANISH)) { Sath->DealDamage(Sath, Sath->GetHealth()); return; } else DoAction(DO_BANISH); } else { sLog->outError("TSCR: Didn't find Shathrowar. Kalecgos event reseted."); EnterEvadeMode(); return; } } CheckTimer = 1000; } else CheckTimer -= diff; if (ArcaneBuffetTimer <= diff) { DoCastAOE(SPELL_ARCANE_BUFFET); ArcaneBuffetTimer = 8000; } else ArcaneBuffetTimer -= diff; if (FrostBreathTimer <= diff) { DoCastAOE(SPELL_FROST_BREATH); FrostBreathTimer = 15000; } else FrostBreathTimer -= diff; if (TailLashTimer <= diff) { DoCastAOE(SPELL_TAIL_LASH); TailLashTimer = 15000; } else TailLashTimer -= diff; if (WildMagicTimer <= diff) { DoCastAOE(WildMagic[rand()%6]); WildMagicTimer = 20000; } else WildMagicTimer -= diff; if (SpectralBlastTimer <= diff) { std::list<HostileReference*> &m_threatlist = me->getThreatManager().getThreatList(); std::list<Unit*> targetList; for (std::list<HostileReference*>::const_iterator itr = m_threatlist.begin(); itr!= m_threatlist.end(); ++itr) if ((*itr)->getTarget() && (*itr)->getTarget()->GetTypeId() == TYPEID_PLAYER && (*itr)->getTarget()->GetGUID() != me->getVictim()->GetGUID() && !(*itr)->getTarget()->HasAura(AURA_SPECTRAL_EXHAUSTION) && (*itr)->getTarget()->GetPositionZ() > me->GetPositionZ()-5) targetList.push_back((*itr)->getTarget()); if (targetList.empty()) { SpectralBlastTimer = 1000; return; } std::list<Unit*>::const_iterator i = targetList.begin(); advance(i, rand()%targetList.size()); if ((*i)) { (*i)->CastSpell((*i), SPELL_SPECTRAL_BLAST, true); SpectralBlastTimer = 20000+rand()%5000; } else SpectralBlastTimer = 1000; } else SpectralBlastTimer -= diff; DoMeleeAttackIfReady(); } }
void boss_kalecgos::boss_kalecgosAI::UpdateAI(const uint32 diff) { if(TalkTimer) { if(!TalkSequence) { me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE + UNIT_FLAG_NOT_SELECTABLE); me->InterruptNonMeleeSpells(true); me->RemoveAllAuras(); me->DeleteThreatList(); me->CombatStop(); TalkSequence++; if(pInstance) { pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_FORECEFIELD_COLL_1),true); pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_FORECEFIELD_COLL_2),true); } } if(TalkTimer <= diff) { if(isFriendly) GoodEnding(); else BadEnding(); TalkSequence++; }else TalkTimer -= diff; } else { if (!UpdateVictim()) return; if(!doorClosed) { if(Close_Timer <= diff) { if(pInstance) { pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_FORECEFIELD_COLL_1),false); pInstance->HandleGameObject(pInstance->GetData64(DATA_GO_FORECEFIELD_COLL_2),false); doorClosed = true; } Close_Timer = 10000; }else Close_Timer -= diff; } if(ResetThreat <= diff) { if ( ( me->getVictim()->HasAuraEffect(AURA_SPECTRAL_REALM,0)) && (me->getVictim()->GetTypeId() == TYPEID_PLAYER) ) { for(std::list<HostileReference*>::iterator itr = me->getThreatManager().getThreatList().begin(); itr != me->getThreatManager().getThreatList().end(); ++itr) { if(((*itr)->getUnitGuid()) == (me->getVictim()->GetGUID())) { (*itr)->removeReference(); break; } } } if(me->getVictim() && (me->getVictim()->HasAuraEffect(AURA_SPECTRAL_REALM,0) || me->GetPositionZ() < DRAGON_REALM_Z-10)) me->getThreatManager().modifyThreatPercent(me->getVictim(), -100); ResetThreat = 1000; }else ResetThreat -= diff; if(CheckTimer <= diff) { if (((me->GetHealth()*100 / me->GetMaxHealth()) < 10) && !isEnraged) { Unit* Sath = Unit::GetUnit(*me, SathGUID); if(Sath) { Sath->CastSpell(Sath, SPELL_ENRAGE, true); CAST_AI(boss_sathrovarr::boss_sathrovarrAI,((Creature*)Sath)->AI())->isEnraged = true; } DoCast(me, SPELL_ENRAGE, true); isEnraged = true; } if(!isBanished && (me->GetHealth()*100)/me->GetMaxHealth() < 1) { if(Unit *Sath = Unit::GetUnit(*me, SathGUID)) { if(CAST_AI(boss_sathrovarr::boss_sathrovarrAI,((Creature*)Sath)->AI())->isBanished) { Sath->DealDamage(Sath, Sath->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false); return; } else { DoCast(me, SPELL_BANISH); isBanished = true; } } else { sLog->outError("TSCR: Didn't find Shathrowar. Kalecgos event reseted."); EnterEvadeMode(); return; } } CheckTimer = 1000; }else CheckTimer -= diff; if(ArcaneBuffetTimer <= diff) { if(TryDoCastAOE(SPELL_ARCANE_BUFFET)) ArcaneBuffetTimer = 8000; }else ArcaneBuffetTimer -= diff; if(FrostBreathTimer <= diff) { if(TryDoCastAOE(SPELL_FROST_BREATH)) FrostBreathTimer = 15000; }else FrostBreathTimer -= diff; if(TailLashTimer <= diff) { if(TryDoCastAOE(SPELL_TAIL_LASH)) TailLashTimer = 15000; }else TailLashTimer -= diff; if(WildMagicTimer <= diff) { if(TryDoCastAOE(WildMagic[rand()%6])) WildMagicTimer = 20000; }else WildMagicTimer -= diff; if(SpectralBlastTimer <= diff) { //this is a hack. we need to find a victim without aura in core Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1, 100, true); if( target && target->isAlive() && !(target->HasAuraEffect(AURA_SPECTRAL_EXHAUSTION, 0)) ) { if(TryDoCast(target, SPELL_SPECTRAL_BLAST)) SpectralBlastTimer = 20000+(rand()%5000); } else { SpectralBlastTimer = 1000; } }else SpectralBlastTimer -= diff; DoMeleeAttackIfReady(); } };