From 492f467bccb1fb95f4709eb3ac305cf4d26b1e1c Mon Sep 17 00:00:00 2001 From: VladimirMangos Date: Wed, 16 Jun 2010 17:21:15 +0400 Subject: [PATCH] [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. --- src/game/Creature.cpp | 25 +------------------------ src/game/Creature.h | 1 - src/game/CreatureAISelector.cpp | 3 ++- src/game/DestinationHolderImp.h | 7 ++++++- src/game/PetHandler.cpp | 2 +- src/game/TargetedMovementGenerator.cpp | 11 ++++++++--- src/game/Traveller.h | 16 +++++++++++++++- src/game/Unit.cpp | 2 +- src/shared/revision_nr.h | 2 +- 9 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index d27c0d826..4d2bc717b 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -791,29 +791,6 @@ bool Creature::isCanTrainingAndResetTalentsOf(Player* pPlayer) const && 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() { loot.clear(); @@ -2221,4 +2198,4 @@ void Creature::RelocationNotify() MaNGOS::CreatureRelocationNotifier relocationNotifier(*this); float radius = MAX_CREATURE_ATTACK_RADIUS * sWorld.getConfig(CONFIG_FLOAT_RATE_CREATURE_AGGRO); Cell::VisitAllObjects(this, relocationNotifier, radius); -} +} \ No newline at end of file diff --git a/src/game/Creature.h b/src/game/Creature.h index c6dff5dfc..af068e33f 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -444,7 +444,6 @@ class MANGOS_DLL_SPEC Creature : public Unit bool AIM_Initialize(); - void AI_SendMoveToPacket(float x, float y, float z, uint32 time, SplineFlags MovementFlags, SplineType type); CreatureAI* AI() { return i_AI; } void AddSplineFlag(SplineFlags f) diff --git a/src/game/CreatureAISelector.cpp b/src/game/CreatureAISelector.cpp index 4b78c329d..96645c239 100644 --- a/src/game/CreatureAISelector.cpp +++ b/src/game/CreatureAISelector.cpp @@ -90,7 +90,8 @@ namespace FactorySelector { MovementGeneratorRegistry &mv_registry(MovementGeneratorRepository::Instance()); 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 ) { diff --git a/src/game/DestinationHolderImp.h b/src/game/DestinationHolderImp.h index b4932944b..32ca246b4 100644 --- a/src/game/DestinationHolderImp.h +++ b/src/game/DestinationHolderImp.h @@ -86,7 +86,12 @@ DestinationHolder::StartTravel(TRAVELLER &traveller, bool sendMove) i_totalTravelTime = traveller.GetTotalTrevelTimeTo(i_destX,i_destY,i_destZ); i_timeElapsed = 0; if(sendMove) - traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime); + { + if (i_totalTravelTime) + traveller.MoveTo(i_destX, i_destY, i_destZ, i_totalTravelTime); + else + traveller.Stop(); + } return i_totalTravelTime; } diff --git a/src/game/PetHandler.cpp b/src/game/PetHandler.cpp index e306f8078..77b018a52 100644 --- a/src/game/PetHandler.cpp +++ b/src/game/PetHandler.cpp @@ -86,7 +86,7 @@ void WorldSession::HandlePetAction( WorldPacket & recv_data ) { case COMMAND_STAY: //flat=1792 //STAY pet->StopMoving(); - pet->GetMotionMaster()->Clear(); + pet->GetMotionMaster()->Clear(false); pet->GetMotionMaster()->MoveIdle(); charmInfo->SetCommandState( COMMAND_STAY ); break; diff --git a/src/game/TargetedMovementGenerator.cpp b/src/game/TargetedMovementGenerator.cpp index b59e6c8f1..efc52bfc8 100644 --- a/src/game/TargetedMovementGenerator.cpp +++ b/src/game/TargetedMovementGenerator.cpp @@ -37,12 +37,17 @@ void TargetedMovementGeneratorMedium::_setTargetLocation(T &owner) if (owner.hasUnitState(UNIT_STAT_NOT_MOVE)) return; + float x, y, z; + // prevent redundant micro-movement for pets, other followers. if (i_offset && i_target->IsWithinDistInMap(&owner,2*i_offset)) - return; + { + if (i_destinationHolder.HasDestination()) + return; - float x, y, z; - if (!i_offset) + owner.GetPosition(x, y, z); + } + else if (!i_offset) { // to nearest contact position i_target->GetContactPoint( &owner, x, y, z ); diff --git a/src/game/Traveller.h b/src/game/Traveller.h index dd5fad5a0..d854f3294 100644 --- a/src/game/Traveller.h +++ b/src/game/Traveller.h @@ -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) { Relocation(x, y, z, i_traveller.GetOrientation()); } void MoveTo(float x, float y, float z, uint32 t) {} + void Stop() {} }; template @@ -102,7 +103,13 @@ inline float Traveller::GetMoveDestinationTo(float x, float y, float z template<> inline void Traveller::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::Stop() +{ + i_traveller.SendMonsterMove(i_traveller.GetPositionX(), i_traveller.GetPositionY(), i_traveller.GetPositionZ(), SPLINETYPE_STOP, i_traveller.GetSplineFlags(), 0); } // specialization for players @@ -141,6 +148,13 @@ inline void Traveller::MoveTo(float x, float y, float z, uint32 t) i_traveller.SendMonsterMove(x, y, z, SPLINETYPE_NORMAL, SPLINEFLAG_WALKMODE, t); } +template<> +inline void Traveller::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 CreatureTraveller; typedef Traveller PlayerTraveller; #endif diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index ca8e033af..fb064a128 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -12783,7 +12783,7 @@ void Unit::StopMoving() // send explicit stop packet // 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 WorldPacket data; diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index aeef1c1f4..ce3b4eb93 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10067" + #define REVISION_NR "10068" #endif // __REVISION_NR_H__