Core/Movement: Allow setting position or object facing targets for jump movement
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -291,4 +291,9 @@ namespace Movement
|
||||
|
||||
return input;
|
||||
}
|
||||
|
||||
void MoveSplineInitFacingVisitor::operator()(Position const& point) const
|
||||
{
|
||||
init.SetFacing(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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*/)
|
||||
{
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user