From 91b32fdbe5a69204a09436991002b4ee34e2b57d Mon Sep 17 00:00:00 2001 From: insunaa Date: Fri, 9 Aug 2024 11:46:17 +0200 Subject: [PATCH] StaticFlags: Implement CANNOT_TURN Closes https://github.com/cmangos/mangos-wotlk/pull/536 --- src/game/Entities/Creature.h | 2 ++ src/game/Entities/CreatureSettings.cpp | 2 ++ src/game/Entities/Unit.h | 2 ++ src/game/MotionGenerators/TargetedMovementGenerator.cpp | 6 ++++-- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/game/Entities/Creature.h b/src/game/Entities/Creature.h index 70ea2020d92..15b5db99088 100644 --- a/src/game/Entities/Creature.h +++ b/src/game/Entities/Creature.h @@ -909,6 +909,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 d5d4759daa4..8b2b0644714 100644 --- a/src/game/Entities/CreatureSettings.cpp +++ b/src/game/Entities/CreatureSettings.cpp @@ -56,6 +56,8 @@ void CreatureSettings::ResetStaticFlags(CreatureStaticFlags staticFlags, Creatur m_owner->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DO_NOT_FADE_IN); if (HasFlag(CreatureStaticFlags3::SPELL_CLICK_FOR_PARTY_ONLY)) m_owner->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_SPELL_CLICK_IN_GROUP); + 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 d3fb9f26cef..2e34f945d6e 100644 --- a/src/game/Entities/Unit.h +++ b/src/game/Entities/Unit.h @@ -2640,6 +2640,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; }