From 00da79c7a93ac354d4e8147dfe459e53f9b93233 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 18 May 2021 13:45:37 -0400 Subject: [PATCH] Core/Unit: Abide UNIT_FLAG2_DISABLE_TURN on creatures. Port From (https://github.com/TrinityCore/TrinityCore/commit/ac8ff492744e65437fc906372058a0b29147af3f) --- Source/Game/Entities/Creature/Creature.cs | 41 +++++++++++-------- Source/Game/Entities/Unit/Unit.Combat.cs | 4 +- ...021_05_16_13_world_2018_01_10_00_world.sql | 2 + 3 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 sql/updates/world/master/2021_05_16_13_world_2018_01_10_00_world.sql diff --git a/Source/Game/Entities/Creature/Creature.cs b/Source/Game/Entities/Creature/Creature.cs index 47550d453..1b031aaa9 100644 --- a/Source/Game/Entities/Creature/Creature.cs +++ b/Source/Game/Entities/Creature/Creature.cs @@ -519,14 +519,19 @@ namespace Game.Entities if (m_shouldReacquireTarget && !IsFocusing(null, true)) { SetTarget(m_suppressedTarget); - if (!m_suppressedTarget.IsEmpty()) + + if (!HasUnitFlag2(UnitFlags2.DisableTurn)) { - WorldObject objTarget = Global.ObjAccessor.GetWorldObject(this, m_suppressedTarget); - if (objTarget) - SetFacingToObject(objTarget); + if (!m_suppressedTarget.IsEmpty()) + { + WorldObject objTarget = Global.ObjAccessor.GetWorldObject(this, m_suppressedTarget); + if (objTarget) + SetFacingToObject(objTarget); + } + else + SetFacingTo(m_suppressedOrientation); } - else - SetFacingTo(m_suppressedOrientation); + m_shouldReacquireTarget = false; } @@ -2979,18 +2984,22 @@ namespace Game.Entities } } - bool canTurnDuringCast = !focusSpell.GetSpellInfo().HasAttribute(SpellAttr5.DontTurnDuringCast); - // Face the target - we need to do this before the unit state is modified for no-turn spells - if (target) - SetFacingToObject(target, false); - else if (!canTurnDuringCast) + bool noTurnDuringCast = spellInfo.HasAttribute(SpellAttr5.DontTurnDuringCast); + + if (!HasUnitFlag2(UnitFlags2.DisableTurn)) { - Unit victim = GetVictim(); - if (victim) - SetFacingToObject(victim, false); // ensure server-side orientation is correct at beginning of cast + // Face the target - we need to do this before the unit state is modified for no-turn spells + if (target) + SetFacingToObject(target, false); + else if (!noTurnDuringCast) + { + Unit victim = GetVictim(); + if (victim) + SetFacingToObject(victim, false); // ensure server-side orientation is correct at beginning of cast + } } - if (!canTurnDuringCast) + if (!noTurnDuringCast) AddUnitState(UnitState.CannotTurn); } @@ -3028,7 +3037,7 @@ namespace Game.Entities if (focusSpell && focusSpell != _focusSpell) return; - if (IsPet())// player pets do not use delay system + if (IsPet() && !HasUnitFlag2(UnitFlags2.DisableTurn))// player pets do not use delay system { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.Target), m_suppressedTarget); if (!m_suppressedTarget.IsEmpty()) diff --git a/Source/Game/Entities/Unit/Unit.Combat.cs b/Source/Game/Entities/Unit/Unit.Combat.cs index dee22b778..49bfaa0ac 100644 --- a/Source/Game/Entities/Unit/Unit.Combat.cs +++ b/Source/Game/Entities/Unit/Unit.Combat.cs @@ -517,7 +517,7 @@ namespace Game.Entities if (attType != WeaponAttackType.BaseAttack && attType != WeaponAttackType.OffAttack) return; - if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled)) + if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled) && !HasUnitFlag2(UnitFlags2.DisableTurn)) SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) // melee attack spell casted at main hand attack only - no normal melee dmg dealt @@ -600,7 +600,7 @@ namespace Game.Entities if (attType != WeaponAttackType.BaseAttack && attType != WeaponAttackType.OffAttack) return; // ignore ranged case - if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled)) + if (IsTypeId(TypeId.Unit) && !HasUnitFlag(UnitFlags.PlayerControlled) && !HasUnitFlag2(UnitFlags2.DisableTurn)) SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) CalcDamageInfo damageInfo = new(); diff --git a/sql/updates/world/master/2021_05_16_13_world_2018_01_10_00_world.sql b/sql/updates/world/master/2021_05_16_13_world_2018_01_10_00_world.sql new file mode 100644 index 000000000..8f0631560 --- /dev/null +++ b/sql/updates/world/master/2021_05_16_13_world_2018_01_10_00_world.sql @@ -0,0 +1,2 @@ +-- +UPDATE `creature_template` SET `unit_flags2` = `unit_flags2`|0x8000 WHERE `entry` IN (32930,33909);