this is a boss script i made im studyin C++ and this is my work [some of what i dont understand i had to take from moon++ so creds there XD]
Code:
#include "StdAfx.h"
#include "Setup.h"
/************************************************************************/
/* DarkKnight.cpp Script */
/************************************************************************/
#define NPCID [your NPC ID]
#define DARK_DECAY 33129
#define SHADOW_BLAST 41078
class DARKKNIGHTAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(DARKKNIGHTAI);
SP_AI_Spell spells[2];
bool m_spellcheck[2];
CHRONOLORDDEJAAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 2;
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = dbcSpell.LookupEntry(DARK_DECAY);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].cooldown = 10;
spells[0].perctrigger = 0.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = dbcSpell.LookupEntry(SHADOW_BLAST);
spells[1].targettype = TARGET_ATTACKING;
spells[1].instant = false;
spells[1].cooldown = 14;
spells[1].perctrigger = 0.0f;
spells[1].attackstoptimer = 1000;
}
void OnCombatStart(Unit* mTarget)
{
CastTime();
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Prepare to taste the wrath of the night");
RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
}
void CastTime()
{
for(int i=0;i<nrspells;i++)
spells[i].casttime = spells[i].cooldown;
}
void OnTargetDied(Unit* mTarget)
{
if(_unit->GetHealthPct() > 0)
{
uint32 sound = 0;
char *text;
switch(RandomUInt(1))
{
case 0:
text = "AHAHAHAHA NONE CAN AMOUNT TO MY POWER!!!!!";
break;
case 1:
text = "Fool you honestly thought you could defeat me ahahaha!";
break;
}
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, text);
}
}
void OnCombatStop(Unit *mTarget)
{
CastTime();
_unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
_unit->GetAIInterface()->SetAIState(STATE_IDLE);
RemoveAIUpdateEvent();
}
void OnDied(Unit * mKiller)
{
CastTime();
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "H..ho..how did you...");
RemoveAIUpdateEvent();
}
void AIUpdate()
{
float val = (float)RandomFloat(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++)
{
spells[i].casttime--;
if (m_spellcheck[i])
{
spells[i].casttime = spells[i].cooldown;
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)) || !spells[i].casttime)
{
_unit->setAttackTimer(spells[i].attackstoptimer, false);
m_spellcheck[i] = true;
}
comulativeperc += spells[i].perctrigger;
}
}
}
protected:
int nrspells;
};
void SetupMagerScript(ScriptMgr * mgr)
{
mgr->register_creature_script(NPCID, &DARKKNIGHTAI::Create);
}
its not tested sorry but i dont have visual C++ on this comp so anyone mind runnin a test of it for me and telling me if it works