mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-22 13:16:23 +00:00
fix(Core/Creatures): Critters should start fleeing upon entering comb… (#14253)
This commit is contained in:
@@ -18131,7 +18131,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::SetControlled(bool apply, UnitState state)
|
||||
void Unit::SetControlled(bool apply, UnitState state, Unit* source /*= nullptr*/, bool isFear /*= false*/)
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
@@ -18164,7 +18164,7 @@ void Unit::SetControlled(bool apply, UnitState state)
|
||||
ClearUnitState(UNIT_STATE_MELEE_ATTACKING);
|
||||
SendMeleeAttackStop();
|
||||
// SendAutoRepeatCancel ?
|
||||
SetFeared(true);
|
||||
SetFeared(true, source, isFear);
|
||||
CastStop(0, false);
|
||||
}
|
||||
break;
|
||||
@@ -18234,7 +18234,21 @@ void Unit::SetControlled(bool apply, UnitState state)
|
||||
if (HasUnitState(UNIT_STATE_CONFUSED) || HasAuraType(SPELL_AURA_MOD_CONFUSE))
|
||||
SetConfused(true);
|
||||
else if (HasUnitState(UNIT_STATE_FLEEING) || HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
SetFeared(true);
|
||||
{
|
||||
bool isFear = false;
|
||||
if (HasAuraType(SPELL_AURA_MOD_FEAR))
|
||||
{
|
||||
isFear = true;
|
||||
source = ObjectAccessor::GetUnit(*this, GetAuraEffectsByType(SPELL_AURA_MOD_FEAR).front()->GetCasterGUID());
|
||||
}
|
||||
|
||||
if (!source)
|
||||
{
|
||||
source = getAttackerForHelper();
|
||||
}
|
||||
|
||||
SetFeared(true, source, isFear);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18369,19 +18383,12 @@ void Unit::DisableRotate(bool apply)
|
||||
RemoveUnitFlag(UNIT_FLAG_POSSESSED);
|
||||
}
|
||||
|
||||
void Unit::SetFeared(bool apply)
|
||||
void Unit::SetFeared(bool apply, Unit* fearedBy /*= nullptr*/, bool isFear /*= false*/)
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
SetTarget();
|
||||
|
||||
Unit* caster = nullptr;
|
||||
Unit::AuraEffectList const& fearAuras = GetAuraEffectsByType(SPELL_AURA_MOD_FEAR);
|
||||
if (!fearAuras.empty())
|
||||
caster = ObjectAccessor::GetUnit(*this, fearAuras.front()->GetCasterGUID());
|
||||
if (!caster)
|
||||
caster = getAttackerForHelper();
|
||||
GetMotionMaster()->MoveFleeing(caster, fearAuras.empty() ? sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY) : 0); // caster == nullptr processed in MoveFleeing
|
||||
GetMotionMaster()->MoveFleeing(fearedBy, isFear ? 0 : sWorld->getIntConfig(CONFIG_CREATURE_FAMILY_FLEE_DELAY));
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
|
||||
@@ -2280,7 +2280,7 @@ public:
|
||||
[[nodiscard]] uint16 GetExtraUnitMovementFlags() const { return m_movementInfo.flags2; }
|
||||
void SetExtraUnitMovementFlags(uint16 f) { m_movementInfo.flags2 = f; }
|
||||
|
||||
void SetControlled(bool apply, UnitState state);
|
||||
void SetControlled(bool apply, UnitState state, Unit* source = nullptr, bool isFear = false);
|
||||
void DisableRotate(bool apply);
|
||||
void DisableSpline();
|
||||
|
||||
@@ -2557,7 +2557,7 @@ private:
|
||||
[[nodiscard]] uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const;
|
||||
|
||||
protected:
|
||||
void SetFeared(bool apply);
|
||||
void SetFeared(bool apply, Unit* fearedBy = nullptr, bool isFear = false);
|
||||
void SetConfused(bool apply);
|
||||
void SetStunned(bool apply);
|
||||
void SetRooted(bool apply, bool isStun = false);
|
||||
|
||||
Reference in New Issue
Block a user