Jump to content

Recommended Posts

Posted
;~ - AutoFight
;~ = AutoPickUp

Opt("WinWaitDelay", 1000)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("PixelCoordMode", 2)
Opt("MouseCoordMode", 2)
WinWait("FiestaOnline", "")
If Not WinActive("FiestaOnline", "") Then WinActivate("FiestaOnline", "")
WinWaitActive("FiestaOnline", "")

$title_b = "FiestaOnline"
$Process = WinGetProcess($title_b, "") ;Open process

HotKeySet("{END}", "Terminate")

$Pickup = 0
$Fight = 0
Global $lastaction = 0
Global $mem_lastaction = "0074CFEF" ;Address of HP
Global $lowhealth = 100 ;value before heal is needed
Global $lastaction2 = 0
Global $mem_lastaction2 = "0074CFF3" ;Address of SP
Global $lowmana = 10 ;value before heal is needed

While $Pickup = 0
Send("{= 30}") ;use auto pickup ;~ Send("{= 20}") ;Presses the = key 30 times for fighting
Call("Heal")
WEnd

;~ auto fight function will not call it
Func FIGHT()
Sleep(100)
$skill1 = Random(1, 3, 1) ;send
Send("{- 5}") ;use auto fight
Send($skill1)
Sleep(5500)
Send("{= 20}")
$Fight = 1
EndFunc ;==>FIGHT

Func Heal()
Readlast();Reads the memory address from $mem_lastaction = "0074CFRF"
;Decomment the msg box line only for testing what the memory address fro HP reads.
;~ MsgBox(0,"value of $lastaction is ",$lastaction)
If $lastaction < $lowhealth Then
Send("{= 10}")
Send("{HOME down}")
sleep(500)
Send("{HOME up}")
Sleep(40000)
Send("{HOME down}")
Sleep(500)
Send("{HOME up}")
ElseIf $lastaction2 < $lowmana Then
Send("{= 10}")
Send("{HOME down}")
sleep(500)
Send("{HOME up}")
Sleep(20000)
Send("{HOME down}")
Sleep(500)
Send("{HOME up}")
Else
Send("{TAB}") ;Press TAB
Send("{= 10}")
Sleep(500)
Call("CheckTarget")
EndIf
EndFunc ;==>Heal

Func CheckTarget()
$Color = PixelGetColor(496, 35) ;Returns Decimal of the color. 0XF70000
;~ UNComment out MsgBox only for testing
;~ MsgBox(0, "Checking the Color", "Hexadecimal of Color " & Hex($Color, 6) & " Decimal of Color: " & $Color)
If $Color = 16187392 Then ;The Decimal of 0XF70000
$Color = 0
Call("FIGHT")
Else
Send("{= 10}")
Call("movcamera")
EndIf
EndFunc ;==>CheckTarget


Func movcamera()
MouseMove(500, 400, 0)
MouseDown("right")
MouseMove(502, 400, 0)
MouseUp("right")
Send("{TAB}") ;Press TAB
Sleep(500)
Send("{= 10}")
Call("CheckTarget")
EndFunc ;==>movcamera

Func Terminate()
$MB_MsgBoxButtons = 5 ;What buttons that show in messagebox 5 = Retry and Cancel
$MB_Cancel = 2 ;What button is pressed to exit the script 2 = Cancel, If Cancel buton is pushed the script stops.
If MsgBox($MB_MsgBoxButtons, $title_b, "Retry or Cancel the bot?") == $MB_Cancel Then
Exit
EndIf
EndFunc ;==>Terminate

;~ Do not worry about anything below this line it is all that is needed already to read memory.
#region read/write memory
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)

If Not ProcessExists($iv_Pid) Then
MsgBox(0, "value of lastaction", "3")
SetError(1)
Return 0
EndIf

