aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJeremy <Golrag@users.noreply.github.com>2024-08-05 01:51:29 +0200
committerGitHub <noreply@github.com>2024-08-05 01:51:29 +0200
commit66abfd1c530e81f24856825f7ebe5a1c1ba8c58e (patch)
treef9d7f902ec42f3d24a15878bacafbe2be927e9a1 /src
parent4eccc196d636a9cd037ed242efe6a7b9a88228fb (diff)
Spells/Auras: Implement SPELL_AURA_ACT_AS_CONTROL_ZONE (#30083)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp5
-rw-r--r--src/server/game/Spells/Auras/SpellAuraDefines.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp37
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h2
5 files changed, 45 insertions, 3 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index a8903ee3c9f..6fffcbe2b8c 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -724,7 +724,7 @@ public:
if (static_cast<uint32>(std::abs(delta)) < minSuperiority)
return 0;
- float slope = (static_cast<float>(minTime) - maxTime) / (maxSuperiority - minSuperiority);
+ float slope = (static_cast<float>(minTime) - maxTime) / std::max<uint32>((maxSuperiority - minSuperiority), 1);
float intercept = maxTime - slope * minSuperiority;
float timeNeeded = slope * std::abs(delta) + intercept;
float percentageIncrease = 100.0f / timeNeeded;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index db619aba0cb..c59f3b150d4 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -12562,6 +12562,11 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
GetMap()->PlayerRelocation(ToPlayer(), x, y, z, orientation);
else
GetMap()->CreatureRelocation(ToCreature(), x, y, z, orientation);
+
+ AuraEffectList& controlZoneAuras = GetAuraEffectsByType(SPELL_AURA_ACT_AS_CONTROL_ZONE);
+ for (AuraEffect const* auraEffect : controlZoneAuras)
+ if (GameObject* controlZone = GetGameObject(auraEffect->GetSpellInfo()->Id))
+ GetMap()->GameObjectRelocation(controlZone, x, y, z, orientation);
}
else if (turn)
UpdateOrientation(orientation);
diff --git a/src/server/game/Spells/Auras/SpellAuraDefines.h b/src/server/game/Spells/Auras/SpellAuraDefines.h
index c4289c7028a..c3fb03e4690 100644
--- a/src/server/game/Spells/Auras/SpellAuraDefines.h
+++ b/src/server/game/Spells/Auras/SpellAuraDefines.h
@@ -492,7 +492,7 @@ enum AuraType : uint32
SPELL_AURA_BATTLEGROUND_PLAYER_POSITION = 398,
SPELL_AURA_MOD_TIME_RATE = 399,
SPELL_AURA_MOD_SKILL_2 = 400,
- SPELL_AURA_401 = 401,
+ SPELL_AURA_ACT_AS_CONTROL_ZONE = 401,
SPELL_AURA_MOD_OVERRIDE_POWER_DISPLAY = 402,
SPELL_AURA_OVERRIDE_SPELL_VISUAL = 403,
SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT = 404,
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 26d90a10c99..0d7d98afc25 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -470,7 +470,7 @@ NonDefaultConstructible<pAuraEffectHandler> AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleBattlegroundPlayerPosition, //398 SPELL_AURA_BATTLEGROUND_PLAYER_POSITION
&AuraEffect::HandleNULL, //399 SPELL_AURA_MOD_TIME_RATE
&AuraEffect::HandleAuraModSkill, //400 SPELL_AURA_MOD_SKILL_2
- &AuraEffect::HandleNULL, //401
+ &AuraEffect::HandleAuraActAsControlZone, //401 SPELL_AURA_ACT_AS_CONTROL_ZONE
&AuraEffect::HandleAuraModOverridePowerDisplay, //402 SPELL_AURA_MOD_OVERRIDE_POWER_DISPLAY
&AuraEffect::HandleNoImmediateEffect, //403 SPELL_AURA_OVERRIDE_SPELL_VISUAL implemented in Unit::GetCastSpellXSpellVisualId
&AuraEffect::HandleOverrideAttackPowerBySpellPower, //404 SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT
@@ -6473,6 +6473,41 @@ void AuraEffect::HandleForceBreathBar(AuraApplication const* aurApp, uint8 mode,
playerTarget->UpdatePositionData();
}
+void AuraEffect::HandleAuraActAsControlZone(AuraApplication const* aurApp, uint8 mode, bool apply) const
+{
+ if (!(mode & AURA_EFFECT_HANDLE_REAL))
+ return;
+
+ Unit* auraOwner = aurApp->GetTarget();
+ if (!apply)
+ {
+ auraOwner->RemoveGameObject(GetSpellInfo()->Id, true);
+ return;
+ }
+
+ GameObjectTemplate const* gameobjectTemplate = sObjectMgr->GetGameObjectTemplate(GetMiscValue());
+ if (!gameobjectTemplate)
+ {
+ TC_LOG_WARN("spells.aura.effect", "AuraEffect::HanldeAuraActAsControlZone: Spell {} [EffectIndex: {}] does not have an existing gameobject template.", GetId(), GetEffIndex());
+ return;
+ }
+
+ if (gameobjectTemplate->type != GAMEOBJECT_TYPE_CONTROL_ZONE)
+ {
+ TC_LOG_WARN("spells.aura.effect", "AuraEffect::HanldeAuraActAsControlZone: Spell {} [EffectIndex: {}] has a gameobject template ({}) that is not a control zone.", GetId(), GetEffIndex(), gameobjectTemplate->entry);
+ return;
+ }
+
+ if (gameobjectTemplate->displayId)
+ {
+ TC_LOG_WARN("spell.aura.effect", "AuraEffect::HanldeAuraActAsControlZone: Spell {} [EffectIndex: {}] has a gameobject template ({}) that has a display id. Only invisible gameobjects are supported.", GetId(), GetEffIndex(), gameobjectTemplate->entry);
+ return;
+ }
+
+ if (GameObject* controlZone = auraOwner->SummonGameObject(gameobjectTemplate->entry, auraOwner->GetPosition(), QuaternionData::fromEulerAnglesZYX(aurApp->GetTarget()->GetOrientation(), 0.f, 0.f), 24h, GO_SUMMON_TIMED_OR_CORPSE_DESPAWN))
+ controlZone->SetSpellId(GetSpellInfo()->Id);
+}
+
template TC_GAME_API void AuraEffect::GetTargetList(std::list<Unit*>&) const;
template TC_GAME_API void AuraEffect::GetTargetList(std::deque<Unit*>&) const;
template TC_GAME_API void AuraEffect::GetTargetList(std::vector<Unit*>&) const;
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 810af0fc8a7..c6ac44bc24c 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -362,6 +362,8 @@ class TC_GAME_API AuraEffect
// pvp talents
void HandleAuraPvpTalents(AuraApplication const* auraApp, uint8 mode, bool apply) const;
+
+ void HandleAuraActAsControlZone(AuraApplication const* aurApp, uint8 mode, bool apply) const;
};
namespace Trinity