Physical Posted October 20, 2008 Share Posted October 20, 2008 expandcollapse popupHotKeySet("{HOME}", "Automate") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") Global $Paused, $MobHP, $Count, $BuffCount, $Drop $Count = 0 $BuffCount = 3 $Drop = 0 While 1 Sleep (100) WEnd Func Automate() Do If $BuffCount = 3 Then Send ("{4}") Sleep (1000) $BuffCount = 0 ElseIf $BuffCount < 3 Then $BuffCount = $BuffCount + 1 EndIf $MobHP = PixelGetColor (415, 25) ;Checks target hp If $MobHP <> 0xD63839 Then ;If no target or target dead then Send ("{TAB}") ;Select target EndIf Sleep (100) Send ("{3}") ;Attack Sleep (1000) $MobHP = PixelGetColor (415, 25) ;Check target hp While $MobHP = 0xD63839 ;If target is alive then continue to attack $MobHP = PixelGetColor (415, 25) Send ("{3}") Sleep (500) WEnd Sleep (1500) While $Drop < 4 ;Collect Drops <---- TROUBLE IS HERE Send ("{SPACE 2}") Sleep (1000) $Drop = $Drop + 1 WEnd $Drop = 0 Send ("{0}") Sleep (7000) Until $Count = 10000 EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Terminate() Exit 0 EndFunc This is a script to act as a simple macro for a game, kill, loot, use skill on corpse, repeat. Very simple. The problem is in the collecting the drops. I have tried to seperate the code in every way i can think of. I put it in loops, i put it in functions, i put it in IF statements. It will work just fine for a while and then randomly it will completely skip the drop collection after killing the monster and go straight to using the skill on the corpse. I can't for the life of me figure out why. If anyone could please explain to me what i need to do/ direct me to helpfile section i would greatly appreciate it. Also if anyone happens to notice something i can do differently that would improve my coding methods i would appreciate any advice. I recoded this script about 3 or 4 different ways redoing the entire script trying to figure out this problem. Thankyou for any help. Link to comment Share on other sites More sharing options...
dbzfanatic Posted October 20, 2008 Share Posted October 20, 2008 (edited) You told it to only collect the dropped items for times. Change that. Edit: are you sure it's skipping and the problem isn't there's just nothing to pick up? Also if you want it to be an infinite loop do something like Until 0 > 1 or something,no need to waste memory on an unnecessary variable. Also try AdlibEnable and/or GUIOnEventMode, that way you can interrupt the action at any time. Edited October 20, 2008 by dbzfanatic Go to my website. | My Zazzle Page (custom products)Al Bhed Translator | Direct linkScreenRec ProSimple Text Editor (STE) [TUTORIAL]Task Scheduler UDF <--- First ever UDF!_ControlPaste() UDF[quote name='renanzin' post='584064' date='Sep 26 2008, 07:00 AM']whats help ?[/quote] Link to comment Share on other sites More sharing options...
Physical Posted October 20, 2008 Author Share Posted October 20, 2008 (edited) yes i only want it to pickup 4 times, usually there are only 2 things to pickup. The problem is its completely skipping the pickup part altogether and going directly to the using skill on corpse part. I will read up on the onguievent thing because i dont know how to use the function. I will look and see if that helps. Thankyou for the help and any further help from anyone would be appreciated. Edit - I read about the GUIOnEvent function and i am not sure how it could be used in this situation. It seems to me this is for gui buttons being pushed or clicked or an action taken on the window itself like minimize or close. In the situation of this script there are no buttons to push in the actual window, everything is controled with keyboard commands. Edited October 20, 2008 by Physical Link to comment Share on other sites More sharing options...
bogQ Posted October 20, 2008 Share Posted October 20, 2008 yes i only want it to pickup 4 times, usually there are only 2 things to pickup. The problem is its completely skipping the pickup part altogether and going directly to the using skill on corpse part. I will read up on the onguievent thing because i dont know how to use the function. I will look and see if that helps. Thankyou for the help and any further help from anyone would be appreciated. Edit - I read about the GUIOnEvent function and i am not sure how it could be used in this situation. It seems to me this is for gui buttons being pushed or clicked or an action taken on the window itself like minimize or close. In the situation of this script there are no buttons to push in the actual window, everything is controled with keyboard commands. i think that your problem is in If no target or target dead then, becose you dont have collect in it so he can see that the target is dead and dont collect items try something like this to see if itl work expandcollapse popupHotKeySet("{HOME}", "Automate") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") Global $Paused, $MobHP, $Count, $BuffCount, $Drop $Count = 0 $BuffCount = 3 $Drop = 0 While 1 Sleep (100) WEnd Func Automate() While 1 If $BuffCount = "3" Then Send ("{4}") Sleep (1000) $BuffCount = "" Else $BuffCount = $BuffCount + 1 EndIf If PixelGetColor(415, 25) <> "0xD63839" Then;If no target or target dead then collect() Send ("{TAB}");Select target Sleep(1000) EndIf Send ("{3}");Attack Sleep (1000) While PixelGetColor(415, 25) = "0xD63839";If target is alive then continue to attack Send ("{3}") Sleep (500) WEnd collect() Sleep (1500) Send ("{0}") Sleep (7000) WEnd EndFunc Func collect() Do;Collect Drops <---- TROUBLE IS HERE Send ("{SPACE 2}") Sleep (1000) $Drop = $Drop + 1 Until $Drop = "3" $Drop = "" EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Terminate() Exit 0 EndFunc TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.  Link to comment Share on other sites More sharing options...
Physical Posted October 20, 2008 Author Share Posted October 20, 2008 (edited) Thanks for your help. Last night when i got home from work i worked on the script some more and found the problem. It was a combination of the method i was using to target and check the hp of mobs and the delays i had set. The reason the script was skipping lines randomly is because it was basicly getting ahead of itself and kept exiting the loops sooner then i wanted it to and continuing on in the script. Since it left the loop early it made the other conditional statements false and would skip them entirely which meant it was trying to collect drops when no drops were present due to the mob still being alive. Thanks for all the help tho, u guys have given me some good ideas. Writing these little scripts for a game like this helps me learn a lot because i have to think about things i wouldnt normally think about like it exiting the loops. Thanks for all the help. Here is the new script which a change i just made. BogQ in your example u used While loops instead of Do loops which seems like a good idea and possibly a more efficent way of doing it. (i am not sure which loop is more efficent but in this case i like the while one) So i replaced my Do loops which the while loops. Here is the new script: expandcollapse popupHotKeySet("{HOME}", "Automate") HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{END}", "Terminate") Global $Paused, $MobHP, $BuffCount, $Drop $BuffCount = 3 $Drop = 0 While 1 Sleep (100) WEnd Func Automate() Do If $BuffCount = 3 Then Send ("{4}") Sleep (1000) $BuffCount = 0 ElseIf $BuffCount < 3 Then $BuffCount = $BuffCount + 1 EndIf $MobHP = PixelGetColor (412, 25) ;Check target hp If $MobHP <> 0xD63839 Then ;If no target or target dead While $MobHP <> 0xD63839 ;Continue selecting new target until live target is found Send ("{TAB}") ;Select target Sleep (1500) $MobHP = PixelGetColor (412, 25) ;Check target hp WEnd EndIf $MobHP = PixelGetColor (412, 25) ;Check target hp If $MobHP = 0xD63839 Then ;Placed actions in If statment to protect against accidental out of loop situations While $MobHP <> 0x81714A ;Continue attack until target is dead Send ("{3}") ;Attack Sleep (250) $MobHP = PixelGetColor (412, 25) ;Check target hp WEnd Send ("{0}") ;Use Skill Sleep (7000) While $Drop < 4 ;Collect Drops Send ("{SPACE}") Sleep (500) $Drop = $Drop + 1 WEnd EndIf $Drop = 0 Until 0 > 1 EndFunc Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) WEnd EndFunc Func Terminate() Exit 0 EndFunc Edited October 20, 2008 by Physical 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