Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix item destroy by doors #4856

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ArturKnopik
Copy link
Contributor

Pull Request Prelude

  • I have followed [proper The Forgotten Server code styling][code].
  • I have read and understood the [contribution guidelines][cont] before making this PR.
  • 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:
#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

@@ -22,7 +22,7 @@ function closingDoor.onStepOut(creature, item, position, fromPosition)
while tileItem and i < tileCount do
tileItem = tile:getThing(i)
if tileItem and tileItem:getUniqueId() ~= item.uid and tileItem:getType():isMovable() then
tileItem:remove()
doRelocate(position, creature:getPosition())
Copy link
Contributor Author

@ArturKnopik ArturKnopik Nov 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't use position or fromPosition from function parameters, they returns always the same positions, creature position is good becouse it's should be always valid
issue opened: #4857

@ramon-bernardo
Copy link
Contributor

ramon-bernardo commented Nov 24, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants