diff --git a/src/game/AI/PetAI.cpp b/src/game/AI/PetAI.cpp index c5977f371..50afaa83f 100644 --- a/src/game/AI/PetAI.cpp +++ b/src/game/AI/PetAI.cpp @@ -337,8 +337,8 @@ void PetAI::UpdateAI(const uint32 diff) } // Update speed as needed to prevent dropping too far behind and despawning - m_creature->UpdateSpeed(MOVE_RUN, true); - m_creature->UpdateSpeed(MOVE_WALK, true); + m_creature->UpdateSpeed(MOVE_RUN, false); + m_creature->UpdateSpeed(MOVE_WALK, false); } void PetAI::UpdateAllies() diff --git a/src/game/CMakeLists.txt b/src/game/CMakeLists.txt index 5b4d6a7b9..1cae21ad5 100644 --- a/src/game/CMakeLists.txt +++ b/src/game/CMakeLists.txt @@ -180,6 +180,7 @@ set (game_SRCS Movement/IdleMovementGenerator.cpp Movement/MotionMaster.cpp Movement/MovementGenerator.cpp + Movement/MovementPacketSender.cpp Movement/PointMovementGenerator.cpp Movement/RandomMovementGenerator.cpp Movement/TargetedMovementGenerator.cpp @@ -366,6 +367,7 @@ set (game_SRCS Movement/MotionMaster.h Movement/MovementGenerator.h Movement/MovementGeneratorImpl.h + Movement/MovementPacketSender.h Movement/PointMovementGenerator.h Movement/RandomMovementGenerator.h Movement/TargetedMovementGenerator.h diff --git a/src/game/Commands/CharacterCommands.cpp b/src/game/Commands/CharacterCommands.cpp index e8d28ef30..2c05f27d9 100644 --- a/src/game/Commands/CharacterCommands.cpp +++ b/src/game/Commands/CharacterCommands.cpp @@ -4090,7 +4090,7 @@ bool ChatHandler::HandleModifySpeedCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); - chr->UpdateSpeed(MOVE_RUN, true, modSpeed); + chr->UpdateSpeed(MOVE_RUN, false, modSpeed); return true; } @@ -4152,7 +4152,7 @@ bool ChatHandler::HandleModifySwimCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_SWIM_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); - chr->UpdateSpeed(MOVE_SWIM, true, modSpeed); + chr->UpdateSpeed(MOVE_SWIM, false, modSpeed); return true; } @@ -4199,7 +4199,7 @@ bool ChatHandler::HandleModifyBWalkCommand(char* args) if (needReportToTarget(chr)) ChatHandler(chr).PSendSysMessage(LANG_YOURS_BACK_SPEED_CHANGED, GetNameLink().c_str(), modSpeed); - chr->UpdateSpeed(MOVE_RUN_BACK, true, modSpeed); + chr->UpdateSpeed(MOVE_RUN_BACK, false, modSpeed); return true; } @@ -5075,9 +5075,9 @@ bool ChatHandler::HandleWaterwalkCommand(char* args) return false; if (value) - player->SetMovement(MOVE_WATER_WALK); // ON + player->SetWaterWalking(true); else - player->SetMovement(MOVE_LAND_WALK); // OFF + player->SetWaterWalking(false); PSendSysMessage(LANG_YOU_SET_WATERWALK, args, GetNameLink(player).c_str()); if (needReportToTarget(player)) diff --git a/src/game/Commands/UnitCommands.cpp b/src/game/Commands/UnitCommands.cpp index 01b1cb8f1..20aae495f 100644 --- a/src/game/Commands/UnitCommands.cpp +++ b/src/game/Commands/UnitCommands.cpp @@ -1438,9 +1438,9 @@ bool ChatHandler::HandleModifyASpeedCommand(char* args) } PSendSysMessage(LANG_YOU_CHANGE_ASPEED, modSpeed, chrNameLink.c_str()); - chr->UpdateSpeed(MOVE_WALK, true, modSpeed); - chr->UpdateSpeed(MOVE_RUN, true, modSpeed); - chr->UpdateSpeed(MOVE_SWIM, true, modSpeed); + chr->UpdateSpeed(MOVE_WALK, false, modSpeed); + chr->UpdateSpeed(MOVE_RUN, false, modSpeed); + chr->UpdateSpeed(MOVE_SWIM, false, modSpeed); return true; } diff --git a/src/game/Handlers/CharacterHandler.cpp b/src/game/Handlers/CharacterHandler.cpp index 9f133c5a5..bf369d4fb 100644 --- a/src/game/Handlers/CharacterHandler.cpp +++ b/src/game/Handlers/CharacterHandler.cpp @@ -494,7 +494,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) // If the character had a logout request, then he is articifially stunned (cf CMSG_LOGOUT_REQUEST handler). Fix it here. if (pCurrChar->CanFreeMove()) { - pCurrChar->SetMovement(MOVE_UNROOT); + pCurrChar->SetRooted(false); pCurrChar->SetStandState(UNIT_STAND_STATE_STAND); pCurrChar->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } @@ -678,7 +678,7 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder *holder) pCurrChar->CastSpell(pCurrChar, 20584, true); // auras SPELL_AURA_INCREASE_SPEED(+speed in wisp form), SPELL_AURA_INCREASE_SWIM_SPEED(+swim speed in wisp form), SPELL_AURA_TRANSFORM (to wisp form) pCurrChar->CastSpell(pCurrChar, 8326, true); // auras SPELL_AURA_GHOST, SPELL_AURA_INCREASE_SPEED(why?), SPELL_AURA_INCREASE_SWIM_SPEED(why?) - pCurrChar->SetMovement(MOVE_WATER_WALK); + pCurrChar->SetWaterWalking(true); } } diff --git a/src/game/Handlers/MiscHandler.cpp b/src/game/Handlers/MiscHandler.cpp index 4725478f2..9f35328f6 100644 --- a/src/game/Handlers/MiscHandler.cpp +++ b/src/game/Handlers/MiscHandler.cpp @@ -358,7 +358,7 @@ void WorldSession::HandleLogoutRequestOpcode(WorldPacket & /*recv_data*/) if ((GetPlayer()->GetPositionZ() < height + 0.1f) && !(GetPlayer()->IsInWater()) && GetPlayer()->getStandState() == UNIT_STAND_STATE_STAND) GetPlayer()->SetStandState(UNIT_STAND_STATE_SIT); - GetPlayer()->SetMovement(MOVE_ROOT); + GetPlayer()->SetRooted(true); GetPlayer()->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED); } @@ -387,7 +387,7 @@ void WorldSession::HandleLogoutCancelOpcode(WorldPacket & /*recv_data*/) if (GetPlayer()->CanFreeMove()) { //!we can move again - GetPlayer()->SetMovement(MOVE_UNROOT); + GetPlayer()->SetRooted(false); //! Stand Up GetPlayer()->SetStandState(UNIT_STAND_STATE_STAND); diff --git a/src/game/Handlers/MovementHandler.cpp b/src/game/Handlers/MovementHandler.cpp index 12a8adb90..9949674ff 100644 --- a/src/game/Handlers/MovementHandler.cpp +++ b/src/game/Handlers/MovementHandler.cpp @@ -38,6 +38,7 @@ #include "packet_builder.h" #include "MoveSpline.h" #include "MovementBroadcaster.h" +#include "MovementPacketSender.h" void WorldSession::HandleMoveWorldportAckOpcode(WorldPacket & /*recv_data*/) @@ -225,7 +226,6 @@ void WorldSession::HandleMoveTeleportAckOpcode(WorldPacket& recv_data) DEBUG_LOG("MSG_MOVE_TELEPORT_ACK"); ObjectGuid guid; - recv_data >> guid; uint32 counter = 0; @@ -385,33 +385,28 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) /* extract packet */ ObjectGuid guid; - MovementInfo movementInfo; - float newspeed; - recv_data >> guid; #if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data >> Unused(); // counter or moveEvent + uint32 movementCounter; + recv_data >> movementCounter; #endif + MovementInfo movementInfo; recv_data >> movementInfo; - recv_data >> newspeed; + float speedReceived; + recv_data >> speedReceived; movementInfo.UpdateTime(recv_data.GetPacketTime()); // now can skip not our packet - ObjectGuid moverGuid = _player->GetMover()->GetObjectGuid(); - if (guid != moverGuid && guid != _clientMoverGuid) + if (guid != _clientMoverGuid && guid != _player->GetObjectGuid() && guid != _player->GetMover()->GetObjectGuid()) return; if (!VerifyMovementInfo(movementInfo)) return; // Process anticheat checks, remember client-side speed ... - if (_player->IsSelfMover() && !_player->GetCheatData()->HandleSpeedChangeAck(movementInfo, this, &recv_data, newspeed)) + if (_player->IsSelfMover() && !_player->GetCheatData()->HandleSpeedChangeAck(movementInfo, this, &recv_data, speedReceived)) return; - // Process position-change - HandleMoverRelocation(movementInfo); - _player->UpdateFallInformationIfNeed(movementInfo, opcode); - /*----------------*/ // client ACK send one packet for mounted/run case and need skip all except last from its @@ -442,45 +437,318 @@ void WorldSession::HandleForceSpeedChangeAckOpcodes(WorldPacket &recv_data) return; } - // Daemon TODO: enregistrement de cette position ? - // Daemon: mise a jour de la vitesse pour les joueurs a cote. - // Cf Unit::SetSpeedRate pour plus d'infos. - const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE] = - { - MSG_MOVE_SET_WALK_SPEED, - MSG_MOVE_SET_RUN_SPEED, - MSG_MOVE_SET_RUN_BACK_SPEED, - MSG_MOVE_SET_SWIM_SPEED, - MSG_MOVE_SET_SWIM_BACK_SPEED, - MSG_MOVE_SET_TURN_RATE - }; + Unit* mover = ObjectAccessor::GetUnit(*_player, guid); - if (!_player->IsTaxiFlying() && !_player->GetTransport()) - { - // Maybe update movespeed using the spline packet. works for move splines - // and normal movement, but reverted due to issues in same changeset - WorldPacket data(SetSpeed2Opc_table[move_type], 31); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << _player->GetMover()->GetPackGUID(); -#else - data << _player->GetMover()->GetGUID(); -#endif - data << movementInfo; - data << float(newspeed); - _player->SendMovementMessageToSet(std::move(data), false); + if (!mover) + return; - if (!_player->GetMover()->movespline->Finalized()) - { - WorldPacket splineData(SMSG_MONSTER_MOVE, 31); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - splineData << _player->GetMover()->GetPackGUID(); -#else - splineData << _player->GetMover()->GetGUID(); -#endif - Movement::PacketBuilder::WriteMonsterMove(*(_player->GetMover()->movespline), splineData); - _player->SendMovementMessageToSet(std::move(splineData), false); - } + // verify that indeed the client is replying with the changes that were send to him + if (!mover->HasPendingMovementChange()) + { + sLog.outInfo("WorldSession::HandleForceSpeedChangeAck: Player %s from account id %u kicked because no movement change ack was expected from this player", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; } + + PlayerMovementPendingChange pendingChange = mover->PopPendingMovementChange(); + float speedSent = pendingChange.newValue; + MovementChangeType changeType = pendingChange.movementChangeType; + UnitMoveType moveTypeSent; + switch (changeType) + { + case SPEED_CHANGE_WALK: moveTypeSent = MOVE_WALK; break; + case SPEED_CHANGE_RUN: moveTypeSent = MOVE_RUN; break; + case SPEED_CHANGE_RUN_BACK: moveTypeSent = MOVE_RUN_BACK; break; + case SPEED_CHANGE_SWIM: moveTypeSent = MOVE_SWIM; break; + case SPEED_CHANGE_SWIM_BACK: moveTypeSent = MOVE_SWIM_BACK; break; + case RATE_CHANGE_TURN: moveTypeSent = MOVE_TURN_RATE; break; + default: + sLog.outInfo("WorldSession::HandleForceSpeedChangeAck: Player %s from account id %u kicked for incorrect data returned in an ack", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + uint32 movementCounter = pendingChange.movementCounter; +#endif + + if (pendingChange.movementCounter != movementCounter || std::fabs(speedSent - speedReceived) > 0.01f || moveTypeSent!= move_type) + { + sLog.outInfo("WorldSession::HandleForceSpeedChangeAck: Player %s from account id %u kicked for incorrect data returned in an ack", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + // the client data has been verified. let's do the actual change now + float newSpeedRate = speedSent / baseMoveSpeed[move_type]; + HandleMoverRelocation(movementInfo); + _player->UpdateFallInformationIfNeed(movementInfo, opcode); + mover->SetSpeedRateReal(move_type, newSpeedRate); + + MovementPacketSender::SendSpeedChangeToObservers(mover, move_type, speedSent); +} + +/* +handles those packets: +CMSG_MOVE_WATER_WALK_ACK +CMSG_MOVE_HOVER_ACK +CMSG_MOVE_FEATHER_FALL_ACK +*/ +void WorldSession::HandleMovementFlagChangeToggleAck(WorldPacket& recvData) +{ + /* extract packet */ + ObjectGuid guid; + recvData >> guid; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + uint32 movementCounter; + recvData >> movementCounter; +#endif + MovementInfo movementInfo; + recvData >> movementInfo; + movementInfo.UpdateTime(recvData.GetPacketTime()); + uint32 applyInt; + recvData >> applyInt; + bool applyReceived = applyInt == 0u ? false : true; + + // make sure this client is allowed to control the unit which guid is provided + if (guid != _clientMoverGuid && guid != _player->GetObjectGuid() && guid != _player->GetMover()->GetObjectGuid()) + return; + + if (!VerifyMovementInfo(movementInfo)) + return; + + if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recvData)) + return; + + Unit* mover = ObjectAccessor::GetUnit(*_player, guid); + + if (!mover) + return; + + // verify that indeed the client is replying with the changes that were send to him + if (!mover->HasPendingMovementChange()) + { + sLog.outInfo("WorldSession::HandleMovementFlagChangeToggleAck: Player %s from account id %u kicked because no movement change ack was expected from this player", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + PlayerMovementPendingChange pendingChange = mover->PopPendingMovementChange(); + bool applySent = pendingChange.apply; + MovementChangeType changeTypeSent = pendingChange.movementChangeType; + + MovementFlags mFlag = MOVEFLAG_NONE; + MovementChangeType changeTypeReceived; + switch (recvData.GetOpcode()) + { + case CMSG_MOVE_WATER_WALK_ACK: changeTypeReceived = WATER_WALK; mFlag = MOVEFLAG_WATERWALKING; break; + case CMSG_MOVE_HOVER_ACK: changeTypeReceived = SET_HOVER; mFlag = MOVEFLAG_HOVER; break; + case CMSG_MOVE_FEATHER_FALL_ACK: changeTypeReceived = FEATHER_FALL; mFlag = MOVEFLAG_SAFE_FALL; break; + default: + sLog.outInfo("WorldSession::HandleMovementFlagChangeToggleAck: Unknown move type opcode: %u", recvData.GetOpcode()); + return; + } + +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + uint32 movementCounter = pendingChange.movementCounter; +#endif + + if (pendingChange.movementCounter != movementCounter + || applySent != applyReceived + || changeTypeSent != changeTypeReceived) + { + sLog.outInfo("WorldSession::HandleMovementFlagChangeToggleAck: Player %s from account id %u kicked for incorrect data returned in an ack", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + // Position change + HandleMoverRelocation(movementInfo); + _player->UpdateFallInformationIfNeed(movementInfo, recvData.GetOpcode()); + + switch (changeTypeReceived) + { + case WATER_WALK: mover->SetWaterWalkingReal(applyReceived); break; + case SET_HOVER: mover->SetHoverReal(applyReceived); break; + case FEATHER_FALL: mover->SetFeatherFallReal(applyReceived); break; + default: + sLog.outInfo("WorldSession::HandleMovementFlagChangeToggleAck: Unknown move type opcode: %u", recvData.GetOpcode()); + return; + } + + if(mFlag != MOVEFLAG_NONE) + MovementPacketSender::SendMovementFlagChangeToObservers(mover, mFlag, applySent); +} + +/* +handles those packets: +CMSG_FORCE_MOVE_ROOT_ACK +CMSG_FORCE_MOVE_UNROOT_ACK +*/ +void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) +{ + DEBUG_LOG("HandleMoveRootAck"); + + /* extract packet */ + ObjectGuid guid; + recv_data >> guid; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + uint32 movementCounter; + recv_data >> movementCounter; +#endif + MovementInfo movementInfo; + recv_data >> movementInfo; + movementInfo.UpdateTime(recv_data.GetPacketTime()); + + // make sure this client is allowed to control the unit which guid is provided + if (guid != _clientMoverGuid && guid != _player->GetObjectGuid() && guid != _player->GetMover()->GetObjectGuid()) + return; + + if (!VerifyMovementInfo(movementInfo)) + return; + + if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) + return; + + Unit* mover = ObjectAccessor::GetUnit(*_player, guid); + + if (!mover) + return; + + // verify that indeed the client is replying with the changes that were send to him + if (!mover->HasPendingMovementChange()) + { + sLog.outInfo("WorldSession::HandleMoveRootAck: Player %s from account id %u kicked because no movement change ack was expected from this player", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + PlayerMovementPendingChange pendingChange = mover->PopPendingMovementChange(); + bool applySent = pendingChange.apply; + MovementChangeType changeTypeSent = pendingChange.movementChangeType; + + MovementFlags mFlag = MOVEFLAG_ROOT; + MovementChangeType changeTypeReceived = ROOT; + bool applyReceived = (recv_data.GetOpcode() == CMSG_FORCE_MOVE_ROOT_ACK); + +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + uint32 movementCounter = pendingChange.movementCounter; +#endif + + if (pendingChange.movementCounter != movementCounter + || applySent != applyReceived + || changeTypeSent != changeTypeReceived) + { + sLog.outInfo("WorldSession::HandleMoveRootAck: Player %s from account id %u kicked for incorrect data returned in an ack", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + // Update position if it has changed + HandleMoverRelocation(movementInfo); + _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode()); + mover->SetRootedReal(applyReceived); + + MovementPacketSender::SendMovementFlagChangeToObservers(mover, mFlag, applySent); + + // Set unit client state for brevity, though it should not be used + if (applyReceived) + mover->addUnitState(UNIT_STAT_CLIENT_ROOT); + else + mover->clearUnitState(UNIT_STAT_CLIENT_ROOT); +} + +void WorldSession::HandleMoveKnockBackAck(WorldPacket & recv_data) +{ + DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK"); + + ObjectGuid guid; + recv_data >> guid; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + uint32 movementCounter; + recv_data >> movementCounter; +#endif + MovementInfo movementInfo; + recv_data >> movementInfo; + movementInfo.UpdateTime(recv_data.GetPacketTime()); + + Unit* mover = ObjectAccessor::GetUnit(*_player, guid); + + if (!mover) + return; + + Player *pPlayerMover = mover->ToPlayer(); + + // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck + if (pPlayerMover && pPlayerMover->IsBeingTeleported()) + { + mover->PopPendingMovementChange(); + recv_data.rpos(recv_data.wpos()); // prevent warnings spam + return; + } + + if (guid != _clientMoverGuid && guid != _player->GetObjectGuid() && guid != _player->GetMover()->GetObjectGuid()) + return; + + if (!VerifyMovementInfo(movementInfo)) + return; + + if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) + return; + + // verify that indeed the client is replying with the changes that were send to him + if (!mover->HasPendingMovementChange()) + { + sLog.outInfo("WorldSession::HandleMoveKnockBackAck: Player %s from account id %u kicked because no movement change ack was expected from this player", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + PlayerMovementPendingChange pendingChange = mover->PopPendingMovementChange(); + +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + uint32 movementCounter = pendingChange.movementCounter; +#endif + + if (pendingChange.movementCounter != movementCounter || pendingChange.movementChangeType != KNOCK_BACK + || std::fabs(pendingChange.knockbackInfo.speedXY - movementInfo.jump.xyspeed) > 0.01f + || std::fabs(pendingChange.knockbackInfo.speedZ - movementInfo.jump.velocity) > 0.01f + || std::fabs(pendingChange.knockbackInfo.vcos - movementInfo.jump.cosAngle) > 0.01f + || std::fabs(pendingChange.knockbackInfo.vsin - movementInfo.jump.sinAngle) > 0.01f) + { + sLog.outInfo("WorldSession::HandleMoveKnockBackAck: Player %s from account id %u kicked for incorrect data returned in an ack", + _player->GetName(), _player->GetSession()->GetAccountId()); + _player->GetSession()->KickPlayer(); + return; + } + + HandleMoverRelocation(movementInfo); + + MovementPacketSender::SendKnockBackToObservers(mover, movementInfo.jump.cosAngle, movementInfo.jump.sinAngle, movementInfo.jump.xyspeed, movementInfo.jump.velocity); +} + +void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) +{ + DEBUG_LOG("WORLD: Received CMSG_MOVE_SPLINE_DONE"); + + MovementInfo movementInfo; // used only for proper packet read + + recv_data >> movementInfo; + recv_data >> Unused(); // unk + recv_data >> Unused(); // unk2 + + // Forward packet to near players + recv_data.SetOpcode(MSG_MOVE_STOP); + recv_data.rpos(0); + HandleMovementOpcodes(recv_data); } void WorldSession::HandleSetActiveMoverOpcode(WorldPacket &recv_data) @@ -551,6 +819,10 @@ void WorldSession::HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data) _clientMoverGuid = ObjectGuid(); #endif + // Prevent client from removing root flag. + if (_player->HasUnitMovementFlag(MOVEFLAG_ROOT) && !mi.HasMovementFlag(MOVEFLAG_ROOT)) + mi.AddMovementFlag(MOVEFLAG_ROOT); + _player->m_movementInfo = mi; } @@ -564,81 +836,6 @@ void WorldSession::HandleMountSpecialAnimOpcode(WorldPacket& /*recvdata*/) GetPlayer()->SendMovementMessageToSet(std::move(data), false); } -void WorldSession::HandleMoveKnockBackAck(WorldPacket & recv_data) -{ - DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK"); - - Unit *mover = _player->GetMover(); - Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL; - - // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck - if (plMover && plMover->IsBeingTeleported()) - { - recv_data.rpos(recv_data.wpos()); // prevent warnings spam - return; - } - - ObjectGuid guid; - MovementInfo movementInfo; - - recv_data >> guid; -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data >> Unused(); // knockback packets counter -#endif - recv_data >> movementInfo; - movementInfo.UpdateTime(recv_data.GetPacketTime()); - - if (guid != _clientMoverGuid) - return; - if (!VerifyMovementInfo(movementInfo, guid)) - return; - - if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) - return; - - HandleMoverRelocation(movementInfo); - - // Actually other clients don't need this packet ... - // CMSG_MOVE_KNOCK_BACK_ACK only use is to update position server side for now. - /* - WorldPacket data(MSG_MOVE_KNOCK_BACK, recv_data.size() + 12); - data << guid.WriteAsPacked(); - data << movementInfo; - data << movementInfo.GetJumpInfo().sinAngle; - data << movementInfo.GetJumpInfo().cosAngle; - data << movementInfo.GetJumpInfo().xyspeed; - data << movementInfo.GetJumpInfo().velocity; - mover->SendMovementMessageToSet(&data, true, _player);*/ -} - -void WorldSession::HandleMoveHoverAck(WorldPacket& recv_data) -{ - DEBUG_LOG("CMSG_MOVE_HOVER_ACK"); - - MovementInfo movementInfo; - - recv_data >> Unused(); // guid -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data >> Unused(); // unk -#endif - recv_data >> movementInfo; - recv_data >> Unused(); // unk2 -} - -void WorldSession::HandleMoveWaterWalkAck(WorldPacket& recv_data) -{ - DEBUG_LOG("CMSG_MOVE_WATER_WALK_ACK"); - - MovementInfo movementInfo; - - recv_data.read_skip(); // guid -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data.read_skip(); // unk -#endif - recv_data >> movementInfo; - recv_data >> Unused(); // unk2 -} - void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) { if (!_player->isAlive() || _player->isInCombat()) @@ -650,6 +847,39 @@ void WorldSession::HandleSummonResponseOpcode(WorldPacket& recv_data) _player->SummonIfPossible(true); } +void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket & recv_data) +{ + DEBUG_LOG("WORLD: Time Lag/Synchronization Resent/Update"); + + ObjectGuid g; + recv_data >> g; + uint32 lag; + recv_data >> lag; + + Player* pl = GetPlayer(); + + pl->m_movementInfo.time += lag; + pl->m_movementInfo.ctime += lag; + + // fix an 1.12 client problem with transports + Transport* tr = pl->GetTransport(); + if (pl->HasJustBoarded() && tr) + { + pl->SetJustBoarded(false); + tr->SendOutOfRangeUpdateToPlayer(pl); + tr->SendCreateUpdateToPlayer(pl); + } +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + else + { + WorldPacket data(MSG_MOVE_TIME_SKIPPED, 12); + data << pl->GetPackGUID(); + data << lag; + pl->SendMovementMessageToSet(std::move(data), false); + } +#endif +} + bool WorldSession::VerifyMovementInfo(MovementInfo const& movementInfo, ObjectGuid const& guid) const { // ignore wrong guid (player attempt cheating own session for not own guid possible...) @@ -684,6 +914,10 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) Unit *mover = _player->GetMover(); movementInfo.CorrectData(mover); + // Prevent client from removing root flag. + if (mover->HasUnitMovementFlag(MOVEFLAG_ROOT) && !movementInfo.HasMovementFlag(MOVEFLAG_ROOT)) + movementInfo.AddMovementFlag(MOVEFLAG_ROOT); + if (Player* plMover = mover->ToPlayer()) { // ignore current relocation if needed @@ -805,167 +1039,3 @@ void WorldSession::HandleMoverRelocation(MovementInfo& movementInfo) } } -void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket & recv_data) -{ - DEBUG_LOG("WORLD: Time Lag/Synchronization Resent/Update"); - - ObjectGuid g; - recv_data >> g; - uint32 lag; - recv_data >> lag; - - Player* pl = GetPlayer(); - - pl->m_movementInfo.time += lag; - pl->m_movementInfo.ctime += lag; - - // fix an 1.12 client problem with transports - Transport* tr = pl->GetTransport(); - if (pl->HasJustBoarded() && tr) - { - pl->SetJustBoarded(false); - tr->SendOutOfRangeUpdateToPlayer(pl); - tr->SendCreateUpdateToPlayer(pl); - } -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - else - { - WorldPacket data(MSG_MOVE_TIME_SKIPPED, 12); - data << pl->GetPackGUID(); - data << lag; - pl->SendMovementMessageToSet(std::move(data), false); - } -#endif -} - -void WorldSession::HandleFeatherFallAck(WorldPacket &recv_data) -{ - DEBUG_LOG("WORLD: CMSG_MOVE_FEATHER_FALL_ACK size %u", recv_data.wpos()); - - ObjectGuid guid; - MovementInfo movementInfo; - recv_data >> guid; // guid -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data.read_skip(); // counter -#endif - recv_data >> movementInfo; - movementInfo.UpdateTime(recv_data.GetPacketTime()); - - if (guid != _clientMoverGuid) - return; - - if (!VerifyMovementInfo(movementInfo)) - return; - - if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) - return; - - // Position change - HandleMoverRelocation(movementInfo); - _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode()); - - WorldPacket data(MSG_MOVE_FEATHER_FALL, recv_data.size()); - data << guid.WriteAsPacked(); - movementInfo.Write(data); - _player->SendMovementMessageToSet(std::move(data), true, _player); -} - -void WorldSession::HandleMoveUnRootAck(WorldPacket& recv_data) -{ - DEBUG_LOG("CMSG_FORCE_MOVE_UNROOT_ACK"); - ObjectGuid guid; - recv_data >> guid; - - // now can skip not our packet - if (_player->GetObjectGuid() != guid) - { - recv_data.rpos(recv_data.wpos()); // prevent warnings spam - return; - } - MovementInfo movementInfo; -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data.read_skip(); // unk -#endif - recv_data >> movementInfo; - movementInfo.UpdateTime(recv_data.GetPacketTime()); - - if (!VerifyMovementInfo(movementInfo)) - return; - - if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) - return; - - // Update position if it has changed (possible on UNROOT ack?) - HandleMoverRelocation(movementInfo); - _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode()); - - WorldPacket data(MSG_MOVE_UNROOT, recv_data.size()); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << _player->GetPackGUID(); -#else - data << _player->GetGUID(); -#endif - movementInfo.Write(data); - _player->SendMovementMessageToSet(std::move(data), true, _player); - - // Clear unit client state for brevity, though it should not be used - _player->clearUnitState(UNIT_STAT_CLIENT_ROOT); -} - -void WorldSession::HandleMoveRootAck(WorldPacket& recv_data) -{ - DEBUG_LOG("WORLD: CMSG_FORCE_MOVE_ROOT_ACK"); - ObjectGuid guid; - recv_data >> guid; - - // now can skip not our packet - if (_player->GetObjectGuid() != guid) - { - recv_data.rpos(recv_data.wpos()); // prevent warnings spam - return; - } - MovementInfo movementInfo; -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - recv_data.read_skip(); // unk -#endif - recv_data >> movementInfo; - movementInfo.UpdateTime(recv_data.GetPacketTime()); - - if (!VerifyMovementInfo(movementInfo)) - return; - - if (!_player->GetCheatData()->HandleAnticheatTests(movementInfo, this, &recv_data)) - return; - - // Position change - HandleMoverRelocation(movementInfo); - _player->UpdateFallInformationIfNeed(movementInfo, recv_data.GetOpcode()); - - WorldPacket data(MSG_MOVE_ROOT, recv_data.size()); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << _player->GetPackGUID(); -#else - data << _player->GetGUID(); -#endif - movementInfo.Write(data); - _player->SendMovementMessageToSet(std::move(data), true, _player); - - // Set unit client state for brevity, though it should not be used - _player->addUnitState(UNIT_STAT_CLIENT_ROOT); -} - -void WorldSession::HandleMoveSplineDoneOpcode(WorldPacket& recv_data) -{ - DEBUG_LOG("WORLD: Received CMSG_MOVE_SPLINE_DONE"); - - MovementInfo movementInfo; // used only for proper packet read - - recv_data >> movementInfo; - recv_data >> Unused(); // unk - recv_data >> Unused(); // unk2 - - // Forward packet to near players - recv_data.SetOpcode(MSG_MOVE_STOP); - recv_data.rpos(0); - HandleMovementOpcodes(recv_data); -} diff --git a/src/game/Movement/MovementPacketSender.cpp b/src/game/Movement/MovementPacketSender.cpp new file mode 100644 index 000000000..ec0f96d04 --- /dev/null +++ b/src/game/Movement/MovementPacketSender.cpp @@ -0,0 +1,296 @@ +/* + * Copyright (C) 2008-2017 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#include "MovementPacketSender.h" +#include "Player.h" +#include "WorldPacket.h" +#include "WorldSession.h" +#include "Anticheat.h" + +// Spline packets are for units controlled by the server. "Force speed change" (wrongly named opcodes) and "move set speed" packets are for units controlled by a player. +OpcodesList const moveTypeToOpcode[MAX_MOVE_TYPE][3] = +{ +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + { SMSG_SPLINE_SET_WALK_SPEED, SMSG_FORCE_WALK_SPEED_CHANGE, MSG_MOVE_SET_WALK_SPEED }, + { SMSG_SPLINE_SET_RUN_SPEED, SMSG_FORCE_RUN_SPEED_CHANGE, MSG_MOVE_SET_RUN_SPEED }, + { SMSG_SPLINE_SET_RUN_BACK_SPEED, SMSG_FORCE_RUN_BACK_SPEED_CHANGE, MSG_MOVE_SET_RUN_BACK_SPEED }, + { SMSG_SPLINE_SET_SWIM_SPEED, SMSG_FORCE_SWIM_SPEED_CHANGE, MSG_MOVE_SET_SWIM_SPEED }, + { SMSG_SPLINE_SET_SWIM_BACK_SPEED, SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, MSG_MOVE_SET_SWIM_BACK_SPEED }, + { SMSG_SPLINE_SET_TURN_RATE, SMSG_FORCE_TURN_RATE_CHANGE, MSG_MOVE_SET_TURN_RATE }, +#else + { MSG_MOVE_SET_WALK_SPEED, SMSG_FORCE_WALK_SPEED_CHANGE, MSG_MOVE_SET_WALK_SPEED }, + { MSG_MOVE_SET_RUN_SPEED, SMSG_FORCE_RUN_SPEED_CHANGE, MSG_MOVE_SET_RUN_SPEED }, + { MSG_MOVE_SET_RUN_BACK_SPEED, SMSG_FORCE_RUN_BACK_SPEED_CHANGE, MSG_MOVE_SET_RUN_BACK_SPEED }, + { MSG_MOVE_SET_SWIM_SPEED, SMSG_FORCE_SWIM_SPEED_CHANGE, MSG_MOVE_SET_SWIM_SPEED }, + { MSG_MOVE_SET_SWIM_BACK_SPEED, SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, MSG_MOVE_SET_SWIM_BACK_SPEED }, + { MSG_MOVE_SET_TURN_RATE, SMSG_FORCE_TURN_RATE_CHANGE, MSG_MOVE_SET_TURN_RATE }, +#endif +}; + +void MovementPacketSender::SendSpeedChangeToMover(Unit* unit, UnitMoveType mtype, float newRate) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendSpeedChangeToMover: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + float newSpeedFlat = newRate * baseMoveSpeed[mtype]; + uint32 mCounter = unit->GetMovementCounterAndInc(); + PlayerMovementPendingChange pendingChange; + pendingChange.movementCounter = mCounter; + pendingChange.newValue = newSpeedFlat; + pendingChange.movementChangeType = MovementPacketSender::GetChangeTypeByMoveType(mtype); + unit->PushPendingMovementChange(pendingChange); + + WorldPacket data; +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + data.Initialize(moveTypeToOpcode[mtype][1], 8 + 4 + 4); + data << unit->GetPackGUID(); + data << mCounter; +#elif SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + data.Initialize(moveTypeToOpcode[mtype][1], 8 + 4); + data << unit->GetPackGUID(); +#else + data.Initialize(moveTypeToOpcode[mtype][1], 8 + 4); + data << unit->GetGUID(); +#endif + data << float(newSpeedFlat); + + mover->GetSession()->SendPacket(&data); + mover->GetCheatData()->OrderSent(&data); +} + +MovementChangeType MovementPacketSender::GetChangeTypeByMoveType(UnitMoveType moveType) +{ + switch (moveType) + { + case MOVE_WALK: return SPEED_CHANGE_WALK; + case MOVE_RUN: return SPEED_CHANGE_RUN; + case MOVE_RUN_BACK: return SPEED_CHANGE_RUN_BACK; + case MOVE_SWIM: return SPEED_CHANGE_SWIM; + case MOVE_SWIM_BACK: return SPEED_CHANGE_SWIM_BACK; + case MOVE_TURN_RATE: return RATE_CHANGE_TURN; + default: + ASSERT(false && "MovementPacketSender::SendSpeedChangeToMover Unsupported UnitMoveType"); + } +} + +void MovementPacketSender::SendSpeedChangeToObservers(Unit* unit, UnitMoveType mtype, float newRate) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendSpeedChangeToObservers: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + WorldPacket data; + data.Initialize(moveTypeToOpcode[mtype][2], 8 + 30 + 4); +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + data << unit->GetPackGUID(); +#else + data << unit->GetGUID(); +#endif + data << unit->m_movementInfo; + data << float(newRate); + unit->SendMovementMessageToSet(std::move(data), false, mover); +} + +void MovementPacketSender::SendSpeedChangeToAll(Unit* unit, UnitMoveType mtype, float newRate) +{ + WorldPacket data; + data.Initialize(moveTypeToOpcode[mtype][0], 8 + 4); + data << unit->GetPackGUID(); + data << float(newRate * baseMoveSpeed[mtype]); + unit->SendMovementMessageToSet(std::move(data), true); +} + +void MovementPacketSender::SendKnockBackToMover(Unit* unit, float vcos, float vsin, float speedXY, float speedZ) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendKnockBackToMover: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + uint32 mCounter = unit->GetMovementCounterAndInc(); + PlayerMovementPendingChange pendingChange; + pendingChange.movementCounter = mCounter; + pendingChange.movementChangeType = KNOCK_BACK; + pendingChange.knockbackInfo.vcos = vcos; + pendingChange.knockbackInfo.vsin = vsin; + pendingChange.knockbackInfo.speedXY = speedXY; + pendingChange.knockbackInfo.speedZ = speedZ; + + unit->PushPendingMovementChange(pendingChange); + + WorldPacket data(SMSG_MOVE_KNOCK_BACK, (8 + 4 + 4 + 4 + 4 + 4)); + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + data << unit->GetPackGUID(); +#else + data << unit->GetGUID(); +#endif + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + data << mCounter; +#endif + + data << float(vcos); // x direction + data << float(vsin); // y direction + data << float(speedXY); // Horizontal speed + data << float(speedZ); // Z Movement speed (vertical) + mover->GetSession()->SendPacket(&data); +} + +void MovementPacketSender::SendKnockBackToObservers(Unit* unit, float vcos, float vsin, float speedXY, float speedZ) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendSpeedChangeToObservers: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + WorldPacket data(MSG_MOVE_KNOCK_BACK); + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + data << unit->GetPackGUID(); +#else + data << unit->GetGUID(); +#endif + + data << unit->m_movementInfo; + data << vcos; + data << vsin; + data << speedXY; + data << speedZ; + unit->SendMovementMessageToSet(std::move(data), false, mover); +} + +void MovementPacketSender::SendMovementFlagChangeToMover(Unit* unit, MovementFlags mFlag, bool apply) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendMovementFlagChangeToMover: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + uint16 opcode; + MovementChangeType movementChangeType; + switch (mFlag) + { + case MOVEFLAG_ROOT: opcode = apply ? SMSG_FORCE_MOVE_ROOT : SMSG_FORCE_MOVE_UNROOT; movementChangeType = ROOT; break; + case MOVEFLAG_WATERWALKING: opcode = apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK; movementChangeType = WATER_WALK; break; + case MOVEFLAG_HOVER: opcode = apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER; movementChangeType = SET_HOVER; break; + case MOVEFLAG_SAFE_FALL: opcode = apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL; movementChangeType = FEATHER_FALL; break; + default: + sLog.outError("MovementPacketSender::SendMovementFlagChangeToMover: Unsupported MovementFlag (%d), data not sent to client.", mFlag); + return; + } + + uint32 mCounter = unit->GetMovementCounterAndInc(); + PlayerMovementPendingChange pendingChange; + pendingChange.movementCounter = mCounter; + pendingChange.movementChangeType = movementChangeType; + pendingChange.apply = apply; + + unit->PushPendingMovementChange(pendingChange); + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + WorldPacket data(opcode, unit->GetPackGUID().size() + 4); + data << unit->GetPackGUID(); +#else + WorldPacket data(opcode, 8 + 4); + data << unit->GetGUID(); +#endif + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 + data << mCounter; +#endif + + mover->GetCheatData()->OrderSent(&data); + mover->GetSession()->SendPacket(&data); +} + +void MovementPacketSender::SendMovementFlagChangeToObservers(Unit* unit, MovementFlags mFlag, bool apply) +{ + Player* mover = unit->GetPlayerMovingMe(); + if (!mover) + { + sLog.outError("MovementPacketSender::SendMovementFlagChangeToMover: Incorrect use of the function. It was called on a unit controlled by the server!"); + return; + } + + uint16 opcode; + switch (mFlag) + { + case MOVEFLAG_ROOT: opcode = apply ? MSG_MOVE_ROOT : MSG_MOVE_UNROOT; break; + case MOVEFLAG_WATERWALKING: opcode = MSG_MOVE_WATER_WALK; break; + case MOVEFLAG_HOVER: opcode = MSG_MOVE_HOVER; break; + case MOVEFLAG_SAFE_FALL: opcode = MSG_MOVE_FEATHER_FALL; break; + default: + sLog.outError("MovementPacketSender::SendMovementFlagChangeToObservers: Unsupported MovementFlag (%d), data not sent to client.", mFlag); + return; + } + + WorldPacket data(opcode, 64); +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + data << unit->GetPackGUID(); +#else + data << unit->GetGUID(); +#endif + data << unit->m_movementInfo; + unit->SendMovementMessageToSet(std::move(data), false, mover); +} + +void MovementPacketSender::SendMovementFlagChangeToAll(Unit* unit, MovementFlags mFlag, bool apply) +{ + uint16 opcode; + switch (mFlag) + { +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + case MOVEFLAG_ROOT: opcode = apply ? SMSG_SPLINE_MOVE_ROOT : SMSG_SPLINE_MOVE_UNROOT; break; + case MOVEFLAG_WATERWALKING: opcode = apply ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK; break; + case MOVEFLAG_SAFE_FALL: opcode = apply ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL; break; + case MOVEFLAG_HOVER: opcode = apply ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER; break; +#else + case MOVEFLAG_ROOT: opcode = apply ? MSG_MOVE_ROOT : MSG_MOVE_UNROOT; break; + case MOVEFLAG_WATERWALKING: opcode = apply ? MSG_MOVE_WATER_WALK : MSG_MOVE_WATER_WALK; break; + case MOVEFLAG_SAFE_FALL: opcode = apply ? MSG_MOVE_FEATHER_FALL : MSG_MOVE_FEATHER_FALL; break; + case MOVEFLAG_HOVER: opcode = apply ? MSG_MOVE_HOVER : MSG_MOVE_HOVER; break; +#endif + default: + sLog.outError("MovementPacketSender::SendMovementFlagChangeToAll: Unsupported MovementFlag (%d), data not sent to client.", mFlag); + return; + } + +#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 + WorldPacket data(opcode, unit->GetPackGUID().size() + 4); + data << unit->GetPackGUID(); +#else + WorldPacket data(opcode, 64); + data << unit->GetGUID(); + data << unit->m_movementInfo; +#endif + + unit->SendMovementMessageToSet(std::move(data), true); +} diff --git a/src/game/Movement/MovementPacketSender.h b/src/game/Movement/MovementPacketSender.h new file mode 100644 index 000000000..43d5bcf10 --- /dev/null +++ b/src/game/Movement/MovementPacketSender.h @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2008-2017 TrinityCore + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#ifndef MOVEMENT_SENDER_H +#define MOVEMENT_SENDER_H + +#include "Unit.h" + +class Player; +class Unit; +class MovementInfo; + +//! +//! movement flag changes for player controlled units: +//! >>> APPLY +//! { +//! // Step1 Sent by the server to the mover's client // Step2 Sent back by the mover's client to the server // Step3 Sent to observers (all of these should be renamed to SMSG! Confirmed by sniff analysis) +//! { SMSG_FORCE_MOVE_ROOT, CMSG_FORCE_MOVE_ROOT_ACK, MSG_MOVE_ROOT }, +//! { SMSG_MOVE_WATER_WALK, CMSG_MOVE_WATER_WALK_ACK, MSG_MOVE_WATER_WALK }, +//! { SMSG_MOVE_SET_HOVER, CMSG_MOVE_HOVER_ACK, MSG_MOVE_HOVER }, +//! { SMSG_MOVE_FEATHER_FALL, CMSG_MOVE_FEATHER_FALL_ACK, MSG_MOVE_FEATHER_FALL }, +//! }, +//! >>> UNAPPLY +//! { +//! { SMSG_FORCE_MOVE_UNROOT, CMSG_FORCE_MOVE_UNROOT_ACK, MSG_MOVE_UNROOT }, +//! { SMSG_MOVE_LAND_WALK, CMSG_MOVE_WATER_WALK_ACK, MSG_MOVE_WATER_WALK }, +//! { SMSG_MOVE_UNSET_HOVER, CMSG_MOVE_HOVER_ACK, MSG_MOVE_HOVER }, +//! { SMSG_MOVE_NORMAL_FALL, CMSG_MOVE_FEATHER_FALL_ACK, MSG_MOVE_FEATHER_FALL }, +//! } +//! +//! ---------------------- +//! Speed changes on player controlled units: +//! // Step1 Sent by the server to the mover's client // Step2 Sent back by the mover's client to the server // Step3 Sent to observers +//! { SMSG_FORCE_WALK_SPEED_CHANGE, CMSG_FORCE_WALK_SPEED_CHANGE_ACK, MSG_MOVE_SET_WALK_SPEED }, +//! { SMSG_FORCE_RUN_SPEED_CHANGE, CMSG_FORCE_RUN_SPEED_CHANGE_ACK, MSG_MOVE_SET_RUN_SPEED }, +//! { SMSG_FORCE_RUN_BACK_SPEED_CHANGE, CMSG_FORCE_RUN_BACK_SPEED_CHANGE_ACK, MSG_MOVE_SET_RUN_BACK_SPEED }, +//! { SMSG_FORCE_SWIM_SPEED_CHANGE, CMSG_FORCE_SWIM_SPEED_CHANGE_ACK, MSG_MOVE_SET_SWIM_SPEED }, +//! { SMSG_FORCE_SWIM_BACK_SPEED_CHANGE, CMSG_FORCE_SWIM_BACK_SPEED_CHANGE_ACK, MSG_MOVE_SET_SWIM_BACK_SPEED }, +//! { SMSG_FORCE_TURN_RATE_CHANGE, CMSG_FORCE_TURN_RATE_CHANGE_ACK, MSG_MOVE_SET_TURN_RATE }, +//! +//! ---------------------- +//! Other type of changes +//! // Step1 Sent by the server to the mover's client // Step2 Sent back by the mover's client to the server // Step3 Sent to observers +//! { MSG_MOVE_TELEPORT_ACK, MSG_MOVE_TELEPORT_ACK, MSG_MOVE_TELEPORT }, +//! { SMSG_MOVE_KNOCK_BACK, CMSG_MOVE_KNOCK_BACK_ACK, MSG_MOVE_KNOCK_BACK }, +//! +//! ---------------------- +//! movement flag changes for server controlled units: (these player movement flags have no equivalent in spline: SET_CAN_FLY and SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY) +//! apply +//! { +//! SMSG_SPLINE_MOVE_GRAVITY_DISABLE, +//! SMSG_SPLINE_MOVE_ROOT, +//! SMSG_SPLINE_MOVE_WATER_WALK, +//! SMSG_SPLINE_MOVE_FEATHER_FALL, +//! SMSG_SPLINE_MOVE_SET_HOVER, +//! } +//! unapply +//! { +//! SMSG_SPLINE_MOVE_GRAVITY_ENABLE, +//! SMSG_SPLINE_MOVE_UNROOT, +//! SMSG_SPLINE_MOVE_LAND_WALK, +//! SMSG_SPLINE_MOVE_NORMAL_FALL, +//! SMSG_SPLINE_MOVE_UNSET_HOVER, +//! } + +/* +xxxxxToMover() and xxxxxToObservers() methods should be only used on a unit controlled & moved by a player (as in direct client control: possess). +ToMover() to send a packet to the client (asking for confirmation before acting the change) and ToObservers once the change has been acted and should be broadcasted to the other players around (the observers). + +xxxxxToAll() method should be used on a unit controlled & moved by the server (@todo note to self: does a player moved unit under the control of a temporary disorient (Scatter Shot eg) or fear fall into this category? EDIT: by looking at the effects of Psychic Scream (10890), the answer is yes) +*/ +namespace MovementPacketSender +{ + /* speed change */ + void SendSpeedChangeToMover(Unit* unit, UnitMoveType mtype, float newRate); + void SendSpeedChangeToObservers(Unit* unit, UnitMoveType mtype, float newRate); + void SendSpeedChangeToAll(Unit* unit, UnitMoveType mtype, float newRate); + + /* knocback */ + void SendKnockBackToMover(Unit* unit, float vcos, float vsin, float speedXY, float speedZ); + void SendKnockBackToObservers(Unit* unit, float vcos, float vsin, float speedXY, float speedZ); + + /* movement flag change */ + void SendMovementFlagChangeToMover(Unit* unit, MovementFlags mFlag, bool apply); + void SendMovementFlagChangeToObservers(Unit* unit, MovementFlags mFlag, bool apply); + void SendMovementFlagChangeToAll(Unit* unit, MovementFlags mFlag, bool apply); + + // utility method + MovementChangeType GetChangeTypeByMoveType(UnitMoveType moveType); +}; + +#endif diff --git a/src/game/Movement/PointMovementGenerator.cpp b/src/game/Movement/PointMovementGenerator.cpp index 036396892..cc224441f 100644 --- a/src/game/Movement/PointMovementGenerator.cpp +++ b/src/game/Movement/PointMovementGenerator.cpp @@ -236,7 +236,7 @@ void ChargeMovementGenerator::Finalize(T &unit) if (unit.hasUnitState(UNIT_STAT_PENDING_STUNNED)) unit.addUnitState(UNIT_STAT_STUNNED); if (unit.hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ROOT)) - unit.SetMovement(MOVE_ROOT); + unit.SetRooted(true); if (_triggerAttack) if (!unit.IsPlayer() || victimGuid == unit.ToPlayer()->GetSelectionGuid()) if (Unit* victim = unit.GetMap()->GetUnit(victimGuid)) @@ -323,7 +323,7 @@ void ChargeMovementGenerator::Interrupt(T &unit) if (unit.hasUnitState(UNIT_STAT_PENDING_STUNNED)) unit.addUnitState(UNIT_STAT_STUNNED); if (unit.hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ROOT)) - unit.SetMovement(MOVE_ROOT); + unit.SetRooted(true); } template @@ -335,7 +335,7 @@ void ChargeMovementGenerator::Reset(T &unit) if (unit.hasUnitState(UNIT_STAT_PENDING_STUNNED)) unit.addUnitState(UNIT_STAT_STUNNED); if (unit.hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_ROOT)) - unit.SetMovement(MOVE_ROOT); + unit.SetRooted(true); } template diff --git a/src/game/Movement/TargetedMovementGenerator.cpp b/src/game/Movement/TargetedMovementGenerator.cpp index 93df6fe0b..812cab5ae 100644 --- a/src/game/Movement/TargetedMovementGenerator.cpp +++ b/src/game/Movement/TargetedMovementGenerator.cpp @@ -657,9 +657,9 @@ void FollowMovementGenerator::_updateSpeed(Creature &u) if (!i_target.isValid() || i_target->GetObjectGuid() != u.GetOwnerGuid()) return; - u.UpdateSpeed(MOVE_RUN, true); - u.UpdateSpeed(MOVE_WALK, true); - u.UpdateSpeed(MOVE_SWIM, true); + u.UpdateSpeed(MOVE_RUN, false); + u.UpdateSpeed(MOVE_WALK, false); + u.UpdateSpeed(MOVE_SWIM, false); } template<> diff --git a/src/game/Objects/Creature.cpp b/src/game/Objects/Creature.cpp index c72b96c4d..43ec5a667 100644 --- a/src/game/Objects/Creature.cpp +++ b/src/game/Objects/Creature.cpp @@ -3781,46 +3781,3 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/) else ForcedDespawn(msTimeToDespawn); } - -void Creature::SetFeatherFall(bool enable) -{ - Unit::SetFeatherFall(enable); - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL); -#else - WorldPacket data(enable ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL); -#endif - data << GetPackGUID(); - SendMessageToSet(&data, true); -} - -void Creature::SetHover(bool enable) -{ - Unit::SetHover(enable); - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_HOVER : SMSG_SPLINE_MOVE_UNSET_HOVER, 9); - data << GetPackGUID(); -#else - WorldPacket data(enable ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 9); - data << GetGUID(); -#endif - - SendMessageToSet(&data, false); -} - -void Creature::SetWaterWalk(bool enable) -{ - Unit::SetWaterWalk(enable); - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK, 9); - data << GetPackGUID(); -#else - WorldPacket data(enable ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 9); - data << GetGUID(); -#endif - - SendMessageToSet(&data, true); -} \ No newline at end of file diff --git a/src/game/Objects/Creature.h b/src/game/Objects/Creature.h index 6017fca83..57880510a 100644 --- a/src/game/Objects/Creature.h +++ b/src/game/Objects/Creature.h @@ -598,10 +598,6 @@ class MANGOS_DLL_SPEC Creature : public Unit CreatureAI const* AI() const { return i_AI; } void SetAInitializeOnRespawn(bool initialize) { m_AI_InitializeOnRespawn = initialize; } - void SetFeatherFall(bool enable) override; - void SetHover(bool enable) override; - void SetWaterWalk(bool enable) override; - uint32 GetShieldBlockValue() const override { return getLevel() / 2 + uint32(GetStat(STAT_STRENGTH) / 20); // dunno mob block value diff --git a/src/game/Objects/Object.cpp b/src/game/Objects/Object.cpp index 4913068b6..b5b4c78bc 100644 --- a/src/game/Objects/Object.cpp +++ b/src/game/Objects/Object.cpp @@ -335,7 +335,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData *data, Player *target) c BuildMovementUpdate(&buf, updateFlags); #if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_8_4 - buf << uint32(target->IsMoverOf(this) ? 1 : 0); // Flags, 1 - Active Player + buf << uint32(target->GetMover() == this ? 1 : 0); // Flags, 1 - Active Player buf << uint32(0); // AttackCycle buf << uint32(0); // TimerId buf << uint64(0); // VictimGuid diff --git a/src/game/Objects/Object.h b/src/game/Objects/Object.h index b706d5fdd..236a9491f 100644 --- a/src/game/Objects/Object.h +++ b/src/game/Objects/Object.h @@ -795,7 +795,7 @@ m_obj->m_updateTracker.Reset(); void AddUnitMovementFlag(uint32 f) { m_movementInfo.moveFlags |= f; } void RemoveUnitMovementFlag(uint32 f) { m_movementInfo.moveFlags &= ~f; } - uint32 HasUnitMovementFlag(uint32 f) const { return m_movementInfo.moveFlags & f; } + bool HasUnitMovementFlag(uint32 f) const { return (m_movementInfo.moveFlags & f) == f; } uint32 GetUnitMovementFlags() const { return m_movementInfo.moveFlags; } void SetUnitMovementFlags(uint32 f) { m_movementInfo.moveFlags = f; } diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 88694dba9..685e4e222 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -4383,65 +4383,6 @@ void Player::SetFly(bool enable) SendHeartBeat(true); } -void Player::SetWaterWalk(bool enable) -{ - Unit::SetWaterWalk(enable); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - WorldPacket data(enable ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4); - data << GetPackGUID(); -#else - WorldPacket data(enable ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 8 + 4); - data << GetGUID(); -#endif - data << uint32(0); - GetSession()->SendPacket(&data); - GetCheatData()->OrderSent(&data); -} - -void Player::SetFeatherFall(bool enable) -{ - Unit::SetFeatherFall(enable); - - WorldPacket data; - if (enable) - data.Initialize(SMSG_MOVE_FEATHER_FALL, 8 + 4); - else - data.Initialize(SMSG_MOVE_NORMAL_FALL, 8 + 4); - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << GetPackGUID(); -#else - data << GetGUID(); -#endif - data << uint32(0); - SendMessageToSet(&data, true); - GetCheatData()->OrderSent(&data); - - // start fall from current height - if (!enable) - SetFallInformation(0, GetPositionZ()); -} - -void Player::SetHover(bool enable) -{ - Unit::SetHover(enable); - - WorldPacket data; - if (enable) - data.Initialize(SMSG_MOVE_SET_HOVER, 8 + 4); - else - data.Initialize(SMSG_MOVE_UNSET_HOVER, 8 + 4); - -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << GetPackGUID(); -#else - data << GetGUID(); -#endif - data << uint32(0); - SendMovementMessageToSet(std::move(data), true); - GetCheatData()->OrderSent(&data); -} - /* Preconditions: - a resurrectable corpse must not be loaded for the player (only bones) - the player must be in world @@ -4482,9 +4423,9 @@ void Player::BuildPlayerRepop() // convert player body to ghost SetHealth(1); - SetWaterWalk(true); + SetWaterWalking(true); if (!GetSession()->isLogingOut()) - SetMovement(MOVE_UNROOT); + SetRooted(false); // BG - remove insignia related RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE); @@ -4514,8 +4455,8 @@ void Player::ResurrectPlayer(float restore_percent, bool applySickness) RemoveAurasDueToSpell(20584); // speed bonuses RemoveAurasDueToSpell(8326); // SPELL_AURA_GHOST - SetWaterWalk(false); - SetMovement(MOVE_UNROOT); + SetWaterWalking(false); + SetRooted(false); // set health/powers (0- will be set in caller) if (restore_percent > 0.0f) @@ -17057,7 +16998,7 @@ Creature* Player::SummonPossessedMinion(uint32 creatureId, uint32 spellId, float pCreature->SetFactionTemporary(getFaction(), TEMPFACTION_NONE); // set same faction than player pCreature->SetCharmerGuid(GetObjectGuid()); // save guid of the charmer - pCreature->SetPossesorGuid(GetObjectGuid()); + pCreature->SetPossessorGuid(GetObjectGuid()); pCreature->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); // set the spell id used to create this pCreature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); // set flag for client that mean this unit is controlled by a player pCreature->addUnitState(UNIT_STAT_POSSESSED); // also set internal unit state flag @@ -17098,7 +17039,7 @@ void Player::UnsummonPossessedMinion() SetClientControl(pMinion, false); pMinion->SetCharmerGuid(ObjectGuid()); - pMinion->SetPossesorGuid(ObjectGuid()); + pMinion->SetPossessorGuid(ObjectGuid()); pMinion->clearUnitState(UNIT_STAT_POSSESSED); pMinion->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); pMinion->DoKillUnit(); @@ -18553,7 +18494,7 @@ void Player::SendInitialPacketsAfterAddToMap(bool login) } if (HasAuraType(SPELL_AURA_MOD_STUN)) - SetMovement(MOVE_ROOT); + SetRooted(true); // manual send package (have code in ApplyModifier(true,true); that don't must be re-applied. if (HasAuraType(SPELL_AURA_MOD_ROOT)) @@ -19444,17 +19385,6 @@ void Player::SetClientControl(Unit* target, uint8 allowMove) #endif } -bool Player::IsMoverOf(Object const* pObject) const -{ - if (Player const* pPlayer = pObject->ToPlayer()) - { - if (GetMover() == pPlayer) - return true; - } - - return false; -} - bool Player::HasSelfMovementControl() const { // Using Mind Vision diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index c9ce5d00f..697061480 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -1785,8 +1785,7 @@ class MANGOS_DLL_SPEC Player final: public Unit void SetClientControl(Unit* target, uint8 allowMove); void SetMover(Unit* target) { m_mover = target ? target : this; } Unit* GetMover() const { return m_mover; } - bool IsSelfMover() const { return m_mover == this; }// normal case for player not controlling other unit - bool IsMoverOf(Object const* pObject) const; + bool IsSelfMover() const { return m_mover == this; } // normal case for player not controlling other unit bool HasSelfMovementControl() const; bool IsNextRelocationIgnored() const { return m_bNextRelocationsIgnored ? true : false; } void SetNextRelocationsIgnoredCount(uint32 count) { m_bNextRelocationsIgnored = count; } @@ -1833,9 +1832,6 @@ class MANGOS_DLL_SPEC Player final: public Unit bool CanFly() const { return IsFlying(); } void SetFly(bool enable) override; - void SetFeatherFall(bool enable) override; - void SetHover(bool enable) override; - void SetWaterWalk(bool enable) override; // Anti undermap void SaveNoUndermapPosition(float x, float y, float z) diff --git a/src/game/Objects/Unit.cpp b/src/game/Objects/Unit.cpp index 421e6d5bd..3b19319a4 100644 --- a/src/game/Objects/Unit.cpp +++ b/src/game/Objects/Unit.cpp @@ -63,6 +63,7 @@ #include "Anticheat.h" #include "CreatureLinkingMgr.h" #include "InstanceStatistics.h" +#include "MovementPacketSender.h" #include #include @@ -6092,7 +6093,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) case AURA_STATE_HEALTHLESS_15_PERCENT: case AURA_STATE_HEALTHLESS_10_PERCENT: case AURA_STATE_HEALTHLESS_5_PERCENT: - UpdateSpeed(MOVE_RUN, true); + UpdateSpeed(MOVE_RUN, false); break; } } @@ -6127,7 +6128,7 @@ void Unit::ModifyAuraState(AuraState flag, bool apply) case AURA_STATE_HEALTHLESS_15_PERCENT: case AURA_STATE_HEALTHLESS_10_PERCENT: case AURA_STATE_HEALTHLESS_5_PERCENT: - UpdateSpeed(MOVE_RUN, true); + UpdateSpeed(MOVE_RUN, false); break; } } @@ -6149,6 +6150,15 @@ Unit *Unit::GetCharmer() const return nullptr; } +Player* Unit::GetPossessor() const +{ + if (ObjectGuid possessor = GetPossessorGuid()) + if (possessor.IsPlayer()) + return ObjectAccessor::FindPlayer(possessor); + + return nullptr; +} + bool Unit::IsCharmerOrOwnerPlayerOrPlayerItself() const { if (GetTypeId() == TYPEID_PLAYER) @@ -8141,6 +8151,50 @@ bool Unit::canDetectStealthOf(Unit const* target, float distance, bool *alert) c return true; } +PlayerMovementPendingChange Unit::PopPendingMovementChange() +{ + PlayerMovementPendingChange result = m_pendingMovementChanges.front(); + m_pendingMovementChanges.pop_front(); + return result; +} + +void Unit::PushPendingMovementChange(PlayerMovementPendingChange newChange) +{ + m_pendingMovementChanges.emplace_back(std::move(newChange)); +} + +bool Unit::HasPendingMovementChange(MovementChangeType changeType) const +{ + return std::find_if(m_pendingMovementChanges.begin(), m_pendingMovementChanges.end(), + [changeType](PlayerMovementPendingChange const& pendingChange) + { + return pendingChange.movementChangeType == changeType; + }) != m_pendingMovementChanges.end(); +} + +Player* Unit::GetPlayerMovingMe() +{ + if (Player* pPossessor = GetPossessor()) + if (pPossessor->GetCharmGuid() == GetObjectGuid()) + return pPossessor; + + return ToPlayer(); +} + +bool Unit::IsMovedByPlayer() const +{ + if (Player* pPossessor = GetPossessor()) + if (pPossessor->GetCharmGuid() == GetObjectGuid()) + return true; + + return IsPlayer(); +} + +PlayerMovementPendingChange::PlayerMovementPendingChange() +{ + time = WorldTimer::getMSTime(); +} + void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) { // not in combat pet have same speed as owner @@ -8153,7 +8207,7 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) case MOVE_RUN: case MOVE_WALK: case MOVE_SWIM: - SetSpeedRate(mtype, owner->GetSpeedRate(mtype), forced); + SetSpeedRate(mtype, owner->GetSpeedRate(mtype)); return; default: break; @@ -8269,7 +8323,10 @@ void Unit::UpdateSpeed(UnitMoveType mtype, bool forced, float ratio) } } - SetSpeedRate(mtype, speed * ratio, forced); + if (forced) + SetSpeedRateReal(mtype, speed * ratio); + else + SetSpeedRate(mtype, speed * ratio); } float Unit::GetSpeed(UnitMoveType mtype) const @@ -8322,63 +8379,155 @@ struct SetSpeedRateHelper bool forced; }; -void Unit::SetSpeedRate(UnitMoveType mtype, float rate, bool forced) +void Unit::SetSpeedRate(UnitMoveType mtype, float rate) { - if (rate <= 0) - rate = 1.0f; + if (rate < 0) + rate = 0.0f; // Update speed only on change - if (m_speed_rate[mtype] != rate) + MovementChangeType changeType = MovementPacketSender::GetChangeTypeByMoveType(mtype); + if (m_speed_rate[mtype] == rate && !HasPendingMovementChange(changeType)) + return; + + if (IsMovedByPlayer() && IsInWorld()) + MovementPacketSender::SendSpeedChangeToMover(this, mtype, rate); + else if (IsMovedByPlayer() && !IsInWorld()) // (1) + SetSpeedRateReal(mtype, rate); + else // <=> if(!IsMovedByPlayer()) { - m_speed_rate[mtype] = rate; - - const uint16 SetSpeed2Opc_table[MAX_MOVE_TYPE][2] = - { - {MSG_MOVE_SET_WALK_SPEED, SMSG_FORCE_WALK_SPEED_CHANGE}, - {MSG_MOVE_SET_RUN_SPEED, SMSG_FORCE_RUN_SPEED_CHANGE}, - {MSG_MOVE_SET_RUN_BACK_SPEED, SMSG_FORCE_RUN_BACK_SPEED_CHANGE}, - {MSG_MOVE_SET_SWIM_SPEED, SMSG_FORCE_SWIM_SPEED_CHANGE}, - {MSG_MOVE_SET_SWIM_BACK_SPEED, SMSG_FORCE_SWIM_BACK_SPEED_CHANGE}, - {MSG_MOVE_SET_TURN_RATE, SMSG_FORCE_TURN_RATE_CHANGE}, - }; - - if (forced) - { - if (Player* me = GetAffectingPlayer()) - { -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_9_4 - WorldPacket dataForMe(SetSpeed2Opc_table[mtype][1], 18); - dataForMe << GetPackGUID(); - dataForMe << uint32(0); -#else - WorldPacket dataForMe(SetSpeed2Opc_table[mtype][1], 14); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - dataForMe << GetPackGUID(); -#else - dataForMe << GetGUID(); -#endif -#endif - dataForMe << float(GetSpeed(mtype)); - me->GetSession()->SendPacket(&dataForMe); - me->GetCheatData()->OrderSent(&dataForMe); - //if (this == me) - //if (WardenInterface* warden = me->GetSession()->GetWarden()) - //warden->SendSpeedChange(mtype, GetSpeed(mtype)); - } - } - - - // TODO: Actually such opcodes should (always?) be packed with SMSG_COMPRESSED_MOVES - // Nostalrius: (google translated) - // Unable to send here the package 'MSG_MOVE_SET _ * _ SPEED', because we do not know the flags of movements, and the position dimension client - // (update every 0.5 sec). If one sends a packet, one leads to a desynchro (in the absence of interpolation of the position) - // This package will be sent after receiving a packet type 'CMSG_FORCE _ * _ SPEED_CHANGE_ACK' (MovementHandler.cpp) - //m_updateFlag |= UPDATEFLAG_LIVING; // Mise a jour des mouvements en cours, spline, vitesses, etc ... Inutile ? - - propagateSpeedChange(); + SetSpeedRateReal(mtype, rate); + MovementPacketSender::SendSpeedChangeToAll(this, mtype, rate); } - CallForAllControlledUnits(SetSpeedRateHelper(mtype, forced), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM | CONTROLLED_MINIPET); + // explaination of (1): + // If the player is not in the world yet, it won't reply to the packets requiring an ack. And once the player is in the world, next time a movement + // packet which requires an ack is sent to the client (change of speed for example), the client is kicked from the + // server on the ground that it should have replied to the first packet first. That line is a hacky fix + // in the sense that it doesn't work like that in retail since buffs are applied only after the player has been + // initialized in the world. cf description of PR #18771 +} + +void Unit::SetSpeedRateReal(UnitMoveType mtype, float rate) +{ + m_speed_rate[mtype] = rate; + propagateSpeedChange(); + CallForAllControlledUnits(SetSpeedRateHelper(mtype, true), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM | CONTROLLED_MINIPET); +} + +void Unit::SetRooted(bool apply) +{ + // do nothing if the unit is already in the required state + if (apply == HasUnitMovementFlag(MOVEFLAG_ROOT) && !HasPendingMovementChange(ROOT)) + return; + + if (apply) + StopMoving(); // @todo: this method needs a rework to work well with players. + + if (IsMovedByPlayer() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEFLAG_ROOT, apply); + else if (IsMovedByPlayer() && !IsInWorld()) + SetRootedReal(apply); + else + { + SetRootedReal(apply); + MovementPacketSender::SendMovementFlagChangeToAll(this, MOVEFLAG_ROOT, apply); + } +} + +void Unit::SetRootedReal(bool apply) +{ + if (apply) + AddUnitMovementFlag(MOVEFLAG_ROOT); + else + RemoveUnitMovementFlag(MOVEFLAG_ROOT); +} + +void Unit::SetWaterWalking(bool apply) +{ + if (apply == HasUnitMovementFlag(MOVEFLAG_WATERWALKING) && !HasPendingMovementChange(WATER_WALK)) + return; + + if (IsMovedByPlayer() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEFLAG_WATERWALKING, apply); + else if (IsMovedByPlayer() && !IsInWorld()) + SetWaterWalkingReal(apply); + else + { + SetWaterWalkingReal(apply); + MovementPacketSender::SendMovementFlagChangeToAll(this, MOVEFLAG_WATERWALKING, apply); + } +} + +void Unit::SetWaterWalkingReal(bool apply) +{ + if (apply) + AddUnitMovementFlag(MOVEFLAG_WATERWALKING); + else + RemoveUnitMovementFlag(MOVEFLAG_WATERWALKING); +} + +void Unit::SetFeatherFall(bool apply) +{ + if (apply == HasUnitMovementFlag(MOVEFLAG_SAFE_FALL) && !HasPendingMovementChange(FEATHER_FALL)) + return; + + if (IsMovedByPlayer() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEFLAG_SAFE_FALL, apply); + else if (IsMovedByPlayer() && !IsInWorld()) + SetFeatherFallReal(apply); + else + { + SetFeatherFallReal(apply); + MovementPacketSender::SendMovementFlagChangeToAll(this, MOVEFLAG_SAFE_FALL, apply); + } +} + +void Unit::SetFeatherFallReal(bool apply) +{ + if (apply) + AddUnitMovementFlag(MOVEFLAG_SAFE_FALL); + else + RemoveUnitMovementFlag(MOVEFLAG_SAFE_FALL); +} + +void Unit::SetHover(bool apply) +{ + if (apply == HasUnitMovementFlag(MOVEFLAG_HOVER) && !HasPendingMovementChange(SET_HOVER)) + return; + + if (IsMovedByPlayer() && IsInWorld()) + MovementPacketSender::SendMovementFlagChangeToMover(this, MOVEFLAG_HOVER, apply); + else if (IsMovedByPlayer() && !IsInWorld()) + SetHoverReal(apply); + else + { + SetHoverReal(apply); + MovementPacketSender::SendMovementFlagChangeToAll(this, MOVEFLAG_HOVER, apply); + } +} + +void Unit::SetHoverReal(bool apply) +{ + if (apply) + AddUnitMovementFlag(MOVEFLAG_HOVER); + else + RemoveUnitMovementFlag(MOVEFLAG_HOVER); +} + +void Unit::SetLevitate(bool enable) +{ + if (enable) + m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); + else + m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); +} + +void Unit::SetFly(bool enable) +{ + if (enable) + m_movementInfo.AddMovementFlag(MOVEFLAG_FLYING | MOVEFLAG_CAN_FLY); + else + m_movementInfo.RemoveMovementFlag(MOVEFLAG_FLYING | MOVEFLAG_CAN_FLY); } void Unit::SetDeathState(DeathState s) @@ -10798,6 +10947,9 @@ void Unit::SetPvP(bool state) void Unit::KnockBackFrom(WorldObject* target, float horizontalSpeed, float verticalSpeed) { + if (IsRooted()) + return; + float angle = this == target ? GetOrientation() + M_PI_F : target->GetAngle(this); // set immune anticheat and calculate speed @@ -10812,27 +10964,18 @@ void Unit::KnockBackFrom(WorldObject* target, float horizontalSpeed, float verti void Unit::KnockBack(float angle, float horizontalSpeed, float verticalSpeed) { + if (IsRooted()) + return; + InterruptNonMeleeSpells(false); // Effect properly implemented only for players - if (GetTypeId() == TYPEID_PLAYER) + if (IsMovedByPlayer() && IsInWorld()) { float vsin = sin(angle); float vcos = cos(angle); - WorldPacket data(SMSG_MOVE_KNOCK_BACK, 8 + 4 + 4 + 4 + 4 + 4); -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << GetPackGUID(); -#else - data << GetGUID(); -#endif - data << uint32(0); // Sequence - data << float(vcos); // x direction - data << float(vsin); // y direction - data << float(horizontalSpeed); // Horizontal speed - data << float(-verticalSpeed); // Z Movement speed (vertical) - SendMovementMessageToSet(std::move(data), true); - - ToPlayer()->GetCheatData()->KnockBack(horizontalSpeed, verticalSpeed, vcos, vsin); + MovementPacketSender::SendKnockBackToMover(this, vcos, vsin, horizontalSpeed, -verticalSpeed); // !! notice the - sign in front of speedZ !! + GetPlayerMovingMe()->GetCheatData()->KnockBack(horizontalSpeed, verticalSpeed, vcos, vsin); } } @@ -11663,46 +11806,6 @@ void Unit::SetWalk(bool enable, bool asDefault) SendObjectMessageToSet(&data, false); } -void Unit::SetLevitate(bool enable) -{ - if (enable) - m_movementInfo.AddMovementFlag(MOVEFLAG_LEVITATING); - else - m_movementInfo.RemoveMovementFlag(MOVEFLAG_LEVITATING); -} - -void Unit::SetFly(bool enable) -{ - if (enable) - m_movementInfo.AddMovementFlag(MOVEFLAG_FLYING | MOVEFLAG_CAN_FLY); - else - m_movementInfo.RemoveMovementFlag(MOVEFLAG_FLYING | MOVEFLAG_CAN_FLY); -} - -void Unit::SetFeatherFall(bool enable) -{ - if (enable) - m_movementInfo.AddMovementFlag(MOVEFLAG_SAFE_FALL); - else - m_movementInfo.RemoveMovementFlag(MOVEFLAG_SAFE_FALL); -} - -void Unit::SetHover(bool enable) -{ - if (enable) - m_movementInfo.AddMovementFlag(MOVEFLAG_HOVER); - else - m_movementInfo.RemoveMovementFlag(MOVEFLAG_HOVER); -} - -void Unit::SetWaterWalk(bool enable) -{ - if (enable) - m_movementInfo.AddMovementFlag(MOVEFLAG_WATERWALKING); - else - m_movementInfo.RemoveMovementFlag(MOVEFLAG_WATERWALKING); -} - void Unit::DisableSpline() { if (Player* me = ToPlayer()) @@ -11826,126 +11929,6 @@ void Unit::RemoveAttackersThreat(Unit* owner) } } -void Unit::SetMovement(UnitMovementType pType) -{ - switch (pType) - { - case MOVE_ROOT: - m_movementInfo.ChangePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - m_movementInfo.UpdateTime(WorldTimer::getMSTime()); - m_movementInfo.moveFlags = MOVEFLAG_ROOT | (m_movementInfo.moveFlags & ~MOVEFLAG_MASK_MOVING_OR_TURN); - break; - case MOVE_UNROOT: - m_movementInfo.ChangePosition(GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation()); - m_movementInfo.UpdateTime(WorldTimer::getMSTime()); - m_movementInfo.moveFlags = (m_movementInfo.moveFlags & ~(MOVEFLAG_MASK_MOVING_OR_TURN | MOVEFLAG_ROOT)); - break; - } - WorldPacket data; - if (!movespline->Finalized()) - { - // Spline roots are sent here. - MovementData mvtData(this); - switch (pType) - { -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - case MOVE_ROOT: - mvtData.SetSplineOpcode(SMSG_SPLINE_MOVE_ROOT, GetObjectGuid()); - return; - case MOVE_UNROOT: - mvtData.SetSplineOpcode(SMSG_SPLINE_MOVE_UNROOT, GetObjectGuid()); - break; - case MOVE_WATER_WALK: - mvtData.SetSplineOpcode(SMSG_SPLINE_MOVE_WATER_WALK, GetObjectGuid()); - break; - case MOVE_LAND_WALK: - mvtData.SetSplineOpcode(SMSG_SPLINE_MOVE_LAND_WALK, GetObjectGuid()); - break; -#else - case MOVE_ROOT: - mvtData.SetSplineOpcode(MSG_MOVE_ROOT, GetObjectGuid()); - return; - case MOVE_UNROOT: - mvtData.SetSplineOpcode(MSG_MOVE_UNROOT, GetObjectGuid()); - break; - case MOVE_WATER_WALK: - mvtData.SetSplineOpcode(SMSG_MOVE_WATER_WALK, GetObjectGuid()); - break; - case MOVE_LAND_WALK: - mvtData.SetSplineOpcode(SMSG_MOVE_LAND_WALK, GetObjectGuid()); - break; -#endif - } - return; - } - // Inform controller - Player* mePlayer = ToPlayer(); - Player* controller = nullptr; - if (Unit* charmer = GetCharmer()) - if (Player* charmerPlayer = charmer->ToPlayer()) - if (charmerPlayer->GetCharmGuid() == GetObjectGuid()) - controller = charmerPlayer; - if (!mePlayer && !controller) - return; - - switch (pType) - { -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - case MOVE_ROOT: - data.Initialize(SMSG_FORCE_MOVE_ROOT, GetPackGUID().size() + 4); - break; - case MOVE_UNROOT: - data.Initialize(SMSG_FORCE_MOVE_UNROOT, GetPackGUID().size() + 4); - break; - case MOVE_WATER_WALK: - data.Initialize(SMSG_MOVE_WATER_WALK, GetPackGUID().size() + 4); - break; - case MOVE_LAND_WALK: - data.Initialize(SMSG_MOVE_LAND_WALK, GetPackGUID().size() + 4); - break; -#else - case MOVE_ROOT: - data.Initialize(SMSG_FORCE_MOVE_ROOT, 8 + 4); - break; - case MOVE_UNROOT: - data.Initialize(SMSG_FORCE_MOVE_UNROOT, 8 + 4); - break; - case MOVE_WATER_WALK: - data.Initialize(SMSG_MOVE_WATER_WALK, 8 + 4); - break; - case MOVE_LAND_WALK: - data.Initialize(SMSG_MOVE_LAND_WALK, 8 + 4); - break; -#endif - default: - sLog.outError("Player::SetMovement: Unsupported move type (%d), data not sent to client.", pType); - return; - } -#if SUPPORTED_CLIENT_BUILD > CLIENT_BUILD_1_8_4 - data << GetPackGUID(); -#else - data << GetGUID(); -#endif - data << uint32(WorldTimer::getMSTime()); // Peut etre msTime : WorldTimer::getMSTime() ? - if (mePlayer) - { - mePlayer->GetCheatData()->OrderSent(&data); - mePlayer->GetSession()->SendPacket(&data); - - // We can't send movement info here because it is out-of-date with the client - // and causes issues with unit speed updates on death/res - /*if (pType == MOVE_ROOT || pType == MOVE_UNROOT) { - WorldPacket rootData(pType == MOVE_ROOT ? MSG_MOVE_ROOT : MSG_MOVE_UNROOT, 31); - rootData << GetPackGUID(); - rootData << m_movementInfo; - - mePlayer->SendMovementMessageToSet(std::move(rootData), false); - }*/ - } - if (controller) - controller->GetSession()->SendPacket(&data); -} - bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const { AuraList const& auras = GetAurasByType(type); diff --git a/src/game/Objects/Unit.h b/src/game/Objects/Unit.h index 680da1b3e..48aee6190 100644 --- a/src/game/Objects/Unit.h +++ b/src/game/Objects/Unit.h @@ -40,12 +40,59 @@ #include "Timer.h" #include -enum UnitMovementType +enum UnitMoveType { - MOVE_ROOT = 1, - MOVE_UNROOT = 2, - MOVE_WATER_WALK = 3, - MOVE_LAND_WALK = 4 + MOVE_WALK = 0, + MOVE_RUN = 1, + MOVE_RUN_BACK = 2, + MOVE_SWIM = 3, + MOVE_SWIM_BACK = 4, + MOVE_TURN_RATE = 5, +}; + +#define MAX_MOVE_TYPE 6 + +extern float baseMoveSpeed[MAX_MOVE_TYPE]; + +#define MOVEMENT_PACKET_TIME_DELAY 0 + +enum MovementChangeType +{ + INVALID, + + ROOT, + WATER_WALK, + SET_HOVER, + FEATHER_FALL, + + SPEED_CHANGE_WALK, + SPEED_CHANGE_RUN, + SPEED_CHANGE_RUN_BACK, + SPEED_CHANGE_SWIM, + SPEED_CHANGE_SWIM_BACK, + RATE_CHANGE_TURN, + + TELEPORT, + KNOCK_BACK +}; + +struct PlayerMovementPendingChange +{ + uint32 movementCounter = 0; + MovementChangeType movementChangeType = INVALID; + uint32 time = 0; + + float newValue = 0.0f; // used if speed or height change + bool apply = false; // used if movement flag change + struct KnockbackInfo + { + float vcos = 0.0f; + float vsin = 0.0f; + float speedXY = 0.0f; + float speedZ = 0.0f; + } knockbackInfo; // used if knockback + + PlayerMovementPendingChange(); }; enum SpellInterruptFlags @@ -456,18 +503,6 @@ enum UnitState UNIT_STAT_ALL_DYN_STATES = UNIT_STAT_ALL_STATE & ~(UNIT_STAT_NO_COMBAT_MOVEMENT | UNIT_STAT_RUNNING | UNIT_STAT_IGNORE_PATHFINDING), }; -enum UnitMoveType -{ - MOVE_WALK = 0, - MOVE_RUN = 1, - MOVE_RUN_BACK = 2, - MOVE_SWIM = 3, - MOVE_SWIM_BACK = 4, - MOVE_TURN_RATE = 5, -}; - -#define MAX_MOVE_TYPE 6 - /// internal used flags for marking special auras - for example some dummy-auras enum UnitAuraFlags { @@ -1498,10 +1533,54 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void SendHeartBeat(bool includingSelf = true); virtual void SetFly(bool enable); void SetWalk(bool enable, bool asDefault = true); - void SetLevitate(bool enable); - virtual void SetFeatherFall(bool /*enabled*/); - virtual void SetHover(bool /*enabled*/); - virtual void SetWaterWalk(bool /*enabled*/); + + private: + // when a player controls this unit, and when change is made to this unit which requires an ack from the client to be acted (change of speed for example), this movementCounter is incremented + uint32 m_movementCounter = 0; + std::deque m_pendingMovementChanges; + + public: + void SetRooted(bool apply); + void SetRootedReal(bool apply); + bool IsRooted() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_ROOT); } + + void SetWaterWalking(bool apply); + void SetWaterWalkingReal(bool apply); + bool IsWaterWalking() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_WATERWALKING); } + + void SetHover(bool apply); + void SetHoverReal(bool apply); + bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_HOVER); } + + void SetFeatherFall(bool apply); + void SetFeatherFallReal(bool apply); + bool IsFallingSlow() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_SAFE_FALL); } + + void SetLevitate(bool apply); + bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEFLAG_LEVITATING); } + + void KnockBackFrom(WorldObject* target, float horizontalSpeed, float verticalSpeed); + void KnockBack(float angle, float horizontalSpeed, float verticalSpeed); + + // reflects direct client control (examples: a player MC another player or a creature (possess effects). etc...) + bool IsMovedByPlayer() const; + Player* GetPlayerMovingMe(); + + uint32 GetMovementCounterAndInc() { return m_movementCounter++; } + uint32 GetMovementCounter() const { return m_movementCounter; } + + PlayerMovementPendingChange PopPendingMovementChange(); + void PushPendingMovementChange(PlayerMovementPendingChange newChange); + bool HasPendingMovementChange() const { return !m_pendingMovementChanges.empty(); } + bool HasPendingMovementChange(MovementChangeType changeType) const; + + void SetSpeedRate(UnitMoveType mtype, float rate); + void SetSpeedRateReal(UnitMoveType mtype, float rate); + void UpdateSpeed(UnitMoveType mtype, bool forced, float ratio = 1.0f); + float GetSpeed(UnitMoveType mtype) const; + float GetXZFlagBasedSpeed() const; + float GetXZFlagBasedSpeed(uint32 moveFlags) const; + float GetSpeedRate(UnitMoveType mtype) const { return m_speed_rate[mtype]; } virtual bool CanWalk() const = 0; virtual bool CanFly() const = 0; @@ -1529,8 +1608,8 @@ class MANGOS_DLL_SPEC Unit : public WorldObject ObjectGuid const& GetChannelObjectGuid() const { return GetGuidValue(UNIT_FIELD_CHANNEL_OBJECT); } void SetChannelObjectGuid(ObjectGuid targetGuid) { SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, targetGuid); } - ObjectGuid const& GetPossessorGuid() { return m_possessorGuid; } - void SetPossesorGuid(ObjectGuid possession) { m_possessorGuid = possession; } + ObjectGuid const& GetPossessorGuid() const { return m_possessorGuid; } + void SetPossessorGuid(ObjectGuid possession) { m_possessorGuid = possession; } virtual Pet* GetMiniPet() const { return nullptr; } // overwrited in Player @@ -1547,6 +1626,7 @@ class MANGOS_DLL_SPEC Unit : public WorldObject Unit* GetOwner() const; Pet* GetPet() const; Unit* GetCharmer() const; + Player* GetPossessor() const; Unit* GetCharm() const; void Uncharm(); void RemoveCharmAuras(); @@ -1901,18 +1981,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject void CalculateAbsorbResistBlock(Unit *pCaster, SpellNonMeleeDamage *damageInfo, SpellEntry const* spellProto, WeaponAttackType attType = BASE_ATTACK, Spell* spell = nullptr); float RollMagicResistanceMultiplierOutcomeAgainst(const Unit* pCaster, SpellSchoolMask schoolMask, DamageEffectType dmgType, SpellEntry const* spellProto) const; - void UpdateSpeed(UnitMoveType mtype, bool forced, float ratio = 1.0f); - float GetSpeed(UnitMoveType mtype) const; - float GetXZFlagBasedSpeed() const; - float GetXZFlagBasedSpeed(uint32 moveFlags) const; - float GetSpeedRate(UnitMoveType mtype) const { return m_speed_rate[mtype]; } - void SetSpeedRate(UnitMoveType mtype, float rate, bool forced = false); - - bool isHover() const { return HasAuraType(SPELL_AURA_HOVER); } - - void KnockBackFrom(WorldObject* target, float horizontalSpeed, float verticalSpeed); - void KnockBack(float angle, float horizontalSpeed, float verticalSpeed); - void _RemoveAllAuraMods(); void _ApplyAllAuraMods(); @@ -2058,7 +2126,6 @@ class MANGOS_DLL_SPEC Unit : public WorldObject bool IsInPartyWith(Unit const* unit) const; bool IsInRaidWith(Unit const* unit) const; - void SetMovement(UnitMovementType pType); bool HasBreakableByDamageCrowdControlAura(Unit* excludeCasterChannel= nullptr) const; bool HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const; diff --git a/src/game/Protocol/Opcodes.cpp b/src/game/Protocol/Opcodes.cpp index e71fc31ac..4d440eb46 100644 --- a/src/game/Protocol/Opcodes.cpp +++ b/src/game/Protocol/Opcodes.cpp @@ -298,7 +298,7 @@ void Opcodes::BuildOpcodeList() /*0x0E8*/ StoreOpcode(SMSG_FORCE_MOVE_ROOT, "SMSG_FORCE_MOVE_ROOT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0E9*/ StoreOpcode(CMSG_FORCE_MOVE_ROOT_ACK, "CMSG_FORCE_MOVE_ROOT_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveRootAck); /*0x0EA*/ StoreOpcode(SMSG_FORCE_MOVE_UNROOT, "SMSG_FORCE_MOVE_UNROOT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); - /*0x0EB*/ StoreOpcode(CMSG_FORCE_MOVE_UNROOT_ACK, "CMSG_FORCE_MOVE_UNROOT_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveUnRootAck); + /*0x0EB*/ StoreOpcode(CMSG_FORCE_MOVE_UNROOT_ACK, "CMSG_FORCE_MOVE_UNROOT_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveRootAck); /*0x0EC*/ StoreOpcode(MSG_MOVE_ROOT, "MSG_MOVE_ROOT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); /*0x0ED*/ StoreOpcode(MSG_MOVE_UNROOT, "MSG_MOVE_UNROOT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); /*0x0EE*/ StoreOpcode(MSG_MOVE_HEARTBEAT, "MSG_MOVE_HEARTBEAT", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMovementOpcodes); @@ -309,7 +309,7 @@ void Opcodes::BuildOpcodeList() /*0x0F3*/ StoreOpcode(SMSG_MOVE_NORMAL_FALL, "SMSG_MOVE_NORMAL_FALL", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0F4*/ StoreOpcode(SMSG_MOVE_SET_HOVER, "SMSG_MOVE_SET_HOVER", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x0F5*/ StoreOpcode(SMSG_MOVE_UNSET_HOVER, "SMSG_MOVE_UNSET_HOVER", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); - /*0x0F6*/ StoreOpcode(CMSG_MOVE_HOVER_ACK, "CMSG_MOVE_HOVER_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveHoverAck); + /*0x0F6*/ StoreOpcode(CMSG_MOVE_HOVER_ACK, "CMSG_MOVE_HOVER_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMovementFlagChangeToggleAck); /*0x0F7*/ StoreOpcode(MSG_MOVE_HOVER, "MSG_MOVE_HOVER", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); /*0x0F8*/ StoreOpcode(CMSG_TRIGGER_CINEMATIC_CHEAT, "CMSG_TRIGGER_CINEMATIC_CHEAT", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); /*0x0F9*/ StoreOpcode(CMSG_OPENING_CINEMATIC, "CMSG_OPENING_CINEMATIC", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_NULL); @@ -792,8 +792,8 @@ void Opcodes::BuildOpcodeList() /*0x2CC*/ StoreOpcode(SMSG_RAID_INSTANCE_INFO, "SMSG_RAID_INSTANCE_INFO", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x2CD*/ StoreOpcode(CMSG_REQUEST_RAID_INFO, "CMSG_REQUEST_RAID_INFO", STATUS_LOGGEDIN, PACKET_PROCESS_WORLD, &WorldSession::HandleRequestRaidInfoOpcode); /*0x2CE*/ StoreOpcode(CMSG_MOVE_TIME_SKIPPED, "CMSG_MOVE_TIME_SKIPPED", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveTimeSkippedOpcode); - /*0x2CF*/ StoreOpcode(CMSG_MOVE_FEATHER_FALL_ACK, "CMSG_MOVE_FEATHER_FALL_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleFeatherFallAck); - /*0x2D0*/ StoreOpcode(CMSG_MOVE_WATER_WALK_ACK, "CMSG_MOVE_WATER_WALK_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveWaterWalkAck); + /*0x2CF*/ StoreOpcode(CMSG_MOVE_FEATHER_FALL_ACK, "CMSG_MOVE_FEATHER_FALL_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMovementFlagChangeToggleAck); + /*0x2D0*/ StoreOpcode(CMSG_MOVE_WATER_WALK_ACK, "CMSG_MOVE_WATER_WALK_ACK", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMovementFlagChangeToggleAck); /*0x2D1*/ StoreOpcode(CMSG_MOVE_NOT_ACTIVE_MOVER, "CMSG_MOVE_NOT_ACTIVE_MOVER", STATUS_LOGGEDIN, PACKET_PROCESS_MOVEMENT, &WorldSession::HandleMoveNotActiveMoverOpcode); /*0x2D2*/ StoreOpcode(SMSG_PLAY_SOUND, "SMSG_PLAY_SOUND", STATUS_NEVER, PACKET_PROCESS_MAX_TYPE, &WorldSession::Handle_ServerSide); /*0x2D3*/ StoreOpcode(CMSG_BATTLEFIELD_STATUS, "CMSG_BATTLEFIELD_STATUS", STATUS_LOGGEDIN, PACKET_PROCESS_MAP, &WorldSession::HandleBattlefieldStatusOpcode); diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 7ad9c5695..06593f646 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -49,7 +49,7 @@ #include "CellImpl.h" #include "MapManager.h" #include "MoveSpline.h" - +#include "MovementPacketSender.h" #include "ZoneScript.h" #include "PlayerAI.h" #include "Anticheat.h" @@ -2163,7 +2163,7 @@ void Aura::HandleAuraWaterWalk(bool apply, bool Real) if (!Real) return; - GetTarget()->SetWaterWalk(apply); + GetTarget()->SetWaterWalking(apply); } void Aura::HandleAuraFeatherFall(bool apply, bool Real) @@ -2833,60 +2833,78 @@ void Aura::HandleModPossess(bool apply, bool Real) if (!Real) return; - Unit* target = GetTarget(); - Unit* caster = GetCaster(); - if (!caster || !target) + Unit* pTarget = GetTarget(); + Unit* pCaster = GetCaster(); + if (!pCaster || !pTarget) return; - caster->ModPossess(target, apply, m_removeMode); - target->AddThreat(caster,target->GetHealth(), false, GetSpellProto()->GetSpellSchoolMask()); +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + // Fix issue with control on old clients if player is afflicted by mind control, + // while he himself is possessing another unit. Client needs to first be told + // he no longer controls the other unit, have time to respond with set active mover, + // and only then to be told he is mind controlled in order to have control disabled. + if (pTarget->GetCharmGuid()) + { + pTarget->CombatStop(true); + AuraRemoveMode removeMode = m_removeMode; + SpellSchoolMask schoolMask = GetSpellProto()->GetSpellSchoolMask(); + pTarget->m_Events.AddLambdaEventAtOffset([pTarget, pCaster, apply, removeMode, schoolMask] + { + pCaster->ModPossess(pTarget, apply, removeMode); + pTarget->AddThreat(pCaster, pTarget->GetHealth(), false, schoolMask); + }, 500); + } + else +#endif + { + pCaster->ModPossess(pTarget, apply, m_removeMode); + pTarget->AddThreat(pCaster, pTarget->GetHealth(), false, GetSpellProto()->GetSpellSchoolMask()); + } if (!apply && GetId() == 24937) // Controlling Steam Tonk { - target->CastSpell(target, 27771, true); // Cast Damaged Tonk - caster->CastSpell(caster, 9179, true); // Cast 3 sec Stun on self - caster->RemoveAurasDueToSpell(24935); // Unroot player + pTarget->CastSpell(pTarget, 27771, true); // Cast Damaged Tonk + pCaster->CastSpell(pCaster, 9179, true); // Cast 3 sec Stun on self + pCaster->RemoveAurasDueToSpell(24935); // Unroot player } } -void Unit::ModPossess(Unit* target, bool apply, AuraRemoveMode m_removeMode) +void Unit::ModPossess(Unit* pTarget, bool apply, AuraRemoveMode m_removeMode) { - // not possess yourself - if (target == this) + // Cannot possess yourself. + if (pTarget == this) return; - Unit* caster = this; - - Player* pPlayerCaster = caster->ToPlayer(); - Player* pPlayerTarget = target->ToPlayer(); - - if (!pPlayerCaster && !pPlayerTarget) + // Only a player can possess units, mobs can charm. + Player* pCaster = ToPlayer(); + if (!pCaster) return; if (apply) { - // Remove dummy auras from spells with EffectSummonPossessed - target->RemoveAurasDueToSpell(126); - target->RemoveAurasDueToSpell(6272); - target->RemoveAurasDueToSpell(11403); + // Remove dummy auras from spells with EffectSummonPossessed. + pTarget->RemoveAurasDueToSpell(126); + pTarget->RemoveAurasDueToSpell(6272); + pTarget->RemoveAurasDueToSpell(11403); - FactionTemplateEntry const* origFactionTemplate = target->getFactionTemplateEntry(); - target->addUnitState(UNIT_STAT_POSSESSED); + FactionTemplateEntry const* origFactionTemplate = pTarget->getFactionTemplateEntry(); - target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); - target->SetCharmerGuid(caster->GetObjectGuid()); - target->setFaction(caster->getFaction()); + pTarget->addUnitState(UNIT_STAT_POSSESSED); + pTarget->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); + pTarget->SetCharmerGuid(pCaster->GetObjectGuid()); + pTarget->SetPossessorGuid(pCaster->GetObjectGuid()); + pTarget->setFaction(pCaster->getFaction()); - // target should became visible at SetView call(if not visible before): - // otherwise client\pPlayerCaster will ignore packets from the target(SetClientControl for example) - pPlayerCaster->GetCamera().SetView(target); + // Target should became visible at SetView call (if not visible before), + // otherwise client will ignore packets from the target (SetClientControl for example). + pCaster->GetCamera().SetView(pTarget); - caster->SetCharm(target); - pPlayerCaster->SetMover(target); + pCaster->SetCharm(pTarget); + pCaster->SetMover(pTarget); - target->CombatStop(true); + pTarget->CombatStop(true); - if (CharmInfo *charmInfo = target->InitCharmInfo(target)) + if (CharmInfo *charmInfo = pTarget->InitCharmInfo(pTarget)) { charmInfo->InitPossessCreateSpells(); charmInfo->SetReactState(REACT_PASSIVE); @@ -2894,90 +2912,89 @@ void Unit::ModPossess(Unit* target, bool apply, AuraRemoveMode m_removeMode) charmInfo->SetOriginalFactionTemplate(origFactionTemplate); } - pPlayerCaster->PossessSpellInitialize(); + pCaster->PossessSpellInitialize(); - if (Creature* pTargetCrea = target->ToCreature()) - if (!pTargetCrea->hasUnitState(UNIT_STAT_CAN_NOT_REACT)) - if (pTargetCrea->AI()->SwitchAiAtControl()) - pTargetCrea->AIM_Initialize(); + if (Creature* pCreature = pTarget->ToCreature()) + if (!pCreature->hasUnitState(UNIT_STAT_CAN_NOT_REACT)) + if (pCreature->AI()->SwitchAiAtControl()) + pCreature->AIM_Initialize(); - if (pPlayerTarget && !pPlayerCaster) - pPlayerTarget->SetControlledBy(caster); - // Les mobs doivent attaquer celui qui est CM. - // On appelle donc 'MoveInLineOfSight' pour les mobs a cote. - target->ScheduleAINotify(0); - target->UpdateControl(); - if (target->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_PENDING_STUNNED | UNIT_STAT_ROOT | UNIT_STAT_PENDING_ROOT)) - target->SetMovement(MOVE_ROOT); - target->StopMoving(); - target->SetWalk(pPlayerCaster->IsWalking()); + // Mobs should attack the target being mind controlled. + // So we call 'MoveInLineOfSight' for nearby mobs. + pTarget->ScheduleAINotify(0); + + pTarget->UpdateControl(); + if (pTarget->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_PENDING_STUNNED | UNIT_STAT_ROOT | UNIT_STAT_PENDING_ROOT)) + pTarget->SetRooted(true); + pTarget->StopMoving(); + pTarget->SetWalk(pCaster->IsWalking()); + + if (pTarget->IsCreature() && pTarget->IsRooted()) + MovementPacketSender::SendMovementFlagChangeToMover(pTarget, MOVEFLAG_ROOT, true); } else { - // Clear threat generated when MC ends - target->RemoveAttackersThreat(caster); + // Clear threat generated when MC ends. + pTarget->RemoveAttackersThreat(pCaster); - // spell is interrupted on channeled aura removal, don't need to interrupt here - //caster->InterruptSpell(CURRENT_CHANNELED_SPELL); + pCaster->SetMover(nullptr); + pCaster->SetCharm(nullptr); + pCaster->UpdateControl(); + pCaster->SetClientControl(pTarget, false); - pPlayerCaster->SetMover(nullptr); - caster->SetCharm(nullptr); - caster->UpdateControl(); + // There is a possibility that target became invisible for client at ResetView call. + // It must be called after movement control unapplying, not before! The reason is same as at aura applying. + pCaster->GetCamera().ResetView(); + pCaster->RemovePetActionBar(); - // there is a possibility that target became invisible for client\pPlayerCaster at ResetView call: - // it must be called after movement control unapplying, not before! the reason is same as at aura applying - pPlayerCaster->GetCamera().ResetView(); - pPlayerCaster->RemovePetActionBar(); - - // on delete only do caster related effects + // On delete only do caster related effects. if (m_removeMode == AURA_REMOVE_BY_DELETE) return; - target->clearUnitState(UNIT_STAT_POSSESSED); + pTarget->clearUnitState(UNIT_STAT_POSSESSED); + pTarget->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); + pTarget->SetCharmerGuid(ObjectGuid()); + pTarget->SetPossessorGuid(ObjectGuid()); - target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); - - target->SetCharmerGuid(ObjectGuid()); - - if (target->GetTypeId() == TYPEID_PLAYER) + if (Player* pPlayerTarget = pTarget->ToPlayer()) { - Player* p_target = ((Player*)target); - p_target->RemoveAI(); - p_target->RelocateToLastClientPosition(); // Movement interpolation - prevent undermap. + pPlayerTarget->RemoveAI(); + pPlayerTarget->RelocateToLastClientPosition(); // Movement interpolation - prevent undermap. } - target->RestoreFaction(); - target->CombatStop(true); - target->UpdateControl(); - target->SetWalk(false); + pTarget->RestoreFaction(); + pTarget->CombatStop(true); + pTarget->UpdateControl(); + pTarget->SetWalk(false); - if (Creature* pCreature = target->ToCreature()) + if (Creature* pCreature = pTarget->ToCreature()) { if (!pCreature->hasUnitState(UNIT_STAT_CAN_NOT_REACT)) { - target->StopMoving(true); + pTarget->StopMoving(true); if (pCreature->AI() && pCreature->AI()->SwitchAiAtControl()) pCreature->AIM_Initialize(); - pCreature->AttackedBy(caster); + pCreature->AttackedBy(pCaster); } } else - target->StopMoving(true); + pTarget->StopMoving(true); // cast mind exhaustion on self when the posess possess ends if the creature // is death knight understudy (razuvious). // todo: if there is a way to know a possess has ended through scriptAI, fix this. - if (target->GetEntry() == 16803) + if (pTarget->GetEntry() == 16803) { - target->CastSpell(target, 29051, true); + pTarget->CastSpell(pTarget, 29051, true); } + + if (pTarget->IsPlayer() && pTarget->IsRooted()) + MovementPacketSender::SendMovementFlagChangeToMover(pTarget, MOVEFLAG_ROOT, true); } - target->SetUnitMovementFlags(MOVEFLAG_NONE); #if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 - if (pPlayerCaster && pPlayerTarget) - pPlayerTarget->SendCreateUpdateToPlayer(pPlayerCaster); + pTarget->SendCreateUpdateToPlayer(pCaster); #endif } @@ -2986,68 +3003,76 @@ void Aura::HandleModPossessPet(bool apply, bool Real) if (!Real) return; - Unit* caster = GetCaster(); - if (!caster || caster->GetTypeId() != TYPEID_PLAYER) + Player* pCaster = ToPlayer(GetCaster()); + if (!pCaster) return; - Unit* target = GetTarget(); - if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->IsPet()) + Unit* pTarget = GetTarget(); + if (!pTarget->IsPet()) return; - Pet* pet = (Pet*)target; - - Player* p_caster = (Player*)caster; - p_caster->ModPossessPet(pet, apply, m_removeMode); + Pet* pPet = (Pet*)pTarget; + pCaster->ModPossessPet(pPet, apply, m_removeMode); } -void Player::ModPossessPet(Pet* pet, bool apply, AuraRemoveMode m_removeMode) +void Player::ModPossessPet(Pet* pPet, bool apply, AuraRemoveMode m_removeMode) { - Player* p_caster = this; - Camera& camera = p_caster->GetCamera(); + Player* pCaster = this; + Camera& camera = pCaster->GetCamera(); if (apply) { - pet->addUnitState(UNIT_STAT_POSSESSED); + pPet->addUnitState(UNIT_STAT_POSSESSED); - // target should became visible at SetView call(if not visible before): - // otherwise client\p_caster will ignore packets from the target(SetClientControl for example) - camera.SetView(pet); + // Target should became visible at SetView call(if not visible before), + // otherwise client will ignore packets from the target(SetClientControl for example). + camera.SetView(pPet); - p_caster->SetCharm(pet); - p_caster->SetMover(pet); + pCaster->SetCharm(pPet); + pCaster->SetMover(pPet); - pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); - pet->SetCharmerGuid(p_caster->GetObjectGuid()); - pet->SetPossesorGuid(p_caster->GetObjectGuid()); + pPet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_POSSESSED); + pPet->SetCharmerGuid(pCaster->GetObjectGuid()); + pPet->SetPossessorGuid(pCaster->GetObjectGuid()); - pet->StopMoving(); - pet->GetMotionMaster()->Clear(false); - pet->GetMotionMaster()->MoveIdle(); - pet->UpdateControl(); - pet->SetWalk(p_caster->IsWalking()); + pPet->StopMoving(); + pPet->GetMotionMaster()->Clear(false); + pPet->GetMotionMaster()->MoveIdle(); + pPet->UpdateControl(); + pPet->SetWalk(pCaster->IsWalking()); - if (CharmInfo* charmInfo = pet->GetCharmInfo()) + if (CharmInfo* charmInfo = pPet->GetCharmInfo()) { charmInfo->SetIsAtStay(false); charmInfo->SetIsReturning(false); charmInfo->SetIsFollowing(false); } + + if (pPet->IsRooted()) + MovementPacketSender::SendMovementFlagChangeToMover(pPet, MOVEFLAG_ROOT, true); } else { - p_caster->SetCharm(nullptr); - p_caster->SetMover(nullptr); + pCaster->SetCharm(nullptr); + pCaster->SetMover(nullptr); - // there is a possibility that target became invisible for client\p_caster at ResetView call: - // it must be called after movement control unapplying, not before! the reason is same as at aura applying + // There is a possibility that target became invisible for client at ResetView call. + // It must be called after movement control unapplying, not before! the reason is same as at aura applying. camera.ResetView(); - pet->UpdateControl(); - pet->SetCharmerGuid(ObjectGuid()); - pet->SetPossesorGuid(ObjectGuid()); + pPet->UpdateControl(); + pPet->SetCharmerGuid(ObjectGuid()); + pPet->SetPossessorGuid(ObjectGuid()); + + if (!pPet->hasUnitState(UNIT_STAT_CAN_NOT_REACT)) + pPet->StopMoving(true); // To avoid moving the wrong unit on server side between cancellation and mover swap // the pet has the controlled state removed in WorldSession::HandleSetActiveMoverOpcode } + +#if SUPPORTED_CLIENT_BUILD <= CLIENT_BUILD_1_9_4 + pPet->SendCreateUpdateToPlayer(pCaster); +#endif } void Aura::HandleModCharm(bool apply, bool Real) @@ -3230,7 +3255,7 @@ void Aura::HandleModCharm(bool apply, bool Real) target->getHostileRefManager().deleteReferences(); } - target->SetUnitMovementFlags(MOVEFLAG_NONE); + //target->SetUnitMovementFlags(MOVEFLAG_NONE); target->StopMoving(); target->GetMotionMaster()->Clear(false); target->GetMotionMaster()->MoveIdle(); @@ -3398,7 +3423,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) if (!inCharge) target->StopMoving(); - target->SetMovement(MOVE_ROOT); + target->SetRooted(true); } else { @@ -3437,7 +3462,7 @@ void Aura::HandleAuraModStun(bool apply, bool Real) target->SetTargetGuid(target->getVictim()->GetObjectGuid()); if (!target->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_PENDING_ROOT)) // prevent allow move if have also root effect - target->SetMovement(MOVE_UNROOT); + target->SetRooted(false); // Wyvern Sting if (GetSpellProto()->IsFitToFamily()) @@ -3636,7 +3661,7 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) if (!target->movespline->Finalized() && !inCharge) target->StopMoving(); - target->SetMovement(MOVE_ROOT); + target->SetRooted(true); } else { @@ -3671,8 +3696,8 @@ void Aura::HandleAuraModRoot(bool apply, bool Real) if (!target->hasUnitState(UNIT_STAT_STUNNED | UNIT_STAT_PENDING_STUNNED)) // prevent allow move if have also stun effect { - target->SetMovement(MOVE_UNROOT); - target->SetUnitMovementFlags(MOVEFLAG_NONE); + target->SetRooted(false); + //target->SetUnitMovementFlags(MOVEFLAG_NONE); } } } @@ -3795,7 +3820,7 @@ void Aura::HandleAuraModIncreaseSpeed(bool apply, bool Real) if (Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(GetSpellProto()->Id, SPELLMOD_SPEED, m_modifier.m_amount); - GetTarget()->UpdateSpeed(MOVE_RUN, true); + GetTarget()->UpdateSpeed(MOVE_RUN, false); } void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) @@ -3804,7 +3829,7 @@ void Aura::HandleAuraModIncreaseMountedSpeed(bool /*apply*/, bool Real) if (!Real) return; - GetTarget()->UpdateSpeed(MOVE_RUN, true); + GetTarget()->UpdateSpeed(MOVE_RUN, false); } void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) @@ -3813,7 +3838,7 @@ void Aura::HandleAuraModIncreaseSwimSpeed(bool /*apply*/, bool Real) if (!Real) return; - GetTarget()->UpdateSpeed(MOVE_SWIM, true); + GetTarget()->UpdateSpeed(MOVE_SWIM, false); } void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) @@ -3828,8 +3853,8 @@ void Aura::HandleAuraModDecreaseSpeed(bool apply, bool Real) Unit* target = GetTarget(); - target->UpdateSpeed(MOVE_RUN, true); - target->UpdateSpeed(MOVE_SWIM, true); + target->UpdateSpeed(MOVE_RUN, false); + target->UpdateSpeed(MOVE_SWIM, false); } void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) @@ -3840,8 +3865,8 @@ void Aura::HandleAuraModUseNormalSpeed(bool /*apply*/, bool Real) Unit *target = GetTarget(); - target->UpdateSpeed(MOVE_RUN, true); - target->UpdateSpeed(MOVE_SWIM, true); + target->UpdateSpeed(MOVE_RUN, false); + target->UpdateSpeed(MOVE_SWIM, false); } /*********************************************************/ diff --git a/src/game/WorldSession.h b/src/game/WorldSession.h index 22f4b4e27..6b8bc3fd6 100644 --- a/src/game/WorldSession.h +++ b/src/game/WorldSession.h @@ -556,40 +556,31 @@ class MANGOS_DLL_SPEC WorldSession void HandlePlayerLoginOpcode(WorldPacket& recvPacket); void HandleCharEnum(QueryResult * result); void HandlePlayerLogin(LoginQueryHolder * holder); - - // played time void HandlePlayedTime(WorldPacket& recvPacket); - // new - void HandleMoveUnRootAck(WorldPacket& recvPacket); + // Movement void HandleMoveRootAck(WorldPacket& recvPacket); - - // new inspect - void HandleInspectOpcode(WorldPacket& recvPacket); - - // new party stats - void HandleInspectHonorStatsOpcode(WorldPacket& recvPacket); - - void HandleMoveWaterWalkAck(WorldPacket& recvPacket); - void HandleFeatherFallAck(WorldPacket &recv_data); - - void HandleMoveHoverAck( WorldPacket & recv_data ); - + void HandleMoveKnockBackAck(WorldPacket& recvPacket); + void HandleMoveTeleportAckOpcode(WorldPacket& recvPacket); + void HandleForceSpeedChangeAckOpcodes(WorldPacket & recv_data); + void HandleMoveWorldportAckOpcode(WorldPacket& recvPacket); + void HandleMoveWorldportAckOpcode(); // for server-side calls + void HandleMovementOpcodes(WorldPacket& recvPacket); + void HandleSetActiveMoverOpcode(WorldPacket &recv_data); + void HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data); + void HandleMoveTimeSkippedOpcode(WorldPacket &recv_data); + void HandleMovementFlagChangeToggleAck(WorldPacket& recvData); + void HandleMoveSplineDoneOpcode(WorldPacket& recvPacket); + void HandleMoveSetRawPosition(WorldPacket& recv_data); + void HandleWorldTeleportOpcode(WorldPacket& recv_data); void HandleMountSpecialAnimOpcode(WorldPacket &recvdata); - // character view + void HandleInspectOpcode(WorldPacket& recvPacket); + void HandleInspectHonorStatsOpcode(WorldPacket& recvPacket); void HandleShowingHelmOpcode(WorldPacket& recv_data); void HandleShowingCloakOpcode(WorldPacket& recv_data); - - // repair void HandleRepairItemOpcode(WorldPacket& recvPacket); - // Knockback - void HandleMoveKnockBackAck(WorldPacket& recvPacket); - - void HandleMoveTeleportAckOpcode(WorldPacket& recvPacket); - void HandleForceSpeedChangeAckOpcodes( WorldPacket & recv_data ); - void HandlePingOpcode(WorldPacket& recvPacket); void HandleAuthSessionOpcode(WorldPacket& recvPacket); void HandleRepopRequestOpcode(WorldPacket& recvPacket); @@ -609,11 +600,9 @@ class MANGOS_DLL_SPEC WorldSession void HandleGMTicketDeleteTicketOpcode(WorldPacket& recvPacket); void HandleGMTicketUpdateTextOpcode(WorldPacket& recvPacket); - void HandleGMSurveySubmitOpcode(WorldPacket& recvPacket); void HandleTogglePvP(WorldPacket& recvPacket); - void HandleZoneUpdateOpcode(WorldPacket& recvPacket); void HandleSetTargetOpcode(WorldPacket& recvPacket); void HandleSetSelectionOpcode(WorldPacket& recvPacket); @@ -631,7 +620,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleItemNameQueryOpcode(WorldPacket& recvPacket); void HandleAreaTriggerOpcode(WorldPacket& recvPacket); - void HandleSetFactionAtWarOpcode( WorldPacket & recv_data ); void HandleSetWatchedFactionOpcode(WorldPacket & recv_data); void HandleSetFactionInactiveOpcode(WorldPacket & recv_data); @@ -646,23 +634,11 @@ class MANGOS_DLL_SPEC WorldSession void HandleMeetingStoneInfoOpcode(WorldPacket& recPacket); void HandleNameQueryOpcode(WorldPacket& recvPacket); - void HandleQueryTimeOpcode(WorldPacket& recvPacket); - void HandleCreatureQueryOpcode(WorldPacket& recvPacket); - void HandleGameObjectQueryOpcode(WorldPacket& recvPacket); - void HandleMoveWorldportAckOpcode(WorldPacket& recvPacket); - void HandleMoveWorldportAckOpcode(); // for server-side calls - - void HandleMovementOpcodes(WorldPacket& recvPacket); - void HandleSetActiveMoverOpcode(WorldPacket &recv_data); - void HandleMoveNotActiveMoverOpcode(WorldPacket &recv_data); - void HandleMoveTimeSkippedOpcode(WorldPacket &recv_data); - void HandleRequestRaidInfoOpcode( WorldPacket & recv_data ); - void HandleGroupInviteOpcode(WorldPacket& recvPacket); void HandleGroupAcceptOpcode(WorldPacket& recvPacket); void HandleGroupDeclineOpcode(WorldPacket& recvPacket); @@ -715,7 +691,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleTaxiQueryAvailableNodes(WorldPacket& recvPacket); void HandleActivateTaxiOpcode(WorldPacket& recvPacket); void HandleActivateTaxiExpressOpcode(WorldPacket& recvPacket); - void HandleMoveSplineDoneOpcode(WorldPacket& recvPacket); void HandleTabardVendorActivateOpcode(WorldPacket& recvPacket); void HandleBankerActivateOpcode(WorldPacket& recvPacket); @@ -801,7 +776,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleCancelAuraOpcode(WorldPacket& recvPacket); void HandleCancelGrowthAuraOpcode(WorldPacket& recvPacket); void HandleCancelAutoRepeatSpellOpcode(WorldPacket& recvPacket); - + void HandleSetActionBarTogglesOpcode(WorldPacket& recv_data); void HandleLearnTalentOpcode(WorldPacket& recvPacket); void HandleTalentWipeConfirmOpcode(WorldPacket& recvPacket); void HandleUnlearnSkillOpcode(WorldPacket& recvPacket); @@ -875,8 +850,7 @@ class MANGOS_DLL_SPEC WorldSession void HandlePetUnlearnOpcode( WorldPacket& recvPacket ); void HandlePetSpellAutocastOpcode( WorldPacket& recvPacket ); void HandlePetCastSpellOpcode( WorldPacket& recvPacket ); - - void HandleSetActionBarTogglesOpcode(WorldPacket& recv_data); + void HandleRequestPetInfoOpcode(WorldPacket& recv_data); void HandleCharRenameOpcode(WorldPacket& recv_data); static void HandleChangePlayerNameOpcodeCallBack(QueryResult *result, uint32 accountId, std::string newname); @@ -893,8 +867,6 @@ class MANGOS_DLL_SPEC WorldSession void HandleLeaveBattlefieldOpcode( WorldPacket &recv_data ); void HandleWardenDataOpcode(WorldPacket& recv_data); - void HandleWorldTeleportOpcode(WorldPacket& recv_data); - void HandleMoveSetRawPosition(WorldPacket& recv_data); void HandleMinimapPingOpcode(WorldPacket& recv_data); void HandleRandomRollOpcode(WorldPacket& recv_data); void HandleFarSightOpcode(WorldPacket& recv_data); @@ -904,7 +876,7 @@ class MANGOS_DLL_SPEC WorldSession void HandleAreaSpiritHealerQueryOpcode(WorldPacket& recv_data); void HandleAreaSpiritHealerQueueOpcode(WorldPacket& recv_data); void HandleSelfResOpcode(WorldPacket& recv_data); - void HandleRequestPetInfoOpcode(WorldPacket& recv_data); + private: // private trade methods void moveItems(Item* myItems[], Item* hisItems[]); diff --git a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_grobbulus.cpp b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_grobbulus.cpp index ad33b6723..fc388c91a 100644 --- a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_grobbulus.cpp +++ b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_grobbulus.cpp @@ -242,7 +242,7 @@ struct grob_poison_cloud : public ScriptedAI { m_creature->addUnitState(UNIT_STAT_ROOT); m_creature->StopMoving(); - m_creature->SetMovement(MOVE_ROOT); + m_creature->SetRooted(true); untilDespawn = 70000; } diff --git a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_heigan.cpp b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_heigan.cpp index 316f19976..5ca603463 100644 --- a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_heigan.cpp +++ b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_heigan.cpp @@ -509,7 +509,7 @@ struct mob_plague_cloudAI : public ScriptedAI { m_creature->addUnitState(UNIT_STAT_ROOT); m_creature->StopMoving(); - m_creature->SetMovement(MOVE_ROOT); + m_creature->SetRooted(true); } void AttackStart(Unit*) { } diff --git a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp index 78aca5d9c..4cb6bdec1 100644 --- a/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp +++ b/src/scripts/eastern_kingdoms/eastern_plaguelands/naxxramas/boss_loatheb.cpp @@ -155,7 +155,7 @@ struct mob_eyeStalkAI : public ScriptedAI { m_creature->addUnitState(UNIT_STAT_ROOT); m_creature->StopMoving(); - m_creature->SetMovement(MOVE_ROOT); + m_creature->SetRooted(true); m_creature->SetNoCallAssistance(true); } diff --git a/src/scripts/eastern_kingdoms/stormwind_city/quest_stormwind_rendezvous.cpp b/src/scripts/eastern_kingdoms/stormwind_city/quest_stormwind_rendezvous.cpp index ac860586e..c1611dae6 100644 --- a/src/scripts/eastern_kingdoms/stormwind_city/quest_stormwind_rendezvous.cpp +++ b/src/scripts/eastern_kingdoms/stormwind_city/quest_stormwind_rendezvous.cpp @@ -288,7 +288,7 @@ void npc_reginald_windsorAI::UpdateAI(const uint32 uiDiff) if (Creature* pMercutio = m_creature->FindNearestCreature(NPC_MERCUTIO, 10.0f)) { - pMercutio->SetSpeedRate(MOVE_WALK, 2.5f, true); + pMercutio->SetSpeedRate(MOVE_WALK, 2.5f); pMercutio->setFaction(m_creature->getFaction()); pMercutio->GetMotionMaster()->MovePoint(0, -9148.395508f, 371.322174f, 90.543655f); pMercutio->ForcedDespawn(12000); @@ -298,7 +298,7 @@ void npc_reginald_windsorAI::UpdateAI(const uint32 uiDiff) } m_creature->SetWalk(true); - m_creature->SetSpeedRate(MOVE_WALK, 1.0f, true); + m_creature->SetSpeedRate(MOVE_WALK, 1.0f); GreetPlayer = true; } } @@ -867,7 +867,7 @@ void npc_squire_roweAI::UpdateAI(const uint32 uiDiff) switch (m_uiStep) { case 0: - m_creature->SetSpeedRate(MOVE_RUN, 1.1f, true); + m_creature->SetSpeedRate(MOVE_RUN, 1.1f); m_creature->GetMotionMaster()->MovePoint(1, RoweDeplacement[0].x, RoweDeplacement[0].y, RoweDeplacement[0].z); m_uiTimer = 1000; ++m_uiStep; @@ -897,7 +897,7 @@ void npc_squire_roweAI::UpdateAI(const uint32 uiDiff) m_bWindsorUp = true; pWindsor->Mount(MOUNT_WINDSOR); pWindsor->SetWalk(false); - pWindsor->SetSpeedRate(MOVE_RUN, 1.0f, true); + pWindsor->SetSpeedRate(MOVE_RUN, 1.0f); pWindsor->GetMotionMaster()->MovePoint(0, WindsorDeplacement[0].x, WindsorDeplacement[0].y, WindsorDeplacement[0].z, MOVE_PATHFINDING); pWindsor->SetRespawnDelay(100000000); pWindsor->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); @@ -1010,7 +1010,7 @@ bool AreaTrigger_at_stormwind_gates(Player* pPlayer, AreaTriggerEntry const* /*p pWindsor->Mount(MOUNT_WINDSOR); pWindsor->SetWalk(false); - pWindsor->SetSpeedRate(MOVE_RUN, 1.0f, true); + pWindsor->SetSpeedRate(MOVE_RUN, 1.0f); pWindsor->GetMotionMaster()->MovePoint(0, WindsorDeplacement[0].x, WindsorDeplacement[0].y, WindsorDeplacement[0].z, MOVE_PATHFINDING); pWindsor->SetRespawnDelay(100000000); pWindsor->RemoveFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); diff --git a/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/boss_herod.cpp b/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/boss_herod.cpp index 462051d77..321a6a359 100644 --- a/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/boss_herod.cpp +++ b/src/scripts/eastern_kingdoms/tirisfal_glades/scarlet_monastery/boss_herod.cpp @@ -278,7 +278,7 @@ struct mob_scarlet_traineeAI : ScriptedAI { if (Start_Timer <= diff) { - m_creature->SetSpeedRate(MOVE_WALK, 2.20f, true); + m_creature->SetSpeedRate(MOVE_WALK, 2.20f); if (group1) m_creature->GetMotionMaster()->MovePoint(1, 1946.433594f, -435.955109f, 16.367277f); diff --git a/src/scripts/kalimdor/dustwallow_marsh/onyxias_lair/boss_onyxia.cpp b/src/scripts/kalimdor/dustwallow_marsh/onyxias_lair/boss_onyxia.cpp index 116e79e8a..ab00909df 100644 --- a/src/scripts/kalimdor/dustwallow_marsh/onyxias_lair/boss_onyxia.cpp +++ b/src/scripts/kalimdor/dustwallow_marsh/onyxias_lair/boss_onyxia.cpp @@ -198,7 +198,7 @@ struct boss_onyxiaAI : public ScriptedAI m_pInstance->SetData(DATA_ONYXIA_EVENT, NOT_STARTED); SetCombatMovement(true); - m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED, true); + m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED); m_creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, 15.0f); m_creature->SetFloatValue(UNIT_FIELD_COMBATREACH, 16.0f); @@ -460,7 +460,7 @@ struct boss_onyxiaAI : public ScriptedAI { if (m_uiDeepBreathTimer <= uiDiff) { - m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_BREATH_SPEED, true); + m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_BREATH_SPEED); m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ, MOVE_PATHFINDING | MOVE_FLY_MODE); // heat up egg pit during Deep Breath m_creature->CastSpell(m_creature, SPELL_HEATED_GROUND_EAST, true); @@ -550,7 +550,7 @@ struct boss_onyxiaAI : public ScriptedAI } m_pPointData = GetMoveData(); - m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED, true); + m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED); m_creature->GetMotionMaster()->MovePoint(m_pPointData->uiLocId, m_pPointData->fX, m_pPointData->fY, m_pPointData->fZ, MOVE_PATHFINDING | MOVE_FLY_MODE); return false; } @@ -628,7 +628,7 @@ struct boss_onyxiaAI : public ScriptedAI m_creature->GetMotionMaster()->Clear(false); m_creature->GetMotionMaster()->MoveIdle(); - m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED, true); + m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED); m_creature->GetMotionMaster()->MovePoint(DEPART_FLIGHT, -57.750641f, -215.610077f, -85.094727f, MOVE_PATHFINDING); m_uiTransTimer = 60000; // handled by MovementInform } @@ -666,7 +666,7 @@ struct boss_onyxiaAI : public ScriptedAI { DoResetThreat(); DoScriptText(SAY_PHASE_3_TRANS, m_creature); - m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED, true); + m_creature->SetSpeedRate(MOVE_RUN, ONYXIA_NORMAL_SPEED); m_creature->InterruptNonMeleeSpells(false); if (m_creature->GetPositionX() < -40.0f) diff --git a/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp b/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp index 0d9f87fad..5524d6ff5 100644 --- a/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp +++ b/src/scripts/kalimdor/feralas/dire_maul/instance_dire_maul.cpp @@ -776,7 +776,7 @@ struct npc_residual_montruosityAI : public ScriptedAI else if ((closestbefore < 32.0f) && (closestbehind > 36.0f)) newspeed = 1.00f; } - m_creature->SetSpeedRate(MOVE_WALK, newspeed, true); + m_creature->SetSpeedRate(MOVE_WALK, newspeed); } void UpdateAI(const uint32 uiDiff) diff --git a/src/scripts/kalimdor/moonglade/moonglade.cpp b/src/scripts/kalimdor/moonglade/moonglade.cpp index 6710a54cf..89c47918b 100644 --- a/src/scripts/kalimdor/moonglade/moonglade.cpp +++ b/src/scripts/kalimdor/moonglade/moonglade.cpp @@ -504,7 +504,7 @@ struct npc_keeper_remulosAI : public npc_escortAI case 0: if (Player* pPlayer = GetPlayerForEscort()) DoScriptText(SAY_REMULOS_INTRO_1, m_creature, pPlayer); - m_creature->SetSpeedRate(MOVE_WALK, 2.2f, true); //du cout faudrait ptetre aussi revoir la vitesse de course. + m_creature->SetSpeedRate(MOVE_WALK, 2.2f); //du cout faudrait ptetre aussi revoir la vitesse de course. m_creature->SetWalk(true); break; case 1: diff --git a/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_ossirian.cpp b/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_ossirian.cpp index 2fd8404de..59c3b26e9 100644 --- a/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_ossirian.cpp +++ b/src/scripts/kalimdor/silithus/ruins_of_ahnqiraj/boss_ossirian.cpp @@ -100,8 +100,8 @@ struct boss_ossirianAI : public ScriptedAI DoCast(m_creature, SPELL_STRENGTH_OF_OSSIRIAN); m_uiSpeed_Timer = 10000; - m_creature->SetSpeedRate(MOVE_RUN, 1.0f, true); - m_creature->SetSpeedRate(MOVE_WALK, 1.0f, true); + m_creature->SetSpeedRate(MOVE_RUN, 1.0f); + m_creature->SetSpeedRate(MOVE_WALK, 1.0f); m_uiCurseOfTongues_Timer = 30000; m_uiStrengthOfOssirian_Timer = 25000; @@ -237,7 +237,7 @@ struct boss_ossirianAI : public ScriptedAI if (m_uiSpeed_Timer >= uiDiff) { m_uiSpeed_Timer -= uiDiff; - m_creature->SetSpeedRate(MOVE_RUN, (2.0f - m_uiSpeed_Timer*1.0f/10000), true); + m_creature->SetSpeedRate(MOVE_RUN, (2.0f - m_uiSpeed_Timer*1.0f/10000)); } if (!m_bIsEnraged && m_uiStrengthOfOssirian_Timer < uiDiff) diff --git a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp index f9a3f9212..25b77ae8d 100644 --- a/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp +++ b/src/scripts/kalimdor/silithus/temple_of_ahnqiraj/boss_cthun.cpp @@ -363,7 +363,7 @@ struct cthunTentacle : public ScriptedAI { m_creature->addUnitState(UNIT_STAT_ROOT); m_creature->StopMoving(); - m_creature->SetMovement(MOVE_ROOT); + m_creature->SetRooted(true); m_creature->SetInCombatWithZone(); } @@ -394,7 +394,7 @@ struct cthunTentacle : public ScriptedAI // retargetting another top-threat target if current leaves melee range m_creature->addUnitState(UNIT_STAT_ROOT); m_creature->StopMoving(); - m_creature->SetMovement(MOVE_ROOT); + m_creature->SetRooted(true); return true; }