Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Minimap GM teleport ( ctrl +shift + click on minimap) #885

Merged
merged 7 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions modules/gamelib/ui/uiminimap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,9 @@ function UIMinimap:onMouseRelease(pos, button)

if button == MouseLeftButton then
local player = g_game.getLocalPlayer()
if g_game.getClientVersion() > 1288 and g_keyboard.isCtrlPressed() and g_keyboard.isShiftPressed() then
return g_game.sendGmTeleport(mapPos)
end
if Position.distance(player:getPosition(), mapPos) > 250 then
modules.game_textmessage.displayStatusMessage(tr('Destination is out of range.'))
return false
Expand Down
10 changes: 9 additions & 1 deletion src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1766,4 +1766,12 @@ void Game::openContainerQuickLoot(const uint8_t action, const uint8_t category,
enableBotCall();
m_protocolGame->openContainerQuickLoot(action, category, pos, itemId, stackpos, useMainAsFallback);
disableBotCall();
}
}

void Game::sendGmTeleport(const Position& pos)
{
if (!canPerformGameAction())
return;

m_protocolGame->sendGmTeleport(pos);
}
1 change: 1 addition & 0 deletions src/client/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@ class Game
void requestBless();
void requestQuickLootBlackWhiteList(const uint8_t filter, const uint16_t size, const std::vector<uint16_t>& listedItems);
void openContainerQuickLoot(const uint8_t action, const uint8_t category, const Position& pos, const uint16_t itemId, const uint8_t stackpos, const bool useMainAsFallback);
void sendGmTeleport(const Position& pos);

protected:
void enableBotCall() { m_denyBotCall = false; }
Expand Down
1 change: 1 addition & 0 deletions src/client/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "requestBless", &Game::requestBless, &g_game);
g_lua.bindSingletonFunction("g_game", "requestQuickLootBlackWhiteList", &Game::requestQuickLootBlackWhiteList, &g_game);
g_lua.bindSingletonFunction("g_game", "openContainerQuickLoot", &Game::openContainerQuickLoot, &g_game);
g_lua.bindSingletonFunction("g_game", "sendGmTeleport", &Game::sendGmTeleport, &g_game);

g_lua.registerSingletonClass("g_gameConfig");
g_lua.bindSingletonFunction("g_gameConfig", "loadFonts", &GameConfig::loadFonts, &g_gameConfig);
Expand Down
1 change: 1 addition & 0 deletions src/client/protocolcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ namespace Proto
ClientTurnEast = 112,
ClientTurnSouth = 113,
ClientTurnWest = 114,
ClientGmTeleport = 115,
ClientEquipItem = 119,
ClientMove = 120,
ClientInspectNpcTrade = 121,
Expand Down
1 change: 1 addition & 0 deletions src/client/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ProtocolGame : public Protocol
void sendTurnEast();
void sendTurnSouth();
void sendTurnWest();
void sendGmTeleport(const Position& Pos);
kokekanon marked this conversation as resolved.
Show resolved Hide resolved
void sendEquipItem(const uint16_t itemId, const uint16_t countOrSubType);
void sendMove(const Position& fromPos, const uint16_t thingId, const uint8_t stackpos, const Position& toPos, const uint16_t count);
void sendInspectNpcTrade(const uint16_t itemId, const uint16_t count);
Expand Down
8 changes: 8 additions & 0 deletions src/client/protocolgamesend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,14 @@ void ProtocolGame::sendTurnWest()
send(msg);
}

void ProtocolGame::sendGmTeleport(const Position& Pos)
{
const auto& msg = std::make_shared<OutputMessage>();
msg->addU8(Proto::ClientGmTeleport);
addPosition(msg, Pos);
send(msg);
}

void ProtocolGame::sendEquipItem(const uint16_t itemId, const uint16_t countOrSubType)
{
const auto& msg = std::make_shared<OutputMessage>();
Expand Down
Loading