From 75619e833fd08636f5f21bb8a020c86f83bc90d1 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 25 Jul 2018 12:17:32 -0400 Subject: [PATCH] Core/Players: Changed flight masters to suppress positive transforms/shapeshifts instead of preventing starting flight --- Source/Game/Entities/Player/Player.cs | 15 ++++----- Source/Game/Entities/Unit/Unit.cs | 32 +++++++++++++++---- Source/Game/Handlers/ArtifactHandler.cs | 2 +- .../Movement/Generators/WaypointMovement.cs | 1 + Source/Game/Spells/Auras/AuraEffect.cs | 4 +-- 5 files changed, 37 insertions(+), 17 deletions(-) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index d6977460b..8d7c6d0d5 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -6694,13 +6694,12 @@ namespace Game.Entities if (npc != null) { // not let cheating with start flight mounted - if (IsMounted()) - { - GetSession().SendActivateTaxiReply(ActivateTaxiReply.PlayerAlreadyMounted); - return false; - } + RemoveAurasByType(AuraType.Mounted); - if (IsInDisallowedMountForm()) + if (GetDisplayId() != GetNativeDisplayId()) + RestoreDisplayId(true); + + if (IsDisallowedMountForm(getTransForm(), FORM_NONE, GetDisplayId())) { GetSession().SendActivateTaxiReply(ActivateTaxiReply.PlayerShapeshifted); return false; @@ -6718,8 +6717,8 @@ namespace Game.Entities { RemoveAurasByType(AuraType.Mounted); - if (IsInDisallowedMountForm()) - RemoveAurasByType(AuraType.ModShapeshift); + if (GetDisplayId() != GetNativeDisplayId()) + RestoreDisplayId(true); Spell spell = GetCurrentSpell(CurrentSpellTypes.Generic); if (spell != null) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index db2a72d27..3ed6bd864 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -252,13 +252,17 @@ namespace Game.Entities } public bool IsInDisallowedMountForm() + { + return IsDisallowedMountForm(getTransForm(), GetShapeshiftForm(), GetDisplayId()); + } + + bool IsDisallowedMountForm(uint spellId, ShapeShiftForm form, uint displayId) { SpellInfo transformSpellInfo = Global.SpellMgr.GetSpellInfo(getTransForm()); if (transformSpellInfo != null) if (transformSpellInfo.HasAttribute(SpellAttr0.CastableWhileMounted)) return false; - ShapeShiftForm form = GetShapeshiftForm(); if (form != 0) { SpellShapeshiftFormRecord shapeshift = CliDB.SpellShapeshiftFormStorage.LookupByKey(form); @@ -268,10 +272,10 @@ namespace Game.Entities if (!shapeshift.Flags.HasAnyFlag(SpellShapeshiftFormFlags.IsNotAShapeshift)) return true; } - if (GetDisplayId() == GetNativeDisplayId()) + if (displayId == GetNativeDisplayId()) return false; - CreatureDisplayInfoRecord display = CliDB.CreatureDisplayInfoStorage.LookupByKey(GetDisplayId()); + CreatureDisplayInfoRecord display = CliDB.CreatureDisplayInfoStorage.LookupByKey(displayId); if (display == null) return true; @@ -2545,7 +2549,7 @@ namespace Game.Entities public uint GetDisplayId() { return GetUInt32Value(UnitFields.DisplayId); } - public void RestoreDisplayId() + public void RestoreDisplayId(bool ignorePositiveAurasPreventingMounting = false) { AuraEffect handledAura = null; // try to receive model from transform auras @@ -2559,7 +2563,18 @@ namespace Game.Entities if (aurApp != null) { if (handledAura == null) - handledAura = eff; + { + if (!ignorePositiveAurasPreventingMounting) + handledAura = eff; + else + { + CreatureTemplate ci = Global.ObjectMgr.GetCreatureTemplate((uint)eff.GetMiscValue()); + if (ci != null) + if (!IsDisallowedMountForm(eff.GetId(), ShapeShiftForm.None, ObjectManager.ChooseDisplayId(ci))) + handledAura = eff; + } + } + // prefer negative auras if (!aurApp.IsPositive()) { @@ -2575,7 +2590,12 @@ namespace Game.Entities handledAura.HandleEffect(this, AuraEffectHandleModes.SendForClient, true); // we've found shapeshift else if ((modelId = GetModelForForm(GetShapeshiftForm())) != 0) - SetDisplayId(modelId); + { + if (!ignorePositiveAurasPreventingMounting || !IsDisallowedMountForm(0, GetShapeshiftForm(), modelId)) + SetDisplayId(modelId); + else + SetDisplayId(GetNativeDisplayId()); + } // no auras found - set modelid to default else SetDisplayId(GetNativeDisplayId()); diff --git a/Source/Game/Handlers/ArtifactHandler.cs b/Source/Game/Handlers/ArtifactHandler.cs index a0c6ec9ad..4979a9bae 100644 --- a/Source/Game/Handlers/ArtifactHandler.cs +++ b/Source/Game/Handlers/ArtifactHandler.cs @@ -163,7 +163,7 @@ namespace Game // change druid form appearance if (artifactAppearance.OverrideShapeshiftDisplayID != 0 && artifactAppearance.OverrideShapeshiftFormID != 0 && _player.GetShapeshiftForm() == (ShapeShiftForm)artifactAppearance.OverrideShapeshiftFormID) - _player.RestoreDisplayId(); + _player.RestoreDisplayId(_player.IsMounted()); } } diff --git a/Source/Game/Movement/Generators/WaypointMovement.cs b/Source/Game/Movement/Generators/WaypointMovement.cs index 738d23a12..53af67ae8 100644 --- a/Source/Game/Movement/Generators/WaypointMovement.cs +++ b/Source/Game/Movement/Generators/WaypointMovement.cs @@ -442,6 +442,7 @@ namespace Game.Movement } owner.RemoveFlag(PlayerFields.Flags, PlayerFlags.TaxiBenchmark); + owner.RestoreDisplayId(); } public override void DoReset(Player owner) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index f91de3fa5..4eb7eff59 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -1394,7 +1394,7 @@ namespace Game.Spells } if (modelid > 0) - target.RestoreDisplayId(); + target.RestoreDisplayId(target.IsMounted()); switch (form) { @@ -1659,7 +1659,7 @@ namespace Game.Spells if (target.GetTransForm() == GetId()) target.setTransForm(0); - target.RestoreDisplayId(); + target.RestoreDisplayId(target.IsMounted()); // Dragonmaw Illusion (restore mount model) if (GetId() == 42016 && target.GetMountID() == 16314)