Local $ah_Handle[2] = [DllOpen('kernel32.dll') ]
;~ Local $ah_Handle = DllOpen('kernel32.dll') -the brackets are because an array is being declared, no brackets neccessary if it was a standalone variable
;~ msgbox(0,"value of ah_Handle[2] is", $ah_Handle[1])
If @error Then
MsgBox(0, "value of lastaction", "error4")
SetError(2)
Return 0
EndIf
;~ msgbox(0,"value of ah_Handle[0] is", $ah_Handle[0]&"inherithandle"&$if_InheritHandle&"and the iv_pid"&$iv_Pid)
Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
;~ Local $av_OpenProcess = DllCall('kernel32.dll', 'int', 'OpenProcess', 'int', 0x1F0FFF(all access), 'int', 1, 'int', 4084)
;~ msgbox(0,"value of $av_openprocess is", $av_OpenProcess[0]) ;1820
;~ msgbox(0,"value of iv_pid is", $iv_Pid) ; 4084
If @error Then
MsgBox(0, "value of lastaction", "error5")
DllClose($ah_Handle[0])
SetError(3)
Return 0
EndIf

$ah_Handle[1] = $av_OpenProcess[0]
;~ msgbox(0,"value of ah_Handle is", $ah_Handle)
Return $ah_Handle

EndFunc ;==>_MemoryOpen


Func _MemoryRead($ah_Handle, $iv_Address, $sv_Type = 'dword')

If Not IsArray($ah_Handle) Then
SetError(1)
MsgBox(0, "value of lastaction", "error1")
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @error Then
MsgBox(0, "value of lastaction", "error2")
SetError(@error + 1)
Return 0
EndIf

;~ DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $iv_Address, 'int', $ah_Handle[1], 'int', DllStructGetSize($v_Buffer), 'int', '', 'ptr', DllStructGetPtr($v_Buffer))
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
;~ msgbox(0,"value of ah_Handle[0],[1] is", $ah_Handle[0]&", "&$ah_Handle[1]);1,1788
If Not @error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf

EndFunc ;==>_MemoryRead


Func _MemoryWrite($ah_Handle, $iv_Address, $v_Data, $sv_Type = 'dword')

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @error Then
SetError(@error + 1)
Return 0
Else
DllStructSetData($v_Buffer, 1, $v_Data)
If @error Then
SetError(6)
Return 0
EndIf
EndIf

DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If Not @error Then
Return 1
Else
SetError(7)
Return 0
EndIf

EndFunc ;==>_MemoryWrite


Func _MemoryClose($ah_Handle)

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
If Not @error Then
DllClose($ah_Handle[0])
Return 1
Else
DllClose($ah_Handle[0])
SetError(2)
Return 0
EndIf

EndFunc ;==>_MemoryClose

Func Readlast()
$M_open = _MemoryOpen($Process)
$lastaction = _MemoryRead($M_open, "0x" & $mem_lastaction)
$lastaction2 = _Me;~ - AutoFight
;~ = AutoPickUp

Opt("WinWaitDelay", 1000)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("PixelCoordMode", 2)
Opt("MouseCoordMode", 2)
WinWait("FiestaOnline", "")
If Not WinActive("FiestaOnline", "") Then WinActivate("FiestaOnline", "")
WinWaitActive("FiestaOnline", "")

$title_b = "FiestaOnline"
$Process = WinGetProcess($title_b, "") ;Open process

HotKeySet("{END}", "Terminate")

$Pickup = 0
$Fight = 0
Global $lastaction = 0
Global $mem_lastaction = "0074CFEF" ;Address of HP
Global $lowhealth = 100 ;value before heal is needed
Global $lastaction2 = 0
Global $mem_lastaction2 = "0074CFF3" ;Address of SP
Global $lowmana = 10 ;value before heal is needed

While $Pickup = 0
Send("{= 30}") ;use auto pickup ;~ Send("{= 20}") ;Presses the = key 30 times for fighting
Call("Heal")
WEnd

;~ auto fight function will not call it
Func FIGHT()
Sleep(100)
$skill1 = Random(1, 3, 1) ;send
Send("{- 5}") ;use auto fight
Send($skill1)
Sleep(5500)
Send("{= 20}")
$Fight = 1
EndFunc ;==>FIGHT

