*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
This commit is contained in:
@@ -530,27 +530,26 @@ void Creature::Update(uint32 diff)
|
||||
break;
|
||||
|
||||
bool bIsPolymorphed = IsPolymorphed();
|
||||
bool bNotInCombat = !isInCombat() || getThreatManager().isThreatListEmpty() ||
|
||||
(getVictim() && getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() &&
|
||||
getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster());
|
||||
bool bControlledOrOwnedByPlayer = GetCharmerOrOwner() && GetCharmerOrOwner()->GetTypeId() == TYPEID_PLAYER;
|
||||
bool bInCombat = isInCombat() && (!getVictim() || // if isInCombat() is true and this has no victim
|
||||
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself() || // or the victim/owner/charmer is not a player
|
||||
!getVictim()->GetCharmerOrOwnerPlayerOrPlayerItself()->isGameMaster()); // or the victim/owner/charmer is not a GameMaster
|
||||
|
||||
if(m_regenTimer > diff && !bIsPolymorphed && // if polymorphed, skip the timer
|
||||
((bNotInCombat && bControlledOrOwnedByPlayer) || // if not in combat and a pet, do not skip the timer
|
||||
!bNotInCombat)) // if in combat, do not skip the timer
|
||||
if(m_regenTimer > diff && !bIsPolymorphed) // if polymorphed, skip the timer
|
||||
m_regenTimer -= diff;
|
||||
else
|
||||
{
|
||||
if(bNotInCombat || bIsPolymorphed) // regenerate health if not in combat or polymorphed
|
||||
if(!bInCombat || bIsPolymorphed) // regenerate health if not in combat or if polymorphed
|
||||
RegenerateHealth();
|
||||
|
||||
if(getPowerType() == POWER_ENERGY)
|
||||
{
|
||||
if(!IsVehicle() || GetVehicleKit()->GetVehicleInfo()->m_powerType != POWER_PYRITE)
|
||||
Regenerate(POWER_ENERGY);
|
||||
}
|
||||
else
|
||||
RegenerateMana();
|
||||
|
||||
if(!bNotInCombat && !bIsPolymorphed) // only increase the timer if not in combat and not polymorphed
|
||||
if(!bIsPolymorphed) // only increase the timer if not polymorphed
|
||||
m_regenTimer += 2000 - diff;
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user