rendered paste body#include "StdAfx.h"
#include "Setup.h"
/************************************************************************/
/* Instance_Steam Vaults.cpp Script */
/************************************************************************/
// Coilfang Engineer AI
#define CN_COILFANG_ENGINEER 17721
#define BOMB 40332 // AOE
#define NET 38338 // Should stay for 5 or 8 sec?
class COILFANGENGINEERAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(COILFANGENGINEERAI);
COILFANGENGINEERAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 2;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(BOMB);
spells[0].targettype = TARGET_DESTINATION;
spells[0].instant = false;
spells[0].perctrigger = 15.0f;
spells[0].attackstoptimer = 3000;
spells[1].info = sSpellStore.LookupEntry(NET);
spells[1].targettype = TARGET_ATTACKING;
spells[1].instant = true;
spells[1].perctrigger = 15.0f;
spells[1].attackstoptimer = 1500;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Coilfang Oracle AI
#define CN_COILFANG_ORACLE 17803
#define FROST_SHOCK 34353
#define SONIC_BURST 39052 // Should make dmg?
#define HEAL 39378 // Hmm... no idea if this is correct id (and how much should heal)
class COILFANGORACLEAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(COILFANGORACLEAI);
COILFANGORACLEAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 3;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(FROST_SHOCK);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].perctrigger = 15.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = sSpellStore.LookupEntry(SONIC_BURST);
spells[1].targettype = TARGET_VARIOUS;
spells[1].instant = true;
spells[1].perctrigger = 18.0f;
spells[1].attackstoptimer = 2000;
spells[2].info = sSpellStore.LookupEntry(HEAL);
spells[2].targettype = TARGET_SELF;
spells[2].instant = true;
spells[2].perctrigger = 2.0f;
spells[2].attackstoptimer = 1000;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Coilfang Warrior AI
#define CN_COILFANG_WARRIOR 17802
#define MORTAL_STRIKE 29572
class COILFANGWARRIORAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(COILFANGWARRIORAI);
COILFANGWARRIORAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 1;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(MORTAL_STRIKE);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = false;
spells[0].perctrigger = 20.0f;
spells[0].attackstoptimer = 1000;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Coilfang Siren AI
#define CN_COILFANG_SIREN 17801
#define FEAR 27641 // Little bugged, target stands in place instead of running away and still not sure to id
#define LIGHTNING_BOLT 36152 // 1 target
class COILFANGSIRENAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(COILFANGSIRENAI);
COILFANGSIRENAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 2;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(FEAR);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].perctrigger = 10.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = sSpellStore.LookupEntry(LIGHTNING_BOLT);
spells[1].targettype = TARGET_ATTACKING;
spells[1].instant = false;
spells[1].perctrigger = 15.0f;
spells[1].attackstoptimer = 3000;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Bog OverlordAI
#define CN_BOG_OVERLORD 21694
#define FUNGAL_DECAY 32065
class BOGOVERLORDAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(BOGOVERLORDAI);
BOGOVERLORDAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 1;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(FUNGAL_DECAY);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].perctrigger = 20.0f;
spells[0].attackstoptimer = 1000;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Coilfang water elemental
#define CN_COILFANG_WATER_ELEMENTAL 17917
#define FROSTBOLT_VOLLEY 36741
class COILFANGWATERELEMENTALAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(COILFANGWATERELEMENTALAI);
COILFANGWATERELEMENTALAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 1;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(FROSTBOLT_VOLLEY);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true; // Should be false, but doesn't work then
spells[0].perctrigger = 15.0f;
spells[0].attackstoptimer = 1000;
}
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();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
//Mekgineer Steamrigger
#define CN_MEKGINEER_STEAMRIGGER 17796
#define SUPER_SHRINK_RAY 31485
#define SAW_BLADE 31486 // Or this: 35318
#define ELECTRIFIED_NET 35107
#define ENRAGE 41447 // No idea if these are good ids
// Must spawn 3 Steamrigger Mechanics when his health is on 75%, 50% and 25%
class MEKGINEERSTEAMRIGGERAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(MEKGINEERSTEAMRIGGERAI);
MEKGINEERSTEAMRIGGERAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 4;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(SUPER_SHRINK_RAY);
spells[0].targettype = TARGET_SELF;
spells[0].instant = true;
spells[0].perctrigger = 7.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = sSpellStore.LookupEntry(SAW_BLADE);
spells[1].targettype = TARGET_VARIOUS;
spells[1].instant = true;
spells[1].perctrigger = 15.0f;
spells[1].attackstoptimer = 1000;
spells[2].info = sSpellStore.LookupEntry(ELECTRIFIED_NET);
spells[2].targettype = TARGET_ATTACKING;
spells[2].instant = true;
spells[2].perctrigger = 18.0f;
spells[2].attackstoptimer = 1000;
spells[3].info = sSpellStore.LookupEntry(ENRAGE); //Should enrage after 5 minutes
spells[3].targettype = TARGET_SELF;
spells[3].instant = true;
spells[3].perctrigger = 2.0f;
spells[3].attackstoptimer = 1000;
}
void OnCombatStart(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your in for a World-O-Hurt !");
_unit->PlaySoundToSet(387898);
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)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Mommy");
_unit->PlaySoundToSet(388242);
RemoveAIUpdateEvent();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void OnTargetDied(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You just got served, Punk !");
_unit->PlaySoundToSet(388098);
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Hydromancer ThespiaAI
#define CN_HYDROMANCER_THESPIA 17797
#define ENVELOPING_WINDS 31718 // 1 target
#define LIGHTNING_CLOUD 25033 // various targets on not attacked.
#define LUNG_BURST 31481
class HYDROMANCERTHESPIAAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(HYDROMANCERTHESPIAAI);
HYDROMANCERTHESPIAAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 3;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(ENVELOPING_WINDS);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].perctrigger = 14.0f;
spells[0].attackstoptimer = 2500;
spells[1].info = sSpellStore.LookupEntry(LIGHTNING_CLOUD);
spells[1].targettype = TARGET_DESTINATION;
spells[1].instant = true;
spells[1].perctrigger = 6.0f;
spells[1].attackstoptimer = 1500;
spells[2].info = sSpellStore.LookupEntry(LUNG_BURST);
spells[2].targettype = TARGET_ATTACKING;
spells[2].instant = true;
spells[2].perctrigger = 10.0f;
spells[2].attackstoptimer = 1000;
}
void OnCombatStart(Unit* mTarget)
{
RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
}
void OnCombatStop(Unit *mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "The depts will consume you !");
_unit->PlaySoundToSet(10372);
_unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
_unit->GetAIInterface()->SetAIState(STATE_IDLE);
RemoveAIUpdateEvent();
}
void OnDied(Unit * mKiller)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Our matron will be ... The end of you all");
_unit->PlaySoundToSet(10372);
RemoveAIUpdateEvent();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void OnTargetDied(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "To the depts of oblivion with you !");
_unit->PlaySoundToSet(387684);
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
// Warlord Kalitresh AI
#define CN_WARLORD_KALITRESH 17798
#define IMPALE 24049 // 1 target Correct spell id? Maybe 34451 or ...
#define HEAD_CRACK 16172 // 1 target <--- does he really has that spell?
#define WARLORDS_RAGE 36453
#define SPELL_REFLECTION 33961
//more spells to add
class WARLORDKALITRESHAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(WARLORDKALITRESHAI);
WARLORDKALITRESHAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 4;
m_spellcheck = new bool[nrspells];
spells = new SP_AI_Spell[nrspells];
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = sSpellStore.LookupEntry(IMPALE);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = false;
spells[0].perctrigger = 20.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = sSpellStore.LookupEntry(HEAD_CRACK);
spells[1].targettype = TARGET_ATTACKING;
spells[1].instant = false;
spells[1].perctrigger = 15.0f;
spells[1].attackstoptimer = 2000;
spells[2].info = sSpellStore.LookupEntry(WARLORDS_RAGE); // Needs to add check if rage is already on Warlord
spells[2].targettype = TARGET_SELF;
spells[2].instant = true;
spells[2].perctrigger = 2.0f;
spells[2].attackstoptimer = 1000;
spells[3].info = sSpellStore.LookupEntry(SPELL_REFLECTION);
spells[3].targettype = TARGET_SELF;
spells[3].instant = true;
spells[3].perctrigger = 10.0f;
spells[3].attackstoptimer = 1000;
}
void OnCombatStart(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your head will roll !");
_unit->PlaySoundToSet(389079);
RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
}
void OnCombatStop(Unit *mTarget)
{
_unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
_unit->GetAIInterface()->SetAIState(STATE_IDLE);
RemoveAIUpdateEvent();
}
void OnTargetDied(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Squirm , Surface filth !");
_unit->PlaySoundToSet(388962);
}
void OnDied(Unit * mKiller)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "For her exelencty , For Vash...");
_unit->PlaySoundToSet(389285);
RemoveAIUpdateEvent();
delete[] spells;
delete[] m_spellcheck;
spells = NULL;
m_spellcheck = NULL;
}
void AIUpdate()
{
float val = sRand.rand(100.0f);
SpellCast(val);
}
void SpellCast(float val)
{
if(m_spellcheck && spells && _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_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;
}
}
}
protected:
bool *m_spellcheck;
SP_AI_Spell *spells;
int nrspells;
};
void SetupSteamVaults(ScriptMgr * mgr)
{
mgr->register_creature_script(CN_COILFANG_ORACLE, &COILFANGORACLEAI::Create);
mgr->register_creature_script(CN_COILFANG_ENGINEER, &COILFANGENGINEERAI::Create);
//mgr->register_creature_script(CN_Coilfang_sorceress, &CoilfangsorceressAI::Create);
mgr->register_creature_script(CN_COILFANG_WARRIOR, &COILFANGWARRIORAI::Create);
mgr->register_creature_script(CN_COILFANG_SIREN, &COILFANGSIRENAI::Create);
mgr->register_creature_script(CN_HYDROMANCER_THESPIA, &HYDROMANCERTHESPIAAI::Create);
mgr->register_creature_script(CN_WARLORD_KALITRESH, &WARLORDKALITRESHAI::Create);
mgr->register_creature_script(CN_BOG_OVERLORD, &BOGOVERLORDAI::Create);
mgr->register_creature_script(CN_COILFANG_WATER_ELEMENTAL, &COILFANGWATERELEMENTALAI::Create);
mgr->register_creature_script(CN_MEKGINEER_STEAMRIGGER, &MEKGINEERSTEAMRIGGERAI::Create);
}