Here is the script with runebook support, wich it's not complete yet but it works fine. I don't like much the new code and I have to think a way to find a more elegant and understandable solution.
;=================================================================
; Script Name: Fishing 4x4 Harbor Edition
; Author: VicVega
; Version: 0.1
; Shard OSI / FS: UO Legends
; Revision Date: 15/5/2009
; Purpose: Fishing in a harbor till you are overloaded
; Globals: None
;=================================================================
; Instructions:
; You need wearing a pole in the paperdoll, you also need a dagger
; in the backpack.
; %sellFishsteaks - set #true for sell the fish steaks or #false
; It's #true by default, you need to add fishSteaks
; at the Razor's Sell Agent
; %saveData - set #true for save data in fishing4x4DataHarbor.txt or #false
; It's #true by default
; You need the SaveTextToFile.vbs script for this
; %saveData - set #true for save data in fishing4x4Data.txt or #false
; It's #true by default. You need the SaveTextToFile.vbs script for this.
; Important: Remember to rename it from .txt to .vbs
; %recall - set #true for recall, #true by default, uses sacred journey
; Thanks: TrailMyx for his ConvertTimeHourMinSec sub
; JoMac for his saveTextToFile.vbs script
;************************ Setup **********************************
gosub setup
;*********************** Main Loop *******************************
repeat
gosub fishingPlace
gosub checkWeight
gosub fishingLoop
gosub dropBoots
gosub dropSpecialFishes
if %saveData
gosub saveData
until #CharGhost = YES
halt
;************************* Subs **********************************
sub fishingPlace
if %fishingPlace = firstFishingPlace
{
event sysmessage going to second fishing place
set %fishingPlace secondFishingPlace
gosub recallFishingSpot secondFishingPlace
}
else
{
event sysmessage going to first fishing place
set %fishingPlace firstFishingPlace
gosub recallFishingSpot firstFishingPlace
}
return
sub setup
set %sellFishSteaks #true
set %saveData #true
set %recall #true
set %fishingPlace secondFishingPlace
set %maxWeight #maxweight - 50
set %poleType KDF
set %daggerType WSF
gosub setID poleID %poleType #charID
gosub setID daggerID %daggerType #backpackID
if %saveData
gosub saveStartData
return
sub setID
finditem %2 C_ , %3
set % . %1 #findID
return
sub saveStartData
set %goldType POF
set %startTime #scnt
set %lastSave %startTime
gosub time #time
finditem %goldType C_ , #backpackID
set %startGold #findStack
gosub writeStartData
return
sub writeStartData
execute SaveTextToFile.Vbs #false #false #curPath fishing4x4DataHarbor.txt
+ Start Time: %time |
+ Start Gold: %startGold
return
sub fishingLoop
for %fishingSpot 1 4
{
gosub pullFishes %fishingSpot
gosub cutFish
if %sellFishSteaks
gosub sellFishSteaks
}
return
sub pullFishes
gosub fishingSpot %1
gosub tileName %fishingSpotX %fishingSpotY
event sysmessage %fishingSpotX %fishingSpotY
while #result = #true
{
gosub usePole
gosub scanMessages
}
return
sub fishingSpot
set %fishingSpot %1
if %fishingSpot = 1
gosub setTargets 4 4
if %fishingSpot = 2
gosub setTargets 4 -4
if %fishingSpot = 3
gosub setTargets -4 4
if %fishingSpot = 4
gosub setTargets -4 -4
return
sub setTargets
event sysmessage %fishingPlace
if %fishingPlace = firstFishingPlace
set #lTargetKind 2
if %fishingPlace = secondFishingPlace
set #lTargetKind 3
set %fishingSpotX %1
set %fishingSpotY %2
set #lTargetX #charPosX + %fishingSpotX
set #lTargetY #charPosY + %fishingSpotY
return
sub tileName
set %fishingPosX #charPosX + %1
set %fishingPosY #charPosY + %2
tile init
tile cnt %fishingPosX %fishingPosY
for %tileCount 1 #tilecnt
{
tile get %fishingPosX %fishingPosY %tileCount
set #lTargetZ #tileZ
set #ltargetTile #tileType
set %canFish water in #tileName || jungle in #tileName
if %canFish
return #true
}
return
sub UsePole
set #lObjectID %poleID
event macro 17
target
event macro 22
return
sub scanMessages
set %maxTimeOutScan 15
set %timeOut #scnt + %maxTimeOutScan
set %jrnl #jindex
set %successMessage pull_out
set %failMessage fail_to_catch
set %emptySpotMessage don't_seem_to_be_biting
scanjournal %jrnl
while #scnt < %timeOut
{
if %jrnl < #jindex
{
set %jrnl %jrnl + 1
scanjournal %jrnl
}
set %spotWithFish %successMessage in #journal || %failMessage in #journal
set %spotWithoutFish %emptySpotMessage in #journal
if %spotWithFish
return #false
if %spotWithoutFish
return #false
}
return
sub dropBoots
set %bootsType TVI_ZVI_ZVI_PVI_NVI
finditem %bootsType C_ , #backpackID
while #findKind <> -1
{
exevent drag #findID #findStack
wait 1s
exevent dropg #charPosX #charPosY #charPosZ
wait 1s
finditem %bootsType C_ , #backpackID
}
return
sub dropSpecialFishes
set %fishType YDF
finditem %fishType C_ , #backpackID
while #findKind <> -1
{
exevent drag #findID #findStack
wait 1s
exevent dropg #charPosX #charPosY #charPosZ
wait 1s
finditem %fishType C_ , #backpackID
}
return
sub saveData
if #scnt >= %lastSave + 600
{
set %timeFishing #scnt - %startTime
gosub ConvertTimeHourMinSec %timeFishing
set %timeFishingConverted #result
set %lastSave #scnt
finditem %goldType C_ , #backpackID
set %gold #findStack
set %goldGained %gold - %startGold
set %goldPerHour ( %goldGained * 3600 ) / %timeFishing
gosub time #time
gosub writeData
}
return
sub writeData
execute SaveTextToFile.Vbs #false #false #curPath fishing4x4DataHarbor.txt
+ Time: %time |
+ Time Fishing: %timeFishingConverted |
+ Gold: %gold |
+ Gold Gained: %goldGained |
+ Gold Per Hour: %goldPerHour
return
sub cutFish
set %fishType FQD_DQD_GQD_EQD
set #lTargetKind 1
set #lObjectID %daggerID
finditem %fishType C_ , #backpackID
while #findKind <> -1
{
set #lTargetID #findID
event macro 17
target
event macro 22
wait 1s
finditem %fishType C_ , #backpackID
}
return
sub sellFishSteaks
set %vendorType IS_HS
set %fishSteaksType IND
finditem %vendorType G_2
event property #findID
set %canSell Fisher in #property && #findDist <= 2
while ! %canSell
{
wait 1s
finditem %vendorType G_2
if #findID = #charID
ignoreitem #findID
event property #findID
set %canSell Fisher in #property && #findDist <= 2
}
ignoreitem reset
finditem %fishSteaksType C_ , #backpackID
if #findKind <> -1
msg vendor sell $
return
sub checkWeight
if #weight > %maxWeight
{
if %recall
{
gosub recallBank
gosub dropItemsBank
gosub recallFishingSpot
}
else
halt
}
return
sub recallBank
set %bankPosX 3489
set %bankPosY 2571
set %runeNo 1
set %recallType sacred
call runeBook.txt %recallType %runeNo
gosub waitingRecallPos %bankPosX %bankPosY recallBank
return
sub recallFishingSpot
if %1 = firstFishingPlace
{
set %fishingPosX 3504
set %fishingPosY 2610
set %runeNo 2
}
if %1 = secondFishingPlace
{
set %fishingPosX 1503
set %fishingPosY 3695
set %runeNo 3
}
set %recallType sacred
call runeBook.txt %recallType %runeNo
gosub waitingRecallPos %fishingPosX %fishingPosY recallFishingSpot
return
sub waitingRecallPos
set %maxTimeOut 5
set %timeOut #scnt + %maxTimeOut
while #charPosX <> %1 && #scnt < %timeOut
wait 1s
set %timeOut #scnt + %maxTimeOut
while #charPosY <> %2 && #scnt < %timeOut
wait 1s
if #scnt >= %timeOut
gosub %3
return
sub dropItemsBank
set %bankType IKF
set %goldType POF
set %pearlsType WWS
msg bank $
while #contType <> %bankType
wait 5
gosub dropItems
click #contPosX #contPosY r
wait 1s
return
sub dropItems
finditem %goldType C_ , #backpackID
if #findKind <> -1
{
event sysmessage droping gold
exevent drag #findID #findStack
wait 1s
finditem %bankType
exevent dropC #findID
wait 1s
}
finditem %pearlsType C_ , #backpackID
if #findKind <> -1
{
event sysmessage droping pearls
exevent drag #findID #findStack
wait 1s
finditem %bankType
exevent dropC #findID
wait 1s
}
return
sub time
set %time %1
str ins %time : 3
set %time #strRes
str ins %time : 6
set %time #strRes
return
; %1 = input - Time to convert
; #RESULT - Time converted to H:MM:SS format
sub ConvertTimeHourMinSec
namespace push
namespace local ctime
set !hourpart %1 / 3600
set !secpart ( %1 % 3600 ) % 60
set !minpart ( ( %1 % 3600 ) / 60 )
if !hourpart >= 10
set #RESULT !hourpart , :
else
set #RESULT 0 , !hourpart , :
if !minpart < 10
set #RESULT #RESULT , 0
set #RESULT #RESULT , !minpart , :
if !secpart < 10
set #RESULT #RESULT , 0
set #RESULT #RESULT , !secpart
namespace pop
return #RESULT
I also use this other script for calling runebooks:
finditem ZBN C_ , #backpackID
gosub runeBookDo %1 %2 #findID
exit
;==================================
; Script Name: RuneBookDo
; Author: Vito
; Version: 1.0a
; Client Tested with: 6.0.13 (91)
; EUO version tested with: 1.5 (148)
; Shard OSI / FS: FS ( RunUO ) Should work on OSI
; Revision Date: 13/04/2009
; Public Release: 13/04/2009
; Purpose: Handles most runebook functions
;==================================
;|
;| Parameters:
;| %1 - "Do" ( setdefault - Set default rune
;| drop - Drop rune
;| charge - Use charge on rune
;| recall - Recall to rune
;| gate - Open a gate to rune
;| sacred - Sacred J. to rune )
;| %2 - "Rune" ( Rune number, 1 to 16 )
;| %3 - "Book" ( Runebook ID )
;| [%4] - "TimeOut" ( Optional, sets timeout for
;| event based actions, in seconds )
;|
;| Return: #True if ok, else #False
;+-----------------------------------------------------------
sub RuneBookDo
set %RBD_Do %1
set %RBD_Rune %2 - 1
set %RBD_Book %3
; Some security checks
if %0 = 4
set %RBD_TimeOut %4
else
set %RBD_TimeOut 10
set %RBD_End #SCnt + %RBD_TimeOut
if %0 < 3
return #False
if %RBD_Rune < 0 || %RBD_Rune > 15
return #False
; Open the book
finditem ZBN C_ , #BackPackID
set #LObjectID #FindID
event macro 17
while #ContKind <> GJZ && %RBD_End > #SCnt
wait 1
if %RBD_Do = charge
{
set %RBD_X #ContPosX + 135
if %RBD_Rune > 7
set %RBD_X #ContPosX + 295
; Rather complex, uh?
set %RBD_Y #ContPosY + 70 + ( 15 * ( %RBD_Rune % 8 ) )
}
else
{
; Open the right page
set %RBD_Page ( %RBD_Rune / 2 ) + 1
if %RBD_Page < 5
set %RBD_Page %RBD_Page - 1
set %RBD_X #ContPosX + 140 + ( 35 * %RBD_Page )
set %RBD_Y #ContPosY + 200
click %RBD_X %RBD_Y dmc
; Unable to do event-based without using #PixCol (Puah!)
wait 10
if %RBD_Do = setdefault
{
set %RBD_X #ContPosX + 165 + ( 140 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 25
}
if %RBD_Do = drop
{
set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 120
}
if %RBD_Do = recall
{
set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 145
}
if %RBD_Do = gate
{
set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 163
}
if %RBD_Do = sacred
{
set %RBD_X #ContPosX + 140 + ( 160 * ( %RBD_Rune % 2 ) )
set %RBD_Y #ContPosY + 181
}
}
click %RBD_X %RBD_Y dmc
return #True