diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-01-10 21:22:28 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-01-10 21:22:28 +0100 |
commit | 069771e22ef29e47298c62e6cb9d7dce72375348 (patch) | |
tree | 4cfd5dbb536d04831f5e3c6ad8f8ec763dc38125 /src | |
parent | 84b0eca4476faa68d9cf06431bc60c9a61c6152f (diff) |
Core/AreaTriggers: Replace fixed movement times in database for areatriggers with speed
Diffstat (limited to 'src')
10 files changed, 102 insertions, 151 deletions
diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp index 8c749bc6b2e..de24c32adcf 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp +++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.cpp @@ -196,7 +196,7 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::VisualAnim).ModifyValue(&UF::VisualAnim::AnimationDataID), GetCreateProperties()->AnimId); SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::VisualAnim).ModifyValue(&UF::VisualAnim::AnimKitID), GetCreateProperties()->AnimKitId); - if (GetCreateProperties() && GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::VisualAnimIsDecay)) + if (GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::VisualAnimIsDecay)) SetUpdateFieldValue(areaTriggerData.ModifyValue(&UF::AreaTriggerData::VisualAnim).ModifyValue(&UF::VisualAnim::IsDecay), true); if (caster) @@ -207,7 +207,7 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti PhasingHandler::InitDbPhaseShift(GetPhaseShift(), spawnData->phaseUseFlags, spawnData->phaseId, spawnData->phaseGroup); } - if (target && GetCreateProperties() && GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::HasAttached)) + if (target && GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::HasAttached)) m_movementInfo.transport.guid = target->GetGUID(); if (!IsStaticSpawn()) @@ -215,8 +215,6 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti UpdateShape(); - uint32 timeToTarget = GetCreateProperties()->TimeToTarget != 0 ? GetCreateProperties()->TimeToTarget : *m_areaTriggerData->Duration; - if (GetCreateProperties()->OrbitInfo) { AreaTriggerOrbitInfo orbit = *GetCreateProperties()->OrbitInfo; @@ -225,11 +223,11 @@ bool AreaTrigger::Create(AreaTriggerCreatePropertiesId areaTriggerCreateProperti else orbit.Center = pos; - InitOrbit(orbit, timeToTarget); + InitOrbit(orbit, GetCreateProperties()->Speed); } else if (GetCreateProperties()->HasSplines()) { - InitSplineOffsets(GetCreateProperties()->SplinePoints, timeToTarget); + InitSplineOffsets(GetCreateProperties()->SplinePoints); } // movement on transport of areatriggers on unit is handled by themself @@ -881,7 +879,7 @@ void AreaTrigger::HandleUnitEnterExit(std::vector<Unit*> const& newTargetList) SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::NumUnitsInside), _insideUnits.size()); SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::NumPlayersInside), - std::count_if(_insideUnits.begin(), _insideUnits.end(), [](ObjectGuid const& guid) { return guid.IsPlayer(); })); + std::ranges::count_if(_insideUnits, [](ObjectGuid const& guid) { return guid.IsPlayer(); })); } AreaTriggerTemplate const* AreaTrigger::GetTemplate() const @@ -1066,7 +1064,7 @@ void AreaTrigger::UndoActions(Unit* unit) unit->RemoveAurasDueToSpell(action.Param, GetCasterGuid()); } -void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, uint32 timeToTarget) +void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, Optional<float> overrideSpeed) { float angleSin = std::sin(GetOrientation()); float angleCos = std::cos(GetOrientation()); @@ -1086,20 +1084,25 @@ void AreaTrigger::InitSplineOffsets(std::vector<Position> const& offsets, uint32 rotatedPoints.emplace_back(x, y, z); } - InitSplines(rotatedPoints, timeToTarget); + InitSplines(rotatedPoints, overrideSpeed); } -void AreaTrigger::InitSplines(std::vector<G3D::Vector3> const& splinePoints, uint32 timeToTarget) +void AreaTrigger::InitSplines(std::vector<G3D::Vector3> const& splinePoints, Optional<float> overrideSpeed) { if (splinePoints.size() < 2) return; _movementTime = 0; - _spline = std::make_unique<::Movement::Spline<int32>>(); - _spline->init_spline(splinePoints.data(), splinePoints.size(), ::Movement::SplineBase::ModeLinear); - _spline->initLengths(); + std::unique_ptr<Movement::Spline<int32>> spline = std::make_unique<::Movement::Spline<int32>>(); + spline->init_spline(splinePoints.data(), splinePoints.size(), ::Movement::SplineBase::ModeLinear); + spline->initLengths(); + + float speed = overrideSpeed.value_or(GetCreateProperties()->Speed); + if (speed <= 0.0f) + speed = 1.0f; + uint32 timeToTarget = spline->length() / speed * float(IN_MILLISECONDS); SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTarget), timeToTarget); if (IsInWorld()) @@ -1116,65 +1119,69 @@ void AreaTrigger::InitSplines(std::vector<G3D::Vector3> const& splinePoints, uin reshape.AreaTriggerSpline.emplace(); reshape.AreaTriggerSpline->ElapsedTimeForMovement = GetElapsedTimeForMovement(); reshape.AreaTriggerSpline->TimeToTarget = timeToTarget; - for (G3D::Vector3 const& vec : splinePoints) + for (G3D::Vector3 const& vec : spline->getPoints()) reshape.AreaTriggerSpline->Points.emplace_back(vec.x, vec.y, vec.z); SendMessageToSet(reshape.Write(), true); } _reachedDestination = false; + _movement = std::move(spline); } bool AreaTrigger::HasSplines() const { - return bool(_spline); + return std::holds_alternative<std::unique_ptr<::Movement::Spline<int32>>>(_movement); } -void AreaTrigger::InitOrbit(AreaTriggerOrbitInfo const& orbit, uint32 timeToTarget) +void AreaTrigger::InitOrbit(AreaTriggerOrbitInfo const& orbit, Optional<float> overrideSpeed) { // Circular movement requires either a center position or an attached unit ASSERT(orbit.Center.has_value() || orbit.PathTarget.has_value()); - // should be sent in object create packets only - DoWithSuppressingObjectUpdates([&]() - { - SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTarget), timeToTarget); - const_cast<UF::AreaTriggerData&>(*m_areaTriggerData).ClearChanged(&UF::AreaTriggerData::TimeToTarget); - }); + float speed = overrideSpeed.value_or(GetCreateProperties()->Speed); + if (speed <= 0.0f) + speed = 1.0f; + + uint32 timeToTarget = static_cast<uint32>(orbit.Radius * 2.0f * static_cast<float>(M_PI) * static_cast<float>(IN_MILLISECONDS) / speed); + SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::TimeToTarget), timeToTarget); SetUpdateFieldValue(m_values.ModifyValue(&AreaTrigger::m_areaTriggerData).ModifyValue(&UF::AreaTriggerData::OrbitPathTarget), orbit.PathTarget.value_or(ObjectGuid::Empty)); - _orbitInfo = orbit; + std::unique_ptr<AreaTriggerOrbitInfo> movementOrbit = std::make_unique<AreaTriggerOrbitInfo>(); - _orbitInfo->TimeToTarget = timeToTarget; - _orbitInfo->ElapsedTimeForMovement = 0; + movementOrbit->TimeToTarget = timeToTarget; + movementOrbit->ElapsedTimeForMovement = 0; if (IsInWorld()) { WorldPackets::AreaTrigger::AreaTriggerRePath reshape; reshape.TriggerGUID = GetGUID(); - reshape.AreaTriggerOrbit = _orbitInfo; + reshape.AreaTriggerOrbit = *movementOrbit; SendMessageToSet(reshape.Write(), true); } + + _movement = std::move(movementOrbit); } bool AreaTrigger::HasOrbit() const { - return _orbitInfo.has_value(); + return std::holds_alternative<std::unique_ptr<AreaTriggerOrbitInfo>>(_movement); } Position const* AreaTrigger::GetOrbitCenterPosition() const { - if (!_orbitInfo) + if (!HasOrbit()) return nullptr; - if (_orbitInfo->PathTarget) - if (WorldObject* center = ObjectAccessor::GetWorldObject(*this, *_orbitInfo->PathTarget)) + AreaTriggerOrbitInfo const& orbit = *std::get<std::unique_ptr<AreaTriggerOrbitInfo>>(_movement); + if (orbit.PathTarget) + if (WorldObject* center = ObjectAccessor::GetWorldObject(*this, *orbit.PathTarget)) return center; - if (_orbitInfo->Center) - return &_orbitInfo->Center->Pos; + if (orbit.Center) + return &orbit.Center->Pos; return nullptr; } @@ -1186,7 +1193,7 @@ Position AreaTrigger::CalculateOrbitPosition() const return GetPosition(); AreaTriggerCreateProperties const* createProperties = GetCreateProperties(); - AreaTriggerOrbitInfo const& cmi = *_orbitInfo; + AreaTriggerOrbitInfo const& cmi = GetOrbit(); // AreaTrigger make exactly "Duration / TimeToTarget" loops during his life time float pathProgress = float(cmi.ElapsedTimeForMovement) / float(cmi.TimeToTarget); @@ -1231,10 +1238,11 @@ Position AreaTrigger::CalculateOrbitPosition() const void AreaTrigger::UpdateOrbitPosition(uint32 /*diff*/) { - if (_orbitInfo->StartDelay > GetElapsedTimeForMovement()) + AreaTriggerOrbitInfo& orbit = *std::get<std::unique_ptr<AreaTriggerOrbitInfo>>(_movement); + if (orbit.StartDelay > GetElapsedTimeForMovement()) return; - _orbitInfo->ElapsedTimeForMovement = GetElapsedTimeForMovement() - _orbitInfo->StartDelay; + orbit.ElapsedTimeForMovement = GetElapsedTimeForMovement() - orbit.StartDelay; Position pos = CalculateOrbitPosition(); @@ -1251,12 +1259,14 @@ void AreaTrigger::UpdateSplinePosition(uint32 diff) _movementTime += diff; + Movement::Spline<int32>& spline = *std::get<std::unique_ptr<::Movement::Spline<int32>>>(_movement); + if (_movementTime >= GetTimeToTarget()) { _reachedDestination = true; - _lastSplineIndex = int32(_spline->last()); + _lastSplineIndex = int32(spline.last()); - G3D::Vector3 lastSplinePosition = _spline->getPoint(_lastSplineIndex); + G3D::Vector3 lastSplinePosition = spline.getPoint(_lastSplineIndex); GetMap()->AreaTriggerRelocation(this, lastSplinePosition.x, lastSplinePosition.y, lastSplinePosition.z, GetOrientation()); #ifdef TRINITY_DEBUG DebugVisualizePosition(); @@ -1285,12 +1295,12 @@ void AreaTrigger::UpdateSplinePosition(uint32 diff) currentTimePercent = progress; } - int lastPositionIndex = 0; + int32 lastPositionIndex = 0; float percentFromLastPoint = 0; - _spline->computeIndex(currentTimePercent, lastPositionIndex, percentFromLastPoint); + spline.computeIndex(currentTimePercent, lastPositionIndex, percentFromLastPoint); G3D::Vector3 currentPosition; - _spline->evaluate_percent(lastPositionIndex, percentFromLastPoint, currentPosition); + spline.evaluate_percent(lastPositionIndex, percentFromLastPoint, currentPosition); float orientation = GetStationaryO(); if (createProperties && createProperties->FacingCurveId) @@ -1299,7 +1309,7 @@ void AreaTrigger::UpdateSplinePosition(uint32 diff) if (GetCreateProperties() && !GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::HasAbsoluteOrientation) && GetCreateProperties()->Flags.HasFlag(AreaTriggerCreatePropertiesFlag::HasFaceMovementDir)) { G3D::Vector3 derivative; - _spline->evaluate_derivative(lastPositionIndex, percentFromLastPoint, derivative); + spline.evaluate_derivative(lastPositionIndex, percentFromLastPoint, derivative); if (derivative.x != 0.0f || derivative.y != 0.0f) orientation += std::atan2(derivative.y, derivative.x); } diff --git a/src/server/game/Entities/AreaTrigger/AreaTrigger.h b/src/server/game/Entities/AreaTrigger/AreaTrigger.h index 90b4b299c17..56ebef02f5d 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTrigger.h +++ b/src/server/game/Entities/AreaTrigger/AreaTrigger.h @@ -152,15 +152,15 @@ class TC_GAME_API AreaTrigger final : public WorldObject, public GridObject<Area float GetMaxSearchRadius() const; Position const& GetRollPitchYaw() const { return _rollPitchYaw; } Position const& GetTargetRollPitchYaw() const { return _targetRollPitchYaw; } - void InitSplineOffsets(std::vector<Position> const& offsets, uint32 timeToTarget); - void InitSplines(std::vector<G3D::Vector3> const& splinePoints, uint32 timeToTarget); + void InitSplineOffsets(std::vector<Position> const& offsets, Optional<float> overrideSpeed = {}); + void InitSplines(std::vector<G3D::Vector3> const& splinePoints, Optional<float> overrideSpeed = {}); bool HasSplines() const; - ::Movement::Spline<int32> const& GetSpline() const { return *_spline; } + ::Movement::Spline<int32> const& GetSpline() const { return *std::get<std::unique_ptr<::Movement::Spline<int32>>>(_movement); } uint32 GetElapsedTimeForMovement() const { return GetTimeSinceCreated(); } /// @todo: research the right value, in sniffs both timers are nearly identical - void InitOrbit(AreaTriggerOrbitInfo const& orbit, uint32 timeToTarget); + void InitOrbit(AreaTriggerOrbitInfo const& orbit, Optional<float> overrideSpeed = {}); bool HasOrbit() const; - Optional<AreaTriggerOrbitInfo> const& GetOrbit() const { return _orbitInfo; } + AreaTriggerOrbitInfo const& GetOrbit() const { return *std::get<std::unique_ptr<AreaTriggerOrbitInfo>>(_movement); } bool HasOverridePosition() const; @@ -223,14 +223,12 @@ class TC_GAME_API AreaTrigger final : public WorldObject, public GridObject<Area Position _rollPitchYaw; Position _targetRollPitchYaw; std::vector<Position> _polygonVertices; - std::unique_ptr<::Movement::Spline<int32>> _spline; + std::variant<std::monostate, std::unique_ptr<::Movement::Spline<int32>>, std::unique_ptr<AreaTriggerOrbitInfo>> _movement; bool _reachedDestination; int32 _lastSplineIndex; uint32 _movementTime; - Optional<AreaTriggerOrbitInfo> _orbitInfo; - AreaTriggerCreateProperties const* _areaTriggerCreateProperties; AreaTriggerTemplate const* _areaTriggerTemplate; GuidUnorderedSet _insideUnits; diff --git a/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.cpp b/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.cpp index c4c9502c979..aa7d6d2c930 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.cpp +++ b/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.cpp @@ -16,7 +16,6 @@ */ #include "AreaTriggerTemplate.h" -#include <G3D/Vector3.h> #include <algorithm> #include <cstring> #include <cmath> @@ -73,37 +72,10 @@ float AreaTriggerShapeInfo::GetMaxSearchRadius() const return 0.0f; } -AreaTriggerTemplate::AreaTriggerTemplate() : Flags(AreaTriggerFlag::None), ActionSetFlags(AreaTriggerActionSetFlag::None) -{ - Id = { 0, false }; - ActionSetId = 0; -} - +AreaTriggerTemplate::AreaTriggerTemplate() = default; AreaTriggerTemplate::~AreaTriggerTemplate() = default; -AreaTriggerCreateProperties::AreaTriggerCreateProperties() : Flags(AreaTriggerCreatePropertiesFlag::None) -{ - Id = { 0, false }; - Template = nullptr; - - MoveCurveId = 0; - ScaleCurveId = 0; - MorphCurveId = 0; - FacingCurveId = 0; - - AnimId = 0; - AnimKitId = 0; - - DecalPropertiesId = 0; - - TimeToTarget = 0; - TimeToTargetScale = 0; - - ExtraScale.emplace(); - - ScriptId = 0; -} - +AreaTriggerCreateProperties::AreaTriggerCreateProperties() = default; AreaTriggerCreateProperties::~AreaTriggerCreateProperties() = default; bool AreaTriggerCreateProperties::HasSplines() const diff --git a/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.h b/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.h index 2fe1797cd60..a5846beb78c 100644 --- a/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.h +++ b/src/server/game/Entities/AreaTrigger/AreaTriggerTemplate.h @@ -207,10 +207,10 @@ public: AreaTriggerTemplate(); ~AreaTriggerTemplate(); - AreaTriggerId Id; - EnumFlag<AreaTriggerFlag> Flags; - uint32 ActionSetId; - EnumFlag<AreaTriggerActionSetFlag> ActionSetFlags; + AreaTriggerId Id = { .Id = 0, .IsCustom = false }; + EnumFlag<AreaTriggerFlag> Flags = AreaTriggerFlag::None; + uint32 ActionSetId = 0; + EnumFlag<AreaTriggerActionSetFlag> ActionSetFlags = AreaTriggerActionSetFlag::None; std::vector<AreaTriggerAction> Actions; }; @@ -222,34 +222,34 @@ public: bool HasSplines() const; - AreaTriggerCreatePropertiesId Id; - AreaTriggerTemplate const* Template; - EnumFlag<AreaTriggerCreatePropertiesFlag> Flags; + AreaTriggerCreatePropertiesId Id = { .Id = 0, .IsCustom = false }; + AreaTriggerTemplate const* Template = nullptr; + EnumFlag<AreaTriggerCreatePropertiesFlag> Flags = AreaTriggerCreatePropertiesFlag::None; - uint32 MoveCurveId; - uint32 ScaleCurveId; - uint32 MorphCurveId; - uint32 FacingCurveId; + uint32 MoveCurveId = 0; + uint32 ScaleCurveId = 0; + uint32 MorphCurveId = 0; + uint32 FacingCurveId = 0; - int32 AnimId; - int32 AnimKitId; + int32 AnimId = 0; + int32 AnimKitId = 0; - uint32 DecalPropertiesId; + uint32 DecalPropertiesId = 0; Optional<int32> SpellForVisuals; - uint32 TimeToTarget; - uint32 TimeToTargetScale; + uint32 TimeToTargetScale = 0; Optional<AreaTriggerScaleCurveTemplate> OverrideScale; - Optional<AreaTriggerScaleCurveTemplate> ExtraScale; + Optional<AreaTriggerScaleCurveTemplate> ExtraScale = Optional<AreaTriggerScaleCurveTemplate>(std::in_place); AreaTriggerShapeInfo Shape; + float Speed = 1.0f; std::vector<Position> SplinePoints; Optional<AreaTriggerOrbitInfo> OrbitInfo; - uint32 ScriptId; + uint32 ScriptId = 0; }; struct AreaTriggerSpawn : SpawnData diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 724e852e58c..57a44646ce3 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -623,7 +623,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, CreateObjectBits flags, Playe // *data << *areaTrigger->GetMovementScript(); // AreaTriggerMovementScriptInfo if (hasOrbit) - *data << *areaTrigger->GetOrbit(); + *data << areaTrigger->GetOrbit(); } if (flags.GameObject) diff --git a/src/server/game/Globals/AreaTriggerDataStore.cpp b/src/server/game/Globals/AreaTriggerDataStore.cpp index 62ff42c0de0..12b9236a1a2 100644 --- a/src/server/game/Globals/AreaTriggerDataStore.cpp +++ b/src/server/game/Globals/AreaTriggerDataStore.cpp @@ -168,8 +168,8 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates() // 0 1 2 3 4 if (QueryResult areatriggerCreateProperties = WorldDatabase.Query("SELECT Id, IsCustom, AreaTriggerId, IsAreatriggerCustom, Flags, " - // 5 6 7 8 9 10 11 12 13 14 - "MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTarget, TimeToTargetScale, " + // 5 6 7 8 9 10 11 12 13 14 + "MoveCurveId, ScaleCurveId, MorphCurveId, FacingCurveId, AnimId, AnimKitId, DecalPropertiesId, SpellForVisuals, TimeToTargetScale, Speed, " // 15 16 17 18 19 20 21 22 23 24 "Shape, ShapeData0, ShapeData1, ShapeData2, ShapeData3, ShapeData4, ShapeData5, ShapeData6, ShapeData7, ScriptName FROM `areatrigger_create_properties`")) { @@ -233,10 +233,10 @@ void AreaTriggerDataStore::LoadAreaTriggerTemplates() } } - createProperties.TimeToTarget = fields[13].GetUInt32(); - createProperties.TimeToTargetScale = fields[14].GetUInt32(); + createProperties.TimeToTargetScale = fields[13].GetUInt32(); + createProperties.Speed = fields[14].GetFloat(); - createProperties.Shape.Type = static_cast<AreaTriggerShapeType>(shape); + createProperties.Shape.Type = shape; for (uint8 i = 0; i < MAX_AREATRIGGER_ENTITY_DATA; ++i) createProperties.Shape.DefaultDatas.Data[i] = fields[16 + i].GetFloat(); @@ -361,7 +361,7 @@ void AreaTriggerDataStore::LoadAreaTriggerSpawns() continue; } - if (createProperties->TimeToTarget || createProperties->TimeToTargetScale || createProperties->FacingCurveId || createProperties->MoveCurveId) + if (createProperties->TimeToTargetScale) { TC_LOG_ERROR("sql.sql", "Table `areatrigger` has listed AreaTriggerCreatePropertiesId (Id: {}, IsCustom: {}) with time to target values", createPropertiesId.Id, uint32(createPropertiesId.IsCustom)); diff --git a/src/server/scripts/BrokenIsles/MawOfSouls/boss_ymiron_the_fallen_king.cpp b/src/server/scripts/BrokenIsles/MawOfSouls/boss_ymiron_the_fallen_king.cpp index 514a386767a..6ab34f040b7 100644 --- a/src/server/scripts/BrokenIsles/MawOfSouls/boss_ymiron_the_fallen_king.cpp +++ b/src/server/scripts/BrokenIsles/MawOfSouls/boss_ymiron_the_fallen_king.cpp @@ -470,7 +470,7 @@ class spell_ymiron_the_fallen_king_bane_periodic_AuraScript : public AuraScript static constexpr float BANE_MISSILE_DIST_BASE = 10.0f; static constexpr float BANE_MISSILE_ANGLE_OFFSET = 0.75f; - static constexpr int8 BANE_MAX_TOTAL_TICKS = 4 + 4 + 14; + static constexpr std::size_t BANE_MAX_TOTAL_TICKS = 4 + 4 + 14; void CalcPeriodic(AuraEffect const* /*aurEff*/, bool& /*isPeriodic*/, int32& amplitude) { @@ -494,7 +494,7 @@ class spell_ymiron_the_fallen_king_bane_periodic_AuraScript : public AuraScript void OnAfterApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { - for (int8 i = 0; i < BANE_MAX_TOTAL_TICKS; i++) + for (std::size_t i = 0; i < BANE_MAX_TOTAL_TICKS; i++) { float angle = Position::NormalizeOrientation(GetCaster()->GetOrientation() + (i * BANE_MISSILE_ANGLE_OFFSET)); _angles[2 * i + 0] = angle; @@ -533,16 +533,14 @@ class spell_ymiron_the_fallen_king_bane_periodic_AuraScript : public AuraScript } private: - std::array<float, BANE_MAX_TOTAL_TICKS * 2> _angles; - std::array<float, BANE_MAX_TOTAL_TICKS * 2> _distances; + std::array<float, BANE_MAX_TOTAL_TICKS * 2> _angles = { }; + std::array<float, BANE_MAX_TOTAL_TICKS * 2> _distances = { }; }; struct at_ymiron_the_fallen_king_bane : AreaTriggerAI { at_ymiron_the_fallen_king_bane(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } - static constexpr float TIME_TO_TARGET_DIST_MULTIPLIER = 966.6466466434464f; - void OnInitialize() override { Unit* caster = at->GetCaster(); @@ -550,7 +548,6 @@ struct at_ymiron_the_fallen_king_bane : AreaTriggerAI return; float radius = at->GetExactDist(caster); - float timeToTarget = radius * TIME_TO_TARGET_DIST_MULTIPLIER; float angle = at->GetOrientation(); AreaTriggerOrbitInfo orbitInfo; @@ -562,7 +559,7 @@ struct at_ymiron_the_fallen_king_bane : AreaTriggerAI orbitInfo.BlendFromRadius = radius; orbitInfo.InitialAngle = angle; orbitInfo.PathTarget = caster->GetGUID(); - at->InitOrbit(orbitInfo, timeToTarget); + at->InitOrbit(orbitInfo); } void OnUnitEnter(Unit* unit) override diff --git a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp index 871c4d33bef..8ec595ede47 100644 --- a/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp +++ b/src/server/scripts/Shadowlands/SepulcherOfTheFirstOnes/boss_anduin_wrynn.cpp @@ -2922,24 +2922,13 @@ class spell_anduin_wrynn_wicked_star_selector_AuraScript : public AuraScript } }; +// 365017 - Wicked Star CreatePropertiesId: 24322 +// 365017 - Wicked Star CreatePropertiesId: 24740 // 365017 - Wicked Star CreatePropertiesId: 24741 struct at_anduin_wrynn_wicked_star : AreaTriggerAI { at_anduin_wrynn_wicked_star(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { } - static constexpr float GetWickedStarSpeed(Difficulty difficulty) - { - // in yards per second - switch (difficulty) - { - case DIFFICULTY_HEROIC_RAID: - case DIFFICULTY_MYTHIC_RAID: - return 18.0f; - default: // LFR + Normal - return 15.0f; - } - } - void OnInitialize() override { if (Unit* caster = at->GetCaster()) @@ -2951,13 +2940,10 @@ struct at_anduin_wrynn_wicked_star : AreaTriggerAI std::vector<G3D::Vector3> splinePoints; splinePoints.push_back(PositionToVector3(at->GetPosition())); - splinePoints.push_back(PositionToVector3(at->GetPosition())); splinePoints.push_back(PositionToVector3(destPos)); splinePoints.push_back(PositionToVector3(at->GetPosition())); - splinePoints.push_back(PositionToVector3(at->GetPosition())); - float timeToTarget = at->GetDistance(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ()) * 2 / GetWickedStarSpeed(at->GetMap()->GetDifficultyID()) * 1000; - at->InitSplines(splinePoints, timeToTarget); + at->InitSplines(splinePoints); } } @@ -2972,9 +2958,9 @@ struct at_anduin_wrynn_wicked_star : AreaTriggerAI return; if (caster->IsValidAttackTarget(unit)) - caster->CastSpell(unit, SPELL_WICKED_STAR_DAMAGE_SILENCE, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS))); + caster->CastSpell(unit, SPELL_WICKED_STAR_DAMAGE_SILENCE, TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS); else if (caster->IsValidAssistTarget(unit)) - caster->CastSpell(unit, SPELL_WICKED_STAR_EMPOWERMENT, CastSpellExtraArgs(TriggerCastFlags(TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS))); + caster->CastSpell(unit, SPELL_WICKED_STAR_EMPOWERMENT, TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS); } void OnDestinationReached() override @@ -3002,8 +2988,6 @@ struct at_anduin_wrynn_empowered_wicked_star : public at_anduin_wrynn_wicked_sta { at_anduin_wrynn_empowered_wicked_star(AreaTrigger* areatrigger) : at_anduin_wrynn_wicked_star(areatrigger) { } - static float constexpr EMPOWERED_WICKED_STAR_SPEED = 14.0f; // in yards per second - void HandleMovement(float angle) const { Unit* caster = at->GetCaster(); @@ -3016,12 +3000,9 @@ struct at_anduin_wrynn_empowered_wicked_star : public at_anduin_wrynn_wicked_sta std::vector<G3D::Vector3> splinePoints; splinePoints.push_back(PositionToVector3(at)); - splinePoints.push_back(PositionToVector3(at)); - splinePoints.push_back(PositionToVector3(destPos)); splinePoints.push_back(PositionToVector3(destPos)); - float timeToTarget = at->GetDistance(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ()) / EMPOWERED_WICKED_STAR_SPEED * 1000; - at->InitSplines(splinePoints, timeToTarget); + at->InitSplines(splinePoints); } void OnInitialize() override diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index f27e555c621..4c7415a4119 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -1035,7 +1035,7 @@ class spell_pri_divine_star_shadow : public SpellScript // 122121 - Divine Star (Shadow) struct areatrigger_pri_divine_star : AreaTriggerAI { - areatrigger_pri_divine_star(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger), _maxTravelDistance(0.0f) { } + using AreaTriggerAI::AreaTriggerAI; void OnInitialize() override { @@ -1053,18 +1053,15 @@ struct areatrigger_pri_divine_star : AreaTriggerAI _casterCurrentPosition = caster->GetPosition(); // Note: max. distance at which the Divine Star can travel to is EFFECT_1's BasePoints yards. - _maxTravelDistance = float(spellInfo->GetEffect(EFFECT_1).CalcValue(caster)); + float maxTravelDistance = float(spellInfo->GetEffect(EFFECT_1).CalcValue(caster)); Position destPos = _casterCurrentPosition; - at->MovePositionToFirstCollision(destPos, _maxTravelDistance, 0.0f); + at->MovePositionToFirstCollision(destPos, maxTravelDistance, 0.0f); PathGenerator firstPath(at); firstPath.CalculatePath(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ(), false); - G3D::Vector3 const& endPoint = firstPath.GetPath().back(); - - // Note: it takes 1000ms to reach EFFECT_1's BasePoints yards, so it takes (1000 / EFFECT_1's BasePoints)ms to run 1 yard. - at->InitSplines(firstPath.GetPath(), at->GetDistance(endPoint.x, endPoint.y, endPoint.z) * float(1000 / _maxTravelDistance)); + at->InitSplines(firstPath.GetPath()); } void OnUpdate(uint32 diff) override @@ -1089,7 +1086,7 @@ struct areatrigger_pri_divine_star : AreaTriggerAI if (!caster) return; - if (std::find(_affectedUnits.begin(), _affectedUnits.end(), unit->GetGUID()) != _affectedUnits.end()) + if (advstd::ranges::contains(_affectedUnits, unit->GetGUID())) return; constexpr TriggerCastFlags TriggerFlags = TRIGGERED_IGNORE_GCD | TRIGGERED_IGNORE_CAST_IN_PROGRESS; @@ -1133,11 +1130,9 @@ struct areatrigger_pri_divine_star : AreaTriggerAI Movement::PointsArray returnSplinePoints; returnSplinePoints.push_back(PositionToVector3(at)); - returnSplinePoints.push_back(PositionToVector3(at)); - returnSplinePoints.push_back(PositionToVector3(caster)); returnSplinePoints.push_back(PositionToVector3(caster)); - at->InitSplines(returnSplinePoints, uint32(at->GetDistance(caster) / _maxTravelDistance * 1000)); + at->InitSplines(returnSplinePoints); task.Repeat(250ms); }); @@ -1147,7 +1142,6 @@ private: TaskScheduler _scheduler; Position _casterCurrentPosition; std::vector<ObjectGuid> _affectedUnits; - float _maxTravelDistance; }; // 391339 - Empowered Renew diff --git a/src/server/scripts/World/areatrigger_scripts.cpp b/src/server/scripts/World/areatrigger_scripts.cpp index 94f6bd43ccc..45cfcd40ceb 100644 --- a/src/server/scripts/World/areatrigger_scripts.cpp +++ b/src/server/scripts/World/areatrigger_scripts.cpp @@ -484,8 +484,7 @@ struct at_void_orb_harbinger : AreaTriggerAI PathGenerator path(at); path.CalculatePath(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ(), false); - float timeToTarget = at->GetDistance(destPos.GetPositionX(), destPos.GetPositionY(), destPos.GetPositionZ()) * 144.5f; - at->InitSplines(path.GetPath(), timeToTarget); + at->InitSplines(path.GetPath()); } } |