Skip to content

Commit

Permalink
StaticFlags: Implement CANNOT_TURN
Browse files Browse the repository at this point in the history
Closes #536
  • Loading branch information
insunaa authored and killerwife committed Oct 7, 2024
1 parent 65d9086 commit 91b32fd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/game/Entities/CreatureSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions src/game/MotionGenerators/TargetedMovementGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 91b32fd

Please sign in to comment.