i copy this script from someone and tried it. but it only does is move around but cant search the target.
how can i search for the pixel of a mob? i already change the pixel but still not clicking or search the mob pls help me
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("!{PAUSE}","Close")
#Region State Machine Functions
Func EnemySearch()
;Search enemy bar
$cords = PixelSearch(12,47,951,702,0xFFFFFFA0,5)
Return IsArray($cords)
EndFunc
Func AttackEnemy()
;inner state of Attacking state
$state = "attacking"
;Heal check important to be in top
If(haveLowHealth()) Then
$state = "heal"
Return $state
EndIf
;Switch attacking enemy state to killed if close target was killed
$cords = isTargetAlive()
If(@error) Then
$state = "killed"
Return $state
EndIf
;Continue attacking otherwise
MouseClick("left",$cords[0],$cords[1],1,3)
Sleep(500)
Send("{f1}")
Sleep(Random(200, 400, 1))
Send("{2}")
Sleep(Random(100, 300, 1))
Return $state
EndFunc
Func Wander()
Sleep(Random(100, 300, 1))
Send("{w down}") ; Holds the A key down
Sleep(Random(1000, 2000, 1))
Send("{w up}") ; Releases the A key
Sleep(Random(700, 1100, 1))
MouseClick("left",82,133,1,3)
Sleep(Random(1000, 2100, 1))
MouseClick("left",876,128,1,3)
Sleep(Random(1000, 2100, 1))
MouseClick("left",940,617,1,3)
Sleep(Random(1000, 2100, 1))
MouseMove(595,374)
MouseDown("right")
MouseMove(612,374)
MouseUp("right")
EndFunc
Func Heal()
Sleep(Random(100, 200, 1))
Send("{4 2}")
EndFunc
#EndRegion
#Region AttackState sub states
Func isTargetAlive()
;Search close target alive
$cords = PixelSearch(406,337,689,487,0xEB1609,5)
If @error Then Return SetError(1)
Return $cords
EndFunc
Func haveLowHealth()
;Check low health threshold
$cords = PixelSearch(147,717,147,717,0x222222,1)
Return IsArray($cords)
EndFunc
#EndRegion
Func TogglePause()
$isPaused = Not $isPaused ; toggle pause state
if($isPaused) Then
$LAST_STATE = $CURRENT_STATE
$CURRENT_STATE = $STATE_PAUSED
Else
$CURRENT_STATE = $LAST_STATE
EndIf
EndFunc
Func Close()
Exit 0
EndFunc
Global Const $STATE_ENEMY_SEARCH = "searching"
Global Const $STATE_ATTACKING = "attacking"
Global Const $STATE_HEAL = "healing"
Global Const $STATE_WANDER = "wandering"
Global Const $STATE_PAUSED = "paused"
Global $isPaused = True
Global $CURRENT_STATE = $STATE_PAUSED
Global $LAST_STATE = $STATE_ENEMY_SEARCH ; for pause purposes
;Only change state if not paused
Func changeState($newState)
if(Not $isPaused) Then $CURRENT_STATE = $newState
EndFunc
Func mainLoop()
While Sleep(5) ; prevent high cpu ussage
ToolTip($CURRENT_STATE,0,0)
Switch $CURRENT_STATE
Case $STATE_ENEMY_SEARCH
$found = EnemySearch()
If($found) Then
changeState($STATE_ATTACKING)
Else
changeState($STATE_WANDER)
EndIf
Case $STATE_ATTACKING
$state = AttackEnemy()
if($state == "killed") Then
changeState($STATE_ENEMY_SEARCH)
ElseIf ($state == "heal") Then
changeState($STATE_HEAL)
EndIf
Case $STATE_HEAL
Heal()
changeState($STATE_ATTACKING)
Case $STATE_WANDER
Wander()
changeState($STATE_ENEMY_SEARCH)
Case $STATE_PAUSED
Sleep(10)
EndSwitch
WEnd
EndFunc
;call main loop function
mainLoop()