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 7ebb6a6 commit ea86060
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 47 deletions.
47 changes: 43 additions & 4 deletions data/events/scripts/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 0 additions & 43 deletions data/libs/functions/player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit ea86060

Please sign in to comment.