forgottenserver
forgottenserver copied to clipboard
fix item destroy by doors
Pull Request Prelude
- [x] I have followed [proper The Forgotten Server code styling][code].
- [x] I have read and understood the [contribution guidelines][cont] before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
Changes Proposed
Fix items damaged by doors
Issues addressed: https://github.com/otland/forgottenserver/issues/4839
How to test:
Use doors in position 121, 83, 10
Create item 1787 like on image
Open doors Put items under player Move back from doors
Could you create Position::relocate and avoid using compat doRelocate
-- data\lib\core\position.lua
function Position:relocate(toPos)
if self == toPos then
return false
end
local fromTile = Tile(self)
if not fromTile then
return false
end
if not Tile(toPos) then
return false
end
for i = fromTile:getThingCount() - 1, 0, -1 do
local thing = fromTile:getThing(i)
if thing then
if thing:isItem() then
if ItemType(thing:getId()):isMovable() then
thing:moveTo(toPos)
end
elseif thing:isCreature() then
thing:teleportTo(toPos)
end
end
end
return true
end
position::relocate(creature:getPosition())
this needs major rewriting imo, items should be moved and if cannot be moved then deleted