Jump to content

Sytax help


dirtybob
 Share

Recommended Posts

Here is some code im working on for a World of warcraft bot. I belive i have some sytax erros. Ill post the code. then what im trying to do with it.

; <AUT2EXE VERSION: 3.1.0.4> 

; ---------------------------------------------------------------------------- 
; <AUT2EXE INCLUDE-START: C:\Documents and Settings\Home\My Documents\NutralBot.au3> 
; ---------------------------------------------------------------------------- 

; ************************************************** ************************************************** **** 
; NutralBot by Dirtybob. 
; Stuff that you may need to know. 
; Color of nutral mobs = 0xD2CF00 
; Color of hostile mobs = 0xD20000 
; When you use "sleep(XXX)" to wait in AutoIT 1000=1 second

; Globals 
$win_title = "World of Warcraft" 

; Sets the "Pause" Key to Exit the bot. 
HotKeySet("{PAUSE}", "EndScript") 



; Fires up WOW, puts it on top. I recomend Windowed Mode. 
WinActivate($win_title, "") 
WinSetOnTop($win_title, "", 0) 
Sleep(1000) 




; Checks your toons life, its its too low it sits down to rest.
Func Life_Check()
while 1
$Coord = PixelSearch ( 0, 0, 172, 76, 0x00D100 , 0, 0 ) 
ToolTip("Toon Health looks good.", 486, 277)
send("Z")
sleep(1000)
If @error Then 
ToolTip("Toon Heath is low!", 486, 277)
Send("X")
sleep(15000)
endif
wend
EndFunc 

; Looks for a mob
func Find_Mob() 
Send("{TAB}") 
sleep(500) 
While 1 
$Coord = PixelSearch ( 0, 0, 271, 62, 0xD20000 , 0, 0 ) 
Pull_Mob()
If @error Then 
sleep(1000) 
Life_Check()
Find_Mob() 
EndIf 
Wend 
EndFunc 

; Pulls the mob by shooting, or whatever ranged you have set to key 8
Func Pull_Mob()
Send("8")
Sleep(2500)
Attack_Mob()
EndFunc

; Attacks useing the defualt attack key 1
Func Attack_Mob()
While 1
$Coord = PixelSearch ( 0, 0, 371, 61, 0xD20000 , 0, 0 ) 
Send("1")
ToolTip("Mob is still alive.", 486, 277)
if @error then
ToolTip("Mob is dead, looting!", 486, 277)
Loot_mob()
endif
wend
Endfunc

; Trys to loot the mob
Func Loot_mob()
send("{SHIFTDOWN}") 
MouseClick("right", 507, 360, 1, 1)
send("{SHIFTUP}")
endfunc

Life_Check()
Find_Mob() 
Pull_Mob()

; Exits the Bot. 
Func EndScript() 
$exit = MsgBox(4, "Ender", "Exit the Bot?") 
If $exit = 6 Then 
Exit 
EndIf 
EndFunc

Everything seems to work except the Attack_Mob() function. Im not sure how to set it up so that it will send the 1 key once and only once and then do nothing untill

$Coord = PixelSearch ( 0, 0, 371, 61, 0xD20000 , 0, 0 ) returns an erorr.

i cant figure it out to save my life.

What it does now is Spam the 1 key over and over. It only needs to be sent once. its like a toggle for attacking or to stop attacking.

Also in this game when the mob does, the red color at PixelSearch ( 0, 0, 371, 61, 0xD20000 , 0, 0 ) disapears. thats when i want to stop the attack, and call the Loot_mob() function.

any ideas?

i havent had any luck with the Do...Until loops.

ty

Link to comment
Share on other sites

Hi,

nice idea... could become very handy to grab the needed 1.000 pieces of heavy leather I need to satisfy the Thorium-Brotherhood. ;)

How about this changes? (I have to admit that I did not check it, since I don't have WoW installed in my office) :mad2:

Func Attack_Mob()
    While 1
        $coord = PixelSearch(0, 0, 371, 61, 0xD20000, 0, 0)
        If @error Then
            ToolTip("Mob is dead, looting!", 486, 277)
            Loot_mob()
            ExitLoop
        Else
            Send("1")
            ToolTip("Mob is still alive.", 486, 277)
        EndIf
    WEnd
EndFunc ;==>Attack_Mob

Overall, there are way too much

while 1
   ...
wend

loops without any ExitLoop in your code. And FindMob() calls itself...Looks odd to me :P

best regards

Marc

Edited by Marc

Any of my own codes posted on the forum are free for use by others without any restriction of any kind. (WTFPL)

Link to comment
Share on other sites

  • Moderators

Everything seems to work except the Attack_Mob() function. Im not sure how to set it up so that it will send the 1 key once and only once and then do nothing untill

$Coord = PixelSearch ( 0, 0, 371, 61, 0xD20000 , 0, 0 ) returns an erorr .

Maybe something like this?

Func Attack_Mob()
Local $Coord = PixelSearch(0, 0, 371, 61, 0xD20000); Step "0" is not an option
Do
    Sleep(100)
Until Not $Coord = 1
Send("1")
Do
    Sleep(100)
Until $Coord = 1
Loot_mob()
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...