ScriptUO
Official ScriptUO EasyUO Scripts => Script Debug => Topic started by: VicVega on April 19, 2009, 02:09:21 AM
-
I was wondering if there is a better way to handle the spots where I can't fish in the fishing sub (too close spots or too far ones) in order to avoid them.
Right now the badspots are handle with "sub badspots" called from the fishing sub.
Also I would like to know if it's better to call the "badspots" passing parameters like this:
gosub badSpots %x %y
And then use %1 and %2 in the sub, or if it's the same and it does not improve stability.
set %poleType NSL_KSL
set %pathReconnect reconnect.txt
set %maxTimeOutScan 20
sub fishing
for %x -5 5
{
for %y -5 5
{
if #contkind = ORLB
call %pathReconnect
if #weight < %maxweight
{
event sysmessage %x %y
gosub badSpots
if #result = good
{
gosub usePole
gosub scan
deletejournal
gosub pickupFish
}
}
}
}
return
sub pickUpFish
finditem %fishType G_2
if #findkind <> -1
call pickupFish.txt
return
sub badSpots
if %x = -5 && %y = -5 ; too far
return bad
if %x = -5 && %y = 5 ; too far
return bad
if %x = -1 && %y = 0 ; too close
return bad
if %x = -1 && %y = -1 ; too close
return bad
if %x = -1 && %y = 1 ; too close
return bad
if %x = 0 && %y = -1 ; too close
return bad
if %x = 0 && %y = 0 ; too close
return bad
if %x = 0 && %y = 1 ; too close
return bad
if %x = 1 && %y = 0 ; too close
return bad
if %x = 1 && %y = -1 ; too close
return bad
if %x = 1 && %y = 1 ; too close
return bad
if %x = 5 && %y = -4 ; too far
return bad
if %x = 5 && %y = -5 ; too far
return bad
return good
sub scan
set %timeout #scnt + %maxTimeOutScan
set %jrnl #jindex
scanjournal %jrnl
while #scnt < %timeout
{
if %jrnl < #jindex
{
set %jrnl %jrnl + 1
scanjournal %jrnl
}
if ( mala_suerte in #journal || Pescaste in #journal )
{
set %timeout #scnt + %maxTimeOutScan
gosub usePole
}
if ( no_hay_peces in #journal || demasiado_lejos in #journal
+ || no_puedes_pescar in #journal || mejor_pesca in #journal )
{
wait 5
return
}
}
sub UsePole
set #lTargetKind 2
set #lTargetX #CHARPOSX + %x
set #lTargetY #CHARPOSY + %y
finditem %poleType
set #LOBJECTID #FINDID
event macro 17
target 3s
event macro 22
return
sub pickUpFish
finditem %fishType G_2
if #findkind <> -1
call pickupFish.txt
return
-
Will you be fishing from a boat? If so you can really simplify you code by only fishing once in each 8x8 resource block. You can look at my fisherman here, but the gist is that you only need to fish N, S, E, W and 4 spaces from your character. This covers the entire 8x8 resource allocation of UO.
Also, I think you saw how useful the journal can be for fishing, so you can use a journal scanner to tell when you have depleted your area or are fishing an an invalid area.
-
Where is that fisherman script?, I didn't find it
What do you mean only fishing once in each 8x8 block?
Right now my character fish in every spot that can be fished, if fish or fail to fish, tries again in the same spot, and when is depleted, it goes to the next one.
Why I don't think fishing only once per spot a good idea?
Because I would end my area of fishing very quickly without fishing all the fish around me.
I fish in ports over water, each time the character goes to fish, walks a random amount of steps in order to change the fishing zone.
-
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.
So I guess I didn't explain correctly. When I meant fish "once", I meant fish in one area of a 4x4 block and exhaust the fish. That effectively fishes out the whole area and then you just shift N,S,E,W to the next 4x4 block. You can effectively fish in one place constantly and never run out of places to fish and you'll only fail to fish 4 times. Try it, it works... ;)
Here's a link to my fish hunter:
http://www.scriptuo.com/index.php?topic=133.0
The other one is for the Elite members and that one handles collection, archery and slayer books, ancient AOS farming, etc.
Oh, and there are places in UO where you can use this 4x4 method off land so you don't even need a boat!
-
I always thought that the minerals, fishes, etc, where respawned tile by tile
The shard I play it's sphere 0.56b, if that matters
Thanks for the explanation but I don't know if I understood you correctly.
You mean that if I do my bucles to only fish in a 4x4 squares, and then in the other oposite 4x4 square, they do not deplete so quickly?
So:
11112222
11112222
11112222
11112222
33334444
33334444
33334444
33334444
Fish first in zone 1, then zone 2, then zone 3, then zone 4 and then move?
Or like this:
11111111
11111111
11111111
11111111
22222222
22222222
22222222
22222222
-
Great example!
Your first graphic explains it best. Picture yourself standing at the 4-corners of your example. What I do is just fish zone 1, then 2, then 3 and finally 4. By the time I've fished back to zone 1, the fish have nearly always replenished.
You may have to do some experimentation with Sphere. I can't speak for that server since I've never played a shard based on it. Only OSI and RunUO for me. But my guess is that it'll be something similar. Really it comes down to memory management and it's much more memory efficient to manage resources in 8x8 groups than it is to do it on a tile/tile basis. (read: hella-smaller - 64x compression)
-
Here's another look at what I do (using your example):
F111 222F
1111 2222
1111 2222
1111 2222
C
3333 4444
3333 4444
3333 4444
F333 444F
If you fish out to the 4 corners labeled by "F", it really doesn't matter where you are at in the world coordinates because you should aways be fishing into 4 different resources 8x8 squares.
-
I understand better now, so as I said, I fish over a port shape in a line form.
And each round the character goes fishing, I walk a random amount of steps from my initial fishing zone.
So, if for example I have 30 steps maximum to walk, I can make the first random amount of stepts between 0 and 8, and the next one between 8 and 16, and so on.
Would that improve the code and minimize the depleting zones?
Or I should better instead of fishing straight in line, fish something like this:
(http://i524.photobucket.com/albums/cc324/duncanHaleck/fishingZone.jpg)
-
I guess the most efficient way of getting away with this is to figure out a way to not move at all. I think that's why I first started using a ship instead of fishing from shore. Instead of physically moving your character, I just sail forward 16 spaces and I'm in a completely new set of resource spots. Finally I just don't really move the ship at all.
Is your need to move at all just a matter of style, or is there some other reason for it? I'm not sure if there's additional requirements on Sphere. I just know that I've been able to minimize the need to move at all.
-
Seeing from your picture, I'll bet you could get away with fishing and not moving at all. Again, there's probably something different from Sphere. But if you can get away with just fishing those 4 zones, then you only have 4 coordinates to set (you can even steal those from my fisher) and then a simple journal scanner.
-
In the shard I play there is no ships, I have to fish like this.
I moved the character because I thought the respawn was tile by tile.
So, something like this then:
(http://i524.photobucket.com/albums/cc324/duncanHaleck/portZones.jpg)
Or if I'm lucky, I can test first only the first zone, right?
-
NO SHIPS!?!?!? Barf!
Anyhow... ;)
Ya, that might simply things.
-
Some more aclarations that I still don't get:
F111 222F
1111 2222
1111 2222
1111 2222
C
3333 4444
3333 4444
3333 4444
F333 444F
Do you mean that if the character stands at C, it will deplenish all the fish in the Zone 1 (4x4 tiles) only fishing in the (-4, 4) spot (marked with F) ?
It wouldn't be necessary to fish on the other "Zone 1" spots marked with 1? They would be empty once fished the (-4, 4 ) spot?
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!
Also I don't understand this.
So a 8x8 zone has four 4x4 zones inside. If a 8x8 resource blocks is how UO handles the fish respawn and not 4x4 zones, then if you deplenish only one of the 4x4 zones, it wouldn't be also deplenishing the rest of the 8x8 zone?
If you fish out to the 4 corners labeled by "F", it really doesn't matter where you are at in the world coordinates because you should aways be fishing into 4 different resources 8x8 squares.
Do you mean "you should aways be fishing into 4 different resources 4x4 squares", instead of "you should aways be fishing into 4 different resources 8x8 squares." ?
I ask the question because of this:
I guess the most efficient way of getting away with this is to figure out a way to not move at all. I think that's why I first started using a ship instead of fishing from shore. Instead of physically moving your character, I just sail forward 16 spaces and I'm in a completely new set of resource spots. Finally I just don't really move the ship at all.
Is your need to move at all just a matter of style, or is there some other reason for it? I'm not sure if there's additional requirements on Sphere. I just know that I've been able to minimize the need to move at all.
Thanks for the help.
-
I talk about this with one of the shard's scripts and he told me this:
I don't know how it works in RunUO, but here if you fish in one spot, it will respawn in that spot in one hour, just that simple.
-
It might be worth some experimentation for you. I can only tell you how it works with OSI and RunUO. I've heard that Sphere is pretty different for some implementations and this might be one of them. 1 hour spawn time alone doesn't sound right. On OSI/RunUO it's around 10 minutes.
Oh, I definitely mean 4x4 when I'm talking about this method. Yes, it's 8x8 when it comes to the resource distribution, but if you stand anywhere in an 8x8 resource block and fish 4 spaces in any direction, you'll reach the neighboring 8x8 resource blocks. That's where the 4x4 method comes from that I'm talking about.
But again, this seems to be server distribution dependent. It would be pretty easy to throw together a test script validate this. From what it sounds like, I won't be running off to find a Sphere-based server any time soon for my fishing needs. :)
-
but if you stand anywhere in an 8x8 resource block and fish 4 spaces in any direction
4 spaces in any direction?, wasn't the point to try to only fish in one spot for each 4x4 set?, ergo, the 4 spaces shouldn't be random spots in any direction ...
So for fishing:
(-4,4) and then (-4,3) = wrong because there is no more fish after fishing in (-4,4), both spots are in the same 4x4 and 8x8 set
(-4,4) and then (4,4) = right because it's a different 4x4 set
Is this correct?
-
Ya, right. You definitely want to make your fishing attempt at the maximum distance in a direction (>=4). If you are fishing at +/-4, you are really covering a 9x9 box (-4...0...4) so this will lead to you fishing across to the next resource grids in each direction.
Again, you might want to verify this is in fact how it functions on your particular shard.
-
I really don't get the logic about it but I think I can make it work now.
(http://i524.photobucket.com/albums/cc324/duncanHaleck/4x4_fishing.png)
I hope it's more or less like I think. :-\
-
Nothing quite describes logic like code, so take a look at what's implemented in the fisherman here. ;)
-
I give up. I made a script that does exactly like in the pic, but it happened what I thought It would happen, instead of what I like it would happen ...
So, fish in -4 4 spot, after fishing a couple times it's deplenish, then fish on 4 4, and same with -4 -4 and 4 -4.
After fishing in those four spots (like 2 - 3 min, and some fishes ), there is no more fish and if it respawns every hour, what the hell do I do meanwhile?
It's not the complete code because it's too long.
sub fishing
for %i 1 4
{
if #contkind = ORLB
call %pathReconnect
if #weight > %maxweight
return
gosub fishingSpot %i
event sysmessage %1 %2
gosub usePole
gosub scan
wait 5
deletejournal
gosub pickupFish
}
return
sub fishingSpot
if %1 = 1
gosub setTargets 4 4
if %1 = 2
gosub setTargets 4 -4
if %1 = 3
gosub setTargets -4 4
if %1 = 4
gosub setTargets -4 -4
return
sub setTargets
set #lTargetKind 2
set #LTARGETX #CHARPOSX + %1
set #LTARGETY #CHARPOSY + %2
return
So I don't think I can improve my fish rate this way. :'(
My fishdata.txt (generated from my fish script, without improvements but works fine)
Time: 13:06:09
Initial Gold: 109309
Initial skill: 1122
Time: 13:19:12
Time fishing: 781 s 13 min
Total time fishing: 781 s 13 min
Gold: 110415
Gold Gain: 1106
Total Gold Gain: 1106
Skill: 1122
Skill Gain: 0
Time: 13:33:36
Time fishing: 852 s 14 min
Total time fishing: 1633 s 27 min
Gold: 111392
Gold Gain: 957
Total Gold Gain: 2063
Skill: 1122
Skill Gain: 0
...
-
Ouch. 1 hr respawn is just harsh. How committed are you to the shard you're on? Those are the kinds of things that make me start looking for something a bit more reasonable.
Did you determine if the fish are at each square, or distributed in an 8x8 area?
-
It might be a Sphere thing I suppose, I'm sure it works fine in OSI and RunUO. I prefer to move on to another scripts, and thanks for the help, I learned things trying to solve this.
This is the script I'm currently using to fish, in case anyone wants to see how it works:
;=================================================================
; Script Name: Fishing Script
; Author: VicVega
; Version: 0.1
; Shard OSI / FS: FS EpsilonUO
; Revision Date: 15/4/2009
; Purpose: Fish, sells the fish, and fish again
; Globals: None
;=================================================================
;************************ Setup **********************************
gosub setup
;*********************** Main Loop *******************************
repeat
if #contkind = ORLB
call %pathReconnect
else
{
set %initialRoundTime #scnt
set %initialRoundGold #gold + %goldCorrection
set %initialRoundSkill #skill
call eatFood.txt
gosub fishingPos
call hidingSub.txt
gosub fishing
gosub dropFish
gosub sell
gosub saveData
call saveMoney.txt
}
while #CharGhost = YES
wait 0
until #CharGhost = YES
;************************* Subs **********************************
sub setup
set %fishType GQD_TLW_VLW_DMW_LGW_NGW_GMW_FQD_OGW_WLW_
+YLW_DQD_SLW_ULW_FMW_EMW_XLW_RLW_EQD_NMW
set %poleType NSL_KSL
set %pathReconnect reconnect.txt
set %maxTimeOutScan 15
set %maxTilesToWalk 23
set %maxweight #maxweight - 15
set %vendorPosX 1372
set %vendorPosY 3894
set %vendorID PTGB
set %charPosX 1372
set %charPosY 3895
set %goldCorrection 131072
set %fishingLocation = 1
set %path c:\euo\ ; Easy UO scripts path
chooseSkill Fish
gosub dataSetup
return
sub badSpots
if ( ( %x = -6 && -6 >= %y <= -3 ) || ( %x = -6 && 3 >= %y <= 6 ) || ( %x = -5 && -6 >= %y <= -5 )
+ || ( %x = -5 && 6 >= %y <= 5 ) || ( %x = -4 && %y = -6 ) || ( %x = -4 && %y = 6 )
+ || ( %x = -3 && %y = -6 ) || ( %x = -3 && %y = 6 ) || ( %x = -1 && %y = -6 )
+ || ( %x = -1 && 1 >= %y <= -1 ) || ( %x = -1 && %y = 6 ) || ( %x = 0 && %y = -6 )
+ || ( %x = 0 && 1 >= %y <= -1 ) || ( %x = 0 && %y = 6 ) || ( %x = 1 && %y = -6 )
+ || ( %x = 1 && 1 >= %y <= -1 ) || ( %x = 1 && %y = 6 )
+ || ( %x = 3 && %y = -6 ) || ( %x = 3 && %y = 6 ) || ( %x = 4 && %y = -6 ) || ( %x = 4 && %y = 6 )
+ || ( %x = 5 && -6 >= %y <= -5 ) || ( %x = 5 && 6 >= %y <= 5 )
+ || ( %x = 6 && -6 >= %y <= -3 ) || ( %x = 6 && 3 >= %y <= 6 ) )
return #false
return #true
sub fishing
for %x -6 6
{
for %y -6 6
{
if #contkind = ORLB
call %pathReconnect
if #weight > %maxweight
return
gosub badSpots
while #result = #true
{
gosub usePole
gosub scan
}
wait 5
deletejournal
gosub pickupFish
}
}
return
sub sell
move %vendorPosX %vendorPosY 0 60s
finditem %vendorID
if #findkind <> -1
move #findx #findy 1 60s
call sellSub.txt
return
sub fishingPos
set %random #random % %maxTilesToWalk
set %newPosY %charPosY + %random
move %charPosX %newPosY 0 60s
return
sub scan
set %timeout #scnt + %maxTimeOutScan
set %jrnl #jindex
scanjournal %jrnl
while #scnt < %timeout
{
if %jrnl < #jindex
{
set %jrnl %jrnl + 1
scanjournal %jrnl
}
if ( mala_suerte in #journal || Pescaste in #journal )
return #true
if ( no_hay_peces in #journal || mejor_pesca in #journal )
return #false
}
if #targCurs = 1
set #targCurs 0
}
return
sub UsePole
set #lTargetKind 2
set #lTargetX #CHARPOSX + %x
set #lTargetY #CHARPOSY + %y
finditem %poleType
set #LOBJECTID #FINDID
event macro 17
target 3s
event macro 22
return
sub pickUpFish
finditem %fishType G_2
if #findkind <> -1
call pickupFish.txt
return
sub dataSetup
set %totalGoldGain 0
set %totalTime 0
set %initialGold #gold + %goldCorrection
set %initialTime #time
set %initialSkill #skill
execute SaveTextToFile.Vbs #false #false %path fishingData.txt
+ Time: %initialTime $
+ Initial Gold: %Initialgold $ Initial skill: #skill $ $
return
sub saveData
set %gold #gold + %goldCorrection
set %goldGain #gold - %initialRoundGold + %goldCorrection
set %totalGoldGain %totalGoldGain + %goldGain
set %time #scnt - %initialRoundTime
set %totalTime %totalTime + %time
set %timeMinutes %time / 60
set %totalTimeMinutes %totalTime / 60
set %skill #skill - %initialSkill
execute SaveTextToFile.Vbs #false #false %path fishingData.txt
+ Time: #time $ Time fishing: %time s %timeMinutes min $
+ Total time fishing: %totalTime s %totalTimeMinutes min
+ $ Gold: %gold $ Gold Gain: %goldGain $
+ Total Gold Gain: %totalGoldGain $
+ Skill: #skill $ Skill Gain: %skill $ $
return
-
So that you know you haven't been wasting your time on this, I have changed shard (this time RunUO) and now the Script 4x4 Fishing I made it seems to work like charm. After I test it a little longer I will post it in the forum.
-
Good to hear! At least you got something going that's we useful.