Skip to content

Commit

Permalink
feat: Minimap GM teleport ( ctrl +shift + click on minimap) (#885)
Browse files Browse the repository at this point in the history
Co-authored-by: Luan Luciano <[email protected]>
  • Loading branch information
kokekanon and luanluciano93 authored Oct 2, 2024
1 parent 12bafb0 commit 3a22c81
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 0 deletions.
3 changes: 3 additions & 0 deletions modules/gamelib/ui/uiminimap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,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
8 changes: 8 additions & 0 deletions src/client/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,14 @@ void Game::openContainerQuickLoot(const uint8_t action, const uint8_t category,
disableBotCall();
}

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

m_protocolGame->sendGmTeleport(pos);
}

void Game::inspectionNormalObject(const Position& position)
{
if (!canPerformGameAction())
Expand Down
1 change: 1 addition & 0 deletions src/client/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,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);

// cyclopedia related
void inspectionNormalObject(const Position& position);
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.bindSingletonFunction("g_game", "inspectionNormalObject", &Game::inspectionNormalObject, &g_game);
g_lua.bindSingletonFunction("g_game", "inspectionObject", &Game::inspectionObject, &g_game);
g_lua.bindSingletonFunction("g_game", "requestBestiary", &Game::requestBestiary, &g_game);
Expand Down
1 change: 1 addition & 0 deletions src/client/protocolcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,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);
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

0 comments on commit 3a22c81

Please sign in to comment.