chaosnight
Would you like to react to this message? Create an account in a few clicks or log in to continue.
chaosnight

Rednightwow Forums
 
HomeHome  Latest imagesLatest images  SearchSearch  RegisterRegister  Log in  

 

 Sharrior boss script

Go down 
2 posters
AuthorMessage
Swanitalia
Admin
Admin
Swanitalia


Posts : 161
Join date : 2008-09-22
Location : I dont know

Sharrior boss script Empty
PostSubject: Sharrior boss script   Sharrior boss script Icon_minitimeThu Nov 13, 2008 10:31 am

made this yesterday:

/***********************************************************************
* Sharrior.ccp writen by: Swanitalia *
***********************************************************************/



/* Sharrior AI - Creature AI Class */

#define CN_Sharrior # //not maded yet

#define CONSECRATION 20924
#define CLEANSING 53659
#define HOLY_SHOCK 27174
#define DIVINE 642

class SharriorAI : public CreatureAIScript
{
public:
ADD_CREATURE_FACTORY_FUNCTION(SharriorAI);
SP_AI_Spell spells[4];
bool m_spellcheck[4];

SharriorAI(Creature* pCreature) : CreatureAIScript(pCreature)
{
nrspells = 3;
for(int i=0;i<nrspells;i++)
{
m_spellcheck[i] = false;
spells[i].casttime = 0;
}

spells[0].info = dbcSpell.LookupEntry(CONSECRATION);
spells[0].targettype = TARGET_ATTACKING;
spells[0].instant = true;
spells[0].cooldown = 30;
spells[0].perctrigger = 7.0f;
spells[0].attackstoptimer = 1000;

spells[1].info = dbcSpell.LookupEntry(CLEANSING);
spells[1].targettype = TARGET_SELF;
spells[1].instant = true;
spells[1].cooldown = 35;
spells[1].prectrigger = 13.0f;
spells[1].attackstoptimer = 1000;

spells[2].info = dbcSpell.LookupEntry(HOLY_SHOCK);
spells[2].targettype = TARGET_ATTACKING;
spells[2].instant = true;
spells[2].cooldown = 15;
spells[2].prectrigger = 20.0f;
spells[2].attackstoptimer = 1000;

spells[3].info = dbcSpell.LookupEntry(DIVINE);
spells[3].targettype = TARGET_SELF;
spells[3].instant = true;
spells[3].cooldown = 60;

_unit->m_noRespawn = true;
}

void OnCombatStart(Unit* mTarget)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Deadswan, I will not let you down!!");
RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME));
}

void OnCombatStop(Unit *mTarget)
{
_unit->GetAIInterface()->setCurrentAgent(AGENT_NULL);
_unit->GetAIInterface()->SetAIState(STATE_IDLE);
RemoveAIUpdateEvent();

for (int i = 0; i < nrspells; i++)
spells[i].casttime = 0;
}

void OnDied(Unit * mKiller)
{
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Deadswan I failed you!!");
RemoveAIUpdateEvent();
FoADeaths[_unit->GetInstanceID()]--;
}

void AIUpdate()
{
if (_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())
{
Unit *target = NULL;
target = _unit->GetAIInterface()->GetNextTarget();

if (_unit->GetDistance2dSq(target) >= 20.0f && _unit->GetDistance2dSq(target) <= 1225 && rand()%5 == 0) // I must test this value (15-35yards for now)
{
_unit->CastSpell(target, spells[0].info, spells[0].instant);
_unit->CastSpell(target, spells[1].info, spells[1].instant);
_unit->CastSpell(target, spells[2].info, spells[2].instant);

if(_unit->GetHealthPct() == 20)
{
_unit->CastSpell(target, spells[3].info, spells[3].instant);
}

}
}
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++)
{
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;
}

uint32 t = (uint32)time(NULL);
if(val > comulativeperc && val <= (comulativeperc + spells[i].perctrigger) && t > spells[i].casttime)
{
_unit->setAttackTimer(spells[i].attackstoptimer, false);
spells[i].casttime = t + spells[i].cooldown;
m_spellcheck[i] = true;
}
comulativeperc += spells[i].perctrigger;
}
}
}

protected:

int nrspells;
};
Back to top Go down
http://rednight.selfip.net
sharrior
GM
GM
sharrior


Posts : 78
Join date : 2008-09-25
Age : 28
Location : Norway

Sharrior boss script Empty
PostSubject: Re: Sharrior boss script   Sharrior boss script Icon_minitimeThu Nov 13, 2008 11:13 am

nice,understand a little bit of it Razz


Last edited by sharrior on Fri Nov 06, 2009 7:29 pm; edited 2 times in total
Back to top Go down
Swanitalia
Admin
Admin
Swanitalia


Posts : 161
Join date : 2008-09-22
Location : I dont know

Sharrior boss script Empty
PostSubject: Re: Sharrior boss script   Sharrior boss script Icon_minitimeThu Nov 13, 2008 11:14 am

this is what i have to add to deadswan's script:




void SummonSharrior(Unit* mTarget)
{
Summoned = _unit->GetMapMgr()->GetInterface()->SpawnCreature(CN_SHARRIOR, mTarget->GetPositionX(), mTarget->GetPositionY(), mTarget->GetPositionZ(), 0,true, false, _unit->GetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE), 50);
Summoned->GetAIInterface()->SetNextTarget(mTarget);
}



if (_unit->GetHealthPct() == 40)
{
//Inturrupt any spell casting
_unit->InterruptSpell();
//Root self
_unit->CastSpell(_unit, 23973, true);
_unit->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, 35);
//_unit->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);

//Summon sharrior
SummonSharrior(_unit->GetAIInterface()->GetNextTarget());
_unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Sharrior come and take care of these pests, I dont feel like using anymore power");
}


Creature* Summoned;
Back to top Go down
http://rednight.selfip.net
Swanitalia
Admin
Admin
Swanitalia


Posts : 161
Join date : 2008-09-22
Location : I dont know

Sharrior boss script Empty
PostSubject: Re: Sharrior boss script   Sharrior boss script Icon_minitimeThu Nov 13, 2008 11:14 am

just a little bit more
u should checkout the WotLK 2do list
Back to top Go down
http://rednight.selfip.net
Sponsored content





Sharrior boss script Empty
PostSubject: Re: Sharrior boss script   Sharrior boss script Icon_minitime

Back to top Go down
 
Sharrior boss script
Back to top 
Page 1 of 1
 Similar topics
-
» sharrior boss script made by sharrior
» Sharrior's introducing himself.
» 2 lua bosses made by sharrior
» New problem(not server side) ~sharrior~
» anuthar lua script

Permissions in this forum:You cannot reply to topics in this forum
chaosnight :: Rednight server forums :: Coding-
Jump to: