From ea86060977bfbb77af0670b399c75e22563aa8e3 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Fri, 6 Sep 2024 06:33:31 -0300 Subject: [PATCH] update --- data/events/scripts/player.lua | 47 +++++++++++++++++++++++++++++++--- data/libs/functions/player.lua | 43 ------------------------------- 2 files changed, 43 insertions(+), 47 deletions(-) diff --git a/data/events/scripts/player.lua b/data/events/scripts/player.lua index 72e5402263f..39219822bf1 100644 --- a/data/events/scripts/player.lua +++ b/data/events/scripts/player.lua @@ -321,15 +321,54 @@ function Player:onMoveItem(item, count, fromPosition, toPosition, fromCylinder, end -- Reward System - self: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 - if tile and tile:getItemById(370) then - -- Trapdoor + -- 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) - self:getPosition():sendMagicEffect(CONST_ME_POFF) return false end + if tile then + -- 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 + + -- Trapdoor + 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 return false end diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 8c86349c0be..dccf92c340d 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -859,49 +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()) - 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 -end - do local loyaltySystem = { enable = configManager.getBoolean(configKeys.LOYALTY_ENABLED),