diff options
author | Jeremy <Golrag@users.noreply.github.com> | 2024-08-05 01:51:29 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2024-08-17 14:02:00 +0200 |
commit | 2624503e7ed25a5a93b930a52552669a0be3e2c3 (patch) | |
tree | 2f2ebc42e58f6c0b666c2144f4aba4fd5c15d4b5 /src | |
parent | 33376009030738d56333c04fbb14b310099e4fc2 (diff) |
Spells/Auras: Implement SPELL_AURA_ACT_AS_CONTROL_ZONE (#30083)
(cherry picked from commit 66abfd1c530e81f24856825f7ebe5a1c1ba8c58e)
# Conflicts:
# src/server/game/Spells/Auras/SpellAuraEffects.cpp
# src/server/game/Spells/Auras/SpellAuraEffects.h
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/GameObject/GameObject.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 5 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraDefines.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 36 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.h | 2 |
5 files changed, 44 insertions, 3 deletions
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp index feb5b263b05..0513a68ad86 100644 --- a/src/server/game/Entities/GameObject/GameObject.cpp +++ b/src/server/game/Entities/GameObject/GameObject.cpp @@ -721,7 +721,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 bc7333a02ce..a8d166e38b3 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12819,6 +12819,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 edbbdb52ef6..68c8f5c0f1f 100644 --- a/src/server/game/Spells/Auras/SpellAuraDefines.h +++ b/src/server/game/Spells/Auras/SpellAuraDefines.h @@ -493,7 +493,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 05f4865fb2e..90ec31a6411 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 @@ -6432,6 +6432,40 @@ void AuraEffect::HandleConvertRune(AuraApplication const* aurApp, uint8 mode, bo playerTarget->RemoveRunesByAuraEffect(this); } +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 aeb51472173..6d7f07256c7 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -358,6 +358,8 @@ class TC_GAME_API AuraEffect void HandleProcTriggerSpellAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); void HandleProcTriggerSpellWithValueAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); void HandleProcTriggerDamageAuraProc(AuraApplication* aurApp, ProcEventInfo& eventInfo); + + void HandleAuraActAsControlZone(AuraApplication const* aurApp, uint8 mode, bool apply) const; }; namespace Trinity |