From eb025b177ad88fa664d021d3f83ca945a2d288f3 Mon Sep 17 00:00:00 2001 From: AtelierWindows Date: Sun, 24 Jan 2021 15:35:52 +1300 Subject: [PATCH] Add %GOTO and %NOCLIP --- .../Horse Isle Server/Game/Chat/Chat.cs | 2 + .../Horse Isle Server/Game/Chat/Command.cs | 48 +++++++++++++++---- .../Horse Isle Server/Player/User.cs | 1 + .../Horse Isle Server/Server/GameServer.cs | 20 ++++---- 4 files changed, 52 insertions(+), 19 deletions(-) diff --git a/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs b/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs index 09d2b79..2a77a3e 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Chat/Chat.cs @@ -60,6 +60,8 @@ namespace HISP.Game.Chat return Command.Give(message, args, user); if (message.StartsWith("%GOTO")) return Command.Goto(message, args, user); + if (message.StartsWith("%NOCLIP")) + return Command.NoClip(message, args, user); return false; } if (message[0] == '!') diff --git a/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs b/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs index 86e2f17..325d4b7 100644 --- a/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs +++ b/Horse Isle Server/Horse Isle Server/Game/Chat/Command.cs @@ -100,22 +100,52 @@ namespace HISP.Game.Chat return true; } + public static bool NoClip(string message, string[] args, User user) + { + if (!user.Administrator) + return false; + user.NoClip = !user.NoClip; + + byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT); + user.LoggedinClient.SendPacket(chatPacket); + return true; + } + public static bool Goto(string message, string[] args, User user) { if (args.Length <= 0) return false; if (!user.Administrator) return false; + if(args[0] == "PLAYER") + { + if(args.Length <= 1) + return false; + try + { + User teleportTo = GameServer.GetUserByName(args[1]); + user.Teleport(teleportTo.X, teleportTo.Y); + } + catch (KeyNotFoundException) + { + return false; + } + } + if(args[0].Contains(",")) + { + try + { + string[] xy = args[0].Split(','); + int x = int.Parse(xy[0]); + int y = int.Parse(xy[1]); + user.Teleport(x, y); + } + catch(FormatException) + { + return false; + } + } - try - { - User teleportTo = GameServer.GetUserByName(args[0]); - user.Teleport(teleportTo.X, teleportTo.Y); - } - catch (KeyNotFoundException) - { - return false; - } byte[] chatPacket = PacketBuilder.CreateChat(Messages.FormatAdminCommandCompleteMessage(message.Substring(1)), PacketBuilder.CHAT_BOTTOM_LEFT); diff --git a/Horse Isle Server/Horse Isle Server/Player/User.cs b/Horse Isle Server/Horse Isle Server/Player/User.cs index b6fb317..0695933 100644 --- a/Horse Isle Server/Horse Isle Server/Player/User.cs +++ b/Horse Isle Server/Horse Isle Server/Player/User.cs @@ -31,6 +31,7 @@ namespace HISP.Player public bool MuteSocials = false; public bool MuteAll = false; public bool MuteLogins = false; + public bool NoClip = false; public string Gender; public bool MetaPriority = false; diff --git a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs index e23821f..49a44a6 100644 --- a/Horse Isle Server/Horse Isle Server/Server/GameServer.cs +++ b/Horse Isle Server/Horse Isle Server/Server/GameServer.cs @@ -2080,7 +2080,7 @@ namespace HISP.Server if (tile.ExitY != 0) newY = tile.ExitY; else - if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1)) + if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1) || loggedInUser.NoClip) newY += 1; @@ -2103,7 +2103,7 @@ namespace HISP.Server } else { - if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1)) + if (Map.CheckPassable(loggedInUser.X, loggedInUser.Y + 1) || loggedInUser.NoClip) loggedInUser.Y += 1; Direction = PacketBuilder.DIRECTION_DOWN; @@ -2121,12 +2121,12 @@ namespace HISP.Server if (movementDirection == PacketBuilder.MOVE_UP) { direction = PacketBuilder.DIRECTION_UP; - if (Map.CheckPassable(newX, newY - 1)) + if (Map.CheckPassable(newX, newY - 1) || loggedInUser.NoClip) newY -= 1; if (loggedInUser.Facing == (direction + (onHorse * 5))&& onHorse != 0) // Double move - if (Map.CheckPassable(newX, newY - 1)) + if (Map.CheckPassable(newX, newY - 1) || loggedInUser.NoClip) { newY -= 1; moveTwo = true; @@ -2135,12 +2135,12 @@ namespace HISP.Server else if (movementDirection == PacketBuilder.MOVE_LEFT) { direction = PacketBuilder.DIRECTION_LEFT; - if (Map.CheckPassable(newX - 1, newY)) + if (Map.CheckPassable(newX - 1, newY) || loggedInUser.NoClip) newX -= 1; if (loggedInUser.Facing == (direction + (onHorse * 5)) && onHorse != 0) // Double move - if (Map.CheckPassable(newX - 1, newY)) + if (Map.CheckPassable(newX - 1, newY) || loggedInUser.NoClip) { newX -= 1; moveTwo = true; @@ -2149,12 +2149,12 @@ namespace HISP.Server else if (movementDirection == PacketBuilder.MOVE_RIGHT) { direction = PacketBuilder.DIRECTION_RIGHT; - if (Map.CheckPassable(newX + 1, newY)) + if (Map.CheckPassable(newX + 1, newY) || loggedInUser.NoClip) newX += 1; if (loggedInUser.Facing == (direction + (onHorse * 5)) && onHorse != 0) // Double move - if (Map.CheckPassable(newX + 1, newY)) + if (Map.CheckPassable(newX + 1, newY) || loggedInUser.NoClip) { newX += 1; moveTwo = true; @@ -2163,12 +2163,12 @@ namespace HISP.Server else if (movementDirection == PacketBuilder.MOVE_DOWN) { direction = PacketBuilder.DIRECTION_DOWN; - if (Map.CheckPassable(newX, newY + 1)) + if (Map.CheckPassable(newX, newY + 1) || loggedInUser.NoClip) newY += 1; if (loggedInUser.Facing == (direction + (onHorse * 5)) && onHorse != 0) // Double move - if (Map.CheckPassable(newX, newY + 1)) + if (Map.CheckPassable(newX, newY + 1) || loggedInUser.NoClip) { newY += 1; moveTwo = true;