Jump to content

Help please! How do I combine these 2 codes?


Recommended Posts

If PixelGetColor(1063,662) = Dec("103452") Then

MouseClick("left", 1071,18, 1)

MouseClick("left", 550,442, 1)

Sleep(30000000000)

and

HotKeySet("{ESC}", "MyExit")

WinActivate("[Conquer]")

While 1 ; repeat statements over

; look for monster and attack him

$CoordMonster = PixelSearch ( 0,0,800,800,0xbd0000,5 )

If Not @error Then

MouseClick ( "Right" , $CoordMonster[0], $CoordMonster[1] , 1,1)

EndIf

; if mana is empty replenish it

If PixelGetColor( 119, 780) = (0x94929c) Then

For $i = 3 to $i = 1 Step -1

Send("{F7}")

Sleep(2000)

Next

EndIf

Wend

Func MyExit()

Exit

EndFunc

i want code 2 to run as normal, but if at anytime (1063,662) = Dec("103452"), then do those functions

main problem: i dont know how to organize ifs and ends B)

Link to comment
Share on other sites

Something like this? It is not clear from your description what is supposed to happen when. Check out SciTe, Context check and Tidy as these make it easier to maintain code.

Don't understand what the Sleep(3000...) is for. Why so long?

; Setup hotkey
HotKeySet("{ESC}", "MyExit")

;Activate Game
WinActivate("[Conquer]")

While 1; repeat statements over
    
    If PixelGetColor(1063, 662) = Dec("103452") Then
        MouseClick("left", 1071, 18, 1)
        MouseClick("left", 550, 442, 1)
        Sleep(30000000000)
        
    ; look for monster and attack him
        $CoordMonster = PixelSearch(0, 0, 800, 800, 0xbd0000, 5)
        If Not @error Then
            MouseClick("Right", $CoordMonster[0], $CoordMonster[1], 1, 1)
        EndIf
        
    ; if mana is empty replenish it
        If PixelGetColor(119, 780) = (0x94929c) Then
            For $i = 3 To 1 Step - 1
                Send("{F7}")
                Sleep(2000)
            Next
        EndIf
    EndIf
WEnd

Func MyExit()
    Exit
EndFunc  ;==>MyExit

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

well i used to run both seperately, but i found that it was too troublesome to open 2 autoit scripts so i just wanted to combine them, but still operating the same way it used to (2 opened seperatly)

You something something like this?

; Setup hotkey
HotKeySet("{ESC}", "MyExit")

;Activate Game
WinActivate("[Conquer]")

While 1; repeat statements over
    
    If PixelGetColor(1063, 662) = Dec("103452") Then
        MouseClick("left", 1071, 18, 1)
        MouseClick("left", 550, 442, 1)
        Sleep(30000000000)
    EndIf
    
; look for monster and attack him
    $CoordMonster = PixelSearch(0, 0, 800, 800, 0xbd0000, 5)
    If Not @error Then
        MouseClick("Right", $CoordMonster[0], $CoordMonster[1], 1, 1)
    EndIf
    
; if mana is empty replenish it
    If PixelGetColor(119, 780) = (0x94929c) Then
        For $i = 3 To 1 Step - 1
            Send("{F7}")
            Sleep(2000)
        Next
    EndIf
WEnd

Func MyExit()
    Exit
EndFunc ;==>MyExit

Note that if you want the two time delays, but don't want the one delay to affect the other then you are better off keeping the two as seperate scripts, compiling them and then calling them from a third script that will be the one that you, the user, executes.

This way they can run independantly, other wise you will need to stop using Sleep and perform a time delay comparison function yourself which can be a pain.

Edited by Stumpii

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

PixelGetColor should be fast, PixelSearch will be slow. An area of 800x800 is 640,000 pixels to search (128,000 by stepping 5 pixels at a time).

As PixelSearch is CPU work, the time will vary greatly depending on how fast a CPU you have. I have used PixelSearch before and found that what works on my PC runs very slow on someone elses PC if they have even a slightly older computer.

Try narrowing the check area to 100, 100, 700, 700 or increasing the step of the PixelSearch. A step 0f 5 sounds reasonable though. What speed CPU do you have?

What game if this for anyway? Command & Conquer?

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

no its conqueronline --- conqueronline.com

$CoordMonster = PixelSearch(0, 0, 800, 800, 0xbd0000, 5)

that does the 5 mean anyways?

The five means only check every 5th pixel, i.e. pixel 0, 4, 9 etc. This is five time faster than checking every pixel. Of course, if you are looking for an object of width 3, then it might get missed with a step of 5.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

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