Core/Units: Added helper methods to cancel mount/shapeshift auras

Port From (https://github.com/TrinityCore/TrinityCore/commit/0b16756172b2c3cc78b0861af86b93daae60edda)
This commit is contained in:
Hondacrx
2025-05-19 17:42:40 -04:00
parent 3e0e2354b7
commit f62d303ec7
3 changed files with 58 additions and 2 deletions
@@ -938,6 +938,18 @@ namespace Game.Entities
return true;
}
void CancelMountAura(bool force)
{
if (!HasAuraType(AuraType.Mounted))
return;
RemoveAurasByType(AuraType.Mounted, aurApp =>
{
SpellInfo spellInfo = aurApp.GetBase().GetSpellInfo();
return force || (!spellInfo.HasAttribute(SpellAttr0.NoAuraCancel) && spellInfo.IsPositive() && !spellInfo.IsPassive());
});
}
public MountCapabilityRecord GetMountCapability(uint mountType)
{
if (mountType == 0)
@@ -1043,6 +1055,14 @@ namespace Game.Entities
if (IsLoading())
return;
var spellShapeshiftForm = CliDB.SpellShapeshiftFormStorage.LookupByKey(GetShapeshiftForm());
if (spellShapeshiftForm != null)
{
uint mountType = spellShapeshiftForm.MountTypeID;
if (mountType != 0 && GetMountCapability(mountType) == null)
CancelTravelShapeshiftForm(AuraRemoveMode.Interrupt);
}
var mounts = GetAuraEffectsByType(AuraType.Mounted);
foreach (AuraEffect aurEff in mounts.ToArray())
{
+37 -1
View File
@@ -1645,6 +1645,41 @@ namespace Game.Entities
SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ShapeshiftForm), (byte)form);
}
void CancelTravelShapeshiftForm(AuraRemoveMode removeMode = AuraRemoveMode.Default, bool force = false) { CancelShapeshiftForm(true, removeMode, force); }
void CancelShapeshiftForm(bool onlyTravelShapeshiftForm = false, AuraRemoveMode removeMode = AuraRemoveMode.Default, bool force = false)
{
ShapeShiftForm form = GetShapeshiftForm();
if (form == ShapeShiftForm.None)
return;
bool isTravelShapeshiftForm()
{
var shapeInfo = CliDB.SpellShapeshiftFormStorage.LookupByKey(form);
if (shapeInfo != null)
{
if (shapeInfo.MountTypeID != 0)
return true;
if (shapeInfo.Id == (uint)ShapeShiftForm.TravelForm || shapeInfo.Id == (uint)ShapeShiftForm.AquaticForm)
return true;
}
return false;
}
if (onlyTravelShapeshiftForm && !isTravelShapeshiftForm())
return;
var shapeshifts = GetAuraEffectsByType(AuraType.ModShapeshift);
foreach (AuraEffect aurEff in shapeshifts)
{
SpellInfo spellInfo = aurEff.GetBase().GetSpellInfo();
if (force || (!spellInfo.HasAttribute(SpellAttr0.NoAuraCancel) && spellInfo.IsPositive() && !spellInfo.IsPassive()))
aurEff.GetBase().Remove(removeMode);
}
}
// creates aura application instance and registers it in lists
// aura application effects are handled separately to prevent aura list corruption
public AuraApplication _CreateAuraApplication(Aura aura, uint effMask)
@@ -2873,7 +2908,8 @@ namespace Game.Entities
return true;
return false;
};
}
;
bool isCastDelayed()
{