diff options
author | megamage <none@none> | 2009-01-28 20:16:11 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-01-28 20:16:11 -0600 |
commit | 30c5bff102bc089bcc18677352bf506ac0219111 (patch) | |
tree | e06486f994a3b64ee6f971d495c5230e5b5ab6d4 /src/game/Unit.cpp | |
parent | 3a229014dca17012b623d5d4524ba8a5e069822f (diff) |
*Fix critter AI.
*Some AI structure change.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0296f7ceb4d..b2e214f915e 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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 |