forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

fix item destroy by doors

Open ArturKnopik opened this issue 1 year ago • 2 comments

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 image

Open doors Put items under player Move back from doors

ArturKnopik avatar Nov 24 '24 16:11 ArturKnopik

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())

ramon-bernardo avatar Nov 24 '24 18:11 ramon-bernardo

this needs major rewriting imo, items should be moved and if cannot be moved then deleted

nekiro avatar Dec 05 '24 23:12 nekiro