Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticFlags: Implement CANNOT_TURN #536

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
2 changes: 2 additions & 0 deletions src/game/Entities/Creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
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 @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion src/game/Entities/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down Expand Up @@ -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;

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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe

return false;

?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is prolly not necessary. Likely client will handle the "not turning", i.e. when npc has smth in crosshairs, then client wont turn npc to it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but I've also seen cases with Kologarn for example where he's not supposed to turn, but then when he dies and plays his death animation his corpse falls sideways, or he turns for a millisecond while doing an attack and then snaps back forward, so I added this to be safer, I guess.

else
o = (i_faceTarget ? owner.GetAngle(i_target.getTarget()) : i_target->GetOrientation());
return true;
}

Expand Down