*Fix critter AI.

*Some AI structure change.

--HG--
branch : trunk
This commit is contained in:
megamage committed 2009-01-28 20:16:11 -06:00
1 parent 3a229014dc
commit 30c5bff102
21 files changed
+97 -53

No files matched your search

+12 -9
View File
@@ -650,9 +650,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
// no xp,health if type 8 /critters/
if ( pVictim->GetCreatureType() == CREATURE_TYPE_CRITTER)
{
// critters run away when hit
pVictim->GetMotionMaster()->MoveFleeing(this);
// allow loot only if has loot_id in creature_template
if(damage >= pVictim->GetHealth())
{
@@ -750,13 +747,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if(damagetype != DOT)
{
if(getVictim())
{
if(!getVictim())
/*{
// if have target and damage pVictim just call AI reaction
if(pVictim != getVictim() && pVictim->GetTypeId()==TYPEID_UNIT && ((Creature*)pVictim)->AI())
((Creature*)pVictim)->AI()->AttackedBy(this);
}
else
else*/
{
// if not have main target then attack state with target (including AI call)
//start melee attacks only after melee hit
@@ -8195,8 +8192,8 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
m_attacking = victim;
m_attacking->_addAttacker(this);
if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI())
((Creature*)m_attacking)->AI()->AttackedBy(this);
//if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->AI())
// ((Creature*)m_attacking)->AI()->AttackedBy(this);
if(GetTypeId()==TYPEID_UNIT)
{
@@ -12904,7 +12901,13 @@ void Unit::SetFeared(bool apply)
Unit::AuraList const& fearAuras = GetAurasByType(SPELL_AURA_MOD_FEAR);
if(!fearAuras.empty())
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
if(!caster) caster = getVictim();
if(!caster)
{
if(getVictim())
caster = getVictim();
else if(m_attackers.size())
caster = *m_attackers.begin();
}
GetMotionMaster()->MoveFleeing(caster); // caster==NULL processed in MoveFleeing
}
else