From a14038d374b74f62ccb7806d5cd49bf01bd044c8 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 5 Jan 2023 17:22:24 -0500 Subject: [PATCH] Core/Auras: Implemented SPELL_AURA_MOD_STUN_DISABLE_GRAVITY Port From (https://github.com/TrinityCore/TrinityCore/commit/6515319b7542930ffe2237c309a3dc3773d70f72) --- Source/Game/Entities/Player/Player.cs | 2 +- Source/Game/Entities/Unit/Unit.Movement.cs | 4 +-- Source/Game/Spells/Auras/AuraEffect.cs | 31 +++++++++++++++++++--- Source/Game/Spells/Spell.cs | 7 +++++ 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index 1604f9e4c..0221f1226 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -5240,7 +5240,7 @@ namespace Game.Entities auraList.First().HandleEffect(this, AuraEffectHandleModes.SendForClient, true); } - if (HasAuraType(AuraType.ModStun)) + if (HasAuraType(AuraType.ModStun) || HasAuraType(AuraType.ModStunDisableGravity)) SetRooted(true); MoveSetCompoundState setCompoundState = new(); diff --git a/Source/Game/Entities/Unit/Unit.Movement.cs b/Source/Game/Entities/Unit/Unit.Movement.cs index 70647c800..d986eaf5a 100644 --- a/Source/Game/Entities/Unit/Unit.Movement.cs +++ b/Source/Game/Entities/Unit/Unit.Movement.cs @@ -1216,7 +1216,7 @@ namespace Game.Entities switch (state) { case UnitState.Stunned: - if (HasAuraType(AuraType.ModStun)) + if (HasAuraType(AuraType.ModStun) || HasAuraType(AuraType.ModStunDisableGravity)) return; ClearUnitState(state); @@ -1255,7 +1255,7 @@ namespace Game.Entities void ApplyControlStatesIfNeeded() { // Unit States might have been already cleared but auras still present. I need to check with HasAuraType - if (HasUnitState(UnitState.Stunned) || HasAuraType(AuraType.ModStun)) + if (HasUnitState(UnitState.Stunned) || HasAuraType(AuraType.ModStun) || HasAuraType(AuraType.ModStunDisableGravity)) SetStunned(true); if (HasUnitState(UnitState.Root) || HasAuraType(AuraType.ModRoot) || HasAuraType(AuraType.ModRoot2)) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index f31cf5968..be53c05ed 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -2467,6 +2467,31 @@ namespace Game.Spells target.SetControlled(false, UnitState.Fleeing); } + [AuraEffectHandler(AuraType.ModStunDisableGravity)] + void HandleAuraModStunAndDisableGravity(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) + { + if (!mode.HasAnyFlag(AuraEffectHandleModes.Real)) + return; + + Unit target = aurApp.GetTarget(); + + target.SetControlled(apply, UnitState.Stunned); + + if (apply) + target.GetThreatManager().EvaluateSuppressed(); + + // Do not remove DisableGravity if there are more than this auraEffect of that kind on the unit or if it's a creature with DisableGravity on its movement template. + if (!apply + && (target.HasAuraType(GetAuraType()) + || target.HasAuraType(AuraType.ModStunDisableGravity) + || (target.IsCreature() && target.ToCreature().GetMovementTemplate().Flight == CreatureFlightMovementType.DisableGravity))) + return; + + if (target.SetDisableGravity(apply)) + if (!apply && !target.IsFlying()) + target.GetMotionMaster().MoveFall(); + } + /***************************/ /*** CHARM ***/ /***************************/ @@ -3245,7 +3270,7 @@ namespace Game.Spells aurApp.GetTarget().UpdateArmor(); } - + [AuraEffectHandler(AuraType.ModStatBonusPct)] void HandleModStatBonusPercent(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) { @@ -4646,7 +4671,7 @@ namespace Game.Spells target.RemoveUnitFlag3(UnitFlags3.AlternativeDefaultLanguage); } } - + [AuraEffectHandler(AuraType.Linked)] void HandleAuraLinked(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) { @@ -5762,7 +5787,7 @@ namespace Game.Spells } } } - + [AuraEffectHandler(AuraType.SetFFAPvp)] void HandleSetFFAPvP(AuraApplication aurApp, AuraEffectHandleModes mode, bool apply) { diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index 2f629a445..f71005791 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -5901,6 +5901,7 @@ namespace Game.Spells switch (auraType) { case AuraType.ModStun: + case AuraType.ModStunDisableGravity: return SpellCastResult.Stunned; case AuraType.ModFear: return SpellCastResult.Fleeing; @@ -5939,6 +5940,12 @@ namespace Game.Spells SpellCastResult mechanicResult = mechanicCheck(AuraType.ModFear, ref param1); if (mechanicResult != SpellCastResult.SpellCastOk) result = mechanicResult; + else + { + mechanicResult = mechanicCheck(AuraType.ModStunDisableGravity, ref param1); + if (mechanicResult != SpellCastResult.SpellCastOk) + result = mechanicResult; + } } else if (!CheckSpellCancelsFear(ref param1)) result = SpellCastResult.Fleeing;