Jump to content

My first script


Backnor
 Share

Recommended Posts

ok tried to post this in the example script section but it would not let me.

So anyway be gentile if you have any sugestions plz feel free. Like I said I am just learning... been doing alot of reading and just wanted to see if anyone could tell me where this needs to be streamlined. The script works but... Anyway here it is.

CODE
#cs ----------------------------------------------------------------------------

AutoIt Version: 3.2.9.12 (beta)

Author: Backnor

Script Function: take target check health fight target

Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here

Global $Paused

HotKeySet("{Pause}", "Pause")

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

While 1 ;Begin LOOP ;

PixelSearch ( 346, 37, 536, 39, 0xE80000, 50 ); Checks for target.

If Not @error Then ; If target = True then moves to checkhealth func

Call ("CheckHealth") ;

EndIf ;

;

PixelSearch ( 346, 37, 536, 39, 0xE80000, 50 );

If @error Then ;

Call ("Target") ;

EndIf ;

;

WEnd ;End Loop ;

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

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

Func Weak() ; checks for the Icap Icon ;

PixelSearch (52, 53, 228, 70, 0xBD3425, 50);

If Not @error Then ;

Call ("HealTime4") ;

EndIf ;

PixelSearch (52, 53, 228,70, 0xBD3425, 50) ;

If @error Then ;

Call ("Fight") ; No Icap Icon = Fight Func

EndIf ;

EndFunc ;

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

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

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

Func CheckHealth() ; Checks your health at three diff points if health low it sleeps script

PixelSearch (67, 37, 77, 39, 0xE80000, 50)

If @error Then

Call ("HealTime1")

EndIf

PixelSearch (115, 37, 168, 39, 0xE80000, 50)

If @error Then

Call ("HealTime2")

EndIf

PixelSearch (133, 37, 205, 39, 0xE80000, 50)

If @error Then

Call ("HealTime3")

EndIf

PixelSearch (207, 37, 237, 39, 0xE80000, 50)

If Not @error Then

Call ("Weak") ; if health is no longer low it moves to the weak func

EndIf

EndFunc

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

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

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

Func Target() ;

Sleep (300) ; Get Target

Send ("{Z}");

EndFunc ;

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

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

Func Pause() ;

$Paused = Not $Paused ;

While $Paused ;

Sleep(100) ; Pause

ToolTip( 'SCRIPT PAUSED', 0, 0) ;

WEnd ;

ToolTip("") ;

EndFunc ;

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

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

;************** Healing Timers *****************

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

Func HealTime1()

Sleep (50000)

EndFunc

Func HealTime2()

Sleep (20000)

EndFunc

Func HealTime3()

Sleep (10000)

EndFunc

Func HealTime4()

Sleep (70000)

EndFunc

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

;************ FIGHTING STUFF *************

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

Func Fight() ; Your fighting moves

Sleep (9)

Send ("{`}")

Sleep (500)

send ("{1}")

Sleep (500)

send ("{2}")

Sleep (500)

send ("{3}")

Sleep (500)

send ("{4}")

Sleep (500)

send ("{5}")

Sleep (500)

send ("{6}")

Sleep (500)

send ("{7}")

Sleep (500)

send ("{8}")

Sleep (500)

send ("{9}")

Sleep (500)

send ("{0}")

Sleep (500)

send ("{-}")

Sleep (500)

send ("{=}")

Sleep (500)

EndFunc

Link to comment
Share on other sites

ok tried to post this in the example script section but it would not let me.

So anyway be gentile if you have any sugestions plz feel free. Like I said I am just learning... been doing alot of reading and just wanted to see if anyone could tell me where this needs to be streamlined. The script works but... Anyway here it is.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.9.12 (beta)
 Author:         Backnor

 Script Function: take target check health fight target
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
Global $Paused
HotKeySet("{Pause}", "Pause")


;**********************************************
While 1  ;Begin LOOP                          ;
PixelSearch ( 346, 37, 536, 39, 0xE80000, 50 ); Checks for target.
    If Not @error Then                        ; If target = True then moves to checkhealth func
        Call ("CheckHealth")                  ;
    EndIf                                     ;
                                              ;
PixelSearch ( 346, 37, 536, 39, 0xE80000, 50 );
    If @error Then                            ;
        Call ("Target")                       ;
    EndIf                                     ;
                                              ;
WEnd ;End Loop                                ;
;**********************************************

;*******************************************
Func Weak()  ; checks for the Icap Icon    ;
PixelSearch (52, 53, 228, 70, 0xBD3425, 50);
If Not @error Then                         ;
    Call ("HealTime4")                     ;
EndIf                                      ;
PixelSearch (52, 53, 228,70, 0xBD3425, 50) ;
If @error Then                             ;
    Call ("Fight")                         ; No Icap Icon = Fight Func
EndIf                                      ;
EndFunc                                    ;
;*******************************************

