From 06be062d91e345b7bfd04b91ded334804d9a0658 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 29 Nov 2021 14:38:37 -0500 Subject: [PATCH] Core/Spell: SpellAura Redux Port From (https://github.com/TrinityCore/TrinityCore/commit/f7299dce9770a5b4a3a5ab289e930a390aa0407a) --- Source/Game/Entities/Unit/Unit.Spells.cs | 4 +-- Source/Game/Entities/Unit/Unit.cs | 5 ++++ Source/Game/Spells/Auras/Aura.cs | 3 -- Source/Game/Spells/Spell.cs | 28 ++++++++++--------- Source/Scripts/Spells/Generic.cs | 17 +++++++++++ Source/Scripts/Spells/Warlock.cs | 2 +- ...021_11_24_26_world_2019_03_08_00_world.sql | 4 +++ 7 files changed, 44 insertions(+), 19 deletions(-) create mode 100644 sql/updates/world/master/2021_11_24_26_world_2019_03_08_00_world.sql diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 2299c9a46..a2d4a5932 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -3822,14 +3822,14 @@ namespace Game.Entities if (aura.IsRemoved()) return; - aura.SetIsSingleTarget(caster != null && aura.GetSpellInfo().IsSingleTarget() || aura.HasEffectType(AuraType.ControlVehicle)); + aura.SetIsSingleTarget(caster != null && aura.GetSpellInfo().IsSingleTarget()); if (aura.IsSingleTarget()) { // @HACK: Player is not in world during loading auras. //Single target auras are not saved or loaded from database //but may be created as a result of aura links (player mounts with passengers) - Cypher.Assert((IsInWorld && !IsDuringRemoveFromWorld()) || (aura.GetCasterGUID() == GetGUID()) || (IsLoading() && aura.HasEffectType(AuraType.ControlVehicle))); + Cypher.Assert((IsInWorld && !IsDuringRemoveFromWorld()) || aura.GetCasterGUID() == GetGUID()); // register single target aura caster.m_scAuras.Add(aura); diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 4e24f0f5e..e9aff56b7 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -900,6 +900,11 @@ namespace Game.Entities } else if (seatId >= 0 && seatId == GetTransSeat()) return; + else + { + //Exit the current vehicle because unit will reenter in a new seat. + m_vehicle.GetBase().RemoveAurasByType(AuraType.ControlVehicle, GetGUID(), aurApp.GetBase()); + } } if (aurApp.HasRemoveMode()) diff --git a/Source/Game/Spells/Auras/Aura.cs b/Source/Game/Spells/Auras/Aura.cs index 2957185e5..996c6df2e 100644 --- a/Source/Game/Spells/Auras/Aura.cs +++ b/Source/Game/Spells/Auras/Aura.cs @@ -1056,9 +1056,6 @@ namespace Game.Spells break; } - if (HasEffectType(AuraType.ControlVehicle) && aura.HasEffectType(AuraType.ControlVehicle)) - return true; - return false; } diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 7cfc9f7d2..fb86f8e7f 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -2012,7 +2012,7 @@ namespace Game.Spells if (caster != null) { // delayed spells with multiple targets need to create a new aura object, otherwise we'll access a deleted aura - if (spellAura == null || (m_spellInfo.HasHitDelay() && !m_spellInfo.IsChanneled())) + if (hitInfo.HitAura == null) { bool resetPeriodicTimer = !_triggeredCastFlags.HasFlag(TriggerCastFlags.DontResetPeriodicTimer); uint allAuraEffectMask = Aura.BuildEffectMaskForOwner(m_spellInfo, SpellConst.MaxEffectMask, unit); @@ -2027,23 +2027,23 @@ namespace Game.Spells Aura aura = Aura.TryRefreshStackOrCreate(createInfo); if (aura != null) { - spellAura = aura.ToUnitAura(); + hitInfo.HitAura = aura.ToUnitAura(); // Set aura stack amount to desired value if (m_spellValue.AuraStackAmount > 1) { if (!createInfo.IsRefresh) - spellAura.SetStackAmount((byte)m_spellValue.AuraStackAmount); + hitInfo.HitAura.SetStackAmount((byte)m_spellValue.AuraStackAmount); else - spellAura.ModStackAmount(m_spellValue.AuraStackAmount); + hitInfo.HitAura.ModStackAmount(m_spellValue.AuraStackAmount); } - spellAura.SetDiminishGroup(hitInfo.DRGroup); + hitInfo.HitAura.SetDiminishGroup(hitInfo.DRGroup); if (!m_spellValue.Duration.HasValue) { - hitInfo.AuraDuration = caster.ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, spellAura.GetEffectMask()); + hitInfo.AuraDuration = caster.ModSpellDuration(m_spellInfo, unit, hitInfo.AuraDuration, hitInfo.Positive, hitInfo.HitAura.GetEffectMask()); if (hitInfo.AuraDuration > 0) { @@ -2056,7 +2056,7 @@ namespace Game.Spells { int origDuration = hitInfo.AuraDuration; hitInfo.AuraDuration = 0; - foreach (AuraEffect auraEff in spellAura.GetAuraEffects()) + foreach (AuraEffect auraEff in hitInfo.HitAura.GetAuraEffects()) { if (auraEff != null) { @@ -2075,21 +2075,21 @@ namespace Game.Spells else hitInfo.AuraDuration = m_spellValue.Duration.Value; - if (hitInfo.AuraDuration != spellAura.GetMaxDuration()) + if (hitInfo.AuraDuration != hitInfo.HitAura.GetMaxDuration()) { - spellAura.SetMaxDuration(hitInfo.AuraDuration); - spellAura.SetDuration(hitInfo.AuraDuration); + hitInfo.HitAura.SetMaxDuration(hitInfo.AuraDuration); + hitInfo.HitAura.SetDuration(hitInfo.AuraDuration); } } } else - spellAura.AddStaticApplication(unit, aura_effmask); - - hitInfo.HitAura = spellAura; + hitInfo.HitAura.AddStaticApplication(unit, aura_effmask); } } + spellAura = hitInfo.HitAura; HandleEffects(unit, null, null, spellEffectInfo, SpellEffectHandleMode.HitTarget); + spellAura = null; } public void DoTriggersOnSpellHit(Unit unit, uint effMask) @@ -8070,7 +8070,9 @@ namespace Game.Spells spell.GetCaster().ToPlayer().UpdatePvP(true); } + spell.spellAura = HitAura; spell.CallScriptAfterHitHandlers(); + spell.spellAura = null; } } diff --git a/Source/Scripts/Spells/Generic.cs b/Source/Scripts/Spells/Generic.cs index 3757e8a44..1e1404498 100644 --- a/Source/Scripts/Spells/Generic.cs +++ b/Source/Scripts/Spells/Generic.cs @@ -277,6 +277,9 @@ namespace Scripts.Spells.Generic //CorruptinPlagueEntrys public const uint CorruptingPlague = 40350; + //SiegeTankControl + public const uint SiegeTankControl = 47963; + //FreezingCircleMisc public const uint FreezingCirclePitOfSaronNormal = 69574; public const uint FreezingCirclePitOfSaronHeroic = 70276; @@ -3724,6 +3727,20 @@ namespace Scripts.Spells.Generic } } + [Script] + class spell_gen_vehicle_control_link : AuraScript + { + void OnRemove(AuraEffect aurEff, AuraEffectHandleModes mode) + { + GetTarget().RemoveAurasDueToSpell(SpellIds.SiegeTankControl); //aurEff->GetAmount() + } + + public override void Register() + { + AfterEffectRemove.Add(new EffectApplyHandler(OnRemove, 1, AuraType.Dummy, AuraEffectHandleModes.Real)); + } + } + [Script] // 34779 - Freezing Circle class spell_freezing_circle : SpellScript { diff --git a/Source/Scripts/Spells/Warlock.cs b/Source/Scripts/Spells/Warlock.cs index 1101400ec..951829ef5 100644 --- a/Source/Scripts/Spells/Warlock.cs +++ b/Source/Scripts/Spells/Warlock.cs @@ -233,7 +233,7 @@ namespace Scripts.Spells.Warlock { AuraEffect aurEff = aura.GetEffect(1); if (aurEff != null) - aurEff.SetAmount(MathFunctions.CalculatePct(aurEff.GetAmount(), GetHitDamage())); + aurEff.SetAmount(MathFunctions.CalculatePct(GetHitDamage(), aurEff.GetAmount())); } } diff --git a/sql/updates/world/master/2021_11_24_26_world_2019_03_08_00_world.sql b/sql/updates/world/master/2021_11_24_26_world_2019_03_08_00_world.sql new file mode 100644 index 000000000..1cf16d8a6 --- /dev/null +++ b/sql/updates/world/master/2021_11_24_26_world_2019_03_08_00_world.sql @@ -0,0 +1,4 @@ +DELETE FROM `spell_script_names` WHERE `ScriptName` = 'spell_gen_vehicle_control_link' AND `spell_id` IN (49078, 50343); +INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES +(49078, 'spell_gen_vehicle_control_link'), +(50343, 'spell_gen_vehicle_control_link');