diff options
author | megamage <none@none> | 2009-04-13 18:03:28 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-04-13 18:03:28 -0500 |
commit | 25f71813c5666ad5105418601b5ea89e55f4516a (patch) | |
tree | 39d7de9965e865abd433ea1f02af27dea4c7f839 | |
parent | 6b11f9a511ac5893b93f693b5320e3a89bb5f349 (diff) |
*Update moveinLOS assistance code.
--HG--
branch : trunk
-rw-r--r-- | src/game/CreatureAI.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/game/CreatureAI.cpp b/src/game/CreatureAI.cpp index 9d9a3fc3a63..d21fe43fcaa 100644 --- a/src/game/CreatureAI.cpp +++ b/src/game/CreatureAI.cpp @@ -23,6 +23,7 @@ #include "Player.h" #include "Pet.h" #include "SpellAuras.h" +#include "World.h" void UnitAI::AttackStart(Unit *victim) { @@ -72,22 +73,15 @@ void CreatureAI::OnCharmed(bool apply) void CreatureAI::MoveInLineOfSight(Unit *who) { - if(!me->getVictim() && me->canStartAttack(who)) - AttackStart(who); + if(me->getVictim()) + return; - if (who->isInCombat() && who->getVictim() && me->GetCreatureType()==CREATURE_TYPE_HUMANOID && me->IsFriendlyTo(who)) - { - if (me->GetDistanceZ(who) <= 2 && me->IsWithinLOSInMap(who)) - { - float attackRadius = (me->GetAttackDistance(who) *0.5); - if (me->IsWithinDistInMap(who, attackRadius)) - { - Unit* target = NULL; - target = who->getVictim(); - AttackStart(target); - } - } - } + if(me->canStartAttack(who)) + AttackStart(who); + else if(who->getVictim() && me->IsFriendlyTo(who) + && me->IsWithinDistInMap(who, sWorld.getConfig(CONFIG_CREATURE_FAMILY_ASSISTANCE_RADIUS)) + && me->canAttack(who->getVictim())) + AttackStart(who->getVictim()); } bool CreatureAI::UpdateVictim() |