Func Heal()
Readlast();Reads the memory address from $mem_lastaction = "0074CFRF"
;Decomment the msg box line only for testing what the memory address fro HP reads.
;~ MsgBox(0,"value of $lastaction is ",$lastaction)
If $lastaction < $lowhealth Then
Send("{= 10}")
Send("{HOME down}")
sleep(500)
Send("{HOME up}")
Sleep(40000)
Send("{HOME down}")
Sleep(500)
Send("{HOME up}")
ElseIf $lastaction2 < $lowmana Then
Send("{= 10}")
Send("{HOME down}")
sleep(500)
Send("{HOME up}")
Sleep(20000)
Send("{HOME down}")
Sleep(500)
Send("{HOME up}")
Else
Send("{TAB}") ;Press TAB
Send("{= 10}")
Sleep(500)
Call("CheckTarget")
EndIf
EndFunc ;==>Heal

Func CheckTarget()
$Color = PixelGetColor(496, 35) ;Returns Decimal of the color. 0XF70000
;~ UNComment out MsgBox only for testing
;~ MsgBox(0, "Checking the Color", "Hexadecimal of Color " & Hex($Color, 6) & " Decimal of Color: " & $Color)
If $Color = 16187392 Then ;The Decimal of 0XF70000
$Color = 0
Call("FIGHT")
Else
Send("{= 10}")
Call("movcamera")
EndIf
EndFunc ;==>CheckTarget


Func movcamera()
MouseMove(500, 400, 0)
MouseDown("right")
MouseMove(502, 400, 0)
MouseUp("right")
Send("{TAB}") ;Press TAB
Sleep(500)
Send("{= 10}")
Call("CheckTarget")
EndFunc ;==>movcamera

Func Terminate()
$MB_MsgBoxButtons = 5 ;What buttons that show in messagebox 5 = Retry and Cancel
$MB_Cancel = 2 ;What button is pressed to exit the script 2 = Cancel, If Cancel buton is pushed the script stops.
If MsgBox($MB_MsgBoxButtons, $title_b, "Retry or Cancel the bot?") == $MB_Cancel Then
Exit
EndIf
EndFunc ;==>Terminate

;~ Do not worry about anything below this line it is all that is needed already to read memory.
#region read/write memory
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)

If Not ProcessExists($iv_Pid) Then
MsgBox(0, "value of lastaction", "3")
SetError(1)
Return 0
EndIf

Local $ah_Handle[2] = [DllOpen('kernel32.dll') ]
;~ Local $ah_Handle = DllOpen('kernel32.dll') -the brackets are because an array is being declared, no brackets neccessary if it was a standalone variable
;~ msgbox(0,"value of ah_Handle[2] is", $ah_Handle[1])
If @error Then
MsgBox(0, "value of lastaction", "error4")
SetError(2)
Return 0
EndIf
;~ msgbox(0,"value of ah_Handle[0] is", $ah_Handle[0]&"inherithandle"&$if_InheritHandle&"and the iv_pid"&$iv_Pid)
Local $av_OpenProcess = DllCall($ah_Handle[0], 'int', 'OpenProcess', 'int', $iv_DesiredAccess, 'int', $if_InheritHandle, 'int', $iv_Pid)
;~ Local $av_OpenProcess = DllCall('kernel32.dll', 'int', 'OpenProcess', 'int', 0x1F0FFF(all access), 'int', 1, 'int', 4084)
;~ msgbox(0,"value of $av_openprocess is", $av_OpenProcess[0]) ;1820
;~ msgbox(0,"value of iv_pid is", $iv_Pid) ; 4084
If @error Then
MsgBox(0, "value of lastaction", "error5")
DllClose($ah_Handle[0])
SetError(3)
Return 0
EndIf

$ah_Handle[1] = $av_OpenProcess[0]
;~ msgbox(0,"value of ah_Handle is", $ah_Handle)
Return $ah_Handle

EndFunc ;==>_MemoryOpen


Func _MemoryRead($ah_Handle, $iv_Address, $sv_Type = 'dword')

If Not IsArray($ah_Handle) Then
SetError(1)
MsgBox(0, "value of lastaction", "error1")
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @error Then
MsgBox(0, "value of lastaction", "error2")
SetError(@error + 1)
Return 0
EndIf

