Jump to content

Making bot for SUN


Recommended Posts

Hi!

I am making a bot for the game SUN (Soul of ultimate nation) and now i want to implement HP buff.

Here is a code that i want to use but the character uses the pot all the time. I used the window tool to get a color at a certain picture.

;Search HP bar for color
$color = PixelGetColor(489,46);Get the color from a specific pixel
    If PixelGetColor(489,46)= 0x0A9600 Then;if the color is green, do nothing
        Sleep(Random(100,200))
    Else
        
        send("9");if color is not green then use the key number 9 for HP pot
    EndIf

I forgot also that i use a ARCHLORD bot script that i found here and trying to modify it for SUN. The archlord bot has a option where you press HOME for starting bot and END for ending it. But when the script now enters the game nothing happens when clicking HOME or END.

I have changed the WinActive title so it goes into the game like it should but i have to go out of game, then click HOME and then enter game again

Edited by pixellegolas
Link to comment
Share on other sites

you prob will find alot of examples if you search for wow fish bots.. but why not do something like this...

; Search for splash 
    while TimerDiff($search_loot_time) < $time_for_loot 
        $pos = PixelSearch($verify_left, $verify_top, $verify_right, $verify_bottom, $verify_color, $verify_tolerance, $verify_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the Loot 
       MouseClick("left", 40, 160, 1, 2) 
            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend

basicly I give it a time to check for an exact color (in your case whatever the color is when it isn't green) if it passes then hit 9 else loop again - your pixel search logic seems a bit backwards... have it check for the bad color and use a timer for how long to keep checking ehh or at least thats the logic that worked for me back when i played wow <_<

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

or if you wanna see my whole script since all it is is timers and color searches

(casts a fishing rod looks for the bobber then looks for the splash around the bobber then finally looks at the loot window to determin if its a 'keeper' hehehe )

either way lots of examples of how to pixelsearch... also a crude example of how to set a hotkey

; ****************************************************************************************************

**** 
; ZhenFisher 
; ~ Will attempt to find bobber for 5 seconds else recast 
; ~ will attempt to only loot a single type of fish 

; Globals 
$title = "ZhenFisher" 
$win_title = "World of Warcraft" 

$top_border_height = 23 
$left_border_width = 4 

$screen_width = 800 
$screen_height = 600 

$time_to_wait = 30000 
$time_for_bobber = 4500 
$time_for_loot = 1000 
$time_for_trans = 600000 

dim $trans_time 
dim $start_time 
dim $bobber_time 
dim $search_loot_time 
; ****************************************************************************************************

**** 
; Hot Keys 
HotKeySet("{PAUSE}", "request_end") 

; ****************************************************************************************************

**** 
if not WinExists($win_title, "") then 
    msg($win_title & " window must be open.") 
    Exit 
endif 

WinActivate($win_title, "") 
WinSetOnTop($win_title, "", 0) 
Sleep(500) 

check_window() 

$win_pos = WinGetPos($win_title, "") 
$win_x = $win_pos[0] + $left_border_width 
$win_y = $win_pos[1] + $top_border_height 

$top = $win_y + (.25 * $screen_height) 
$bottom = $top + (.35 * $screen_height) - 1 
$left = $win_x + (.15 * $screen_width) 
$right = $left + $screen_width - (.15 * 2.0 * $screen_width) - 1 

; Show a visual confirmation by making the mouse draw the area on the screen 
; that will be used to scan for the bobber. 
MouseMove($left, $top, 2) 
MouseMove($right, $top, 2) 
MouseMove($right, $bottom, 2) 
MouseMove($left, $bottom, 2) 

reset_trans_timer() 
cast_pole() 
find_float() 

; ****************************************************************************************************

**** 
func find_float() 
    Sleep(2500) 
    $color_dark_purple = 0x463B4D 
    $color_dark_blue = 0x283A64 
    $color_red = 0xA72C0B 
    $color_stormwind_daylight_blue = 0x2B3254 
    $color_stormwind_daylight_red = 0x6B1F0C 
    $color_beige = 0xBB9B3D 
    $color_night_blue = 0x0B1931 
    $color_bfd_darkshore_bobber = 0xA98863 
    $color_bb_red = 0xCE4D24 
    $color_feathermoon_red = 0x65340D 
    $color_feathermoon_red_night = 0xCD4110 
    $color_deadwind_red = 0x46281F 
    $color_moonglade_dark_red = 0x002416 
    $color_moonglade_black = 0x000505 
    $color_moonglade_bobber = 0x004F3D 
    $color_deviate_red = 0x461607 
    $color_deviate_dark_red = 0x481C10 
    $color_deviate_orangish_red = 0x5D1E08 
    $color_stonebull_night_orangishred = 0xB14013 
    $color_deviate_bobber = 0x67553F 
    
   ; this is the color used to pixelsearch for the bobber. change the color to a good color 
   ; on the bobber that is prominent on the screen 
    $color_to_use = $color_feathermoon_red_night 
    
   ; this is the search tolerance. In areas where the bobber colors really stand out, you can 
   ; use a fairly high threshold. In areas where the bobber colors are fairly muted in with 
   ; the background, you will have to lower the values considerably. 
    $bobber_search_tolerance = 40 

   ; it's better to use lower values here in favor of accurate searching. This will take more 
   ; time for it to detect the bobber, but usually the splash doesn't occur until at least 30% 
   ; of the time has run out, and by that time, it should have detected the bobber (assuming the 
   ; color values and tolerance are correct). 
    $bobber_search_step = 2 
    
   ; Search for float. In certain lighting, the part of the float may look more purple than 
   ; blue. In this case, using $color_red tends to work the best with a tolerance of 20. 
    while 1 
        if TimerDiff($trans_time) >= $time_for_trans then 
      Sleep(30000) 
      Send("2") 
      Sleep(5000) 

      MouseClick("left", 55, 415, 1, 2) 
      Sleep(40000) 
      Send("2") 
      reset_trans_timer() 
        endif 

        if TimerDiff($bobber_time) >= $time_for_bobber then 
            cast_pole() 
        endif 

        Sleep(1000) 
        $pos = PixelSearch($left, $top, $right, $bottom, $color_to_use, $bobber_search_tolerance, $bobber_search_step) 
        if @error then 
            SetError(0) 
        else 
            MouseMove($pos[0], $pos[1], 2) 
            find_splash($pos[0], $pos[1] ) 
        endif 
        Sleep(10) 
    wend 
endfunc 

; ****************************************************************************************************

**** 
func find_splash($float_x, $float_y) 
    $search_left = $float_x - 32 
    $search_right = $search_left + 52 
    $search_top = $float_y - 32 
    $search_bottom = $search_top + 64 

   ; Usually you do not have to modify the search color for the splash, as the pixels 
   ; have a very distinctive, bright color. 
   ; Default white: 0xF6F6F6 
   ; Moonglade Pure WHite: 0xCCFFFF 0xDCFFFF 
    $splash_color = 0xDCFFFF 

   ; Sometimes 30 tolerance works well, sometimes 20 is better in lit areas to avoid catching highlights 
   ; in other things. 
    $splash_tolerance = 30 
    
   ; The search step can be pretty small here (1 to 3) without worries because the search area is 
   ; so small once it has been narrowed down - speed isn't much of an issue. 
    $splash_search_step = 1 

   ; Search for splash 
    while TimerDiff($start_time) < $time_to_wait 
        $pos = PixelSearch($search_left, $search_top, $search_right, $search_bottom, $splash_color, $splash_tolerance, $splash_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the splash 
            Sleep(250) 
            MouseClick("right", $pos[0], $pos[1], 1, 2) 


           ; Click on the loot 
           ; $mouse_pos = MouseGetPos() 
            
            Sleep(1200) 
           ; MouseClick("left", 40, 160, 1, 2) 
       verify_loot_1() 
       verify_loot_2() 
       verify_loot_3() 
       verify_loot_4() 

            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend 
    
   ; Cast pole and start all over again. 
    Sleep(1200) 
   ; MouseClick("left", 40, 160, 1, 2) 
    cast_pole() 
endfunc 
; ****************************************************************************************************

**** 
func verify_loot_1() 
    $search_loot_time = TimerInit() 

    $verify_left = 40 - 32 
    $verify_right = $verify_left + 52 
    $verify_top = 160 - 32 
    $verify_bottom = $verify_top + 64 
    $verify_tolerance = 5 
    $verify_search_step = 1 

    $color_stonescale = 0x9BA54F 
    $color_squid = 0xC162C7 
    $color_fire = 0xF7F739 
    $color_might = 0x1CB895 

    $verify_color = $color_stonescale 
    
   ; Search for splash 
    while TimerDiff($search_loot_time) < $time_for_loot 
        $pos = PixelSearch($verify_left, $verify_top, $verify_right, $verify_bottom, $verify_color, $verify_tolerance, $verify_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the Loot 
       MouseClick("left", 40, 160, 1, 2) 
            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend 
endfunc 
; ****************************************************************************************************

**** 
func verify_loot_2() 
    $search_loot_time = TimerInit() 

    $verify_left = 40 - 32 
    $verify_right = $verify_left + 52 
    $verify_top = 160 - 32 
    $verify_bottom = $verify_top + 64 
    $verify_tolerance = 5 
    $verify_search_step = 1 

    $color_stonescale = 0x9BA54F 
    $color_squid = 0xC162C7 
    $color_fire = 0xF7F739 
    $color_might = 0x1CB895 
    $color_summerbass = 0xC1A61B 

    $verify_color = $color_summerbass 
    
   ; Search for splash 
    while TimerDiff($search_loot_time) < $time_for_loot 
        $pos = PixelSearch($verify_left, $verify_top, $verify_right, $verify_bottom, $verify_color, $verify_tolerance, $verify_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the Loot 
       MouseClick("left", 40, 160, 1, 2) 
            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend 
endfunc 
; ****************************************************************************************************

**** 
func verify_loot_3() 
    $search_loot_time = TimerInit() 

    $verify_left = 40 - 32 
    $verify_right = $verify_left + 52 
    $verify_top = 160 - 32 
    $verify_bottom = $verify_top + 64 
    $verify_tolerance = 5 
    $verify_search_step = 1 

    $color_stonescale = 0x9BA54F 
    $color_squid = 0xC162C7 
    $color_fire = 0xF7F739 
    $color_might = 0x1CB895 

    $verify_color = $color_fire 
    
   ; Search for splash 
    while TimerDiff($search_loot_time) < $time_for_loot 
        $pos = PixelSearch($verify_left, $verify_top, $verify_right, $verify_bottom, $verify_color, $verify_tolerance, $verify_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the Loot 
       MouseClick("left", 40, 160, 1, 2) 
            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend 
endfunc 
; ****************************************************************************************************

**** 
func verify_loot_4() 
    $search_loot_time = TimerInit() 

    $verify_left = 40 - 32 
    $verify_right = $verify_left + 52 
    $verify_top = 160 - 32 
    $verify_bottom = $verify_top + 64 
    $verify_tolerance = 5 
    $verify_search_step = 1 

    $color_stonescale = 0x9BA54F 
    $color_squid = 0xC162C7 
    $color_fire = 0xF7F739 
    $color_might = 0x1CB895 

    $verify_color = $color_might 
    
   ; Search for splash 
    while TimerDiff($search_loot_time) < $time_for_loot 
        $pos = PixelSearch($verify_left, $verify_top, $verify_right, $verify_bottom, $verify_color, $verify_tolerance, $verify_search_step) 
        if @error then 
            SetError(0) 
        else 
           ; Click on the Loot 
       MouseClick("left", 40, 160, 1, 2) 
            Sleep(3200) 
            ExitLoop 
        endif 
        Sleep(100) 
    wend 
endfunc 
; ****************************************************************************************************

**** 
func cast_pole() 
    $start_time = TimerInit() 
    $bobber_time = TimerInit() 
    Send("1") 
    Sleep(2000) 
endfunc 

; ****************************************************************************************************

**** 
func reset_trans_timer() 
    $trans_time = TimerInit() 
endfunc 

; ****************************************************************************************************

**** 
func check_window() 
    $dimensions = WinGetClientSize($win_title, "") 
    if $dimensions[0] <> $screen_width or $dimensions[1] <> $screen_height then 
        msg("Invalid window size. You must use " & $screen_width & "x" & $screen_height & " resolution in window mode.") 
        Exit 
    endif 
endfunc 

; ****************************************************************************************************

**** 
func msg($text) 
    MsgBox(0, $title, $text) 
endfunc 

; ****************************************************************************************************

**** 
func msg_array($title, $array, $num_elements) 
    dim $text 
    $text = $array[0] 

    for $j = 1 to $num_elements - 1 
        $text = $text & ", " & $array[$j] 
    next 

    MsgBox(0, $title, $text) 
endfunc 

; ****************************************************************************************************

**** 
func request_end() 
    $MB_YESNO = 4 
    $MB_YES = 6 
    
    if MsgBox($MB_YESNO, $title, "End script?") == $MB_YES then 
        Exit 
    endif 
endfunc 

; ****************************************************************************************************

**** 
func drain_timer() 
    Msg("Restart") 
    $start_time = $start_time - $time_to_wait 
endfunc 

; ****************************************************************************************************

****

Don't let that status fool you, I am no advanced memeber!

Link to comment
Share on other sites

Ok guys. I am at work now and cannot test any scripts and don't have any reference. I am just trying to understand the logics of autoit and want to know if this code is on the right track. Please read it through and tell me if it looks logical or if i can find a better way of doing things. Thanks

;Define HP color
$Color_ok = 0x000000
$Color_bad = 0xFFFFFF

;Define co-ordinate for checking the HP in HP-bar
$x = 100
$y = 50

;Define HP slot where you keep the pot
$HP = {F1}

;Define SP slot where you keep the SP buff skill
$HP = {F2}

;Define Buff slots
$Buff1 = {F3}
$Buff2 = {F4}
$Buff3 = {F5}

;Define Attack slots
$Att1 = {F6}
$Att2 = {F7}
$Att3 = {F8}

;Define Orange color for arrow above enemy head
$Orange = 0xOROROR

WinActiveTitle (" ") and so on to select the game window

While 1

Search()
HPCheck()

wend

Func Search()

;Look for $orange color and if found do buff and attack sequence:
If GetPixelColor = $Orange Then 
Buff()
sleep
Attack()
else
;If orange is not found then press {TAB} and then do the attack sequence. {TAB} selects closest enemy
press {TAB}

Func end



; + is the key for making character pick up
Func Pickup()
press "+"
sleep
press "+"
sleep
press "+"
sleep

Func end

Func Buff()
press $Buff1
sleep
press $Buff2
sleep
press $Buff3

Func end

Func Attack()

press "1";Normal Attack
sleep
press $Att1
sleep
press $Att2
sleep
press $Att3
sleep
pickup()

Func end

Func HPCheck()

If PixelGetColor = ($Color_ok, $x, $y, 10) then restartloop
else
press $HP

Func end

Func Buff()
press $Buff1
sleep
press $Buff2
sleep
press $Buff3

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