*AI structure update.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-01-30 18:10:05 -06:00
parent 03234a0657
commit 8fee06f041
266 changed files with 460 additions and 598 deletions

View File

@@ -38,29 +38,10 @@ AggressorAI::Permissible(const Creature *creature)
return PERMIT_BASE_NO;
}
AggressorAI::AggressorAI(Creature *c) : i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK)
AggressorAI::AggressorAI(Creature *c) : CreatureAI(c), i_creature(*c), i_victimGuid(0), i_state(STATE_NORMAL), i_tracker(TIME_INTERVAL_LOOK)
{
}
void
AggressorAI::MoveInLineOfSight(Unit *u)
{
if(!i_creature.getVictim() && i_creature.canStartAttack(u))
AttackStart(u);
/*
if(!i_creature.getVictim())
{
AttackStart(u);
}
else if(sMapStore.LookupEntry(i_creature.GetMapId())->IsDungeon())
{
u->SetInCombatWith(&i_creature);
i_creature.AddThreat(u, 0.0f);
}
*/
}
void AggressorAI::EnterEvadeMode()
{
if( !i_creature.isAlive() )
@@ -118,7 +99,7 @@ void
AggressorAI::UpdateAI(const uint32 /*diff*/)
{
// update i_victimGuid if i_creature.getVictim() !=0 and changed
if(!i_creature.SelectHostilTarget() || !i_creature.getVictim())
if(!UpdateVictim())
return;
i_victimGuid = i_creature.getVictim()->GetGUID();
@@ -132,26 +113,3 @@ AggressorAI::UpdateAI(const uint32 /*diff*/)
}
}
}
bool
AggressorAI::IsVisible(Unit *pl) const
{
return i_creature.GetDistance(pl) < sWorld.getConfig(CONFIG_SIGHT_MONSTER)
&& pl->isVisibleForOrDetect(&i_creature,true);
}
void
AggressorAI::AttackStart(Unit *u)
{
if( !u )
return;
if(i_creature.Attack(u,true))
{
i_creature.AddThreat(u, 0.0f);
// DEBUG_LOG("Creature %s tagged a victim to kill [guid=%u]", i_creature.GetName(), u->GetGUIDLow());
i_victimGuid = u->GetGUID();
i_creature.GetMotionMaster()->MoveChase(u);
}
}