Fishing 4x4
(http://i524.photobucket.com/albums/cc324/duncanHaleck/4x4_fishing.png)
The script works fine but I wanna post it here for a while before posting it on the Submit Your Script (http://www.scriptuo.com/index.php?board=75.0) section, in case anyone has any suggestions about the code and how to improve it.
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) Purpose
- Fishes in a harbor or a boat till you are overloaded
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) Current features
- If you are in a harbor near a vendor, sells the steaks using Razor Sells Agent (you have to set the Razor Agent to do this).
- If you are in a boat, moves the boat 12 tiles back or forward each time the fish it's depleted on the 4x4 zone around.
- Cuts the fish with a dagger.
- Drops boots on the ground.
- Drops special fishes on the ground
- Saves the fishing data in a file called fishing4x4Data.txt
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) Version History
new in 0.1 (13/5/09)
- Published the first script's version.
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) Posible Future Features
- Add support for Runebooks in order to drop money and white pearls in the Bank
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) Notes
- How fishing4x4Data.txt looks like, in case you activate this option:
Time: 145210
Time fishing: 436 s 7 min
Total time fishing: 2705 s 45 min
Total Steaks: 860
Steaks Gained This Loop: 132
Total Steaks Gained: 860
Steaks Per Hour: 1144
...
- Explanation how the 4x4 fishing works extracted from here (http://www.scriptuo.com/index.php?topic=1369.0). Warning: This only works with RunUO or OSI shards, not with Sphere ones.
8x8 resource blocks are how UO handles resources that respawn. Resources don't restock in a tile/tile basis. So when you just fish in 4x4 blocks around you, you are depleting all possible resources by only fishing in 4 spots!
Actually it works out pretty close actually. If you fish one 4x4 square to being empty, then the other 3, you are really close to having the resources replenished. Trust me, I have a couple fishing scripts out there and have been doing the fishing thing for just about the beginning of my scripting life, so I've tweaked it a bunch. It's all come to successful fishing attempts/hr so if you over-fish an area, you'll waste a lot of time in that same area knowing you won't fish anything up.
(http://www.uolegends.net/forums/images/smiles/icon_arrow.gif) 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 #false by default, you need to add fishSteaks at the Razor's Sell Agent.
- %saveData - set #true for save data in fishing4x4Data.txt or #false, it's #true by default.
- %boatFishing - set #true for fishing from a boat or #false, it's #false by default.
;=================================================================
; Script Name: Fishing 4x4
; Author: VicVega
; Version: 0.1
; Shard OSI / FS: UO Legends
; Revision Date: 13/5/2009
; Purpose: Fish in a port or a boat 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 #false by default, you need to add fishSteaks
; at the Razor's Sell Agent
; %saveData - set #true for save data in fishing4x4Data.txt or #false
; it's #true by default
; %boatFishing - set #true for fishing from a boat or #false
; it's #false by default
;************************ Setup **********************************
gosub setup
;*********************** Main Loop *******************************
repeat
gosub fishing
gosub saveData
gosub moveBoat
gosub dropBoots
gosub dropSpecialFishes
until #CharGhost = YES
halt
;************************* Subs **********************************
sub setup
set %sellFishSteaks #false
set %saveData #true
set %boatFishing #false
set %poleType KDF
set %daggerType WSF
set %maxTimeOutScan 15
set %maxweight 570
set %totalTimeFishing 0
set %fishSteaksType IND
set %forward #true
finditem %poleType C_ , #charID
set %poleID #findID
finditem %daggerType C_ , #backpackID
set %daggerID #findID
gosub saveStartingData
return
sub saveData
if %saveData
{
set %loopTime #scnt - %startingLoopTime
set %totalTimeFishing %totalTimeFishing + %loopTime
set %loopTimeMinutes %loopTime / 60
set %totalTimeFishingMinutes %totalTimeFishing / 60
finditem %fishSteaksType C_ , #backpackID
set %nSteaks #findStack
set %nSteaksLoop %nSteaks - %nSteaksStartingLoop
set %totalSteaks %nSteaks
set %nSteaks %nSteaks - %nStartingSteaks
set %steaksPerHour ( %nSteaks * 3600 ) / %totalTimeFishing
execute SaveTextToFile.Vbs #false #false #curPath fishing4x4Data.txt
+ Time: #time $
+ Time fishing: %loopTime s %loopTimeMinutes min $
+ Total time fishing: %totalTimeFishing s %totalTimeFishingMinutes min $
+ Total Steaks: %totalSteaks $
+ Steaks Gained This Loop: %nSteaksLoop $
+ Total Steaks Gained: %nSteaks $
+ Steaks Per Hour: %steaksPerHour $
}
return
sub saveStartingData
if %saveData
{
finditem %fishSteaksType C_ , #backpackID
set %nStartingSteaks #findStack
set %startingTime #time
execute SaveTextToFile.Vbs #false #false #curPath fishing4x4Data.txt
+ Starting time: %startingTime $
+ Starting steaks: %nStartingSteaks
}
return
sub fishing
gosub startingLoopData
for %i 1 4
{
gosub sellFishSteaks
gosub fishingSpot
gosub tileName %1 %2
event sysmessage %1 %2
while #result = #true
{
gosub usePole
gosub scan
}
gosub cutFish
}
return
sub moveBoat
if %boat
{
if %forward
{
for %k 0 3
{
msg forward one $
wait 2s
set %forward #false
}
}
else
{
for %m 0 11
{
msg backwards one $
wait 2s
set %forward #true
}
}
}
return
sub startingLoopData
if %saveData
{
finditem %fishSteaksType C_ , #backpackID
set %nSteaksStartingLoop #findStack
set %startingLoopTime #scnt
}
return
sub fishingSpot
if %i = 1
gosub setTargets 4 4
if %i = 2
gosub setTargets 4 -4
if %i = 3
gosub setTargets -4 4
if %i = 4
gosub setTargets -4 -4
return
sub setTargets
set #lTargetKind 2
set #lTargetX #charPosX + %1
set #lTargetY #charPosY + %2
return
sub scan
set %timeout #scnt + %maxTimeOutScan
set %jrnl #jindex
scanjournal %jrnl
while #scnt < %timeout
{
if %jrnl < #jindex
{
set %jrnl %jrnl + 1
scanjournal %jrnl
}
set %spotWithFish fail_to_catch in #journal || pull_out in #journal &&
set %spotWithoutFish don't_seem_to_be_biting in #journal
if %spotWithFish
return #true
if %spotWithoutFish
return #false
}
return
sub UsePole
set #lTargetZ #tileZ
set #lObjectID %poleID
event macro 17
target
event macro 22
return
sub tileName
set %fishingPosX #charPosX + %1
set %fishingPosY #charPosY + %2
tile init
tile cnt %fishingPosX %fishingPosY
for %j 1 #tilecnt
{
tile get %fishingPosX %fishingPosY %j
set %canFish water in #tileName || jungle in #tileName
if %canFish
return #true
}
return
sub dropSpecialFishes
set %fishType YDF
finditem %fishType C_ , #backpackID
while #findKind <> -1
{
exevent drag #findID #findStack
wait 1s
exevent dropg #charPosX #charPosY
wait 1s
finditem %fishType C_ , #backpackID
}
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 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
wait 1s
finditem %bootsType C_ , #backpackID
}
return
sub sellFishSteaks
set %shouldSellFishSteaks %sellFishSteaks && #weight > #maxWeight
if %shouldSellFishSteaks = #true
{
finditem %fishSteaksType C_ , #backpackID
if #findKind <> -1
msg vendor sell $
wait 1s
if %saveData
gosub saveStartingData
}
else
{
if #weight > %maxWeight
halt
}
return