Anti Trap (Poe os itens que o trapou na BP)

const
Items = [2777, 2794, 2808, 6372, 2793, 2806, 2792, 2801, 2811]
BP = 1

Procedure PickUpLoot(Loot: TItem);
begin
if Self.Containers.Container[BP-1].Item[Self.Containers.Container[BP-1].Capacity-1] <> nil then
if Self.Containers.Container[BP-1].Item[Self.Containers.Container[BP-1].Capacity-1].Properties.Container then Self.Containers.Container[BP-1].Item[Self.Containers.Container[BP-1].Capacity-1].Open;
else Self.DisplayText('Your Loot backpacks is full.');
if Self.Containers.Container[BP-1].Count <> 0 then
begin
if Self.Containers.Container[BP-1].Item[0].Properties.Container then Loot.MoveToContainer(Self.Containers.Container[BP-1], Self.Containers.Container[BP-1].Capacity-1, 0);
else Loot.MoveToContainer(Self.Containers.Container[BP-1], 0, 0);
end else Loot.MoveToContainer(Self.Containers.Container[BP-1], 0, 0);
end;

Procedure FindLoot;
var
x, y, z, i, f: integer;
Tile: TTile;
begin
for x := -1 to 1 do
begin
for y := -1 to 1 do
begin
Tile := Screen.Tile[x + 7, y + 5];
begin
for i := 0 to Tile.Count-1 do
begin
if i >= Tile.Count then Break;
for j := Low(Items) to High(Items) do if Tile.Item[Tile.Count-1-i].ID = Items[j] then
begin
if i = 0 then PickUpLoot(Tile.Item[Tile.Count-1-i]);
else if not Tile.Item[Tile.Count-i].Properties.Movable then PickUpLoot(Tile.Item[Tile.Count-i-1]);
else Tile.Item[Tile.Count-i].MoveToGround(Self.X+Random(-1,2), Self.Y+Random(-1,2), Self.Z, 0);
end;
end;
end;
end;
end;
end;

while not terminated do
begin
UpdateWorld;
if Self.Containers.Count >= BP then FindLoot;
Sleep(500);
end;