aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_go.cpp90
-rw-r--r--src/server/scripts/Commands/cs_group.cpp9
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp87
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp22
-rw-r--r--src/server/scripts/Commands/cs_tele.cpp35
5 files changed, 74 insertions, 169 deletions
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index 7e0c3624cd5..3be61113c6d 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -27,7 +27,6 @@ EndScriptData */
#include "DatabaseEnv.h"
#include "Language.h"
#include "MapManager.h"
-#include "MotionMaster.h"
#include "ObjectMgr.h"
#include "PhasingHandler.h"
#include "Player.h"
@@ -152,13 +151,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(mapId, x, y, z, o);
return true;
@@ -197,13 +192,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(gy->Loc);
return true;
@@ -239,13 +230,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
Map* map = sMapMgr->CreateBaseMap(mapId);
float z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
@@ -289,13 +276,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(goData->spawnPoint);
return true;
@@ -352,13 +335,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
Map* map = sMapMgr->CreateBaseMap(mapId);
z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
@@ -400,13 +379,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(node->ContinentID, node->Pos.X, node->Pos.Y, node->Pos.Z, player->GetOrientation());
return true;
@@ -445,13 +420,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(at->ContinentID, at->Pos.X, at->Pos.Y, at->Pos.Z, player->GetOrientation());
return true;
@@ -519,13 +490,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
float z = std::max(map->GetStaticHeight(PhasingHandler::GetEmptyPhaseShift(), x, y, MAX_HEIGHT), map->GetWaterLevel(PhasingHandler::GetEmptyPhaseShift(), x, y));
@@ -580,13 +547,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(mapId, x, y, z, ort);
return true;
@@ -614,13 +577,12 @@ public:
}
Player* player = handler->GetSession()->GetPlayer();
+
+ // stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
ticket->TeleportTo(player);
return true;
@@ -658,13 +620,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(player->GetMapId(), x, y, z, o);
return true;
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index 67358c03243..2f5c92a0082 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -24,7 +24,6 @@
#include "Language.h"
#include "LFG.h"
#include "Map.h"
-#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "PhasingHandler.h"
@@ -144,13 +143,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
// before GM
float x, y, z;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index ffc895f159a..db5c9be254a 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -20,12 +20,10 @@
#include "ArenaTeamMgr.h"
#include "CellImpl.h"
#include "CharacterCache.h"
-#include "ChaseMovementGenerator.h"
#include "Chat.h"
#include "DatabaseEnv.h"
#include "DB2Stores.h"
#include "DisableMgr.h"
-#include "FollowMovementGenerator.h"
#include "GridNotifiers.h"
#include "Group.h"
#include "GroupMgr.h"
@@ -41,7 +39,6 @@
#include "MMapFactory.h"
#include "MotionMaster.h"
#include "MovementDefines.h"
-#include "MovementGenerator.h"
#include "ObjectAccessor.h"
#include "ObjectMgr.h"
#include "Opcodes.h"
@@ -459,13 +456,9 @@ public:
// stop flight if need
if (_player->IsInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ _player->FinishTaxiFlight();
else
- _player->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
// to point to see at target with same orientation
float x, y, z;
@@ -494,13 +487,9 @@ public:
// stop flight if need
if (_player->IsInFlight())
- {
- _player->GetMotionMaster()->MovementExpired();
- _player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ _player->FinishTaxiFlight();
else
- _player->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
_player->TeleportTo(map, x, y, z, _player->GetOrientation());
}
@@ -590,14 +579,10 @@ public:
ChatHandler(target->GetSession()).PSendSysMessage(LANG_SUMMONED_BY, handler->playerLink(_player->GetName()).c_str());
// stop flight if need
- if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ if (_player->IsInFlight())
+ _player->FinishTaxiFlight();
else
- target->SaveRecallPosition();
+ _player->SaveRecallPosition(); // save only in non-flight case
// before GM
float x, y, z;
@@ -899,12 +884,7 @@ public:
return false;
}
- // stop flight if need
- if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
+ target->FinishTaxiFlight();
target->Recall();
return true;
@@ -2210,20 +2190,19 @@ public:
handler->PSendSysMessage(LANG_MOVEGENS_LIST, (unit->GetTypeId() == TYPEID_PLAYER ? "Player" : "Creature"), unit->GetGUID().ToString().c_str());
- MotionMaster* motionMaster = unit->GetMotionMaster();
+ if (unit->GetMotionMaster()->Empty())
+ {
+ handler->SendSysMessage("Empty");
+ return true;
+ }
+
float x, y, z;
- motionMaster->GetDestination(x, y, z);
+ unit->GetMotionMaster()->GetDestination(x, y, z);
- for (uint8 itr = 0; itr < MAX_MOTION_SLOT; ++itr)
+ std::vector<MovementGeneratorInformation> list = unit->GetMotionMaster()->GetMovementGeneratorsInformation();
+ for (MovementGeneratorInformation info : list)
{
- MovementGenerator* movementGenerator = motionMaster->GetMotionSlot(MovementSlot(itr));
- if (!movementGenerator)
- {
- handler->SendSysMessage("Empty");
- continue;
- }
-
- switch (movementGenerator->GetMovementGeneratorType())
+ switch (info.Type)
{
case IDLE_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_IDLE);
@@ -2238,45 +2217,33 @@ public:
handler->SendSysMessage(LANG_MOVEGENS_CONFUSED);
break;
case CHASE_MOTION_TYPE:
- {
- Unit* target = static_cast<ChaseMovementGenerator const*>(movementGenerator)->GetTarget();
-
- if (!target)
+ if (info.TargetGUID.IsEmpty())
handler->SendSysMessage(LANG_MOVEGENS_CHASE_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, target->GetName().c_str(), target->GetGUID().ToString().c_str());
+ else if (info.TargetGUID.IsPlayer())
+ handler->PSendSysMessage(LANG_MOVEGENS_CHASE_PLAYER, info.TargetName.c_str(), info.TargetGUID.ToString().c_str());
else
- handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, target->GetName().c_str(), target->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_MOVEGENS_CHASE_CREATURE, info.TargetName.c_str(), info.TargetGUID.ToString().c_str());
break;
- }
case FOLLOW_MOTION_TYPE:
- {
- Unit* target = static_cast<FollowMovementGenerator const*>(movementGenerator)->GetTarget();
-
- if (!target)
+ if (info.TargetGUID.IsEmpty())
handler->SendSysMessage(LANG_MOVEGENS_FOLLOW_NULL);
- else if (target->GetTypeId() == TYPEID_PLAYER)
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, target->GetName().c_str(), target->GetGUID().ToString().c_str());
+ else if (info.TargetGUID.IsPlayer())
+ handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_PLAYER, info.TargetName.c_str(), info.TargetGUID.ToString().c_str());
else
- handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, target->GetName().c_str(), target->GetGUID().ToString().c_str());
+ handler->PSendSysMessage(LANG_MOVEGENS_FOLLOW_CREATURE, info.TargetName.c_str(), info.TargetGUID.ToString().c_str());
break;
- }
case HOME_MOTION_TYPE:
- {
if (unit->GetTypeId() == TYPEID_UNIT)
handler->PSendSysMessage(LANG_MOVEGENS_HOME_CREATURE, x, y, z);
else
handler->SendSysMessage(LANG_MOVEGENS_HOME_PLAYER);
break;
- }
case FLIGHT_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_FLIGHT);
break;
case POINT_MOTION_TYPE:
- {
handler->PSendSysMessage(LANG_MOVEGENS_POINT, x, y, z);
break;
- }
case FLEEING_MOTION_TYPE:
handler->SendSysMessage(LANG_MOVEGENS_FEAR);
break;
@@ -2287,7 +2254,7 @@ public:
handler->SendSysMessage(LANG_MOVEGENS_EFFECT);
break;
default:
- handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, movementGenerator->GetMovementGeneratorType());
+ handler->PSendSysMessage(LANG_MOVEGENS_UNKNOWN, info.Type);
break;
}
}
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index c5ec5bd5f75..c6b0805de0f 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -1370,7 +1370,7 @@ public:
return true;
}
- //npc unfollow handling
+ // npc unfollow handling
static bool HandleNpcUnFollowCommand(ChatHandler* handler, char const* /*args*/)
{
Player* player = handler->GetSession()->GetPlayer();
@@ -1383,26 +1383,24 @@ public:
return false;
}
- if (/*creature->GetMotionMaster()->empty() ||*/
- creature->GetMotionMaster()->GetCurrentMovementGeneratorType() != FOLLOW_MOTION_TYPE)
+ MovementGenerator* movement = creature->GetMotionMaster()->GetMovementGenerator([player](MovementGenerator const* a) -> bool
{
- handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
- handler->SetSentErrorMessage(true);
+ if (a->GetMovementGeneratorType() == FOLLOW_MOTION_TYPE)
+ {
+ FollowMovementGenerator const* followMovement = dynamic_cast<FollowMovementGenerator const*>(a);
+ return followMovement && followMovement->GetTarget() == player;
+ }
return false;
- }
-
- FollowMovementGenerator const* mgen = static_cast<FollowMovementGenerator const*>((creature->GetMotionMaster()->top()));
+ });
- if (mgen->GetTarget() != player)
+ if (!movement)
{
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU, creature->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
- // reset movement
- creature->GetMotionMaster()->MovementExpired(true);
-
+ creature->GetMotionMaster()->Remove(movement);
handler->PSendSysMessage(LANG_CREATURE_NOT_FOLLOW_YOU_NOW, creature->GetName().c_str());
return true;
}
diff --git a/src/server/scripts/Commands/cs_tele.cpp b/src/server/scripts/Commands/cs_tele.cpp
index 93b55b5d1ef..dc1ac20ac86 100644
--- a/src/server/scripts/Commands/cs_tele.cpp
+++ b/src/server/scripts/Commands/cs_tele.cpp
@@ -29,7 +29,6 @@ EndScriptData */
#include "Group.h"
#include "Language.h"
#include "MapManager.h"
-#include "MotionMaster.h"
#include "ObjectMgr.h"
#include "PhasingHandler.h"
#include "Player.h"
@@ -186,13 +185,9 @@ public:
// stop flight if need
if (target->IsInFlight())
- {
- target->GetMotionMaster()->MovementExpired();
- target->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ target->FinishTaxiFlight();
else
- target->SaveRecallPosition();
+ target->SaveRecallPosition(); // save only in non-flight case
target->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
@@ -284,13 +279,9 @@ public:
// stop flight if need
if (player->IsInFlight())
- {
- player->GetMotionMaster()->MovementExpired();
- player->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ player->FinishTaxiFlight();
else
- player->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
}
@@ -303,7 +294,7 @@ public:
if (!*args)
return false;
- Player* me = handler->GetSession()->GetPlayer();
+ Player* player = handler->GetSession()->GetPlayer();
// id, or string, or [name] Shift-click form |color|Htele:id|h[name]|h|r
GameTele const* tele = handler->extractGameTeleFromLink((char*)args);
@@ -314,7 +305,7 @@ public:
return false;
}
- if (me->IsInCombat() && !handler->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_TELE_NAME))
+ if (player->IsInCombat() && !handler->GetSession()->HasPermission(rbac::RBAC_PERM_COMMAND_TELE_NAME))
{
handler->SendSysMessage(LANG_YOU_IN_COMBAT);
handler->SetSentErrorMessage(true);
@@ -322,7 +313,7 @@ public:
}
MapEntry const* map = sMapStore.LookupEntry(tele->mapId);
- if (!map || (map->IsBattlegroundOrArena() && (me->GetMapId() != tele->mapId || !me->IsGameMaster())))
+ if (!map || (map->IsBattlegroundOrArena() && (player->GetMapId() != tele->mapId || !player->IsGameMaster())))
{
handler->SendSysMessage(LANG_CANNOT_TELE_TO_BG);
handler->SetSentErrorMessage(true);
@@ -330,16 +321,12 @@ public:
}
// stop flight if need
- if (me->IsInFlight())
- {
- me->GetMotionMaster()->MovementExpired();
- me->CleanupAfterTaxiFlight();
- }
- // save only in non-flight case
+ if (player->IsInFlight())
+ player->FinishTaxiFlight();
else
- me->SaveRecallPosition();
+ player->SaveRecallPosition(); // save only in non-flight case
- me->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
+ player->TeleportTo(tele->mapId, tele->position_x, tele->position_y, tele->position_z, tele->orientation);
return true;
}
};