Core/Unit: Added helper functions to modify UNIT_FLAG2_CANNOT_TURN

Port From (https://github.com/TrinityCore/TrinityCore/commit/53f9abec14613c0823b1ee5363b3f873cc23ece9)
This commit is contained in:
hondacrx
2023-09-04 07:22:22 -04:00
parent 8bf185f071
commit 15fe47e0cb
2 changed files with 14 additions and 4 deletions
+3 -3
View File
@@ -3137,7 +3137,7 @@ namespace Game.Entities
_spellFocusInfo.Spell = focusSpell;
bool noTurnDuringCast = spellInfo.HasAttribute(SpellAttr5.AiDoesntFaceTarget);
bool turnDisabled = HasUnitFlag2(UnitFlags2.CannotTurn);
bool turnDisabled = CannotTurn();
// set target, then force send update packet to players if it changed to provide appropriate facing
ObjectGuid newTarget = (target != null && !noTurnDuringCast && !turnDisabled) ? target.GetGUID() : ObjectGuid.Empty;
if (GetTarget() != newTarget)
@@ -3181,7 +3181,7 @@ namespace Game.Entities
if (IsPet()) // player pets do not use delay system
{
if (!HasUnitFlag2(UnitFlags2.CannotTurn))
if (!CannotTurn())
ReacquireSpellFocusTarget();
}
else // don't allow re-target right away to prevent visual bugs
@@ -3200,7 +3200,7 @@ namespace Game.Entities
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Target), _spellFocusInfo.Target);
if (!HasUnitFlag2(UnitFlags2.CannotTurn))
if (!CannotTurn())
{
if (!_spellFocusInfo.Target.IsEmpty())
{
+11 -1
View File
@@ -684,7 +684,17 @@ namespace Game.Entities
}
}
bool IsThreatened()
public bool CannotTurn() { return HasUnitFlag2(UnitFlags2.CannotTurn); }
public void SetCannotTurn(bool apply)
{
if (apply)
SetUnitFlag2(UnitFlags2.CannotTurn);
else
RemoveUnitFlag2(UnitFlags2.CannotTurn);
}
public bool IsThreatened()
{
return !m_threatManager.IsThreatListEmpty();
}