Core/Movement: MotionMaster reimplementation
Port From (https://github.com/TrinityCore/TrinityCore/commit/426f9f2f92b26fbb68e7cda9290ccbd586c6af4e)
This commit is contained in:
@@ -97,13 +97,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -137,13 +133,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
@@ -179,13 +171,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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 = Global.MapMgr.CreateBaseMap(mapId);
|
||||
float z = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));
|
||||
@@ -227,13 +215,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
@@ -287,13 +271,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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 = Global.MapMgr.CreateBaseMap(mapId);
|
||||
z = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));
|
||||
@@ -333,13 +313,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
@@ -372,13 +348,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
@@ -439,13 +411,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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 = Math.Max(map.GetStaticHeight(PhasingHandler.EmptyPhaseShift, x, y, MapConst.MaxHeight), map.GetWaterLevel(PhasingHandler.EmptyPhaseShift, x, y));
|
||||
|
||||
@@ -501,13 +469,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
@@ -548,13 +512,12 @@ namespace Game.Chat.Commands
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -592,13 +555,9 @@ namespace Game.Chat.Commands
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -109,13 +109,9 @@ namespace Game.Chat
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -354,13 +354,9 @@ namespace Game.Chat
|
||||
|
||||
// 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;
|
||||
@@ -387,13 +383,9 @@ namespace Game.Chat
|
||||
|
||||
// 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
|
||||
|
||||
loc.SetOrientation(_player.GetOrientation());
|
||||
_player.TeleportTo(loc);
|
||||
@@ -1216,20 +1208,19 @@ namespace Game.Chat
|
||||
|
||||
handler.SendSysMessage(CypherStrings.MovegensList, (unit.IsTypeId(TypeId.Player) ? "Player" : "Creature"), unit.GetGUID().ToString());
|
||||
|
||||
MotionMaster motionMaster = unit.GetMotionMaster();
|
||||
float x, y, z;
|
||||
motionMaster.GetDestination(out x, out y, out z);
|
||||
|
||||
for (byte i = 0; i < (int)MovementSlot.Max; ++i)
|
||||
if (unit.GetMotionMaster().Empty())
|
||||
{
|
||||
IMovementGenerator movementGenerator = motionMaster.GetMotionSlot(i);
|
||||
if (movementGenerator == null)
|
||||
{
|
||||
handler.SendSysMessage("Empty");
|
||||
continue;
|
||||
}
|
||||
handler.SendSysMessage("Empty");
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (movementGenerator.GetMovementGeneratorType())
|
||||
float x, y, z;
|
||||
unit.GetMotionMaster().GetDestination(out x, out y, out z);
|
||||
|
||||
var list = unit.GetMotionMaster().GetMovementGeneratorsInformation();
|
||||
foreach (MovementGeneratorInformation info in list)
|
||||
{
|
||||
switch (info.Type)
|
||||
{
|
||||
case MovementGeneratorType.Idle:
|
||||
handler.SendSysMessage(CypherStrings.MovegensIdle);
|
||||
@@ -1244,45 +1235,33 @@ namespace Game.Chat
|
||||
handler.SendSysMessage(CypherStrings.MovegensConfused);
|
||||
break;
|
||||
case MovementGeneratorType.Chase:
|
||||
{
|
||||
Unit target = ((ChaseMovementGenerator)movementGenerator).GetTarget();
|
||||
|
||||
if (!target)
|
||||
handler.SendSysMessage(CypherStrings.MovegensChaseNull);
|
||||
else if (target.IsTypeId(TypeId.Player))
|
||||
handler.SendSysMessage(CypherStrings.MovegensChasePlayer, target.GetName(), target.GetGUID().ToString());
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensChaseCreature, target.GetName(), target.GetGUID().ToString());
|
||||
break;
|
||||
}
|
||||
if (info.TargetGUID.IsEmpty())
|
||||
handler.SendSysMessage(CypherStrings.MovegensChaseNull);
|
||||
else if (info.TargetGUID.IsPlayer())
|
||||
handler.SendSysMessage(CypherStrings.MovegensChasePlayer, info.TargetName, info.TargetGUID.ToString());
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensChaseCreature, info.TargetName, info.TargetGUID.ToString());
|
||||
break;
|
||||
case MovementGeneratorType.Follow:
|
||||
{
|
||||
Unit target = ((FollowMovementGenerator)movementGenerator).GetTarget();
|
||||
|
||||
if (!target)
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowNull);
|
||||
else if (target.IsTypeId(TypeId.Player))
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowPlayer, target.GetName(), target.GetGUID().ToString());
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowCreature, target.GetName(), target.GetGUID().ToString());
|
||||
break;
|
||||
}
|
||||
if (info.TargetGUID.IsEmpty())
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowNull);
|
||||
else if (info.TargetGUID.IsPlayer())
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowPlayer, info.TargetName, info.TargetGUID.ToString());
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensFollowCreature, info.TargetName, info.TargetGUID.ToString());
|
||||
break;
|
||||
case MovementGeneratorType.Home:
|
||||
{
|
||||
if (unit.IsTypeId(TypeId.Unit))
|
||||
handler.SendSysMessage(CypherStrings.MovegensHomeCreature, x, y, z);
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensHomePlayer);
|
||||
break;
|
||||
}
|
||||
if (unit.IsTypeId(TypeId.Unit))
|
||||
handler.SendSysMessage(CypherStrings.MovegensHomeCreature, x, y, z);
|
||||
else
|
||||
handler.SendSysMessage(CypherStrings.MovegensHomePlayer);
|
||||
break;
|
||||
case MovementGeneratorType.Flight:
|
||||
handler.SendSysMessage(CypherStrings.MovegensFlight);
|
||||
break;
|
||||
case MovementGeneratorType.Point:
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.MovegensPoint, x, y, z);
|
||||
break;
|
||||
}
|
||||
handler.SendSysMessage(CypherStrings.MovegensPoint, x, y, z);
|
||||
break;
|
||||
case MovementGeneratorType.Fleeing:
|
||||
handler.SendSysMessage(CypherStrings.MovegensFear);
|
||||
break;
|
||||
@@ -1293,7 +1272,7 @@ namespace Game.Chat
|
||||
handler.SendSysMessage(CypherStrings.MovegensEffect);
|
||||
break;
|
||||
default:
|
||||
handler.SendSysMessage(CypherStrings.MovegensUnknown, movementGenerator.GetMovementGeneratorType());
|
||||
handler.SendSysMessage(CypherStrings.MovegensUnknown, info.Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1915,11 +1894,7 @@ namespace Game.Chat
|
||||
}
|
||||
|
||||
// stop flight if need
|
||||
if (target.IsInFlight())
|
||||
{
|
||||
target.GetMotionMaster().MovementExpired();
|
||||
target.CleanupAfterTaxiFlight();
|
||||
}
|
||||
target.FinishTaxiFlight();
|
||||
|
||||
target.Recall();
|
||||
return true;
|
||||
@@ -2162,14 +2137,10 @@ namespace Game.Chat
|
||||
target.SendSysMessage(CypherStrings.SummonedBy, handler.PlayerLink(_player.GetName()));
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -976,23 +976,23 @@ namespace Game.Chat
|
||||
return false;
|
||||
}
|
||||
|
||||
if (/*creature.GetMotionMaster().empty() ||*/
|
||||
creature.GetMotionMaster().GetCurrentMovementGeneratorType() != MovementGeneratorType.Follow)
|
||||
MovementGenerator movement = creature.GetMotionMaster().GetMovementGenerator(a =>
|
||||
{
|
||||
if (a.GetMovementGeneratorType() == MovementGeneratorType.Follow)
|
||||
{
|
||||
FollowMovementGenerator followMovement = a as FollowMovementGenerator;
|
||||
return followMovement != null && followMovement.GetTarget() == player;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if (movement != null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CreatureNotFollowYou, creature.GetName());
|
||||
return false;
|
||||
}
|
||||
|
||||
FollowMovementGenerator mgen = (FollowMovementGenerator)creature.GetMotionMaster().Top();
|
||||
if (mgen.GetTarget() != player)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CreatureNotFollowYou, creature.GetName());
|
||||
return false;
|
||||
}
|
||||
|
||||
// reset movement
|
||||
creature.GetMotionMaster().MovementExpired(true);
|
||||
|
||||
creature.GetMotionMaster().Remove(movement);
|
||||
handler.SendSysMessage(CypherStrings.CreatureNotFollowYouNow, creature.GetName());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -35,40 +35,35 @@ namespace Game.Chat
|
||||
if (args.Empty())
|
||||
return false;
|
||||
|
||||
Player me = handler.GetPlayer();
|
||||
Player player = handler.GetPlayer();
|
||||
|
||||
GameTele tele = handler.ExtractGameTeleFromLink(args);
|
||||
|
||||
if (tele == null)
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CommandTeleNotfound);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (me.IsInCombat() && !handler.GetSession().HasPermission(RBACPermissions.CommandTeleName))
|
||||
if (player.IsInCombat() && !handler.GetSession().HasPermission(RBACPermissions.CommandTeleName))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.YouInCombat);
|
||||
return false;
|
||||
}
|
||||
|
||||
var map = CliDB.MapStorage.LookupByKey(tele.mapId);
|
||||
if (map == null || (map.IsBattlegroundOrArena() && (me.GetMapId() != tele.mapId || !me.IsGameMaster())))
|
||||
if (map == null || (map.IsBattlegroundOrArena() && (player.GetMapId() != tele.mapId || !player.IsGameMaster())))
|
||||
{
|
||||
handler.SendSysMessage(CypherStrings.CannotTeleToBg);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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.posX, tele.posY, tele.posZ, tele.orientation);
|
||||
player.TeleportTo(tele.mapId, tele.posX, tele.posY, tele.posZ, tele.orientation);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -196,13 +191,9 @@ namespace Game.Chat
|
||||
|
||||
// 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.posX, tele.posY, tele.posZ, tele.orientation);
|
||||
}
|
||||
@@ -270,13 +261,9 @@ namespace Game.Chat
|
||||
|
||||
// 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.posX, tele.posY, tele.posZ, tele.orientation);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user