Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Automap = {}
- Automap.Path = "C:\\Users\\" .. os.getenv("USERNAME") .. "\\AppData\\Roaming\\Tibia\\Automap"
- -- parse the contents of the specified minimap file
- Automap.Parse = function(filename)
- local positions = {}
- local mapX,mapY,mapZ = tonumber(filename:sub(1, 3)), tonumber(filename:sub(4, 6)),tonumber(filename:sub(7, 8))
- local file = io.open(Automap.Path .. "\\" .. filename .. ".map", "rb")
- local data = file:read(65536)
- file:close()
- local index = 1
- for x = 0, 255 do
- for y = 0, 255 do
- table.insert(positions, {x=x+(mapX*256),y=y+(mapY*256),z=mapZ, color=data:byte(index)})
- index = index + 1
- end
- end
- return positions
- end
- -- find the minimap file containing the position specified
- Automap.GetFileFromPosition = function(pos)
- local filename = string.format("%03d%03d%02d", math.min(pos.x/256), math.min(pos.y/256), pos.z)
- return Automap.Parse(filename)
- end
- -- get all the water tiles found in the minimap file
- Automap.GetWaterTiles = function()
- local waterTiles = {}
- local curPos = Self.Position()
- local positions = Automap.GetFileFromPosition(curPos)
- for _, tile in ipairs(positions) do
- if(math.abs(tile.x - curPos.x) <= 7 and math.abs(tile.y - curPos.y) <= 5)then
- if(tile.color == 0x28)then
- local block = false
- for _, check in ipairs(positions) do
- -- water is near a tile that is not water, it's probably a border.
- if(isPositionAdjacent(check, tile) and check.color ~= 0x28)then
- block = true
- end
- end
- if(not block)then
- table.insert(waterTiles, tile)
- end
- end
- end
- end
- return waterTiles
- end
- print("Auto Fishing by Syntax...")
- local waterTiles = Automap.GetWaterTiles()
- if(#waterTiles > 0)then
- printf("%d water tile(s) found...", #waterTiles)
- local lastPos, lastCount = Self.Position(), Self.ItemCount(3578)
- local index = 1
- while(true)do
- -- check if we have worms o.O
- if(Self.ItemCount(3492) >= 1)then
- -- if player has moved
- local curPos = Self.Position()
- if(getDistanceBetween(curPos, lastPos) > 0)then
- print("You have moved recently. Finding new fishing spots...")
- lastPos = curPos
- lastCount = Self.ItemCount(3578)
- waterTiles = Automap.GetWaterTiles()
- if(#waterTiles > 0)then
- printf("%d water tile(s) found...", #waterTiles)
- else
- print("No water tiles found. Auto Fishing has been disabled.")
- break
- end
- end
- local tile = waterTiles[index]
- Self.UseItemWithGround(3483, tile.x, tile.y, tile.z)
- wait(200)
- -- fish was caught, go to next tile
- local curCount = Self.ItemCount(3578)
- if(curCount > lastCount)then
- lastCount = curCount
- index = index + 1
- -- if fished all the tiles once
- if(index > #waterTiles)then
- print("Finished fishing all tiles on screen, restarting...")
- index = 1
- end
- end
- wait(500, 1500)
- else
- print("You are out of worms. Auto Fishing has been disabled.")
- break
- end
- end
- else
- print("No water tiles found. Auto Fishing has been disabled.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement