MasonMill Posted August 7, 2009 Share Posted August 7, 2009 Hi, I have a character in a game that I want to swing a weapon. When is weapon breaks I want to arm a new weapon. So i set the pixel search box in the box on the game where the weapon is displayed, when it breaks the weapon disappears from the box. When that happens i would like it to push the 5 key which arms a new one from my bag. It doesnt seem to do this tohugh. I am not a skilled scripter but i have been looking at the help manual and all over the net for days. I know there is something blatantly obvious that I don't understand. The while loop keeps me swinging the weapon, that is working fine. Just not the re-arm. Here is the script. WinWaitActive("Darkfall Online") AdlibEnable("pause", 250); this keeps running at all times till you exit. HotKeySet("{pause}","pauseset"); uses the pause key to change the value of $Pause HotKeySet("{F12}","exitscript") $Pause = -1 While 1 Send("6") Sleep(2000) WEnd $coord = PixelSearch( 1527, 763, 1569, 803, 0xF74D31, 20 ) If Not $coord = "0xF74D31" Then Sleep(1000) Send("5") EndIf Func pauseset() $Pause = $Pause * -1 EndFunc Func pause() While $Pause = -1 Sleep(500) Wend EndFunc Func exitscript() Exit EndFunc Link to comment Share on other sites More sharing options...
mistersquirrle Posted August 7, 2009 Share Posted August 7, 2009 (edited) $coord = PixelSearch( 1527, 763, 1569, 803, 0xF74D31, 20 ) If Not $coord = "0xF74D31" Then Sleep(1000) Send("5") EndIf The PixelSearch command returns the coordinates of where the color's found in an array. So if that's saying that $coord[0] = 1527 and $coord[1] = 763 or something like that. Try something like this: While 1 $coord = PixelSearch(1527, 763, 1569, 803, 0xF74D31, 20) If Not @error Then Sleep(1000) Send("5") EndIf WEnd Also, this part: While 1 Send("6") Sleep(2000) WEnd The script is never getting past that part, so I'd suggest using the code I gave, and making that a function, and at the end of that loop calling that function and taking out the while loop, so: While 1 Send("6") Sleep(2000) _WeaponCheck() WEnd Func _WeaponCheck() $coord = PixelSearch(1527, 763, 1569, 803, 0xF74D31, 20) If Not @error Then Sleep(1000) Send("5") EndIf EndFunc ;==>_WeaponCheck Edited August 7, 2009 by mistersquirrle We ought not to misbehave, but we should look as though we could. Link to comment Share on other sites More sharing options...
jebus495 Posted August 7, 2009 Share Posted August 7, 2009 If you can narrow your search down to one pixel that doesn't change unless your weapon breaks it would probably be faster to use PixelGetColor Just find out what the color would change to when your weapon breaks. $brokenweap = PixelGetColor(coords) If $brokenweap = 0xcolor Then Reequip weapon? EndIf Hope that made sense lol. I'm not great at putting what's in my head into words. Link to comment Share on other sites More sharing options...
MasonMill Posted August 7, 2009 Author Share Posted August 7, 2009 Awesome! thanks guys i will go try all those. and you are right i think the get pixelcolor will be better. Link to comment Share on other sites More sharing options...
MasonMill Posted August 7, 2009 Author Share Posted August 7, 2009 Ok so I augmented the script according to you guys' suggestions and this is what I came up with. Unfortunately the pixelgetcolor section of it is terminating my script. The second I click on the game window the script disappears from the toolbar and closes. I know it was that section because I took it out and put it by its self and it did the same thing. Is there something I'm missing? here is the new one. WinWaitActive("Darkfall Online") AdlibEnable("pause", 250); this keeps running at all times till you exit. HotKeySet("{pause}","pauseset"); uses the pause key to change the value of $Pause HotKeySet("{F12}","exitscript") $Pause = -1 $brokenweap = PixelGetColor(1546,792) If $brokenweap = 0x3D3236 Then Sleep(1000) Send("5") EndIf Func pauseset() $Pause = $Pause * -1 EndFunc Func pause() While $Pause = -1 Sleep(500) Wend EndFunc Func exitscript() Exit EndFunc Link to comment Share on other sites More sharing options...
MasonMill Posted August 7, 2009 Author Share Posted August 7, 2009 Oh and it just terminates when the weapon is gone, so like it sees that pixel color and terminates. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now