Jump to content

while loop + while loop ?


Recommended Posts

sleep(3000)
$mobminhp = PixelGetColor(538,296);Monster dead?
While $mobminhp = 0x9D0000  
    MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
    $mobminhp = PixelGetColor(538,296);Monster dead?        
    
WEnd

$pixel = PixelCheckSum(800,295,893,310);Dead?
While $pixel = PixelCheckSum(800,295,893,310)
    Sleep(30)
Wend

MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town

I want to add the second code part to the first, but i dont have a single clue how to do that.

Please help me

The bot starts to attack a monster and if the bot dies, it's suposed to click the Town button.

Link to comment
Share on other sites

sleep(3000)
 $mobminhp = PixelGetColor(538,296);Monster dead?
 While $mobminhp = 0x9D0000 
     MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
     $mobminhp = PixelGetColor(538,296);Monster dead?       
     
 WEnd

$pixel = PixelCheckSum(800,295,893,310);Dead?
 While $pixel = PixelCheckSum(800,295,893,310)
     Sleep(30)
 Wend
 
 MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town

I want to add the second code part to the first, but i dont have a single clue how to do that.

Please help me

The bot starts to attack a monster and if the bot dies, it's suposed to click the Town button.

There are a few ways you can check 2 or more things continually.

If you just want to check on 2 things then you can have a loop like your first code, and also have an AdliEnable to call the second code every 30 mS, like this

Sleep(3000)

$pixel = PixelChecksum(800, 295, 893, 310);I assume this is a checksum for when the bot is alive

AdlibEnable("IsBOTDead", 30);we'll check if BOT is dead every 30 mS

While PixelGetColor(538, 296) = 0x9D0000;Monster dead?
    MouseClick("left", $attackcoordy, $attackcoordx, 1);Attack
    Sleep(80)

WEnd


Func IsBotDead()
    If $pixel = PixelChecksum(800, 295, 893, 310) Then Return;no change

    MouseClick("left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    AdlibDisable();stop checking, need some code somewhere to decide when to start ADlibEnable again

EndFunc  ;==>IsBotDead
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

sleep(3000)
while 1
    testattack()
    go_home()
    
WEnd


func testattack()
    $mobminhp = PixelGetColor(538,296);Monster dead?
    While $mobminhp = 0x9D0000  
        MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
        $mobminhp = PixelGetColor(538,296);Monster dead?        
    WEnd
EndFunc

func go_home()
    $pixel = PixelCheckSum(800,295,893,310);Dead?
    While $pixel = PixelCheckSum(800,295,893,310)
        Sleep(30)
    Wend
    MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
EndFunc

basically , is this good for what you want. it dont keep testing for anything except what yo have done already but it does what you asked in a very basic form.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

sleep(3000)
 while 1
     testattack()
     go_home()
     
 WEnd
 
 
 func testattack()
     $mobminhp = PixelGetColor(538,296);Monster dead?
     While $mobminhp = 0x9D0000 
         MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
         $mobminhp = PixelGetColor(538,296);Monster dead?       
     WEnd
 EndFunc
 
 func go_home()
     $pixel = PixelCheckSum(800,295,893,310);Dead?
     While $pixel = PixelCheckSum(800,295,893,310)
         Sleep(30)
     Wend
     MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
 EndFunc

basically , is this good for what you want. it dont keep testing for anything except what yo have done already but it does what you asked in a very basic form.

Maybe you need to rethink that JackDinn :)
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

sleep(3000)
while 1
    testattack()
    go_home_test()
    sleep(50)
WEnd


func testattack()
    $mobminhp = PixelGetColor(538,296);Monster dead?
    if $mobminhp = 0x9D0000 then; monster NOT dead
        MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
        $mobminhp = PixelGetColor(538,296);Monster dead?        
    EndIf
EndFunc

func go_home_test()
    $pixel = PixelCheckSum(800,295,893,310);Dead?
    if $pixel = PixelCheckSum(800,295,893,310) then; yes Im dead
        MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    EndIf
    
EndFunc

maybe.

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

