diff options
| author | Shauren <shauren.trinity@gmail.com> | 2017-02-18 21:55:28 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2017-02-18 21:55:28 +0100 |
| commit | 5e437f5d3d500b735eb623914a6cfc6bcb35247b (patch) | |
| tree | 19544b0c8685de73eaf6772b70b7721ec2b52623 /src/server/game/Movement | |
| parent | 255dd29562ae42a73c5947c2a8907faac888af31 (diff) | |
Core/Movement: Implement SpellEffectExtraData curve modifiers
Diffstat (limited to 'src/server/game/Movement')
| -rw-r--r-- | src/server/game/Movement/MotionMaster.cpp | 19 | ||||
| -rw-r--r-- | src/server/game/Movement/MotionMaster.h | 18 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSpline.cpp | 21 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSpline.h | 3 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.h | 7 | ||||
| -rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInitArgs.h | 9 |
6 files changed, 67 insertions, 10 deletions
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp index 6756463283f..22f06801640 100644 --- a/src/server/game/Movement/MotionMaster.cpp +++ b/src/server/game/Movement/MotionMaster.cpp @@ -345,7 +345,7 @@ void MotionMaster::MoveTakeoff(uint32 id, Position const& pos) Mutate(new EffectMovementGenerator(id), MOTION_SLOT_ACTIVE); } -void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ) +void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/) { //this function may make players fall below map if (_owner->GetTypeId() == TYPEID_PLAYER) @@ -366,6 +366,9 @@ void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, floa init.SetParabolic(max_height, 0); init.SetOrientationFixed(true); init.SetVelocity(speedXY); + if (spellEffectExtraData) + init.SetSpellEffectExtraData(*spellEffectExtraData); + init.Launch(); Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED); } @@ -384,7 +387,8 @@ void MotionMaster::MoveJumpTo(float angle, float speedXY, float speedZ) MoveJump(x, y, z, 0.0f, speedXY, speedZ); } -void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, bool hasOrientation /* = false*/, uint32 arrivalSpellId /*= 0*/, ObjectGuid const& arrivalSpellTargetGuid /*= ObjectGuid::Empty*/) +void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id /*= EVENT_JUMP*/, bool hasOrientation /* = false*/, + JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/) { TC_LOG_DEBUG("misc", "Unit (%s) jumps to point (X: %f Y: %f Z: %f).", _owner->GetGUID().ToString().c_str(), x, y, z); if (speedXY <= 0.1f) @@ -399,7 +403,18 @@ void MotionMaster::MoveJump(float x, float y, float z, float o, float speedXY, f init.SetVelocity(speedXY); if (hasOrientation) init.SetFacing(o); + if (spellEffectExtraData) + init.SetSpellEffectExtraData(*spellEffectExtraData); init.Launch(); + + uint32 arrivalSpellId = 0; + ObjectGuid arrivalSpellTargetGuid; + if (arrivalCast) + { + arrivalSpellId = arrivalCast->SpellId; + arrivalSpellTargetGuid = arrivalCast->Target; + } + Mutate(new EffectMovementGenerator(id, arrivalSpellId, arrivalSpellTargetGuid), MOTION_SLOT_CONTROLLED); } diff --git a/src/server/game/Movement/MotionMaster.h b/src/server/game/Movement/MotionMaster.h index 905dcde580e..7e2d6a47e56 100644 --- a/src/server/game/Movement/MotionMaster.h +++ b/src/server/game/Movement/MotionMaster.h @@ -28,6 +28,10 @@ class MovementGenerator; class Unit; class PathGenerator; +namespace Movement +{ + struct SpellEffectExtraData; +} // Creature Entry ID used for waypoints show, visible only for GMs #define VISUAL_WAYPOINT 1 @@ -77,6 +81,12 @@ enum RotateDirection ROTATE_DIRECTION_RIGHT }; +struct JumpArrivalCastArgs +{ + uint32 SpellId; + ObjectGuid Target; +}; + // assume it is 25 yard per 0.6 second #define SPEED_CHARGE 42.0f @@ -186,13 +196,13 @@ class TC_GAME_API MotionMaster //: private std::stack<MovementGenerator *> void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, bool generatePath = false); void MoveCharge(PathGenerator const& path, float speed = SPEED_CHARGE); - void MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ); + void MoveKnockbackFrom(float srcX, float srcY, 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, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty) + void MoveJump(Position const& pos, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false, JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr) { - MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, arrivalSpellId, arrivalSpellTargetGuid); + MoveJump(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), speedXY, speedZ, id, hasOrientation, arrivalCast, spellEffectExtraData); } - void MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty); + void MoveJump(float x, float y, float z, float o, float speedXY, float speedZ, uint32 id = EVENT_JUMP, bool hasOrientation = false, JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr); void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount); void MoveSmoothPath(uint32 pointId, G3D::Vector3 const* pathPoints, size_t pathSize, bool walk); void MoveSmoothPath(uint32 pointId, Movement::PointsArray const& points, bool walk); diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index d4e3cbff60d..a9912745435 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -19,6 +19,7 @@ #include "MoveSpline.h" #include "Log.h" #include "Creature.h" +#include "DB2Stores.h" #include <sstream> @@ -28,10 +29,16 @@ Location MoveSpline::ComputePosition() const { ASSERT(Initialized()); - float u = 1.f; + float u = 1.0f; + float u2 = 1.0f; int32 seg_time = spline.length(point_Idx, point_Idx+1); if (seg_time > 0) + { u = (time_passed - spline.length(point_Idx)) / (float)seg_time; + u2 = u; + if (spell_effect_extra && spell_effect_extra->ProgressCurveId) + u = sDB2Manager.GetCurveValueAt(spell_effect_extra->ProgressCurveId, u); + } Location c; c.orientation = initialOrientation; spline.evaluate_percent(point_Idx, u, c); @@ -39,7 +46,7 @@ Location MoveSpline::ComputePosition() const if (splineflags.animation) ;// MoveSplineFlag::Animation disables falling or parabolic movement else if (splineflags.parabolic) - computeParabolicElevation(c.z); + computeParabolicElevation(c.z, u2 /*progress without curve modifer is expected here*/); else if (splineflags.falling) computeFallElevation(c.z); @@ -66,12 +73,14 @@ Location MoveSpline::ComputePosition() const return c; } -void MoveSpline::computeParabolicElevation(float& el) const +void MoveSpline::computeParabolicElevation(float& el, float u) const { if (time_passed > effect_start_time) { float t_passedf = MSToSec(time_passed - effect_start_time); float t_durationf = MSToSec(Duration() - effect_start_time); //client use not modified duration here + if (spell_effect_extra && spell_effect_extra->ParabolicCurveId) + t_passedf *= sDB2Manager.GetCurveValueAt(spell_effect_extra->ParabolicCurveId, u); // -a*x*x + bx + c: //(dur * v3->z_acceleration * dt)/2 - (v3->z_acceleration * dt * dt)/2 + Z; @@ -165,6 +174,7 @@ void MoveSpline::Initialize(MoveSplineInitArgs const& args) time_passed = 0; vertical_acceleration = 0.f; effect_start_time = 0; + spell_effect_extra = args.spellEffectExtra; splineIsFacingOnly = args.path.size() == 2 && args.facing.type != MONSTER_MOVE_NORMAL && ((args.path[1] - args.path[0]).length() < 0.1f); // Check if its a stop spline @@ -210,6 +220,11 @@ bool MoveSplineInitArgs::Validate(Unit* unit) const CHECK(velocity > 0.01f); CHECK(time_perc >= 0.f && time_perc <= 1.f); CHECK(_checkPathLengths()); + if (spellEffectExtra) + { + CHECK(!spellEffectExtra->ProgressCurveId || sCurveStore.LookupEntry(spellEffectExtra->ProgressCurveId)); + CHECK(!spellEffectExtra->ParabolicCurveId || sCurveStore.LookupEntry(spellEffectExtra->ParabolicCurveId)); + } return true; #undef CHECK } diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h index f4f1e07cbe0..672c42ac3ab 100644 --- a/src/server/game/Movement/Spline/MoveSpline.h +++ b/src/server/game/Movement/Spline/MoveSpline.h @@ -80,12 +80,13 @@ namespace Movement int32 effect_start_time; int32 point_Idx; int32 point_Idx_offset; + Optional<SpellEffectExtraData> spell_effect_extra; void init_spline(const MoveSplineInitArgs& args); protected: MySpline::ControlArray const& getPath() const { return spline.getPoints(); } - void computeParabolicElevation(float& el) const; + void computeParabolicElevation(float& el, float u) const; void computeFallElevation(float& el) const; UpdateResult _updateState(int32& ms_time_diff); diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index f0b5e9aaac0..c873013405a 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -146,6 +146,8 @@ namespace Movement */ void SetVelocity(float velocity); + void SetSpellEffectExtraData(SpellEffectExtraData const& spellEffectExtraData); + PointsArray& Path() { return args.path; } /* Disables transport coordinate transformations for cases where raw offsets are available @@ -204,5 +206,10 @@ namespace Movement } inline void MoveSplineInit::DisableTransportPathTransformations() { args.TransformForTransport = false; } + + inline void MoveSplineInit::SetSpellEffectExtraData(SpellEffectExtraData const& spellEffectExtraData) + { + args.spellEffectExtra = spellEffectExtraData; + } } #endif // TRINITYSERVER_MOVESPLINEINIT_H diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index 60cb4db8b55..fc5b82102cd 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -40,6 +40,14 @@ namespace Movement FacingInfo() : angle(0.0f), type(MONSTER_MOVE_NORMAL) { } }; + struct SpellEffectExtraData + { + ObjectGuid Target; + uint32 SpellVisualId = 0; + uint32 ProgressCurveId = 0; + uint32 ParabolicCurveId = 0; + }; + struct MoveSplineInitArgs { MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), velocity(0.f), @@ -58,6 +66,7 @@ namespace Movement float time_perc; uint32 splineId; float initialOrientation; + Optional<SpellEffectExtraData> spellEffectExtra; bool HasVelocity; bool TransformForTransport; |