;~ DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $iv_Address, 'int', $ah_Handle[1], 'int', DllStructGetSize($v_Buffer), 'int', '', 'ptr', DllStructGetPtr($v_Buffer))
DllCall($ah_Handle[0], 'int', 'ReadProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')
;~ msgbox(0,"value of ah_Handle[0],[1] is", $ah_Handle[0]&", "&$ah_Handle[1]);1,1788
If Not @error Then
Local $v_Value = DllStructGetData($v_Buffer, 1)
Return $v_Value
Else
SetError(6)
Return 0
EndIf

EndFunc ;==>_MemoryRead


Func _MemoryWrite($ah_Handle, $iv_Address, $v_Data, $sv_Type = 'dword')

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

Local $v_Buffer = DllStructCreate($sv_Type)

If @error Then
SetError(@error + 1)
Return 0
Else
DllStructSetData($v_Buffer, 1, $v_Data)
If @error Then
SetError(6)
Return 0
EndIf
EndIf

DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '')

If Not @error Then
Return 1
Else
SetError(7)
Return 0
EndIf

EndFunc ;==>_MemoryWrite


Func _MemoryClose($ah_Handle)

If Not IsArray($ah_Handle) Then
SetError(1)
Return 0
EndIf

DllCall($ah_Handle[0], 'int', 'CloseHandle', 'int', $ah_Handle[1])
If Not @error Then
DllClose($ah_Handle[0])
Return 1
Else
DllClose($ah_Handle[0])
SetError(2)
Return 0
EndIf

EndFunc ;==>_MemoryClose

Func Readlast()
$M_open = _MemoryOpen($Process)
$lastaction = _MemoryRead($M_open, "0x" & $mem_lastaction)
$lastaction2 = _MemoryRead($M_open, "0x" & $mem_lastaction2)
_MemoryClose($M_open)
EndFunc ;==>ReadlastmoryRead($M_open, "0x" & $mem_lastaction2)
_MemoryClose($M_open)
EndFunc ;==>Readlast

That is the code and these are errors

>"C:\Program Files (x86)\AutoIt3\SciTE\..\au3check.exe" -q "C:\Users\Ogi\Documents\script.au3"
"C:\Users\Ogi\Documents\script.au3"(259,1) : error: syntax error
Func
^
"C:\Users\Ogi\Documents\script.au3"(259,1) : error: Statement cannot be just an expression.
Func
^
"C:\Users\Ogi\Documents\script.au3"(269,12) : error: Heal() already defined.
Func Heal()
~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(299,19) : error: CheckTarget() already defined.
Func CheckTarget()
~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(313,17) : error: movcamera() already defined.
Func movcamera()
~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(324,17) : error: Terminate() already defined.
Func Terminate()
~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(334,79) : error: _MemoryOpen() already defined.
Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $if_InheritHandle = 1)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(369,62) : error: _MemoryRead() already defined.
Func _MemoryRead($ah_Handle, $iv_Address, $sv_Type = 'dword')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(399,72) : error: _MemoryWrite() already defined.
Func _MemoryWrite($ah_Handle, $iv_Address, $v_Data, $sv_Type = 'dword')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(431,30) : error: _MemoryClose() already defined.
Func _MemoryClose($ah_Handle)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(450,16) : error: Readlast() already defined.
Func Readlast()
~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(456,21) : warning: $M_open: possibly used before declaration.
_MemoryClose($M_open)
~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(457,1) : error: syntax error
EndFunc
^
"C:\Users\Ogi\Documents\script.au3"(457,1) : error: Statement cannot be just an expression.
EndFunc
^
"C:\Users\Ogi\Documents\script.au3"(456,21) : error: $M_open: undeclared global variable.
_MemoryClose($M_open)
~~~~~~~~~~~~~~~~~~~~^
"C:\Users\Ogi\Documents\script.au3"(227,33) : error: _Me(): undefined function.
$lastaction2 = _Me;~ - AutoFight
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Users\Ogi\Documents\script.au3 - 15 error(s), 1 warning(s)
>Exit code: 2    Time: 0.4284
 

Anyone know how to fix

  • Moderators
Posted

Welcome to the AutoIt forum.

Unfortunately you appear to have missed the Forum rules on your way in. Please read them now - particularly the bit about not discussing game automation - and then you will understand why you will get no help and this thread will now be locked.

See you soon with a legitimate question I hope.

The Moderation team

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Guest
This topic is now closed to further replies.
×
×
  • Create New...