refactor(Core): Clean-up after FD (#8586)

This commit is contained in:
patou01
2021-11-28 07:04:14 +01:00
committed by GitHub
parent 1a27f606f1
commit 801a20fce2
10 changed files with 20 additions and 25 deletions

View File

@@ -57,9 +57,6 @@ bool PetAI::_needToStop()
if (owner->GetExactDist(me) >= (owner->GetVisibilityRange() - 10.0f))
return true;
if (!me->_CanDetectFeignDeathOf(me->GetVictim()))
return true;
return !me->CanCreatureAttack(me->GetVictim());
}
@@ -472,7 +469,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))
if (!myAttacker->HasBreakableByDamageCrowdControlAura() && me->CanCreatureAttack(myAttacker))
return myAttacker;
// Check pet's attackers first to prevent dragging mobs back to owner
@@ -482,7 +479,7 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
if (!tauntAuras.empty())
for (Unit::AuraEffectList::const_reverse_iterator itr = tauntAuras.rbegin(); itr != tauntAuras.rend(); ++itr)
if (Unit* caster = (*itr)->GetCaster())
if (me->_CanDetectFeignDeathOf(caster) && me->CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, me->GetGUID()))
if (me->CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, me->GetGUID()))
return caster;
}
@@ -493,13 +490,13 @@ Unit* PetAI::SelectNextTarget(bool allowAutoSelect) const
// Check owner attackers
if (Unit* ownerAttacker = owner->getAttackerForHelper())
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->_CanDetectFeignDeathOf(ownerAttacker) && me->CanCreatureAttack(ownerAttacker))
if (!ownerAttacker->HasBreakableByDamageCrowdControlAura() && me->CanCreatureAttack(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))
if (me->CanCreatureAttack(ownerVictim))
return ownerVictim;
// Neither pet or owner had a target and aggressive pets can pick any target

View File

@@ -318,7 +318,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
if (currentVictim)
{
Unit* cvUnit = currentVictim->getTarget();
if (!attacker->_CanDetectFeignDeathOf(cvUnit) || !attacker->CanCreatureAttack(cvUnit)) // pussywizard: if currentVictim is not valid => don't compare the threat with it, just take the highest threat valid target
if (!attacker->CanCreatureAttack(cvUnit)) // pussywizard: if currentVictim is not valid => don't compare the threat with it, just take the highest threat valid target
currentVictim = nullptr;
else if (cvUnit->IsImmunedToDamageOrSchool(attacker->GetMeleeDamageSchoolMask()) || cvUnit->HasNegativeAuraWithInterruptFlag(AURA_INTERRUPT_FLAG_TAKE_DAMAGE)) // pussywizard: no 10%/30% if currentVictim is immune to damage or has auras breakable by damage
currentVictim = nullptr;
@@ -353,7 +353,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* attacker, HostileR
}
// pussywizard: skip not valid targets
if (attacker->_CanDetectFeignDeathOf(target) && attacker->CanCreatureAttack(target))
if (attacker->CanCreatureAttack(target))
{
if (currentVictim) // pussywizard: if not nullptr then target must have 10%/30% more threat
{

View File

@@ -2351,13 +2351,6 @@ bool Creature::_IsTargetAcceptable(const Unit* target) const
return false;
}
bool Creature::_CanDetectFeignDeathOf(const Unit* target) const
{
if (target->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH))
return IsGuard();
return true;
}
void Creature::UpdateMoveInLineOfSightState()
{
// xinef: pets, guardians and units with scripts / smartAI should be skipped
@@ -2423,6 +2416,12 @@ bool Creature::CanCreatureAttack(Unit const* victim, bool skipDistCheck) const
return false;
}
// if victim is in FD and we can't see that
if (victim->HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_FEIGN_DEATH) && !CanIgnoreFeignDeath())
{
return false;
}
if (!GetCharmerOrOwnerGUID().IsPlayer())
{
if (GetMap()->IsDungeon())

View File

@@ -255,7 +255,6 @@ public:
bool CanAssistTo(const Unit* u, const Unit* enemy, bool checkfaction = true) const;
bool _IsTargetAcceptable(const Unit* target) const;
bool CanIgnoreFeignDeath() const { return (GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_IGNORE_FEIGN_DEATH) != 0; }
bool _CanDetectFeignDeathOf(const Unit* target) const; // pussywizard
// pussywizard: updated at faction change, disable move in line of sight if actual faction is not hostile to anyone
void UpdateMoveInLineOfSightState();

View File

@@ -13917,7 +13917,7 @@ Unit* Creature::SelectVictim()
if (!tauntAuras.empty())
for (Unit::AuraEffectList::const_reverse_iterator itr = tauntAuras.rbegin(); itr != tauntAuras.rend(); ++itr)
if (Unit* caster = (*itr)->GetCaster())
if (_CanDetectFeignDeathOf(caster) && CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, GetGUID()))
if (CanCreatureAttack(caster) && !caster->HasAuraTypeWithCaster(SPELL_AURA_IGNORED, GetGUID()))
{
target = caster;
break;
@@ -13950,7 +13950,7 @@ Unit* Creature::SelectVictim()
else
return nullptr;
if (target && _CanDetectFeignDeathOf(target) && CanCreatureAttack(target))
if (target && CanCreatureAttack(target))
{
SetInFront(target);
return target;

View File

@@ -581,7 +581,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
// pussywizard (excluded charmed)
if (!pet->IsCharmed())
if (Creature* creaturePet = pet->ToCreature())
if (!creaturePet->_CanDetectFeignDeathOf(TargetUnit) || !creaturePet->CanCreatureAttack(TargetUnit))
if (!creaturePet->CanCreatureAttack(TargetUnit))
return;
// Not let attack through obstructions