diff options
Diffstat (limited to 'Server/Plugins')
-rw-r--r-- | Server/Plugins/Debuggers/Debuggers.lua | 50 | ||||
-rw-r--r-- | Server/Plugins/Debuggers/Info.lua | 6 |
2 files changed, 56 insertions, 0 deletions
diff --git a/Server/Plugins/Debuggers/Debuggers.lua b/Server/Plugins/Debuggers/Debuggers.lua index fb18a0c19..6c47a8a17 100644 --- a/Server/Plugins/Debuggers/Debuggers.lua +++ b/Server/Plugins/Debuggers/Debuggers.lua @@ -1576,6 +1576,56 @@ end +function HandleComeCmd(a_Split, a_Player) + -- Find the first solid block under the player (in case they are flying): + local playerWorld = a_Player:GetWorld() + local playerPos = a_Player:GetPosition() + local toPos = Vector3i(playerPos) + if (toPos.y < 1) then + a_Player:SendMessageFailure("Cannot navigate to you, you're too low in the world") + return true + end + while not(cBlockInfo:IsSolid(playerWorld:GetBlock(toPos.x, toPos.y, toPos.z))) do + if (toPos.y <= 0) then + a_Player:SendMessageFailure("Cannot navigate to you, there's no solid block below you") + return true + end + toPos.y = toPos.y - 1 + end + + -- Find the mob to navigate: + local mob + local playerLook = a_Player:GetLookVector():NormalizeCopy() + local maxDot = 0 + playerWorld:ForEachEntity( + function (a_CBEntity) + local dir = (a_CBEntity:GetPosition() - playerPos) + dir:Normalize() + local dot = dir:Dot(playerLook) + if (dot > maxDot) then + maxDot = dot + mob = a_CBEntity + end + end + ) + if not(mob) then + a_Player:SendMessageFailure("Cannot navigate to you, there's no mob this way") + return true + end + + mob:MoveToPosition(Vector3d(toPos)) + a_Player:SendMessageSuccess(( + string.format("Navigating the %s to position {%d, %d, %d}", + cMonster:MobTypeToString(mob:GetMobType()), toPos.x, toPos.y, toPos.z + ) + )) + return true +end + + + + + function HandleCompo(a_Split, a_Player) -- Send one composite message to self: local msg = cCompositeChat() diff --git a/Server/Plugins/Debuggers/Info.lua b/Server/Plugins/Debuggers/Info.lua index dea656837..e3b0beee1 100644 --- a/Server/Plugins/Debuggers/Info.lua +++ b/Server/Plugins/Debuggers/Info.lua @@ -34,6 +34,12 @@ g_PluginInfo = Handler = HandleClientVersionCmd, HelpString = "Shows your client's protocol version", }, + ["/come"] = + { + Permission = "debuggers.come", + Handler = HandleComeCmd, + HelpString = "Instruct the mob you're looking at to navigate to your position", + }, ["/compo"] = { Permission = "debuggers", |