;***********************************************************************************************
;***********************************************************************************************    
Func CheckHealth() ; Checks your health at three diff points if health low it sleeps script
    PixelSearch (67, 37, 77, 39, 0xE80000, 50)
    If @error Then
        Call ("HealTime1")
        EndIf
        PixelSearch (115, 37, 168, 39, 0xE80000, 50)
    If @error Then
        Call ("HealTime2")
        EndIf
        PixelSearch (133, 37, 205, 39, 0xE80000, 50)
    If @error Then
        Call ("HealTime3")
        EndIf
                PixelSearch (207, 37, 237, 39, 0xE80000, 50)
    If Not @error Then
        Call ("Weak")   ; if health is no longer low it moves to the weak func
    EndIf
EndFunc
;*************************************************************************************************
;*************************************************************************************************

;****************
Func Target()   ;
    Sleep (300) ;  Get Target
    Send ("{Z}");
EndFunc         ;
;****************


;****************************************
Func Pause()                            ;
    $Paused = Not $Paused               ;
    While $Paused                       ;
        Sleep(100)                      ; Pause
        ToolTip( 'SCRIPT PAUSED', 0, 0) ;
    WEnd                                ;
    ToolTip("")                         ;
EndFunc                                 ;
;****************************************


;***********************************************
;************** Healing Timers *****************
;***********************************************
Func HealTime1()
    Sleep (50000)
EndFunc

Func HealTime2()
    Sleep (20000)
EndFunc

Func HealTime3()
    Sleep (10000)
EndFunc

Func HealTime4()
    Sleep (70000)
EndFunc
;*****************************************
;************ FIGHTING STUFF *************
;*****************************************
Func Fight()  ; Your fighting moves
    Sleep (9)
    Send ("{`}")
    Sleep (500)
    send ("{1}")
    Sleep (500)
    send ("{2}")
    Sleep (500)
    send ("{3}")
    Sleep (500)
    send ("{4}")
    Sleep (500)
    send ("{5}")
    Sleep (500)
    send ("{6}")
    Sleep (500)
    send ("{7}")
    Sleep (500)
    send ("{8}")
    Sleep (500)
    send ("{9}")
    Sleep (500)
    send ("{0}")
    Sleep (500)
    send ("{-}")
    Sleep (500)
    send ("{=}")
    Sleep (500)
EndFunc
Link to comment
Share on other sites

Thanks for the speedy reply its for a game I really do not play anymore (SWG) I just wanted to see if I can do it and doing is learning.

As far as the "ControlSend" what should I be replacing that with LOL (Forgive the NOOB)

Any website or link to the game? Get the parameters/class for the control with AutoIt Windows Tool, and it works just like send.
Link to comment
Share on other sites

Agree not really that good of a game the comunity is gone so there is no one to really play with... I am waiting for Warhammer to come out and I will play that (no Bots, takes from the gameplay) till it gets old lol... thanks again.

Link to comment
Share on other sites

Backnor

Very decent. I've noticed a few discrepancies.

First - Call()

You don't need to use Call() to call a function. Functions work like C/C++. You can call them as such.

MyFUNC()
Func MyFUNC()
MsgBox(0, "", "Called.")
EndFunc

Second - Size Ratio

Not everyone has the same desktop resolution or plays the game with the same size. To fix this I invented a tool called Generic Data Tool. You can find it in the Spotlight directory of my fileman - or - the link to it is in the Spotlight link.

Basically - if you review Detection Engine.au3 in the Source/Include of Spotlight and look at what the functions do - you will see that first it gathers the window information. Like size information. Change the FindWindow Function and the variable $Class to your desired Window Title.

Use WinMove and move your window to X0, Y0.

Use Generic Data Tool to gather ratios for your X and Y positions of your pixel searches. Remember to Multiply these ratios by X and Y @DesktopWidth and @DesktopHeight. Alternatively you could be more advanced and gather the Window Size ratio instead of the desktop ratio.

ADVANCED : With a GUI you could possibly allow the user to set those X and Y s with Global variables.

Third - GUI

Use a basic gui with start and stop, and some other useful options. Also allows them to close the bot with a window. This will make the bot basically streamlined because you will need to either adapt your botting system to a universal method - OR add hotkeys in a creative way to aid in stopping - maybe basing it on variables and testing the global variables in the main loop.

Fourth - Documentation

I usually forget this one. Document and comment everything, but not to the point of insanity with stars and stuff. Just on the line is enough. Look at SciTe and Tidy to make your script look clean.

Fifth - Expandability

Ultimately you want your program to be expandable. If so you'll seek bigger and higher methods. If it's just a tool - and it works - you just need to update it with the game updates and post its updates.

Very nice starter script.

~Smith

Link to comment
Share on other sites

Thanks! It was like a lightbulb turning on this week, I have been reading and using other peoples scripts for about a year now. I thought it about time I tried to do this.. I have alot of High hopes but no programing exp. Alot of gametime though!...

Working on adding the ControlSend that Generator sugested atm, I will post as it gets better. Still trying to understand all the commands and stuff.

Thanks for the input on whats needs to be done. I will work on that stuff also.

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