Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
luanluciano93 committed Sep 6, 2024
1 parent fc2608b commit b6bbb71
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 46 deletions.
53 changes: 11 additions & 42 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
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

0 comments on commit b6bbb71

Please sign in to comment.