petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 21, 2005 11:20:05 GMT -5
Sure thing tiny!
I'll try to post it at lunch or after my cross country today. It's your script prettymuch, but I gotta add autosort to it, and I also gotta add another function.
I tried to revamp most of it, but it ended up being lengthy and complex too, so it didnt run as fast as I thought too. So then I'm going to use your script as main body, and then just little functions.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 21, 2005 15:02:10 GMT -5
This is missing a Texteditor, or a textreader, so it can tell you when you have a fish.
I used DarkAquas's string split to determine if you have a fish or not. I think that section works.... I got your script to work which acts as the main body of script.
When you're done fishing then the bot logs off. Until I add Itemsort.
Thanks for the script starts you guys. I hope this one is WAY better than the last one.
My first script I mod from other peoples work.
$BarWidth=64 $BarX=708 $BarY=567 $RedThreshold=128 $CurrentDirection = 4 $hex = Hex(PixelGetColor( $BarX , $BarY ), 6 ) $R = Dec(StringRight( $hex , 2 )) & "|" $G = Dec(StringMid($hex , 3 , 2 )) & "|" $B = Dec(StringLeft($hex , 2 )) $CurrentItemSpace = 23 ; Tiny, this is my itemspace before I go fishing. I'm going to mod this so then I make an autosort function. ; Itemspace is used as your current space, I will use this with a textreader, If I can learn how to make one, or find one, this will help with Autosort.
Func GetRedLevels() Dim $RedLevels[$BarWidth] For $x=0 to $BarWidth Step 1 $PixelColor=PixelGetColor($x+$BarX,$BarY) $PixelHex=Hex($PixelColor,StringLen($PixelColor)) $RedHex=StringLeft($PixelHex,2) $RedLevels[$x]=Dec($RedHex) Next Return $RedLevels EndFunc
Func GetStaminaPercent($RedLevels) $Stamina=0 For $x=0 to $BarWidth Step 1 If $RedLevels[$x]>$RedThreshold Then $Stamina=$Stamina+1 Else Return $Stamina/$BarWidth Endif Next Return 100 EndFunc
; I changed toggle a little bit, because AutoIT seems to think that the $CurrentDirection can only hold small text without the " " in front it. So I set it up to be If statements, and a value. :D
Func ToggleDirection() If $CurrentDirection = 4 Then $CurrentDirection = 6 ElseIf $CurrentDirection = 6 Then $CurrentDirection = 4 EndIf Return $CurrentDirection; EndFunc
Func FishFight()
$OldStamina=100; //Old stamina variable set to 100 $StaminaPercent=100; //Stamina variable set to 100 $CurrentDirection = 4 $Interval=500 AutoItSetOption ("SendKeyDownDelay",$Interval) Do $StaminaPercent=GetStaminaPercent(GetRedLevels())
If $StaminaPercent > $OldStamina Then ToggleDirection() EndIf
$OldStamina=$StaminaPercent; //Set $OldStamina to $StaminaPercent If $CurrentDirection = 4 Then Send( "{NUMPAD4}" ) ElseIf $CurrentDirection = 6 Then Send( "{NUMPAD6}" ) EndIf Sleep($Interval)
Until $StaminaPercent = 0
Send( "{ENTER}" )
EndFunc
Func CheckPixelRBG() $hex = Hex(PixelGetColor( $BarX , $BarY ), 6 ) $R = Dec(StringRight( $hex , 2 )) & "|" $G = Dec(StringMid($hex , 3 , 2 )) & "|" $B = Dec(StringLeft($hex , 2 )) EndFunc
Do
Do CheckPixelRBG() Until $R > $Redthreshold
FishFight()
$CurrentItemSpace = $CurrentItemSpace + 1
Sleep( 5000 )
Send( "!1" )
Until $CurrentItemSpace = 40
Send( "/logout" )
Lemme know if this is a good script or not. Hope it is, and It works 100% for me, this is configured formy pixels. I'll research more about Autosort.
Any suggestions about this, please lemme know. I want this to be user-friendly.
(Tiny cause you helped me with this script, I hope it's allright if I just leave you with the "Rights" to this. )
|
|
|
Post by TinyTerror on Oct 21, 2005 17:51:05 GMT -5
It looks fine to me.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 21, 2005 23:16:05 GMT -5
Oh, and I tested it today si~
It works like a charm. I may want to lower the Incriment it checks on, sometimes the fish swiched even though it's already a half second. Maybe a quarter second..... That'd be as low as it could be.
Edit the script as well. From:
ElseIf $CurrentDirection="{NUMPAD6}" Then $CurrentDirection="{NUMPAD4}"
To: ElseIf $CurrentDirection = 6 Then $CurrentDirection = 4
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 23, 2005 17:14:28 GMT -5
Ok tiny. One last thing. I dont know anything about this error I keep getting in the fishbot. I tested it out before and it worked fine, but now it dosent, and I dont get it. This is the error: Line 0 (File "C:\Documents And settings.....) $RedLevels[$x]=Dec($RedHex) ^ERROR Error: Array variable has incorrect number of subscripts or subsctipt dimension range exceded. I don't get what that says. It means something with I think the Dimensional array is off or something, but I don't know how to fix that. Something that may help me fix it is that in the redlevels variable, I don't know what the [] brackets mean/do around a sequencial variable. Could you tell me that as well? (Oh, if you would as well, don't think I havent looked into this. I can't find a solution to the error in the DIM arrary)
|
|
|
Post by TinyTerror on Oct 23, 2005 19:40:46 GMT -5
Try making the line Dim $RedLevels[$BarWidth] into Dim $RedLevels[$BarWidth+10]. That will give the array an extra 10 slots, and will avoid off by one overruns.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 24, 2005 22:29:19 GMT -5
Ok. thanks for that. I think it's a little laggy now, and it dosent quite read it right methinks..... OR something.
I just noticed its slower right now.... it reels in for me, but not quite enough to catch the legendary fish which awalys seem to evade me. Oh. and those darn sardiens. I wanna know if there is a way that this script could be speeded-up
I recall you saying a few sleep statements here and there, but I don't see how this could help it aside from slow it a little more. Any ideas?
|
|
|
Post by TinyTerror on Oct 24, 2005 22:31:50 GMT -5
Is the game slowing down, or the script? You could try making the interval variable like 100ms, or readying a small range of pixels near the last known stamina line to speed things up.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 25, 2005 8:43:57 GMT -5
Well... I noticed the game script sorta is, mainly in game is when it is.... >.> And that's about all I can think of that slows down, yeah. In game for sure.
How would I "ready" this range of pixels as well? Is it something like making a different set of PixelGetColor for the range of X1, Y1 in the last little bar segment?
|
|
|
Post by TinyTerror on Oct 25, 2005 9:40:45 GMT -5
One thing you will find out about pixel operations is that they are one of the slowest possible things you can do in a script. To speed up a script, you want to get rid of as many pixel reads as you can. For the script in this thread, there are a couple ways that this could be done. The first way (a little harder to code) is to take the last known stamina, or the x coordinate where the pixels turned from life bar to empty bar, and only check the colors of the 10 pixels to the right and left of it. This will cut your pixel checks down a great deal, speeding up the script, while still telling you the stamina of the fish. If I were you, I would leave this method until you are more comfortable with the mechanics of the script. Insted, you might want to try checking only every other pixel in the stamina bar. This will reduce your pixel reads by half, and still give you fairly good accuracy in determining the fish's stamina. You can do this by changing the Step parameter in the GetRedLevels function to 2. You will also need to write the same value that you got from each pixel read to the element behind it in the array. The function might be something like this:
Func GetRedLevels() Dim $RedLevels[$BarWidth] For $x=1 to $BarWidth Step 2 $PixelColor=PixelGetColor($x+$BarX,$BarY) $PixelHex=Hex($PixelColor,StringLen($PixelColor)) $RedHex=StringLeft($PixelHex,2) $RedLevels[$x]=Dec($RedHex) $RedLevels[$x-1]=Dec($RedHex) Next Return $RedLevels EndFunc
The trade off here is that you are giving up a very small bit of precision for speed. If you want some help implimenting the first method, I might be willing to lend a hand. Give the second method a try first though to see how well it works.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 25, 2005 14:48:29 GMT -5
I will test the second method, I've already finished scripting with the idea you gave me. I'll post an updated version of the script once I test it. I can't test it till the weekend though, I got homework on the weekdays, and It's a little difficult to crunch while I'm trying to test a script as well.
(Oh si, I was thinking, and Can't think of much that would require scripting in FFXI. or what is semi-easily bottable, aside from skillup scripts. Made one of those already, I thought it was a little too easy.) What esle is bottable in FFXI?
|
|
|
Post by TinyTerror on Oct 25, 2005 14:53:39 GMT -5
There isn't all that much to bot. Im building Lunar as more of a platform for building tools for the game. While Lunar can automate stuff like crafting or AH stuff, its strong point is extracting and displaying information to the user in-game. Once the alpha is out, I will be adding finer grained control functions as well as pixel color and checksum functionality to bring Lunar closer in line with what autoit could do. If you enjoy writing bots, come up with some new ideas and maybe I can work them into Lunar.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 25, 2005 14:57:14 GMT -5
That would be kickass. I'll post when I get home, Along with hopefully the refined script.
I'll be sure to be thinking of different features to suggest.
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 25, 2005 15:00:10 GMT -5
Ahh during school, whatever. I gotta go to lunch like right now. Here;s the script. I'll see if I can test it as soon as I can. It compiles clean, but I just got a hunch there could be something up with the Dim array again.
$BarWidth=64 $BarX=708 $BarY=567 $RedThreshold=128 $CurrentDirection = 4
$hex = Hex(PixelGetColor( $BarX , $BarY ), 6 ) $R = Dec(StringRight( $hex , 2 )) & "|" $G = Dec(StringMid($hex , 3 , 2 )) & "|" $B = Dec(StringLeft($hex , 2 )) $CurrentItemSpace = 23 ; Tiny, this is my itemspace before I go fishing. I'm going to mod this so then I make an autosort function. ; Itemspace is used as your current space, I will use this with a textreader, If I can learn how to make one, or find one, this will help with Autosort.
Func GetRedLevels() Dim $RedLevels[$BarWidth + 10] For $x=0 to $BarWidth Step 2 $PixelColor=PixelGetColor($x+$BarX,$BarY) $PixelHex=Hex($PixelColor,StringLen($PixelColor)) $RedHex=StringLeft($PixelHex,2) $RedLevels[$x]=Dec($RedHex) $RedLevels[$x - 1]=Dec($RedHex) Next Return $RedLevels EndFunc
Func GetStaminaPercent($RedLevels) $Stamina=0 For $x=0 to $BarWidth Step 1 If $RedLevels[$x]>$RedThreshold Then $Stamina=$Stamina+1 Else Return $Stamina/$BarWidth Endif Next Return 100 EndFunc
; I changed toggle a little bit, because AutoIT seems to think that the $CurrentDirection can only hold small text without the " " in front it. So I set it up to be If statements, and a value. :D
Func ToggleDirection() If $CurrentDirection = 4 Then $CurrentDirection = 6 ElseIf $CurrentDirection = 6 Then $CurrentDirection = 4 EndIf Return $CurrentDirection; EndFunc
Func FishFight()
$OldStamina=100; //Old stamina variable set to 100 $StaminaPercent=100; //Stamina variable set to 100 $CurrentDirection = 4 $Interval=300 AutoItSetOption ("SendKeyDownDelay",$Interval) Do $StaminaPercent=GetStaminaPercent(GetRedLevels())
If $StaminaPercent > $OldStamina Then ToggleDirection() EndIf
$OldStamina=$StaminaPercent; //Set $OldStamina to $StaminaPercent If $CurrentDirection = 4 Then Send( "{NUMPAD4}" ) ElseIf $CurrentDirection = 6 Then Send( "{NUMPAD6}" ) EndIf Sleep($Interval)
Until $StaminaPercent = 0
Send( "{ENTER}" )
EndFunc
Func CheckPixelRBG() $hex = Hex(PixelGetColor( $BarX , $BarY ), 6 ) $R = Dec(StringRight( $hex , 2 )) & "|" $G = Dec(StringMid($hex , 3 , 2 )) & "|" $B = Dec(StringLeft($hex , 2 )) EndFunc
Do
Do CheckPixelRBG()
Until $R > $Redthreshold
FishFight()
$CurrentItemSpace = $CurrentItemSpace + 1
Sleep( 8000 )
Send( "!1" )
Until $CurrentItemSpace = 40
Send( "/logout" ) Just copied and pasted from my USB, so I still have some comments from before. After school
--Peter Romo
|
|
petar113507
Full Member
Damn Straight. I Am the king of waffelagia.
Posts: 166
|
Post by petar113507 on Oct 26, 2005 11:26:58 GMT -5
Tiny, the new part works pretty darn well, but the client side of processing went pretty darn slow. But it worked better than before. I'll look into a different way to test this over the weekend. Friday expect more testing from me.
|
|