sleep(3000)
while 1
    testattack()
    go_home_test()
    sleep(50)
WEnd


func testattack()
    $mobminhp = PixelGetColor(538,296);Monster dead?
    if $mobminhp = 0x9D0000 then; monster NOT dead
        MouseClick( "left", $attackcoordy, $attackcoordx, 1);Attack
        $mobminhp = PixelGetColor(538,296);Monster dead?        
    EndIf
EndFunc

func go_home_test()
    $pixel = PixelCheckSum(800,295,893,310);Dead?
    if $pixel = PixelCheckSum(800,295,893,310) then; yes Im dead
        MouseClick( "left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    EndIf
    
EndFunc

maybe.

couldnt move the mouse ;/
Link to comment
Share on other sites

Sleep(3000)
Global $attacking = 0
Global $mobminhp = 0
Global $pixel = PixelChecksum(800, 295, 893, 310);Dead?
While 1
    testattack()
    go_home_test()
    Sleep(50)
WEnd


Func testattack()
    $mobminhp = PixelGetColor(538, 296);Monster dead?
    If $mobminhp = 0x9D0000 And $attacking = 0 Then;monster NOT dead
        MouseClick("left", $attackcoordy, $attackcoordx, 1);Attack
        $attacking = 1
    ElseIf $mobminhp <> 0x9D0000
        $attacking = 0
    EndIf
EndFunc  ;==>testattack

Func go_home_test()
    If $pixel <> PixelChecksum(800, 295, 893, 310);yes Im dead
        MouseClick("left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    EndIf
EndFunc  ;==>go_home_test

did you get it working ok with Martin's code?

i duno why i keep trying as im blind on this one but i suppose im just addicted to AutoIt

Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

Sleep(3000)
Global $attacking = 0
Global $mobminhp = 0
Global $pixel = PixelChecksum(800, 295, 893, 310);Dead?
While 1
    testattack()
    go_home_test()
    Sleep(50)
WEnd


Func testattack()
    $mobminhp = PixelGetColor(538, 296);Monster dead?
    If $mobminhp = 0x9D0000 And $attacking = 0 Then;monster NOT dead
        MouseClick("left", $attackcoordy, $attackcoordx, 1);Attack
        $attacking = 1
    ElseIf $mobminhp <> 0x9D0000
        $attacking = 0
    EndIf
EndFunc ;==>testattack

Func go_home_test()
    If $pixel <> PixelChecksum(800, 295, 893, 310);yes Im dead
        MouseClick("left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    EndIf
EndFunc ;==>go_home_test

did you get it working ok with Martin's code?

i duno why i keep trying as im blind on this one but i suppose im just addicted to AutoIt

ive alredy solved it but it got stuck after the bot was dead
Link to comment
Share on other sites

yea i guessed that and edited it after so it may work now , but i give for tonight (on this one anyhow ) its a challenge when i cant test.

but have fun with you wow bot

p.s. i have been thinking about doing one but i got hammered in the big ban wave of last year for gliding :) so im a bit hesitant.

duno if wow can see AutoIt running or not and even if they bother about it but duno if i want to take the chance again.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

ok, here is the script:

while 1
    $i = 0
$randomwhile = Random(7, 15)
While $i <= $randomwhile
    $time2 = Random(200,700)
    $time10 = Random(1000,4000)
    $time5 = Random(3000,6000)
    $arenacoordy = Random(210,290)
    $arenacoordx = Random(666,728)
    $summoncoordx = Random(680,780)
    $summoncoordy = Random(209,226)
    $attackcoordx = 332
    $attackcoordy = 639
    $resummoncoordx = Random(800,880)
    $resummoncoordy = Random(295,310)
    $newsleep = Random(4000,10000)
    $time11 = Random(100,1000)  
    $newsleep = Random(4000,10000)
    $long = Random(10000,15000)

    Sleep($newsleep)    
    $maxhp = PixelGetColor(561,151);Checking max hp
    While $maxhp = 0xFFFFFF
            
        sleep(500)
        $maxhp = PixelGetColor(561,151) 
    WEnd

    MouseClick( "left", $arenacoordx, $arenacoordy, 1, $time10);Go arena
    Sleep($time10)
    MouseClick( "left", $summoncoordx, $summoncoordy, 1, $time10);Summon
    Sleep($time11)
    
    

    
    $pixel = PixelChecksum(800, 295, 893, 310);I assume this is a checksum for when the bot is alive
    AdlibEnable("IsBOTDead", 100)
    
    While PixelGetColor(538, 296) = 0x9D0000;Monster dead?
        MouseClick("left", $attackcoordy, $attackcoordx, 1);Attack
            $pixel = PixelChecksum(800, 295, 893, 310)
        IsBotDead() 
        Sleep(80)
        
    WEnd
        $i = $i + 1
    Sleep($newsleep)
Wend
Sleep($long)
WEnd


Func IsBotDead()
    If $pixel = PixelChecksum(800, 295, 893, 310) Then Return;no change
    MouseClick("left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    AdlibDisable()
    
EndFunc ;==>IsBotDead

im stuck, how do i re-activate that AdlibEnable?

Link to comment
Share on other sites

with the assumption that you dont want to do anything else in the script until you are alive again you could do this to the IsBotDead() func

Func IsBotDead()
    If $pixel = PixelChecksum(800, 295, 893, 310) Then Return;no change
;if $Pixel has changed then $pixel will now = checksum for dead bot
    MouseClick("left", $resummoncoordx, $resummoncoordy, 1, $time10);Town
    AdlibDisable(); stay in this func until not dead
    While $pixel = PixelChecksum(800, 295, 893, 310);while still dead
        Sleep(100)
    WEnd
    $pixel = PixelChecksum(800, 295, 893, 310); get Alive CheckSum again
    AdlibEnable("IsBOTDead", 100); re-activate IsBotDead test func
EndFunc  ;==>IsBotDead
Edited by JackDinn

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

i have attempted to answer that above , i hope it works first time off :)

i have got wow but iv prob got it set to a dif rez to yourself so it would be looking in the wrong places for the PixelCheckSums ()

btw when your dead what are you intending to do ? port home as a ghost and then what? sorry i cant remember to well exactly what happens when you die i was having an argument with my partner whether or not you can use the port stone when your dead/ghost. i thought you had to either get to your body or to the angle first, but im prob wrong tehe.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

Link to comment
Share on other sites

i have attempted to answer that above , i hope it works first time off :)

i have got wow but iv prob got it set to a dif rez to yourself so it would be looking in the wrong places for the PixelCheckSums ()

btw when your dead what are you intending to do ? port home as a ghost and then what? sorry i cant remember to well exactly what happens when you die i was having an argument with my partner whether or not you can use the port stone when your dead/ghost. i thought you had to either get to your body or to the angle first, but im prob wrong tehe.

http://www.youtube.com/watch?v=mWVTnb39xio (thats an older version)there you can see whats happeing, but instead of summoning a new mob im going back to town after each kill, or if i get killed, checks if i got full hp and go arena summon over and over

and with your script it presses the button back to town after ive entered the arena, it also tries to do that when im in town

Link to comment
Share on other sites

firstly i must say that iv been working under the assumption that you was doing a bot for World Of Warcraft (WoW) ! but you didn't correct me ages ago :) nm np.

and with your script it presses the button back to town after ive entered the arena, it also tries to do that when im in town

it may well be because the pixelcheck area for checking that your dead or not is changing in some other way when your going into the arena and town, have a close look at the area your doing the pixelchecksum() on. If there is a change when you go into these areas then off course it's guna think your dead because thats how it works as it is , but your getting into the kind of area where we are scripting it all for you. i think you got a good direction pointer as to how to get on a little with what your doing & you need to work out the things that you describe as thats what its all about.

GL.

Thx all,Jack Dinn.

 

JD's Auto Internet Speed Tester

JD's Clip Catch (With Screen Shot Helper)

Projects :- AutoIt - My projects

My software never has bugs. It just develops random features. :-D

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...