rendered paste body// 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 // targetclass 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;i<nrspells;i++) { m_spellcheck[i] = false; } // ---------------------- // Create basic info for spells here, watch out from instant spells or not. spells[0].info = sSpellStore.LookupEntry(FROSTBOLT); spells[0].targettype = TARGET; spells[0].instant = false; spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; // 1sec spells[1].info = sSpellStore.LookupEntry(CHAINS_OF_KELTHUZAD); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = false; spells[1].perctrigger = 15.0f; spells[1].attackstoptimer = 3000; // 1sec spells[1].info = sSpellStore.LookupEntry(SHADOW_FISSURE); spells[1].targettype = TARGET_VARIOUS; spells[1].instant = false; spells[1].perctrigger = 15.0f; spells[1].attackstoptimer = 3000; // 1sec } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(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;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if(m_spellcheck[i]) { target = _unit->GetAIInterface()->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;};