From e3e3fe1a292fed13aa63871fbcaad075d8a82065 Mon Sep 17 00:00:00 2001 From: insunaa Date: Fri, 9 Aug 2024 11:46:17 +0200 Subject: [PATCH] StaticFlags: Implement CANNOT_TURN --- .../scripts/northrend/ulduar/ulduar/boss_kologarn.cpp | 2 +- src/game/Entities/Creature.h | 2 ++ src/game/Entities/CreatureSettings.cpp | 2 ++ src/game/Entities/Unit.h | 4 +++- src/game/MotionGenerators/TargetedMovementGenerator.cpp | 6 ++++-- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/game/AI/ScriptDevAI/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp b/src/game/AI/ScriptDevAI/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp index 58ac7ce7fa1..33a0420e2a6 100644 --- a/src/game/AI/ScriptDevAI/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp +++ b/src/game/AI/ScriptDevAI/scripts/northrend/ulduar/ulduar/boss_kologarn.cpp @@ -106,7 +106,7 @@ struct boss_kologarnAI : public Scripted_NoMovementAI { m_pInstance = (instance_ulduar*)pCreature->GetInstanceData(); m_bIsRegularMode = pCreature->GetMap()->IsRegularDifficulty(); - m_creature->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_UNK15); + m_creature->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN); Reset(); } diff --git a/src/game/Entities/Creature.h b/src/game/Entities/Creature.h index 22ceabcf862..289896a4a54 100644 --- a/src/game/Entities/Creature.h +++ b/src/game/Entities/Creature.h @@ -899,6 +899,8 @@ class Creature : public Unit virtual uint32 GetDuration() const { return 0; } + virtual bool CannotTurn() const override { return m_settings.HasFlag(CreatureStaticFlags3::CANNOT_TURN); } + protected: bool CreateFromProto(uint32 dbGuid, uint32 guidlow, CreatureInfo const* cinfo, const CreatureData* data = nullptr, GameEventCreatureData const* eventData = nullptr); bool InitEntry(uint32 Entry, const CreatureData* data = nullptr, GameEventCreatureData const* eventData = nullptr); diff --git a/src/game/Entities/CreatureSettings.cpp b/src/game/Entities/CreatureSettings.cpp index 929461ab05a..6664fbbddd6 100644 --- a/src/game/Entities/CreatureSettings.cpp +++ b/src/game/Entities/CreatureSettings.cpp @@ -52,6 +52,8 @@ void CreatureSettings::ResetStaticFlags(CreatureStaticFlags staticFlags, Creatur m_owner->DisableThreatPropagationToOwner(); if (HasFlag(CreatureStaticFlags2::HIDE_BODY)) m_owner->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_HIDE_BODY); + if (HasFlag(CreatureStaticFlags3::CANNOT_TURN)) + m_owner->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_CANNOT_TURN); } void CreatureSettings::SetFlag(CreatureStaticFlags flag) diff --git a/src/game/Entities/Unit.h b/src/game/Entities/Unit.h index 2d7ee4ab0c1..e06e61ff2e1 100644 --- a/src/game/Entities/Unit.h +++ b/src/game/Entities/Unit.h @@ -556,7 +556,7 @@ enum UnitFlags2 UNIT_FLAG2_SPELL_CLICK_IN_GROUP = 0x00001000, UNIT_FLAG2_SPELL_CLICK_DISABLED = 0x00002000, UNIT_FLAG2_INTERACT_ANY_REACTION = 0x00004000, - UNIT_FLAG2_UNK15 = 0x00008000, + UNIT_FLAG2_CANNOT_TURN = 0x00008000, UNIT_FLAG2_UNK16 = 0x00010000, UNIT_FLAG2_ALLOW_CHEAT_SPELLS = 0x00040000, }; @@ -2634,6 +2634,8 @@ class Unit : public WorldObject void SetRootVehicle(const ObjectGuid& guid) { m_rootVehicle = guid; } const ObjectGuid& GetRootVehicle() const { return m_rootVehicle; } + virtual bool CannotTurn() const { return false; } + protected: bool MeetsSelectAttackingRequirement(Unit* target, SpellEntry const* spellInfo, uint32 selectFlags, SelectAttackingTargetParams params, int32 unitConditionId) const; diff --git a/src/game/MotionGenerators/TargetedMovementGenerator.cpp b/src/game/MotionGenerators/TargetedMovementGenerator.cpp index 18241ee24e8..9942b020c7c 100644 --- a/src/game/MotionGenerators/TargetedMovementGenerator.cpp +++ b/src/game/MotionGenerators/TargetedMovementGenerator.cpp @@ -934,8 +934,10 @@ bool FollowMovementGenerator::_getOrientation(Unit& owner, float& o) const { if (!i_target.isValid()) return false; - - o = (i_faceTarget ? owner.GetAngle(i_target.getTarget()) : i_target->GetOrientation()); + if (owner.CannotTurn()) + o = owner.GetOrientation(); + else + o = (i_faceTarget ? owner.GetAngle(i_target.getTarget()) : i_target->GetOrientation()); return true; }