Public feed
#887053
/*
* Sean++ Scripts for Ascent MMORPG Server
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/#include "StdAfx.h"
#include "Setup.h"
#define CN_KAMYN 52005
#define DRAIN_LIFE 38817/////
#define CHAIN_LIGHTNING 32337/////
#define WHIRLWIND 33239
#define GROWTH 36300
#define DARK_DECAY 33129/////
#define FLAME_SHOCK 43303/////
#define ENRAGE 39249
class KamynAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(KamynAI);
SP_AI_Spell spells[7];
bool m_spellcheck[7];
KamynAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 7;
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
}
spells[0].info = dbcSpell.LookupEntry(DRAIN_LIFE);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].perctrigger = 10.0f;
spells[0].attackstoptimer = 1000;
spells[1].info = dbcSpell.LookupEntry(DARK_DECAY);
spells[1].targettype = TARGET_ATTACKING;
spells[1].instant = true;
spells[1].perctrigger = 12.0f;
spells[1].attackstoptimer = 1000;
spells[2].info = dbcSpell.LookupEntry(CHAIN_LIGHTNING);
spells[2].targettype = TARGET_ATTACKING;
spells[2].instant = true;
spells[2].cooldown = 8;
spells[2].perctrigger = 0.0f;
spells[2].attackstoptimer = 1000;
spells[3].info = dbcSpell.LookupEntry(FLAME_SHOCK);
spells[3].targettype = TARGET_ATTACKING;
spells[3].instant = true;
spells[3].cooldown = 30;
spells[3].perctrigger = 0.0f;
spells[3].attackstoptimer = 1000;
spells[4].info = dbcSpell.LookupEntry(GROWTH);
spells[4].targettype = TARGET_SELF;
spells[4].instant = true;
spells[4].cooldown = 58;
spells[4].perctrigger = 0.0f;
spells[4].attackstoptimer = 1000;
spells[5].info = dbcSpell.LookupEntry(WHIRLWIND);
spells[5].targettype = TARGET_ATTACKING;
spells[5].instant = true;
spells[5].cooldown = 60;
spells[5].perctrigger = 0.0f;
spells[5].attackstoptimer = 1000;
spells[6].info = dbcSpell.LookupEntry(ENRAGE);
spells[6].targettype = TARGET_SELF;
spells[6].instant = true;
spells[6].cooldown = 480;
spells[6].perctrigger = 0.0f;
spells[6].attackstoptimer = 1000;
}
void OnCombatStart(Unit* mTarget)
{
CastTime();
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "How dare you step into my Lair with your ignorance? I am disgusted by your sight! Your efforts are completely useless and will accomplish nothing! You cannot afford to be owned as hard as you are preparing yourself to be! Back Down!");
RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
}
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, "It cannot be possible! How could you.. I don't.. But it.. Can't... Aghhh!");
///_unit->PlaySoundToSet(11327);
RemoveAIUpdateEvent();
}
void OnTargetDied(Unit* mTarget)
{
if (_unit->GetHealthPct() > 0)
{
int RandomSpeach;
RandomUInt(1000);
RandomSpeach=rand()%5;
switch (RandomSpeach)
{
case 0:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You are pathetic!");
/////_unit->PlaySoundToSet(11023);
break;
case 1:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Your efforts amuse me!");
////_unit->PlaySoundToSet(11055);
break;
case 2:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Did you actually think you stood a chance against your creator?");
/////_unit->PlaySoundToSet(11025);
break;
case 3:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You have underestimated my power.. How clumsy of you!");
////_unit->PlaySoundToSet(11056);
break;
case 4:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "I never fail!");
////_unit->PlaySoundToSet(11057);
break;
case 5:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You shall not succeed!");
////_unit->PlaySoundToSet(11057);
break;
case 6:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "You do not understand what you are fooling with!");
////_unit->PlaySoundToSet(11057);
break;
case 7:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Back Down!");
////_unit->PlaySoundToSet(11057);
break;
case 8:
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Submit!");
////_unit->PlaySoundToSet(11057);
break;
}
}
}
void AIUpdate()
{
float val = (float)RandomFloat(100.0f);
SpellCast(val);
}
void CastTime()
{
for(int i=0;i<nrspells;i++)
spells[i].casttime = spells[i].cooldown;
}
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;
}
if (spells[i].speech != "")
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, spells[i].speech.c_str());
_unit->PlaySoundToSet(spells[i].soundid);
}
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 SetupKamynsLair(ScriptMgr * mgr)
{
mgr->register_creature_script(CN_KAMYN, &KamynAI::Create);
}