Core/Spell: SpellAura Redux

Port From (https://github.com/TrinityCore/TrinityCore/commit/f7299dce9770a5b4a3a5ab289e930a390aa0407a)
This commit is contained in:
hondacrx
2021-11-29 14:38:37 -05:00
parent e08294d332
commit 06be062d91
7 changed files with 44 additions and 19 deletions
+2 -2
View File
@@ -3822,14 +3822,14 @@ namespace Game.Entities
if (aura.IsRemoved()) if (aura.IsRemoved())
return; return;
aura.SetIsSingleTarget(caster != null && aura.GetSpellInfo().IsSingleTarget() || aura.HasEffectType(AuraType.ControlVehicle)); aura.SetIsSingleTarget(caster != null && aura.GetSpellInfo().IsSingleTarget());
if (aura.IsSingleTarget()) if (aura.IsSingleTarget())
{ {
// @HACK: Player is not in world during loading auras. // @HACK: Player is not in world during loading auras.
//Single target auras are not saved or loaded from database //Single target auras are not saved or loaded from database
//but may be created as a result of aura links (player mounts with passengers) //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 // register single target aura
caster.m_scAuras.Add(aura); caster.m_scAuras.Add(aura);
+5
View File
@@ -900,6 +900,11 @@ namespace Game.Entities
} }
else if (seatId >= 0 && seatId == GetTransSeat()) else if (seatId >= 0 && seatId == GetTransSeat())
return; 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()) if (aurApp.HasRemoveMode())
-3
View File
@@ -1056,9 +1056,6 @@ namespace Game.Spells
break; break;
} }
if (HasEffectType(AuraType.ControlVehicle) && aura.HasEffectType(AuraType.ControlVehicle))
return true;
return false; return false;
} }
+15 -13
View File
@@ -2012,7 +2012,7 @@ namespace Game.Spells
if (caster != null) if (caster != null)
{ {
// delayed spells with multiple targets need to create a new aura object, otherwise we'll access a deleted aura // 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); bool resetPeriodicTimer = !_triggeredCastFlags.HasFlag(TriggerCastFlags.DontResetPeriodicTimer);
uint allAuraEffectMask = Aura.BuildEffectMaskForOwner(m_spellInfo, SpellConst.MaxEffectMask, unit); uint allAuraEffectMask = Aura.BuildEffectMaskForOwner(m_spellInfo, SpellConst.MaxEffectMask, unit);
@@ -2027,23 +2027,23 @@ namespace Game.Spells
Aura aura = Aura.TryRefreshStackOrCreate(createInfo); Aura aura = Aura.TryRefreshStackOrCreate(createInfo);
if (aura != null) if (aura != null)
{ {
spellAura = aura.ToUnitAura(); hitInfo.HitAura = aura.ToUnitAura();
// Set aura stack amount to desired value // Set aura stack amount to desired value
if (m_spellValue.AuraStackAmount > 1) if (m_spellValue.AuraStackAmount > 1)
{ {
if (!createInfo.IsRefresh) if (!createInfo.IsRefresh)
spellAura.SetStackAmount((byte)m_spellValue.AuraStackAmount); hitInfo.HitAura.SetStackAmount((byte)m_spellValue.AuraStackAmount);
else 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) 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) if (hitInfo.AuraDuration > 0)
{ {
@@ -2056,7 +2056,7 @@ namespace Game.Spells
{ {
int origDuration = hitInfo.AuraDuration; int origDuration = hitInfo.AuraDuration;
hitInfo.AuraDuration = 0; hitInfo.AuraDuration = 0;
foreach (AuraEffect auraEff in spellAura.GetAuraEffects()) foreach (AuraEffect auraEff in hitInfo.HitAura.GetAuraEffects())
{ {
if (auraEff != null) if (auraEff != null)
{ {
@@ -2075,21 +2075,21 @@ namespace Game.Spells
else else
hitInfo.AuraDuration = m_spellValue.Duration.Value; hitInfo.AuraDuration = m_spellValue.Duration.Value;
if (hitInfo.AuraDuration != spellAura.GetMaxDuration()) if (hitInfo.AuraDuration != hitInfo.HitAura.GetMaxDuration())
{ {
spellAura.SetMaxDuration(hitInfo.AuraDuration); hitInfo.HitAura.SetMaxDuration(hitInfo.AuraDuration);
spellAura.SetDuration(hitInfo.AuraDuration); hitInfo.HitAura.SetDuration(hitInfo.AuraDuration);
} }
} }
} }
else else
spellAura.AddStaticApplication(unit, aura_effmask); hitInfo.HitAura.AddStaticApplication(unit, aura_effmask);
hitInfo.HitAura = spellAura;
} }
} }
spellAura = hitInfo.HitAura;
HandleEffects(unit, null, null, spellEffectInfo, SpellEffectHandleMode.HitTarget); HandleEffects(unit, null, null, spellEffectInfo, SpellEffectHandleMode.HitTarget);
spellAura = null;
} }
public void DoTriggersOnSpellHit(Unit unit, uint effMask) public void DoTriggersOnSpellHit(Unit unit, uint effMask)
@@ -8070,7 +8070,9 @@ namespace Game.Spells
spell.GetCaster().ToPlayer().UpdatePvP(true); spell.GetCaster().ToPlayer().UpdatePvP(true);
} }
spell.spellAura = HitAura;
spell.CallScriptAfterHitHandlers(); spell.CallScriptAfterHitHandlers();
spell.spellAura = null;
} }
} }
+17
View File
@@ -277,6 +277,9 @@ namespace Scripts.Spells.Generic
//CorruptinPlagueEntrys //CorruptinPlagueEntrys
public const uint CorruptingPlague = 40350; public const uint CorruptingPlague = 40350;
//SiegeTankControl
public const uint SiegeTankControl = 47963;
//FreezingCircleMisc //FreezingCircleMisc
public const uint FreezingCirclePitOfSaronNormal = 69574; public const uint FreezingCirclePitOfSaronNormal = 69574;
public const uint FreezingCirclePitOfSaronHeroic = 70276; 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 [Script] // 34779 - Freezing Circle
class spell_freezing_circle : SpellScript class spell_freezing_circle : SpellScript
{ {
+1 -1
View File
@@ -233,7 +233,7 @@ namespace Scripts.Spells.Warlock
{ {
AuraEffect aurEff = aura.GetEffect(1); AuraEffect aurEff = aura.GetEffect(1);
if (aurEff != null) if (aurEff != null)
aurEff.SetAmount(MathFunctions.CalculatePct(aurEff.GetAmount(), GetHitDamage())); aurEff.SetAmount(MathFunctions.CalculatePct(GetHitDamage(), aurEff.GetAmount()));
} }
} }
@@ -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');