Core/Creatures: Allow toggling creature default root state

Port From (https://github.com/TrinityCore/TrinityCore/commit/eb93afffc08a45354e1b896adf38d1f8e8b352ac)
This commit is contained in:
hondacrx
2023-03-14 04:30:36 -04:00
parent 1d5d0a32e6
commit 40898d4b9f
2 changed files with 14 additions and 6 deletions
+11 -3
View File
@@ -410,7 +410,6 @@ namespace Game.Entities
SetIsCombatDisallowed(cInfo.FlagsExtra.HasFlag(CreatureFlagsExtra.CannotEnterCombat));
LoadTemplateRoot();
InitializeMovementFlags();
LoadCreaturesAddon();
@@ -1684,8 +1683,15 @@ namespace Game.Entities
void LoadTemplateRoot()
{
if (GetMovementTemplate().IsRooted())
SetControlled(true, UnitState.Root);
SetTemplateRooted(GetMovementTemplate().IsRooted());
}
public bool IsTemplateRooted() { return _staticFlags.HasFlag(CreatureStaticFlags.Sessile); }
public void SetTemplateRooted(bool rooted)
{
_staticFlags.ApplyFlag(CreatureStaticFlags.Sessile, rooted);
SetControlled(rooted, UnitState.Root);
}
public override bool HasQuest(uint questId)
@@ -2521,6 +2527,8 @@ namespace Game.Entities
void InitializeMovementFlags()
{
LoadTemplateRoot();
// It does the same, for now
UpdateMovementFlags();
}
+3 -3
View File
@@ -721,7 +721,7 @@ namespace Game.Entities
SendMessageToSet(packet, true);
}
if (IsCreature() && updateAnimTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().GetMovementTemplate().IsRooted())
if (IsCreature() && updateAnimTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().IsTemplateRooted())
{
if (IsGravityDisabled())
SetAnimTier(AnimTier.Fly);
@@ -1096,7 +1096,7 @@ namespace Game.Entities
SendMessageToSet(packet, true);
}
if (IsCreature() && updateAnimTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().GetMovementTemplate().IsRooted())
if (IsCreature() && updateAnimTier && IsAlive() && !HasUnitState(UnitState.Root) && !ToCreature().IsTemplateRooted())
{
if (IsGravityDisabled())
SetAnimTier(AnimTier.Fly);
@@ -1224,7 +1224,7 @@ namespace Game.Entities
SetStunned(false);
break;
case UnitState.Root:
if (HasAuraType(AuraType.ModRoot) || HasAuraType(AuraType.ModRoot2) || HasAuraType(AuraType.ModRootDisableGravity) || GetVehicle() != null || (IsCreature() && ToCreature().GetMovementTemplate().IsRooted()))
if (HasAuraType(AuraType.ModRoot) || HasAuraType(AuraType.ModRoot2) || HasAuraType(AuraType.ModRootDisableGravity) || GetVehicle() != null || (IsCreature() && ToCreature().IsTemplateRooted()))
return;
ClearUnitState(state);