diff options
author | maximius <none@none> | 2009-09-27 19:11:52 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-09-27 19:11:52 -0700 |
commit | 15dbc456bb973e9a9e427470ba3b8a2f90a55d21 (patch) | |
tree | 4a3c7885819bc61ccb7343ae6625b0764da505ce /src/game/Unit.cpp | |
parent | 2c14426c76e1d27dd9e3dd8e2397ab3453360940 (diff) |
*If our target of choice is attacking a player, only attack our target if we are friendly towards that player.
*Only regenerate quickly if polymorphed.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 0d45ed36457..a05cc8929ea 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -11344,7 +11344,7 @@ Unit* Creature::SelectVictim() else return NULL; - if(target) + if(target && (!target->isAttackingPlayer() || IsFriendlyTo(target->getVictim()))) // if the victim of target is a player, only defend the victim if we are friendly { SetInFront(target); return target; @@ -11356,7 +11356,9 @@ Unit* Creature::SelectVictim() // Note: creature not have targeted movement generator but have attacker in this case for(AttackerSet::const_iterator itr = m_attackers.begin(); itr != m_attackers.end(); ++itr) { - if(canCreatureAttack(*itr) && ((*itr)->GetTypeId() != TYPEID_PLAYER && (!((Creature*)(*itr))->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN)))) + if(canCreatureAttack(*itr) && (*itr)->GetTypeId() != TYPEID_PLAYER + && !((Creature*)(*itr))->HasUnitTypeMask(UNIT_MASK_CONTROLABLE_GUARDIAN) + && (!(*itr)->isAttackingPlayer() || IsFriendlyTo(target->getVictim()))) // if the victim of target is a player, only defend the victim if we are friendly return NULL; } @@ -11367,7 +11369,8 @@ Unit* Creature::SelectVictim() // search nearby enemy before enter evade mode if(HasReactState(REACT_AGGRESSIVE)) if(target = SelectNearestTarget()) - return target; + if(!target->isAttackingPlayer() || IsFriendlyTo(target->getVictim())) // if the victim of target is a player, only defend the victim if we are friendly + return target; if(m_invisibilityMask) { |