aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTeleqraph <nyrdeveloper@gmail.com>2022-12-30 01:16:29 +0100
committerGitHub <noreply@github.com>2022-12-30 01:16:29 +0100
commit6515319b7542930ffe2237c309a3dc3773d70f72 (patch)
tree47c54618e509829817687de21f14bcc670858660
parent6ce66659929cbd680a91dd5caa1a5957f30b0716 (diff)
Core/Auras: Implemented SPELL_AURA_MOD_STUN_DISABLE_GRAVITY (#28511)
Co-authored-by: Shauren <shauren.trinity@gmail.com>
-rw-r--r--src/server/game/Entities/Player/Player.cpp2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp4
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp26
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
-rw-r--r--src/server/game/Spells/Spell.cpp7
5 files changed, 36 insertions, 4 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index e4b933084a2..b7fc120f178 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -23576,7 +23576,7 @@ void Player::SendInitialPacketsAfterAddToMap()
auraList.front()->HandleEffect(this, AURA_EFFECT_HANDLE_SEND_FOR_CLIENT, true);
}
- if (HasAuraType(SPELL_AURA_MOD_STUN))
+ if (HasAuraType(SPELL_AURA_MOD_STUN) || HasAuraType(SPELL_AURA_MOD_STUN_DISABLE_GRAVITY))
SetRooted(true);
WorldPackets::Movement::MoveSetCompoundState setCompoundState;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index ffedc0da2b4..0e74493dcba 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -10913,7 +10913,7 @@ void Unit::SetControlled(bool apply, UnitState state)
switch (state)
{
case UNIT_STATE_STUNNED:
- if (HasAuraType(SPELL_AURA_MOD_STUN))
+ if (HasAuraType(SPELL_AURA_MOD_STUN) || HasAuraType(SPELL_AURA_MOD_STUN_DISABLE_GRAVITY))
return;
ClearUnitState(state);
@@ -10952,7 +10952,7 @@ void Unit::SetControlled(bool apply, UnitState state)
void Unit::ApplyControlStatesIfNeeded()
{
// Unit States might have been already cleared but auras still present. I need to check with HasAuraType
- if (HasUnitState(UNIT_STATE_STUNNED) || HasAuraType(SPELL_AURA_MOD_STUN))
+ if (HasUnitState(UNIT_STATE_STUNNED) || HasAuraType(SPELL_AURA_MOD_STUN) || HasAuraType(SPELL_AURA_MOD_STUN_DISABLE_GRAVITY))
SetStunned(true);
if (HasUnitState(UNIT_STATE_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT) || HasAuraType(SPELL_AURA_MOD_ROOT_2))
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 2c0a8f11c3d..3eeb30c4d34 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -364,7 +364,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNoImmediateEffect, //295 SPELL_AURA_MOD_PERIODIC_DAMAGE_TAKEN implemented in Unit::MeleeDamageBonusTaken, Unit::SpellDamageBonusTaken
&AuraEffect::HandleAuraSetVehicle, //296 SPELL_AURA_SET_VEHICLE_ID sets vehicle on target
&AuraEffect::HandleNULL, //297 SPELL_AURA_MOD_ROOT_DISABLE_GRAVITY
- &AuraEffect::HandleNULL, //298 SPELL_AURA_MOD_STUN_DISABLE_GRAVITY
+ &AuraEffect::HandleAuraModStunAndDisableGravity, //298 SPELL_AURA_MOD_STUN_DISABLE_GRAVITY
&AuraEffect::HandleUnused, //299 unused (4.3.4)
&AuraEffect::HandleNoImmediateEffect, //300 SPELL_AURA_SHARE_DAMAGE_PCT implemented in Unit::DealDamage
&AuraEffect::HandleNoImmediateEffect, //301 SPELL_AURA_SCHOOL_HEAL_ABSORB implemented in Unit::CalcHealAbsorb
@@ -2901,6 +2901,30 @@ void AuraEffect::HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode,
target->SetControlled(false, UNIT_STATE_FLEEING);
}
+void AuraEffect::HandleAuraModStunAndDisableGravity(AuraApplication const* aurApp, uint8 mode, bool apply) const
+{
+ if (!(mode & AURA_EFFECT_HANDLE_REAL))
+ return;
+
+ Unit* target = aurApp->GetTarget();
+
+ target->SetControlled(apply, UNIT_STATE_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(SPELL_AURA_MOD_ROOT_DISABLE_GRAVITY)
+ || (target->IsCreature() && target->ToCreature()->GetMovementTemplate().Flight == CreatureFlightMovementType::DisableGravity)))
+ return;
+
+ if (target->SetDisableGravity(apply))
+ if (!apply && !target->IsFlying())
+ target->GetMotionMaster()->MoveFall();
+}
+
/***************************/
/*** CHARM ***/
/***************************/
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 50b8ec77412..e877dcc42b7 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -195,6 +195,7 @@ class TC_GAME_API AuraEffect
void HandleAuraModStun(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleAuraModRoot(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandlePreventFleeing(AuraApplication const* aurApp, uint8 mode, bool apply) const;
+ void HandleAuraModStunAndDisableGravity(AuraApplication const* aurApp, uint8 mode, bool apply) const;
// charm
void HandleModPossess(AuraApplication const* aurApp, uint8 mode, bool apply) const;
void HandleModPossessPet(AuraApplication const* aurApp, uint8 mode, bool apply) const;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 58007c844ac..6e65c530cc8 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -6699,6 +6699,7 @@ SpellCastResult Spell::CheckCasterAuras(int32* param1) const
switch (type)
{
case SPELL_AURA_MOD_STUN:
+ case SPELL_AURA_MOD_STUN_DISABLE_GRAVITY:
return SPELL_FAILED_STUNNED;
case SPELL_AURA_MOD_FEAR:
return SPELL_FAILED_FLEEING;
@@ -6720,6 +6721,12 @@ SpellCastResult Spell::CheckCasterAuras(int32* param1) const
SpellCastResult mechanicResult = mechanicCheck(SPELL_AURA_MOD_STUN);
if (mechanicResult != SPELL_CAST_OK)
result = mechanicResult;
+ else
+ {
+ mechanicResult = mechanicCheck(SPELL_AURA_MOD_STUN_DISABLE_GRAVITY);
+ if (mechanicResult != SPELL_CAST_OK)
+ result = mechanicResult;
+ }
}
else if (!CheckSpellCancelsStun(param1))
result = SPELL_FAILED_STUNNED;