mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[11720] Implement spline movement subsystem
Spline movement controls movements of server-side controlled units (monster movement, taxi movement, etc). Proper implementation of effects such as charge, jump, cyclic movement will rely on it. However, need improve our states system before. Technical changes: 1. Added linear, catmullrom and bezier3 splines which based on client's algorthims. They can be reused for proper transport position interpolation. 2. Precission increased. There are no more position desync issues since client's position calculation formulas used. 3. Now possible to move by paths with multiple points, send whole path to client.
This commit is contained in:
parent
e302fce513
commit
9d566398ad
52 changed files with 2471 additions and 1203 deletions
|
|
@ -19,14 +19,13 @@
|
|||
#include "HomeMovementGenerator.h"
|
||||
#include "Creature.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "Traveller.h"
|
||||
#include "DestinationHolderImp.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "movement/MoveSplineInit.h"
|
||||
#include "movement/MoveSpline.h"
|
||||
|
||||
void HomeMovementGenerator<Creature>::Initialize(Creature & owner)
|
||||
{
|
||||
owner.RemoveSplineFlag(SPLINEFLAG_WALKMODE);
|
||||
_setTargetLocation(owner);
|
||||
}
|
||||
|
||||
|
|
@ -39,56 +38,30 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature & owner)
|
|||
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
|
||||
return;
|
||||
|
||||
float x, y, z;
|
||||
|
||||
Movement::MoveSplineInit init(owner);
|
||||
float x, y, z, o;
|
||||
// at apply we can select more nice return points base at current movegen
|
||||
if (owner.GetMotionMaster()->empty() || !owner.GetMotionMaster()->top()->GetResetPosition(owner,x,y,z))
|
||||
owner.GetRespawnCoord(x, y, z);
|
||||
{
|
||||
owner.GetRespawnCoord(x, y, z, &o);
|
||||
init.SetFacing(o);
|
||||
}
|
||||
init.MoveTo(x,y,z);
|
||||
init.SetWalk(false);
|
||||
init.Launch();
|
||||
|
||||
CreatureTraveller traveller(owner);
|
||||
|
||||
uint32 travel_time = i_destinationHolder.SetDestination(traveller, x, y, z);
|
||||
modifyTravelTime(travel_time);
|
||||
owner.clearUnitState(UNIT_STAT_ALL_STATE);
|
||||
}
|
||||
|
||||
bool HomeMovementGenerator<Creature>::Update(Creature &owner, const uint32& time_diff)
|
||||
{
|
||||
CreatureTraveller traveller( owner);
|
||||
if (i_destinationHolder.UpdateTraveller(traveller, time_diff, false))
|
||||
{
|
||||
if (!IsActive(owner)) // force stop processing (movement can move out active zone with cleanup movegens list)
|
||||
return true; // not expire now, but already lost
|
||||
}
|
||||
|
||||
if (time_diff >= i_travel_timer)
|
||||
{
|
||||
i_travel_timer = 0; // Used as check in Finalize
|
||||
return false;
|
||||
}
|
||||
|
||||
i_travel_timer -= time_diff;
|
||||
|
||||
return true;
|
||||
return !owner.movespline->Finalized();
|
||||
}
|
||||
|
||||
void HomeMovementGenerator<Creature>::Finalize(Creature& owner)
|
||||
{
|
||||
if (i_travel_timer == 0)
|
||||
{
|
||||
owner.AddSplineFlag(SPLINEFLAG_WALKMODE);
|
||||
|
||||
// restore orientation of not moving creature at returning to home
|
||||
if (owner.GetDefaultMovementType() == IDLE_MOTION_TYPE)
|
||||
{
|
||||
// such a mob might need very exact spawning point, hence relocate to spawn-position
|
||||
if (CreatureData const* data = sObjectMgr.GetCreatureData(owner.GetGUIDLow()))
|
||||
{
|
||||
owner.Relocate(data->posX, data->posY, data->posZ, data->orientation);
|
||||
owner.SendHeartBeat(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (owner.GetTemporaryFactionFlags() & TEMPFACTION_RESTORE_REACH_HOME)
|
||||
owner.ClearTemporaryFaction();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue