Post by £åߥ®Ñth on Dec 24, 2007 0:22:10 GMT -5
Here is a couple of healing bots. One by a friend of mine and the other by me.
Here is the source to an autohealer using memory to read the HP level.
Created by: Wasted and myself.
This one was created, by helping my friend make a better healing bot. Since it reads from the game, it knows the HP level and does something about it when it is in the danger area.
Works almost the same as the second bot, just the second one is reading from the color on the HP life bar. Both are effective in how they work.
-----------------------------------------------------------------------------------
Here is another version of a healer using pixel detection.
Created by: Wasted
------------------------------------------------------------------------
Here is the source to an autohealer using memory to read the HP level.
Created by: Wasted and myself.
This one was created, by helping my friend make a better healing bot. Since it reads from the game, it knows the HP level and does something about it when it is in the danger area.
Works almost the same as the second bot, just the second one is reading from the color on the HP life bar. Both are effective in how they work.
-----------------------------------------------------------------------------------
Opt("WinWaitDelay", 1000)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
WinWait("ROSE online", "")
If Not WinActive("ROSE online", "") Then WinActivate("ROSE online")
WinWaitActive("ROSE online", "")
$title_b = "ROSE online"
$Process = WinGetProcess($title_b, "") ;Open process
HotKeySet("{END}", "Terminate")
$Pickup = 0
Global $lastaction = 0
Global $mem_lastaction = "0BE4A56C" ;Address of HP
Global $lowhealth = 250 ;value before heal is needed
While $Pickup = 0
Call("Heal")
WEnd
Func Heal()
Readlast()
If $lastaction < $lowhealth Then
Send("{F8}")
Else
EndIf
EndFunc ;==>Heal
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 = 'short')
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 = 'short')
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
Here is another version of a healer using pixel detection.
Created by: Wasted
------------------------------------------------------------------------
Opt("WinWaitDelay", 1000)
Opt("WinTitleMatchMode", 4)
Opt("WinDetectHiddenText", 1)
Opt("MouseCoordMode", 0)
WinWait("ROSE online", "")
If Not WinActive("ROSE online", "") Then WinActivate("ROSE online")
WinWaitActive("ROSE online", "")
$title_b = "ROSE online"
$Process = WinGetProcess($title_b, "") ;Open process
HotKeySet("{END}", "Terminate")
$Pickup = 0
Global $lastaction = 0
Global $mem_lastaction = "0BE4A56C" ;Address of HP
Global $lowhealth = 250 ;value before heal is needed
While $Pickup = 0
Call("Heal")
WEnd
Func Heal()
Readlast()
If $lastaction < $lowhealth Then
Send("{F8}")
Else
EndIf
EndFunc ;==>Heal
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 = 'short')
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 = 'short')
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