From 028db75c67bee7e66069e276e68557e925c05d3e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Tue, 3 Sep 2019 15:44:48 -0400 Subject: [PATCH] Core/Auras: tidy up one little hack Port From (https://github.com/TrinityCore/TrinityCore/commit/9d16dce63365502b45561ce972178a780272b146) --- Source/Game/Entities/Unit/Unit.cs | 32 ++++++++++++++++++++------ Source/Game/Spells/Auras/AuraEffect.cs | 18 +-------------- 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index ab251ef08..51983b6c0 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -1155,8 +1155,19 @@ namespace Game.Entities } } - public uint GetModelForForm(ShapeShiftForm form) + public uint GetModelForForm(ShapeShiftForm form, uint spellId) { + // Hardcoded cases + switch (spellId) + { + case 7090: // Bear Form + return 29414; + case 35200: // Roc Form + return 4877; + default: + break; + } + Player thisPlayer = ToPlayer(); if (thisPlayer != null) { @@ -2134,17 +2145,24 @@ namespace Game.Entities } } } - uint modelId; + + var shapeshiftAura = GetAuraEffectsByType(AuraType.ModShapeshift); + // transform aura was found if (handledAura != null) handledAura.HandleEffect(this, AuraEffectHandleModes.SendForClient, true); // we've found shapeshift - else if ((modelId = GetModelForForm(GetShapeshiftForm())) != 0) + else if (!shapeshiftAura.Empty()) // we've found shapeshift { - if (!ignorePositiveAurasPreventingMounting || !IsDisallowedMountForm(0, GetShapeshiftForm(), modelId)) - SetDisplayId(modelId); - else - SetDisplayId(GetNativeDisplayId()); + // only one such aura possible at a time + uint modelId = GetModelForForm(GetShapeshiftForm(), shapeshiftAura[0].GetId()); + if (modelId != 0) + { + if (!ignorePositiveAurasPreventingMounting || !IsDisallowedMountForm(0, GetShapeshiftForm(), modelId)) + SetDisplayId(modelId); + else + SetDisplayId(GetNativeDisplayId()); + } } // no auras found - set modelid to default else diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index d03f75d2f..f9da56fe6 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -1292,23 +1292,7 @@ namespace Game.Spells Unit target = aurApp.GetTarget(); ShapeShiftForm form = (ShapeShiftForm)GetMiscValue(); - - uint modelid = 0; - - switch (GetId()) - { - // Bear Form - case 7090: - modelid = 29414; - break; - // Roc Form - case 35200: - modelid = 4877; - break; - default: - modelid = target.GetModelForForm(form); - break; - } + uint modelid = target.GetModelForForm(form, GetId()); if (apply) {