Hey,
i have heared that the most TC2 devs think that:
Although smartAI and eventAI is convenient to insert generic data via sniffer, but the readability of it is totaly #$%^, thats why TC2 (actually the developer of SmartAI) want to get away from it.
I now do some structurs for scripting normal Trash NPCs via C++ scripts. But i could need some help doing this.
Archer
Video example: https://www.youtube.com/watch?v=gXn7HRgYe1c
At 1:08
Description:
The NPC xyz is starting whith a range weapon in his main hand. When getting Infight he only starts with shooting and dont move. When the Tank gets in Melee Range he switch to melee mode. He gets other weapons and start chasing. If he get stunned and the tank is away again he stops moving and start shooting again.
#define SPELL_SHOOT
#define SPELL_MELEE
struct mob_archerAI : public ScriptedAI
{
mob_archerAI(Creature* c) : ScriptedAI(c) {}
uint32 Check_Timer;
uint32 Shoot_Timer;
bool InMeleeRange
void Reset()
{
Check_Timer = 1000;
Shoot_Timer = 2000;
}
void EnterCombat(Unit* /*who*/)
{
InMeleeRange = false;
}
void UpdateAI(const uint32 diff)
{
if(!UpdateVictim())
return;
if(Check_Timer < diff)
{
Unit *target;
std::list<HostilReference *> t_list = me->getThreatManager().getThreatList();
for(std::list<HostilReference *>::iterator itr = t_list.begin(); itr!= t_list.end(); ++itr)
{
target = Unit::GetUnit(*me, (*itr)->getUnitGuid());
//if in melee range
if(target && target->IsWithinDistInMap(me, 5))
{
InMeleeRange = true;
break;
}
}
Check_Timer = 1000;
}else Check_Timer -= diff;
// If in Melee Range, Melee AI
if(InMeleeRange)
{
me->GetMotionMaster()->MoveChase(me->getVictim());
}
else if(!InMeleeRange)
{
me->GetMotionMaster()->MoveIdle();
if(Shoot_Timer < diff)
{
DoCast(me->getVictim(), SPELL_SHOOT);
Shoot_Timer = 2000;
}else Shoot_Timer -= diff;
}
DoMeleeAttackIfReady();
}
};