diff options
Diffstat (limited to 'src')
14 files changed, 48 insertions, 32 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 373cdb97e12..64a2a6e8cc1 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -1973,11 +1973,11 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u { float gravity = e.action.jump.UseDefaultGravity ? Movement::gravity : e.action.jump.Gravity; me->GetMotionMaster()->MoveJumpWithGravity(pos, float(e.action.jump.SpeedXY), gravity, e.action.jump.PointId, - false, nullptr, nullptr, std::move(actionResultSetter)); + {}, nullptr, nullptr, std::move(actionResultSetter)); } else me->GetMotionMaster()->MoveJump(pos, float(e.action.jump.SpeedXY), float(e.action.jump.SpeedZ), e.action.jump.PointId, - false, nullptr, nullptr, std::move(actionResultSetter)); + {}, nullptr, nullptr, std::move(actionResultSetter)); mTimedActionWaitEvent = std::move(waitEvent); break; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index b02c7a5f130..894d11973e7 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -12111,14 +12111,6 @@ void Unit::JumpTo(float speedXY, float speedZ, float angle, Optional<Position> d } } -void Unit::JumpTo(WorldObject* obj, float speedZ, bool withOrientation) -{ - float x, y, z; - obj->GetContactPoint(this, x, y, z); - float speedXY = GetExactDist2d(x, y) * 10.0f / speedZ; - GetMotionMaster()->MoveJump(x, y, z, GetAbsoluteAngle(obj), speedXY, speedZ, EVENT_JUMP, withOrientation); -} - void Unit::HandleSpellClick(Unit* clicker, int8 seatId /*= -1*/) { bool spellClickHandled = false; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index c2ecd8d7c7d..41d48b70cdf 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1129,7 +1129,6 @@ class TC_GAME_API Unit : public WorldObject void SendMoveKnockBack(Player* player, float speedXY, float speedZ, float vcos, float vsin); void KnockbackFrom(Position const& origin, float speedXY, float speedZ, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr); void JumpTo(float speedXY, float speedZ, float angle, Optional<Position> dest = {}); - void JumpTo(WorldObject* obj, float speedZ, bool withOrientation = false); void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false); diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index c1f042111cc..bf12944969a 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -843,18 +843,18 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) _owner->GetNearPoint2D(nullptr, x, y, dist, _owner->GetOrientation() + angle); _owner->UpdateAllowedPositionZ(x, y, z); - MoveJump(x, y, z, 0.0f, speedXY, speedZ); + MoveJump(x, y, z, speedXY, speedZ); } -void MotionMaster::MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id/* = EVENT_JUMP*/, bool hasOrientation/* = false*/, +void MotionMaster::MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id/* = EVENT_JUMP*/, MovementFacingTarget const& facing/* = {}*/, JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/) { - MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, - arrivalCast, spellEffectExtraData, std::move(scriptResult)); + MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), speedXY, speedZ, id, facing, arrivalCast, + spellEffectExtraData, std::move(scriptResult)); } -void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, bool hasOrientation /* = false*/, +void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, MovementFacingTarget const& facing /* = {}*/, JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/) { @@ -874,8 +874,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f init.MoveTo(x, y, z, false); init.SetParabolic(max_height, 0); init.SetVelocity(speedXY); - if (hasOrientation) - init.SetFacing(o); + std::visit(Movement::MoveSplineInitFacingVisitor(init), facing); if (effect) init.SetSpellEffectExtraData(*effect); }; @@ -895,7 +894,7 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f Add(movement); } -void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float gravity, uint32 id/* = EVENT_JUMP*/, bool hasOrientation/* = false*/, +void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float gravity, uint32 id/* = EVENT_JUMP*/, MovementFacingTarget const& facing/* = {}*/, JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/) { @@ -914,8 +913,7 @@ void MotionMaster::MoveJumpWithGravity(Position const& pos, float speedXY, float init.SetUncompressed(); init.SetVelocity(speedXY); init.SetUnlimitedSpeed(); - if (hasOrientation) - init.SetFacing(pos.GetOrientation()); + std::visit(Movement::MoveSplineInitFacingVisitor(init), facing); if (effect) init.SetSpellEffectExtraData(*effect); }; diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index e7db6694429..3600a6bb1ec 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -188,13 +188,13 @@ class TC_GAME_API MotionMaster void MoveCharge(PathGenerator const& path, float speed = SPEED_CHARGE, Unit const* target = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr); void MoveKnockbackFrom(Position const& origin, float speedXY, float speedZ, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr); void MoveJumpTo(float angle, float speedXY, float speedZ); - void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false, + void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP, MovementFacingTarget const& facing = {}, JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {}); - void MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false, + void MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id = EVENT_JUMP, MovementFacingTarget const& facing = {}, JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {}); - void MoveJumpWithGravity(Position const& pos, float speedXY, float gravity, uint32 id = EVENT_JUMP, bool hasOrientation = false, + void MoveJumpWithGravity(Position const& pos, float speedXY, float gravity, uint32 id = EVENT_JUMP, MovementFacingTarget const& facing = {}, JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {}); void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount, diff --git a/src/server/game/Movement/MovementDefines.h b/src/server/game/Movement/MovementDefines.h index e2b2dc16e5d..837cb7d81b2 100644 --- a/src/server/game/Movement/MovementDefines.h +++ b/src/server/game/Movement/MovementDefines.h @@ -21,6 +21,10 @@ #include "Common.h" #include "ObjectGuid.h" #include "Optional.h" +#include "Position.h" +#include <variant> + +class Unit; #define SPEED_CHARGE 42.0f // assume it is 25 yard per 0.6 second @@ -151,6 +155,8 @@ struct JumpChargeParams Optional<uint32> ParabolicCurveId; }; +using MovementFacingTarget = std::variant<std::monostate, Position, Unit const*, float>; + inline bool IsInvalidMovementGeneratorType(uint8 const type) { return type == MAX_DB_MOTION_TYPE || type >= MAX_MOTION_TYPE; } inline bool IsInvalidMovementSlot(uint8 const slot) { return slot >= MAX_MOTION_SLOT; } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 6601e4d45a7..8b46249b21e 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -291,4 +291,9 @@ namespace Movement return input; } + + void MoveSplineInitFacingVisitor::operator()(Position const& point) const + { + init.SetFacing(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ()); + } } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index 880ada0c33d..8f8653cbd57 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -23,6 +23,7 @@ class ObjectGuid; class Unit; +struct Position; enum class AnimTier : uint8; namespace Movement @@ -222,5 +223,17 @@ namespace Movement { args.spellEffectExtra = spellEffectExtraData; } + + struct TC_GAME_API MoveSplineInitFacingVisitor + { + explicit MoveSplineInitFacingVisitor(MoveSplineInit& init_) : init(init_) { } + + void operator()(std::monostate) const { } + void operator()(Position const& point) const; + void operator()(Unit const* target) const { init.SetFacing(target); } + void operator()(float angle) const { init.SetFacing(angle); } + + MoveSplineInit& init; + }; } #endif // TRINITYSERVER_MOVESPLINEINIT_H diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index a0ce224c9cc..c35d06f8a62 100644 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -896,7 +896,7 @@ void Spell::EffectJump() JumpArrivalCastArgs arrivalCast; arrivalCast.SpellId = effectInfo->TriggerSpell; arrivalCast.Target = unitTarget->GetGUID(); - unitCaster->GetMotionMaster()->MoveJump(*unitTarget, speedXY, speedZ, EVENT_JUMP, false, &arrivalCast); + unitCaster->GetMotionMaster()->MoveJump(*unitTarget, speedXY, speedZ, EVENT_JUMP, {}, &arrivalCast); } void Spell::EffectJumpDest() @@ -916,9 +916,12 @@ void Spell::EffectJumpDest() float speedXY, speedZ; CalculateJumpSpeeds(effectInfo, unitCaster->GetExactDist2d(destTarget), speedXY, speedZ); + MovementFacingTarget facing; + if (!m_targets.GetUnitTargetGUID().IsEmpty()) + facing = destTarget->GetOrientation(); JumpArrivalCastArgs arrivalCast; arrivalCast.SpellId = effectInfo->TriggerSpell; - unitCaster->GetMotionMaster()->MoveJump(*destTarget, speedXY, speedZ, EVENT_JUMP, !m_targets.GetObjectTargetGUID().IsEmpty(), &arrivalCast); + unitCaster->GetMotionMaster()->MoveJump(*destTarget, speedXY, speedZ, EVENT_JUMP, facing, &arrivalCast); } TeleportToOptions GetTeleportOptions(WorldObject const* caster, Unit const* unitTarget, SpellDestination const& targetDest) @@ -5782,7 +5785,7 @@ void Spell::EffectJumpCharge() effectExtra->ParabolicCurveId = *params->ParabolicCurveId; } - unitCaster->GetMotionMaster()->MoveJumpWithGravity(*destTarget, speed, params->JumpGravity, EVENT_JUMP, false, + unitCaster->GetMotionMaster()->MoveJumpWithGravity(*destTarget, speed, params->JumpGravity, EVENT_JUMP, {}, arrivalCast ? &*arrivalCast : nullptr, effectExtra ? &*effectExtra : nullptr); } diff --git a/src/server/scripts/Battlegrounds/IsleOfConquest/isle_of_conquest.cpp b/src/server/scripts/Battlegrounds/IsleOfConquest/isle_of_conquest.cpp index 357e7bba238..460572978d5 100644 --- a/src/server/scripts/Battlegrounds/IsleOfConquest/isle_of_conquest.cpp +++ b/src/server/scripts/Battlegrounds/IsleOfConquest/isle_of_conquest.cpp @@ -258,7 +258,7 @@ class StartLaunchEvent : public BasicEvent float dist = player->GetExactDist2d(&_pos); player->ExitVehicle(); - player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, true); + player->GetMotionMaster()->MoveJump(_pos, dist, speedZ, EVENT_JUMP, _pos.GetOrientation()); return true; } diff --git a/src/server/scripts/Kalimdor/RagefireChasm/boss_lava_guard_gordoth.cpp b/src/server/scripts/Kalimdor/RagefireChasm/boss_lava_guard_gordoth.cpp index 9c3df91c45c..965bc6660c0 100644 --- a/src/server/scripts/Kalimdor/RagefireChasm/boss_lava_guard_gordoth.cpp +++ b/src/server/scripts/Kalimdor/RagefireChasm/boss_lava_guard_gordoth.cpp @@ -148,7 +148,7 @@ struct boss_lava_guard_gordoth : public BossAI me->SetAIAnimKitId(ANIMKIT_GORDOTH_NONE); DoCastSelf(SPELL_JAIL_BREAK); - me->GetMotionMaster()->MoveJumpWithGravity(GordothJumpPos, 50.0f, 55.5477f, POINT_JUMP, true); + me->GetMotionMaster()->MoveJumpWithGravity(GordothJumpPos, 50.0f, 55.5477f, POINT_JUMP, GordothJumpPos.GetOrientation()); scheduler.Schedule(30ms, [this](TaskContext /*task*/) { diff --git a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp index 6981c20453e..32bc627b92d 100644 --- a/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp +++ b/src/server/scripts/Northrend/CrusadersColiseum/TrialOfTheCrusader/boss_faction_champions.cpp @@ -488,7 +488,7 @@ struct boss_toc_champion_controller : public BossAI else { champion->SetHomePosition((ToCCommonLoc[1].GetPositionX()*2)-vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 3); - champion->GetMotionMaster()->MoveJump((ToCCommonLoc[1].GetPositionX() * 2) - vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), vChampionJumpTarget[pos].GetOrientation(), 20.0f, 20.0f); + champion->GetMotionMaster()->MoveJump((ToCCommonLoc[1].GetPositionX() * 2) - vChampionJumpTarget[pos].GetPositionX(), vChampionJumpTarget[pos].GetPositionY(), vChampionJumpTarget[pos].GetPositionZ(), 20.0f, 20.0f); champion->SetOrientation(3); } } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 294e3cf86b1..917562d6661 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -451,7 +451,7 @@ class boss_mimiron : public CreatureScript DoCastAOE(SPELL_DESPAWN_ASSAULT_BOTS); me->ExitVehicle(); // ExitVehicle() offset position is not implemented, so we make up for that with MoveJump()... - me->GetMotionMaster()->MoveJump(me->GetPositionX() + (10.f * std::cos(me->GetOrientation())), me->GetPositionY() + (10.f * std::sin(me->GetOrientation())), me->GetPositionZ(), me->GetOrientation(), 10.f, 5.f); + me->GetMotionMaster()->MoveJump(me->GetPositionX() + (10.f * std::cos(me->GetOrientation())), me->GetPositionY() + (10.f * std::sin(me->GetOrientation())), me->GetPositionZ(), 10.f, 5.f); events.ScheduleEvent(EVENT_OUTTRO_1, 7s); } diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp index 8ead673fc51..841e8532f07 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_thorim.cpp @@ -709,7 +709,7 @@ class boss_thorim : public CreatureScript me->SetReactState(REACT_AGGRESSIVE); me->SetDisableGravity(false); me->SetControlled(false, UNIT_STATE_ROOT); - me->GetMotionMaster()->MoveJump(2134.8f, -263.056f, 419.983f, me->GetOrientation(), 30.0f, 20.0f); + me->GetMotionMaster()->MoveJump(2134.8f, -263.056f, 419.983f, 30.0f, 20.0f); events.ScheduleEvent(EVENT_START_PERIODIC_CHARGE, 2s, 0, PHASE_2); events.ScheduleEvent(EVENT_UNBALANCING_STRIKE, 15s, 0, PHASE_2); events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 20s, 0, PHASE_2); |