Ich habe auch mal ein wenig rumgespielt,
Ein Fisching Script was Soweit alles Automatisiert. (Theoretisch)
Dem Script bedarf es sicher noch einige Optimierungen und Tests.
Das Script tut folgendes:
- Fischbare Tiles ermitteln
- Tiles Abfischen
- Fische in Packy lagern (Packy detektieren)
- Packy min alle 1h füttern
- Nach dem Abfischen eine Neue Postion suchen (beachtet die Anleitung)
- Angel und Futter selbstständig detektieren und wenn nötig wechseln
- Bei Gefahr Positionmerken, Zum "Sicheren Punkt" entfliehen, Script Pausieren, bei erneuten Starten an die alte Poistion laufen und weiter machen
Das Script habe ich einfach so drauf los geschrieben, Anregungen von Bonboris Script geholt
und es ist für mich ein "Lern Project". Es gibt noch einiges zu Lernen.
Die Sprache Lua ist mir neu. Die bisherigen Test liefen soweit erfolgreich.
Mein Wording ist wie immer eine Katastrophe
Danke Bonbori für die Anregung, OEU hat tatsächlich einiges an Vorteilen, besonder hervorzuheben ist die Geschwindigkeit. Natürlich wird das Scripten um einiges Komplexer aber auch mächtiger.
Ich hoffe es ist okay das ich deinen Thread dafür ausnutze
- Code: Alles auswählen
----------------------------------------------------------------------------------
-- Fishing-Script by Giulia Fourier ----------------------------------------------
-- for UO-Freeshard Sigena (www.uosigena.de) -------------------------------------
-- Version 1.0 Beta --------------------------------------------------------------
----------------------------------------------------------------------------------
-- Anleitung
-- Rettungpunkt einstellen
-- savePointX und savePointY sind die X/Y Koordinaten andem der Char sich bei Gefahr zurückzieht
-- Wegfindungs Routine
-- Der Charakter sucht sich seinen Weg an der Küste entlange in folgenden Formen
-- #A ######################
-- #| <-<-<-<-<-<-<-<-<-<-A#
-- #A |#
-- #| A#
-- #A |#
-- #| A#
-- #A <-<-<-<-<-<-<-< |#
-- ################### A#
-- LEGENDE: # UferTile -> oder v Laufrichtung
-- Laufrichtung kann mit local nDirection = 1 ungedreht werden
-- Im Backpack werden folgende Item benötigt
-- die Angeln
-- Futter (momentan nur Äpfel und Zitronen)
-- Packpferd wird alle 1h gefüttert
----------------------------------------------------------------------------------
-- TODO-List
-- Configuration über ein Menu
-- Einbetten von einer Fischernetzfunktion
-- Fisch Counter
-- Testen Testen Testen
----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
-- INITIALISEING -----------------------------------------------------------------
-- constants ---
local ANGEL = 3519
local nTILEEMPTY = -1
local nFishingRange = 6
local nShoreWaterDistance = 3
local nMaxStateWait = 500 -- * 10ms
local nSearchRange = 24
local nDirection = 1
local savePointX = 262
local savePointY = 381
-- variables ---
local timeToFeed = true
local tFishTiles = {}
local nPackyBagID = 0
local nTableSize = 0
local nTempAngelID
local uferTiles = {}
local nShoreCnt = 0
local nHour, nMinute = gettime ()
local firstTimeFeed = true
local nFeedID = nil
local nNewRef = 0
nNewRef,nCnt= UO.ScanJournal(nNewRef)
tFishingStates = {
succes1 = "praechtiger Fang",
succes2 = "beissen sie heute nicht",
succes3 = "merkwuerdig aussehenden Fisch",
succes4 = "ihr fischt etwas Treibholz heraus",
succes5 = "Ihr zieht eine kleine Truhe an Land",
succes6 = "Ein alter Stiefel haengt am Haken",
fail1 = "es keinen Fisch zu geben",
fail2 = "ihr nicht sehen",
fail3 = "ihr nicht angeln",
fail4 = "zu weit entfernt",
danger = "das ist kein Fisch"
}
tPackAnimals = {
lama = 292,
horse = 291
}
tPackyFeed = {
apfel = 2512,
zitrone = 5928,
bananne = 5919,
limette = 5930,
birne = 5833,
pfirsisch = 5932
}
tFishTypes = {
schwertfisch = 506,
barsch = 507,
hecht = 508,
dorsch = 509,
lachs = 510,
--bless = 41832,
--dex = 41833;
--int = 41834,
--str = 41835,
magic = 3542,
--heal = 41837,
--invis = 41838,
--nightsight = 41839
}
tPackAnimals = {
lama = 292,
horse = 291
}
-- FUNCTIONS ---------------------------------------------------------------------
-- creates an table with tile parameters --
function createTileTable(type ,x ,y)
tileTab = {}
tileTab.type = type
tileTab.x = x
tileTab.y = y
tileTab.maker = false
return tileTab
end
-- search items by item-type in mainbackpack and returns the id of the item which will found and nil if no item found
function findItemIDMB(itemType)
local item = nil
local itemCnt = UO.ScanItems(true)
for i=0, itemCnt do
local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCo = UO.GetItem(i)
if ( nContID == UO.BackpackID or nContID == UO.CharID ) and nType == itemType then
-- print(UO.Property(nID))
-- print("\n")
item = nID
break
end
end
if item == nil then
item = print("no item from type "..itemType.." was found in "..cont)
pause()
end
return item
end
-- search item by type and return therer id
function findItemID(itemType)
local item = nil
local itemCnt = UO.ScanItems(true)
for i=0, itemCnt do
local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCo = UO.GetItem(i)
if nType == itemType then
item = nID
break
end
end
return item
end
-- search items by item-type in containter and returns the id
function findItemIDStack(itemType,nContainerID)
local item = nil
local stack = nil
local itemCnt = UO.ScanItems(true)
for i=0, itemCnt do
local nID,nType,nKind,nContID,nX,nY,nZ,nStack,nRep,nCo = UO.GetItem(i)
if ( nContID == nContainerID) and nType == itemType then
-- print(UO.Property(nID))
-- print("\n")
item = nID
stack = nStack
break
end
end
if item == nil then
item = print("no item from type "..itemType.." was found in "..nContainerID)
end
return item, stack
end
-- checks for existing an tile on x,y in fish tile table
function alreadyExistInTable(x, y)
for i = 0, nTableSize - 1 do
if tFishTiles[i].x == x and tFishTiles[i].y == y then
return true
end
end
return false
end
-- searching of new water tiles for fishing in nRange, new tiles will added to nFishTiles table
function findFishingTiles(nRange)
for i = -nRange, nRange do
for k = -nRange, nRange do
local tile =UO.TileCnt(UO.CharPosX + i, UO.CharPosY + k)
local nType,nZ,sName,nFlags = UO.TileGet(UO.CharPosX + i, UO.CharPosY + k, tile)
--print(nType.." "..nZ.." "..sName.." "..nFlags)
if sName == "water" or sName == "Wasser" and false == alreadyExistInTable(UO.CharPosX + i, UO.CharPosY + k) then
tFishTiles[nTableSize] = createTileTable(nType, UO.CharPosX + i, UO.CharPosY + k)
nTableSize = nTableSize + 1
end
end
end
end
-- return an status code for systemmessages
function analyseJournal()
nReturn = 0
nNewRef,nCnt= UO.ScanJournal(nNewRef)
for i = 0, nCnt - 1 do
local sLine = UO.GetJournal(i)
if string.find(sLine, tFishingStates.succes1 ) ~= nil or
string.find(sLine,tFishingStates.succes2) ~= nil or
string.find(sLine,tFishingStates.succes3) ~= nil or
string.find(sLine,tFishingStates.succes4) ~= nil or
string.find(sLine,tFishingStates.succes5) ~= nil or
string.find(sLine,tFishingStates.succes6) ~= nil then
nReturn = 1
break
elseif string.find(sLine,tFishingStates.fail1) ~= nil or
string.find(sLine,tFishingStates.fail2) ~= nil or
string.find(sLine,tFishingStates.fail3) ~= nil or
string.find(sLine, tFishingStates.fail4) ~= nil then
nReturn = -1
break
elseif string.find(sLine, tFishingStates.danger) ~= nil then
local tempX = UO.CharPosX
local tempY = UO.CharPosY
print("Danger")
UO.Move(savePointX, savePointY)
pause()
UO.Move(tempX, tempY)
nReturn = 1
end
end
--print(nReturn)
return nReturn
end
-- TODO
function checkFeedTime()
nHour2, nMinute2 = gettime ()
if firstTimeFeed or ( nHour2 > nHour and nMinute2 > nMinute ) or nHour2 > (nHour + 2) or nHour == 0 then
feedPackanimal()
nHour = nHour2
nMinute = nMinute2
--nHour = nHour - 1
--nMinute = nMinute + 2
firstTimeFeed = false
end
end
-- table iteration function which fishs an tile while no fish can found at this tile
function fisching(_index)
if tFishTiles[_index].maker == false then
local loopCnt
local state
while(state ~= nTILEEMPTY) do
checkFeedTime()
nTempAngelID = findItemIDStack(ANGEL, UO.CharID)
if nTempAngleID == nil then
nTempAngelID = findItemID(ANGEL)
end
if UO.Weight > UO.MaxWeight then
fishInToPacky()
end
state = 0
UO.LTargetX = tFishTiles[_index].x
UO.LTargetY = tFishTiles[_index].y
UO.LTargetKind = 2
UO.LObjectID = nTempAngelID
UO.Macro(17,0)
loopCnt = 0
repeat
loopCnt = loopCnt + 1
wait(10)
until UO.TargCurs == true or loopCnt >= 20
UO.Macro(22,0)
loopCnt = 0
repeat
wait(10)
state = analyseJournal()
if state ~= 0 or loopCnt >= nMaxStateWait then
break
end
loopCnt = loopCnt + 1
until false
end
state = 0
tFishTiles[_index].maker = true
end
end
-- returns the absolut distance between the char and x,y
function getDis(x, y)
x = x - UO.CharPosX
y = y - UO.CharPosY
return math.abs((x)^2 + (y)^2);
end
-- searching watertiles along the abscissa (x) and an fixed point on the ordinate (y) which abut on grasstiles
function shoreSearchAlongAbscissa(absissaPos)
for i = -nSearchRange, nSearchRange do
local tile =UO.TileCnt(UO.CharPosX + i, UO.CharPosY + absissaPos)
local nType,nZ,sName,nFlags = UO.TileGet(UO.CharPosX + i, UO.CharPosY + absissaPos, tile)
if sName == "water" or sName == "Wasser" then
for j = -1, 1 do
local tile =UO.TileCnt(UO.CharPosX + i + j * nShoreWaterDistance, UO.CharPosY + absissaPos)
local nType,nZ,sName,nFlags = UO.TileGet(UO.CharPosX + i + j * nShoreWaterDistance, UO.CharPosY + absissaPos, tile)
if sName == "grass" then
print("1 shoretile found "..nShoreCnt)
uferTiles[nShoreCnt] = {x = UO.CharPosX + i + j * nShoreWaterDistance,y = UO.CharPosY + absissaPos}
nShoreCnt = nShoreCnt + 1
end
end
end
end
end
-- searching watertiles along the ordinate (y) and an fixed point on the abscissa (x) which abut on grasstiles
function shoreSearchAlongOrdinate(odinatePos)
for k = -nSearchRange, nSearchRange do
local tile =UO.TileCnt(UO.CharPosX + odinatePos, UO.CharPosY + k)
local nType,nZ,sName,nFlags = UO.TileGet(UO.CharPosX + odinatePos, UO.CharPosY + k, tile)
if sName == "grass" then
for j = -1, 1 do
local tile =UO.TileCnt(UO.CharPosX + odinatePos, UO.CharPosY + k + j * nShoreWaterDistance)
local nType,nZ,sName,nFlags = UO.TileGet(UO.CharPosX + odinatePos, UO.CharPosY + k + j * nShoreWaterDistance, tile)
if sName == "water" or sName == "Wasser" then
print("2 shoretile found "..nShoreCnt)
uferTiles[nShoreCnt] = {x = UO.CharPosX + odinatePos,y = UO.CharPosY + k + j * nShoreWaterDistance}
print(uferTiles[nShoreCnt].x)
nShoreCnt = nShoreCnt + 1
end
end
end
end
end
-- searching the next position to move
-- Reouten Muster (with nDirection == 1)
-- # v
-- # |
-- # v
-- # |
-- # v > - > - >
-- #################
function findNextPosition()
local nextX
local nextY
shoreSearchAlongOrdinate(-nFishingRange * 2 * nDirection)
shoreSearchAlongOrdinate(-nFishingRange * nDirection)
if uferTiles[0] == nil then
print("1 no shoretile found")
shoreSearchAlongOrdinate(nFishingRange * 2 * nDirection)
shoreSearchAlongOrdinate(nFishingRange * nDirection)
if uferTiles[0] == nil then
print("2 no shoretile found")
shoreSearchAlongAbscissa(nFishingRange * 2 * nDirection)
shoreSearchAlongAbscissa(nFishingRange * nDirection)
if uferTiles[0] == nil then
print("3 no shoretile found")
shoreSearchAlongAbscissa(-nFishingRange * 2 * nDirection)
shoreSearchAlongAbscissa(-nFishingRange * nDirection)
end
end
end
if uferTiles[0] ~= nil then
print("shorefiles found "..uferTiles[0].x)
nextX = uferTiles[0].x
nextY = uferTiles[0].y
local maxDistance = getDis(uferTiles[0].x, uferTiles[0].y)
for i = 0, nShoreCnt - 1 do
tempDistance = getDis(uferTiles[i].x, uferTiles[i].y)
if tempDistance > maxDistance then
local nextX = uferTiles[i].x
local nextY = uferTiles[i].y
maxDistance = tempDistance
end
end
end
if nextX ~= nil or nextY ~= nil then
print("x"..nextX.." y"..nextY)
return nextX, nextY
else
return nil, nil
end
end
-- itteration function to transfer alle item from type which tFishTypes includes from mainbagpack to packanimal
function transferItemTable(_index)
repeat
local tempItem, tempStack = findItemIDStack(tFishTypes[_index], UO.BackpackID)
if tempItem ~= nil then
print(tempItem.." "..tempStack)
UO.Drag(tempItem, tempStack)
wait(10)
--print(nPackyBagID)
UO.DropC(nPackyBagID)
UO.LObjectID = UO.BackpackID
UO.Macro(17,0) -- BackpackRefresh
else
break
end
until false
end
-- function to transfer all fishitems to packanimal
function fishInToPacky()
nPackyID = findItemID(tPackAnimals.horse)
if nPackyID == nil then
nPackyID = findItemID(tPackAnimals.lama)
end
if nPackyID == nil then
print("couln'd found an pack animal, "..nPackyID)
pause()
else
UO.LObjectID = nPackyID
UO.Macro(17,0)
wait(500)
nPackyBagID = UO.ContID
print(nPackyBagID)
table.foreach(tFishTypes,transferItemTable)
end
end
-- search an packyfeed item
function findOneFromTable(_index)
print(tPackyFeed[_index])
if nFeedID ~= nil then
local test = UO.Property(nFeedID)
if test == nil then
nFeedID = nil
end
end
if nFeedID == nil then
nFeedID = nil
local nItemCnt = UO.ScanItems(true)
for i = 0, nItemCnt do
local nItemID,nType = UO.GetItem(i)
--print(nType)
if nType == tPackyFeed[_index] then
print(nType.." "..nItemID)
nFeedID = nItemID
break
end
end
end
end
-- feed packanimal
function feedPackanimal()
table.foreach(tPackyFeed, findOneFromTable)
local nPacky = findItemID(tPackAnimals.lama)
if nFeedID ~= nil and nPacky ~= nil then
UO.Drag(nFeedID, 1)
UO.DropC(nPacky)
else
print("did not found a packanimal or feed")
end
end
-- MAIN --------------------------------------------------------------------------
if UO.TileInit(true) then
nTempAngelID = findItemID(ANGEL)
repeat
findFishingTiles(nFishingRange)
print(nTableSize)
uferTiles = {}
uferTiles[0] = nil
nShoreCnt = 0
table.foreach(tFishTiles, fisching)
local x,y = findNextPosition()
if x == nil or y == nil then
x = UO.CharPosX
y = UO.CharPosY
print("unexpected error, no new position found. Paused")
pause()
end
UO.Move(x,y,nShoreWaterDistance, 5000)
until false
else
print("Init Fail")
end