diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index ec1a92f3528..2c9fb8163aa 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -275,12 +275,19 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, return true end - -- Bath tube local toTile = Tile(toCylinder:getPosition()) if toTile then local topDownItem = toTile:getTopDownItem() - if topDownItem and table.contains({ BATHTUB_EMPTY, BATHTUB_FILLED }, topDownItem:getId()) then - return false + if topDownItem then + local topDownItemItemId = topDownItem:getId() + -- Bath tube + if table.contains({ BATHTUB_EMPTY, BATHTUB_FILLED }, topDownItemItemId) then + return false + -- Podium + elseif ItemType(topDownItemItemId):isPodium() then + self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) + self:getPosition():sendMagicEffect(CONST_ME_POFF) + end end end @@ -315,45 +322,7 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, end -- Reward System - if toPosition.x == CONTAINER_POSITION then - local containerId = toPosition.y - 64 - local container = self:getContainerById(containerId) - if not container then - return true - end - - -- Do not let the player insert items into either the Reward Container or the Reward Chest - local itemId = container:getId() - if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - - -- The player also shouldn't be able to insert items into the boss corpse - local tileCorpse = Tile(container:getPosition()) - if tileCorpse then - for index, value in ipairs(tileCorpse:getItems() or {}) do - if value:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 and value:getName() == container:getName() then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - end - end - end - - -- Do not let the player move the boss corpse. - if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - - -- Players cannot throw items on reward chest - local tileChest = Tile(toPosition) - if tileChest and tileChest:getItemById(ITEM_REWARD_CHEST) then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - self:getPosition():sendMagicEffect(CONST_ME_POFF) - return false - end + self:executeRewardEvents(item, toPosition) if tile and tile:getItemById(370) then -- Trapdoor diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index a2fb8bc0de6..8c86349c0be 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -877,18 +877,22 @@ function Player:executeRewardEvents(item, toPosition) -- The player also shouldn't be able to insert items into the boss corpse local tileCorpse = Tile(container:getPosition()) - for index, value in ipairs(tileCorpse:getItems() or {}) do - if value:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 and value:getName() == container:getName() then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false + if tileCorpse then + for index, value in ipairs(tileCorpse:getItems() or {}) do + if value:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 and value:getName() == container:getName() then + self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) + return false + end end end end + -- Do not let the player move the boss corpse. if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 then self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) return false end + -- Players cannot throw items on reward chest local tileChest = Tile(toPosition) if tileChest and tileChest:getItemById(ITEM_REWARD_CHEST) then diff --git a/src/lua/functions/items/item_type_functions.cpp b/src/lua/functions/items/item_type_functions.cpp index b528795a050..c186913f055 100644 --- a/src/lua/functions/items/item_type_functions.cpp +++ b/src/lua/functions/items/item_type_functions.cpp @@ -215,6 +215,17 @@ int ItemTypeFunctions::luaItemTypeIsQuiver(lua_State* L) { return 1; } +int ItemTypeFunctions::luaItemTypeIsPodium(lua_State* L) { + // itemType:isPodium() + const ItemType* itemType = getUserdata(L, 1); + if (itemType) { + pushBoolean(L, itemType->isPodium); + } else { + lua_pushnil(L); + } + return 1; +} + int ItemTypeFunctions::luaItemTypeGetType(lua_State* L) { // itemType:getType() const ItemType* itemType = getUserdata(L, 1); diff --git a/src/lua/functions/items/item_type_functions.hpp b/src/lua/functions/items/item_type_functions.hpp index ce53d429804..d283609d947 100644 --- a/src/lua/functions/items/item_type_functions.hpp +++ b/src/lua/functions/items/item_type_functions.hpp @@ -35,6 +35,7 @@ class ItemTypeFunctions final : LuaScriptInterface { registerMethod(L, "ItemType", "isPickupable", ItemTypeFunctions::luaItemTypeIsPickupable); registerMethod(L, "ItemType", "isKey", ItemTypeFunctions::luaItemTypeIsKey); registerMethod(L, "ItemType", "isQuiver", ItemTypeFunctions::luaItemTypeIsQuiver); + registerMethod(L, "ItemType", "isPodium", ItemTypeFunctions::luaItemTypeIsPodium); registerMethod(L, "ItemType", "getType", ItemTypeFunctions::luaItemTypeGetType); registerMethod(L, "ItemType", "getId", ItemTypeFunctions::luaItemTypeGetId); @@ -102,6 +103,7 @@ class ItemTypeFunctions final : LuaScriptInterface { static int luaItemTypeIsPickupable(lua_State* L); static int luaItemTypeIsKey(lua_State* L); static int luaItemTypeIsQuiver(lua_State* L); + static int luaItemTypeIsPodium(lua_State* L); static int luaItemTypeGetType(lua_State* L); static int luaItemTypeGetId(lua_State* L);