feat(core): Ensure that all actions are compared to fixed point in time (#1236) (#1458)

i.e. world update start
This commit is contained in:
Viste(Кирилл)
2019-02-14 21:22:17 +03:00
committed by Francesco Borzì
parent 1b7522ff0e
commit 51b8773528
108 changed files with 933 additions and 509 deletions

View File

@@ -9,6 +9,7 @@
#include "Pet.h"
#include "Player.h"
#include "DBCStores.h"
#include "GameTime.h"
#include "Spell.h"
#include "ObjectAccessor.h"
#include "SpellMgr.h"
@@ -51,7 +52,7 @@ bool PetAI::_needToStop()
if (!me->_CanDetectFeignDeathOf(me->GetVictim()))
return true;
if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), sWorld->GetGameTime(), me->GetVictim()))
if (me->isTargetNotAcceptableByMMaps(me->GetVictim()->GetGUID(), GameTime::GetGameTime(), me->GetVictim()))
return true;
return !me->CanCreatureAttack(me->GetVictim());
@@ -433,7 +434,7 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
// Check pet attackers first so we don't drag a bunch of targets to the owner
if (Unit* myAttacker = me->getAttackerForHelper())
if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), sWorld->GetGameTime(), myAttacker))
if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(myAttacker) && me->CanCreatureAttack(myAttacker) && !me->isTargetNotAcceptableByMMaps(myAttacker->GetGUID(), GameTime::GetGameTime(), myAttacker))
return myAttacker;
// Check pet's attackers first to prevent dragging mobs back to owner
@@ -454,13 +455,13 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
// Check owner attackers
if (Unit* ownerAttacker = owner->getAttackerForHelper())
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), sWorld->GetGameTime(), ownerAttacker))
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker) && !me->isTargetNotAcceptableByMMaps(ownerAttacker->GetGUID(), GameTime::GetGameTime(), ownerAttacker))
return ownerAttacker;
// Check owner victim
// 3.0.2 - Pets now start attacking their owners victim in defensive mode as soon as the hunter does
if (Unit* ownerVictim = owner->GetVictim())
if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), sWorld->GetGameTime(), ownerVictim))
if (me->_CanDetectFeignDeathOf(ownerVictim) && me->CanCreatureAttack(ownerVictim) && !me->isTargetNotAcceptableByMMaps(ownerVictim->GetGUID(), GameTime::GetGameTime(), ownerVictim))
return ownerVictim;
// Neither pet or owner had a target and aggressive pets can pick any target