Post by £åߥ®Ñth on Dec 24, 2007 0:25:55 GMT -5
Bot written by me for Fiesta Online.
Also a couple other tweaked versions of it by: Wasted
--------------------------------------------------------------------
Tweaked by: Wasted
----------------------------
Also a couple other tweaked versions of it by: Wasted
--------------------------------------------------------------------
Opt("WinWaitDelay", 100)
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
Global $lastaction = 0
Global $mem_lastaction = "0074CFEF" ;Address of HP
Global $lowhealth = 30 ;value before heal is needed by House Mushroom
Global $lastaction2 = 0
Global $mem_lastaction2 = "0074CFF3" ;Address of SP
Global $lowmana = 10 ;value before heal is needed
While $Pickup = 0
Send("{2 10}") ;use auto pickup ;~ Send("{2 20}") ;Presses the 2 key 20 times for picking up items
Call("HealFindMonster")
WEnd
;~ auto fight function will not call it
Func FIGHT()
Sleep(100)
Send("{1 4}") ;use to auto fight pressing 1, 3 times
Sleep(10000)
Send("{2 4}")
Call("HealFindMonster")
EndFunc ;==>FIGHT
Func HealFindMonster()
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("{0}")
Send("{2 5}")
Send("{HOME DOWN}")
Sleep(50)
Send("{HOME UP}")
Sleep(40000)
Send("{HOME DOWN}")
Sleep(50)
Send("{HOME UP}")
ElseIf $lastaction2 < $lowmana Then
Send("{2 5}")
Send("{HOME DOWN}")
Sleep(50)
Send("{HOME UP}")
Sleep(40000)
Send("{HOME DOWN}")
Sleep(50)
Send("{HOME UP}")
Else
Send("{2 4}")
Sleep(50)
$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
;~ Pickup Left over Items before Mushroom House
Send("{2 4}")
MouseMove(500, 400, 1)
MouseDown("right")
MouseMove(502, 400)
MouseUp("right")
Sleep(50)
Send("{TAB}") ;Press TAB
EndIf
EndIf
EndFunc ;==>HealFindMonster
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", "error3")
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 ;==>Readlast
Tweaked by: Wasted
----------------------------
Opt("WinWaitDelay", 100)
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 = 30 ;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)
;$plain = Random(1, 3, 1) ;send
Send("{- 5}") ;use auto fight
;Send($plain)
Sleep(500)
$Fight = 1
Sleep(3000)
Send("{= 5}")
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
;~ Healing using the HOME Key
Send("{= 5}")
Send("{HOME}")
Sleep(37000)
Send("{HOME}")
Else
Send("{TAB}") ;Press TAB
Send("{= 5}")
sleep(1000)
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("{= 5}")
Call("movcamera")
EndIf
EndFunc ;==>CheckTarget
Func movcamera()
MouseMove(500, 400, 1)
MouseDown("right")
MouseMove(502, 400)
MouseUp("right")
Send("{TAB}") ;Press TAB
Sleep(1000)
Send("{= 5}")
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", "error3")
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)
_MemoryClose($M_open)
EndFunc ;==>Readlast