[10068] Fixes in pet movments

* Use proper stop packet as expected. In case 0 trevel time used before move packet
  can generate infinity move forward (at client side).
* Avoid reset top movegen before add idle in pet stay command.
* Avoid assign random move to player owned creatures as default movegen.
* Finish follow movegen init including need-stay case.
This commit is contained in:
VladimirMangos 2010-06-16 17:21:15 +04:00
parent a0bbb0fec5
commit 492f467bcc
9 changed files with 35 additions and 34 deletions

View file

@ -791,29 +791,6 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const
&& pPlayer->getClass() == GetCreatureInfo()->trainer_class; && pPlayer->getClass() == GetCreatureInfo()->trainer_class;
} }
void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags flags, SplineType type)
{
/* uint32 timeElap = getMSTime();
if ((timeElap - m_startMove) < m_moveTime)
{
oX = (dX - oX) * ( (timeElap - m_startMove) / m_moveTime );
oY = (dY - oY) * ( (timeElap - m_startMove) / m_moveTime );
}
else
{
oX = dX;
oY = dY;
}
dX = x;
dY = y;
m_orientation = atan2((oY - dY), (oX - dX));
m_startMove = getMSTime();
m_moveTime = time;*/
SendMonsterMove(x, y, z, type, flags, time);
}
void Creature::PrepareBodyLootState() void Creature::PrepareBodyLootState()
{ {
loot.clear(); loot.clear();

View file

@ -444,7 +444,6 @@ class MANGOS_DLL_SPEC Creature : public Unit
bool AIM_Initialize(); bool AIM_Initialize();
void AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags MovementFlags, SplineType type);
CreatureAI* AI() { return i_AI; } CreatureAI* AI() { return i_AI; }
void AddSplineFlag(SplineFlags f) void AddSplineFlag(SplineFlags f)

View file

@ -90,7 +90,8 @@ namespace FactorySelector
{ {
MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance());
ASSERT( creature->GetCreatureInfo() != NULL ); ASSERT( creature->GetCreatureInfo() != NULL );
const MovementGeneratorCreator *mv_factory = mv_registry.GetRegistryItem( creature->GetDefaultMovementType()); MovementGeneratorCreator const * mv_factory = mv_registry.GetRegistryItem(
creature->GetOwnerGUID() ? FOLLOW_MOTION_TYPE : creature->GetDefaultMovementType());
/* if( mv_factory == NULL ) /* if( mv_factory == NULL )
{ {

View file

@ -86,7 +86,12 @@ DestinationHolder<TRAVELLER>::StartTravel(TRAVELLER &traveller, bool sendMove)
i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX,i_destY,i_destZ); i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX,i_destY,i_destZ);
i_timeElapsed = 0; i_timeElapsed = 0;
if(sendMove) if(sendMove)
{
if (i_totalTravelTime)
traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime); traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime);
else
traveller.Stop();
}
return i_totalTravelTime; return i_totalTravelTime;
} }

View file

@ -86,7 +86,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data )
{ {
case COMMAND_STAY: //flat=1792 //STAY case COMMAND_STAY: //flat=1792 //STAY
pet->StopMoving(); pet->StopMoving();
pet->GetMotionMaster()->Clear(); pet->GetMotionMaster()->Clear(false);
pet->GetMotionMaster()->MoveIdle(); pet->GetMotionMaster()->MoveIdle();
charmInfo->SetCommandState( COMMAND_STAY ); charmInfo->SetCommandState( COMMAND_STAY );
break; break;

View file

@ -37,12 +37,17 @@ void TargetedMovementGeneratorMedium<T,D>::_setTargetLocation(T &owner)
if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) if (owner.hasUnitState(UNIT_STAT_NOT_MOVE))
return; return;
float x, y, z;
// prevent redundant micro-movement for pets, other followers. // prevent redundant micro-movement for pets, other followers.
if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset)) if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset))
{
if (i_destinationHolder.HasDestination())
return; return;
float x, y, z; owner.GetPosition(x, y, z);
if (!i_offset) }
else if (!i_offset)
{ {
// to nearest contact position // to nearest contact position
i_target->GetContactPoint( &owner, x, y, z ); i_target->GetContactPoint( &owner, x, y, z );

View file

@ -55,6 +55,7 @@ struct MANGOS_DLL_DECL Traveller
void Relocation(float x, float y, float z, float orientation) {} void Relocation(float x, float y, float z, float orientation) {}
void Relocation(float x, float y, float z) { Relocation(x, y, z, i_traveller.GetOrientation()); } void Relocation(float x, float y, float z) { Relocation(x, y, z, i_traveller.GetOrientation()); }
void MoveTo(float x, float y, float z, uint32 t) {} void MoveTo(float x, float y, float z, uint32 t) {}
void Stop() {}
}; };
template<class T> template<class T>
@ -102,7 +103,13 @@ inline float Traveller<Creature>::GetMoveDestinationTo(float x, float y, float z
template<> template<>
inline void Traveller<Creature>::MoveTo(float x, float y, float z, uint32 t) inline void Traveller<Creature>::MoveTo(float x, float y, float z, uint32 t)
{ {
i_traveller.AI_SendMoveToPacket(x, y, z, t, i_traveller.GetSplineFlags(), SPLINETYPE_NORMAL); i_traveller.SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, i_traveller.GetSplineFlags(), t);
}
template<>
inline void Traveller<Creature>::Stop()
{
i_traveller.SendMonsterMove(i_traveller.GetPositionX(), i_traveller.GetPositionY(), i_traveller.GetPositionZ(), SPLINETYPE_STOP, i_traveller.GetSplineFlags(), 0);
} }
// specialization for players // specialization for players
@ -141,6 +148,13 @@ inline void Traveller<Player>::MoveTo(float x, float y, float z, uint32 t)
i_traveller.SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, t); i_traveller.SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, t);
} }
template<>
inline void Traveller<Player>::Stop()
{
//Only send SPLINEFLAG_WALKMODE, client has strange issues with other move flags
i_traveller.SendMonsterMove(i_traveller.GetPositionX(), i_traveller.GetPositionY(), i_traveller.GetPositionZ(), SPLINETYPE_STOP, SPLINEFLAG_WALKMODE, 0);
}
typedef Traveller<Creature> CreatureTraveller; typedef Traveller<Creature> CreatureTraveller;
typedef Traveller<Player> PlayerTraveller; typedef Traveller<Player> PlayerTraveller;
#endif #endif

View file

@ -12783,7 +12783,7 @@ void Unit::StopMoving()
// send explicit stop packet // send explicit stop packet
// player expected for correct work SPLINEFLAG_WALKMODE // player expected for correct work SPLINEFLAG_WALKMODE
SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_NORMAL, GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : SPLINEFLAG_NONE, 0); SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_STOP, GetTypeId() == TYPEID_PLAYER ? SPLINEFLAG_WALKMODE : SPLINEFLAG_NONE, 0);
// update position and orientation for near players // update position and orientation for near players
WorldPacket data; WorldPacket data;

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "10067" #define REVISION_NR "10068"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__