Ohai guys as a part of mah new instance thing i making for something secret, i would like to present a simple small AI script for a Fire Elemental that i made.
Tested using a female dwarf warrior with 90k hp (i modded it ofc lawl) basically he casts fireball and fire blast at you every so often, wouldnt say hes hard but hes not easyif hes too hard for your server then just edit the spells.
NOTE: For Aspire, tested using the 3.1 branch.
C++ pastebin - collaborative debugging toolCode:/* * FireElemental.cpp Scripts for MMOwned by 2dgreengiant * Copyright (C) 2008-2009 MMOwned 2dgreengiant */ #include "StdAfx.h" #include "Setup.h" /************************************************************************/ /* Instance_ElementalHell.cpp Script */ /************************************************************************/ // Fire Elemental #define FIRE_ELEMENTAL 1337133 #define FIRE_BLAST 13342 //Edit the number to the spell number and change FIRE_BLAST to the new spell, make sure its in caps and has a _ if it has spaces #define FIRE_BALL 54095 class FireElementalAI : public CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(FireElementalAI); SP_AI_Spell spells[2]; bool m_spellcheck[2]; FireElementalAI(CreaturePointer pCreature) : CreatureAIScript(pCreature) { nrspells = 2; for(int i=0;i<nrspells;i++) { m_spellcheck[i] = false; } spells[0].info = dbcSpell.LookupEntry(FIRE_BLAST); // As said before if changing the spell change FIRE_BLAST to the new name, make sure its i ncaps and has a _ for spaces. spells[0].targettype = TARGET_ATTACKING; spells[0].instant = true; // if the spell is a cast spell change to false spells[0].perctrigger = 0.0f; spells[0].attackstoptimer = 1000; spells[1].info = dbcSpell.LookupEntry(FIRE_BALL); spells[1].targettype = TARGET_ATTACKING; spells[1].instant = true; spells[1].perctrigger = 5.0f; spells[1].attackstoptimer = 2000; } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { float val = (float)RandomFloat(100.0f); SpellCast(val); } void OnCombatStart(UnitPointer mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "My flames will burn you mortal fool!"); } void OnDamageTaken(UnitPointer mAttacker, float fAmount) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->CastSpell(_unit, spells[0].info, spells[0].instant); } void OnCombatStop(UnitPointer mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(UnitPointer mKiller) { RemoveAIUpdateEvent(); } void SpellCast(float val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget()) { float comulativeperc = 0; UnitPointer target = NULLUNIT; for(int i=0;i<nrspells;i++) { if(!spells[i].perctrigger) continue; if(m_spellcheck[i]) { if (!spells[i].instant) _unit->GetAIInterface()->StopMovement(1); target = _unit->GetAIInterface()->GetNextTarget(); switch(spells[i].targettype) { case TARGET_SELF: 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; } } } void Destroy() { delete this; }; protected: int nrspells; }; void SetupFireElemental(ScriptMgr * mgr) { mgr->register_creature_script(FIRE_ELEMENTAL, &FireElementalAI::Create); }
Download (if your THAT lazy) : CLICK ME