From 00542155f1f4663982d2e740da41ee04ee99011c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rey=20Alem=C3=A1n?= Date: Thu, 23 Jun 2022 18:07:07 -0500 Subject: [PATCH] SpecialContainersAvailable feature show/hide special containers context menu items when a player is on a depot tile --- data/lib/core/player.lua | 12 ++++++++++++ data/movements/scripts/tiles.lua | 8 +++++++- src/game.cpp | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/data/lib/core/player.lua b/data/lib/core/player.lua index 1d15023757..88d7b4f723 100644 --- a/data/lib/core/player.lua +++ b/data/lib/core/player.lua @@ -371,3 +371,15 @@ function Player.addAllMounts(self) self:addMount(mounts[mount].id) end end + +function Player.setSpecialContainersAvailable(self, available) + local msg = NetworkMessage() + msg:addByte(0x2A) + + msg:addByte(0x00) -- stash + msg:addByte(available and 0x01 or 0x00) -- market + + msg:sendToPlayer(self) + msg:delete() + return true +end diff --git a/data/movements/scripts/tiles.lua b/data/movements/scripts/tiles.lua index c9c0ae076e..6ffed5e651 100644 --- a/data/movements/scripts/tiles.lua +++ b/data/movements/scripts/tiles.lua @@ -29,6 +29,7 @@ function onStepIn(creature, item, position, fromPosition) local depotItems = creature:getDepotChest(getDepotId(depotItem:getUniqueId()), true):getItemHoldingCount() creature:sendTextMessage(MESSAGE_STATUS_DEFAULT, "Your depot contains " .. depotItems .. " item" .. (depotItems > 1 and "s." or ".")) creature:addAchievementProgress("Safely Stored Away", 1000) + creature:setSpecialContainersAvailable(true) return true end end @@ -47,7 +48,12 @@ function onStepOut(creature, item, position, fromPosition) return true end - if creature:isPlayer() and creature:isInGhostMode() then + local isPlayer = creature:isPlayer() + if isPlayer then + creature:setSpecialContainersAvailable(false) + end + + if isPlayer and creature:isInGhostMode() then return true end diff --git a/src/game.cpp b/src/game.cpp index cc6579b73d..b4de1f8453 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -5214,7 +5214,7 @@ void Game::playerBrowseMarket(uint32_t playerId, uint16_t spriteId) } if (!player->isInMarket()) { - return; + player->sendMarketEnter(); } const ItemType& it = Item::items.getItemIdByClientId(spriteId);