From 15fe47e0cb3cd7f84d4a3b2c112efca1e60b23cb Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 4 Sep 2023 07:22:22 -0400 Subject: [PATCH] Core/Unit: Added helper functions to modify UNIT_FLAG2_CANNOT_TURN Port From (https://github.com/TrinityCore/TrinityCore/commit/53f9abec14613c0823b1ee5363b3f873cc23ece9) --- Source/Game/Entities/Creature/Creature.cs | 6 +++--- Source/Game/Entities/Unit/Unit.Combat.cs | 12 +++++++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index ee47d7be4..e85aafa7e 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -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()) { diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index 0090e735b..e2c33978a 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -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(); }