From 6522040c5eac4468dd3734e51eb9fdcdb77646fa Mon Sep 17 00:00:00 2001 From: Treeston Date: Wed, 10 Jan 2018 00:07:37 +0100 Subject: [PATCH] Core/Unit: Abide UNIT_FLAG2_DISABLE_TURN on creatures. Add that flag to Kologarn (from sniff). Hi sirikfoll. --- .../world/3.3.5/2018_01_10_00_world.sql | 2 ++ .../game/Entities/Creature/Creature.cpp | 36 +++++++++++-------- src/server/game/Entities/Unit/Unit.cpp | 4 +-- 3 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 sql/updates/world/3.3.5/2018_01_10_00_world.sql diff --git a/sql/updates/world/3.3.5/2018_01_10_00_world.sql b/sql/updates/world/3.3.5/2018_01_10_00_world.sql new file mode 100644 index 00000000000..275dbe01224 --- /dev/null +++ b/sql/updates/world/3.3.5/2018_01_10_00_world.sql @@ -0,0 +1,2 @@ +-- +UPDATE `creature_template` SET `unit_flags2` = `unit_flags2`|0x8000 WHERE `entry`=32930; diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index a9bf7fb8cd8..832b29db25c 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -591,13 +591,17 @@ void Creature::Update(uint32 diff) if (m_shouldReacquireTarget && !IsFocusing(nullptr, true)) { SetTarget(m_suppressedTarget); - if (m_suppressedTarget) + + if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) { - if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) - SetFacingToObject(objTarget, false); + if (m_suppressedTarget) + { + if (WorldObject const* objTarget = ObjectAccessor::GetWorldObject(*this, m_suppressedTarget)) + SetFacingToObject(objTarget, false); + } + else + SetFacingTo(m_suppressedOrientation, false); } - else - SetFacingTo(m_suppressedOrientation, false); m_shouldReacquireTarget = false; } @@ -2789,15 +2793,19 @@ void Creature::FocusTarget(Spell const* focusSpell, WorldObject const* target) } } - bool const canTurnDuringCast = !spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_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 (!canTurnDuringCast) - if (Unit* victim = GetVictim()) - SetFacingToObject(victim, false); // ensure orientation is correct at beginning of cast + bool const noTurnDuringCast = spellInfo->HasAttribute(SPELL_ATTR5_DONT_TURN_DURING_CAST); + + if (!HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) + { + // 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) + if (Unit* victim = GetVictim()) + SetFacingToObject(victim, false); // ensure orientation is correct at beginning of cast + } - if (!canTurnDuringCast) + if (noTurnDuringCast) AddUnitState(UNIT_STATE_CANNOT_TURN); } @@ -2835,7 +2843,7 @@ void Creature::ReleaseFocus(Spell const* focusSpell, bool withDelay) if (focusSpell && focusSpell != m_focusSpell) return; - if (IsPet()) // player pets do not use delay system + if (IsPet() && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) // player pets do not use delay system { SetGuidValue(UNIT_FIELD_TARGET, m_suppressedTarget); if (m_suppressedTarget) diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 14cfdce12d7..f6d6b047aaf 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1962,7 +1962,7 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType, bool extr if (attType != BASE_ATTACK && attType != OFF_ATTACK) return; // ignore ranged case - if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) + if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) // melee attack spell cast at main hand attack only - no normal melee dmg dealt @@ -2010,7 +2010,7 @@ void Unit::FakeAttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BA if (attType != BASE_ATTACK && attType != OFF_ATTACK) return; // ignore ranged case - if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED)) + if (GetTypeId() == TYPEID_UNIT && !HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED) && !HasFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN)) SetFacingToObject(victim, false); // update client side facing to face the target (prevents visual glitches when casting untargeted spells) CalcDamageInfo damageInfo;