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

fix: problem with stack of items on the podium after server save #2879

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
35 changes: 21 additions & 14 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,18 @@ 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()
if table.contains({ BATHTUB_EMPTY, BATHTUB_FILLED }, topDownItemItemId) then -- Bath tube
return false
elseif ItemType(topDownItemItemId):isPodium() then -- Podium
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end
end

Expand Down Expand Up @@ -347,19 +353,20 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder,
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
if tile then
luanluciano93 marked this conversation as resolved.
Show resolved Hide resolved
-- Players cannot throw items on reward chest
if tile:getItemById(ITEM_REWARD_CHEST) then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

if tile and tile:getItemById(370) then
-- Trapdoor
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
if tile:getItemById(370) then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end
end

if not antiPush(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder) then
Expand Down
39 changes: 0 additions & 39 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -859,45 +859,6 @@ function Player.inBossFight(self)
return false
end

-- For use of data/events/scripts/player.lua
function Player:executeRewardEvents(item, toPosition)
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())
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
-- 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
end

do
local loyaltySystem = {
enable = configManager.getBoolean(configKeys.LOYALTY_ENABLED),
Expand Down
11 changes: 11 additions & 0 deletions src/lua/functions/items/item_type_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,17 @@ int ItemTypeFunctions::luaItemTypeIsQuiver(lua_State* L) {
return 1;
}

int ItemTypeFunctions::luaItemTypeIsPodium(lua_State* L) {
// itemType:isPodium()
const ItemType* itemType = getUserdata<const ItemType>(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<const ItemType>(L, 1);
Expand Down
2 changes: 2 additions & 0 deletions src/lua/functions/items/item_type_functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading