// Kel'Thuzad AI by GiGi*FasT* #define CN_KELTHUZAD 15990 #define FROSTBOLT 28478 // target #define FROSTBOLT 28479 // various #define CHAINS_OF_KELTHUZAD 28410 // various #define SHADOW_FISSURE 27810 // target class KelThuzadAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(Kel'ThuzadAI); SP_AI_Spell spells[2]; bool m_spellcheck[2]; Kel'ThuzadAI(Creature* pCreature) : CreatureAIScript(pCreature) { // -- Number of spells to add -- nrspells = 3; // --- Initialization --- for(int i=0;iGetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->CastSpell(_unit, spells[0].info, spells[0].instant); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = sRand.rand(100.0f); SpellCast(val); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; Unit *target = NULL; for(int i=0;iGetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET: case TARGET_VARIOUS: _unit->CastSpell(_unit, spells[i].info, spells[i].instant); break; case TARGET_ATTACKING: _unit->CastSpell(target, spells[i].info, spells[i].instant); break; case TARGET_DESTINATION: _unit->CastSpellAoF(target->GetPositionX(),target->GetPositionY(),target->GetPositionZ(), spells[i].info, spells[i].instant); break; } m_spellcheck[i] = false; return; } if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger)) { _unit->setAttackTimer(spells[i].attackstoptimer, false); m_spellcheck[i] = true; } comulativeperc += spells[i].perctrigger; } } } protected: int nrspells; };