Post by £åߥ®Ñth on Dec 24, 2007 0:12:18 GMT -5
Here is a bot developed by Chris and Myself.
This bot is ironic because it happened to work for 2 complete games.
Same game, to complete different names. The bot worked for them both, even memory in the game where identical, so we could pull off some really cool stuff.
--------------------------------------------------------------------------------------
Since then PKO & TOP updated the game to making a popup in game you have to type in a code to continue on, this put a stop to this bot.
it doesnt mean they stopped botting, because if we wanted to take the time to do it. We could code some OCR to read the characters and type them in with the bot anyway.
But i didnt bother, and neither did chris.
Well here is the source so anyone can learn from it.
And here is the version we used with memory to detect if there was a target and some other cool stuff like Exp gained..
This bot is ironic because it happened to work for 2 complete games.
Same game, to complete different names. The bot worked for them both, even memory in the game where identical, so we could pull off some really cool stuff.
--------------------------------------------------------------------------------------
Since then PKO & TOP updated the game to making a popup in game you have to type in a code to continue on, this put a stop to this bot.
it doesnt mean they stopped botting, because if we wanted to take the time to do it. We could code some OCR to read the characters and type them in with the bot anyway.
But i didnt bother, and neither did chris.
Well here is the source so anyone can learn from it.
;~ Authors: Chrislivinitup & Lab + Authors of Misc.au3
#Include <Misc.au3>
WinActivate("Pirate")
WinWaitActive("Pirate")
Opt("WinTextMatchMode", 2) ;1=complete, 2=quick
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Opt("PixelCoordMode", 2) ;1=absolute, 0=relative, 2=client
Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client
; Below is some pixel colors to use for certain animals.
;~ 0xEBB5D6 Dry Mystic Shrubs
;~ 0x844952 Snowy Mystic Shrub
;~ 0x295118 Melons & Cactus
;~ 0x538BA7 Debug the HP Bar/Heal function
;~ 0xF7D7BD Humpy Camel
;~ 0xCE9231 Bear Cub
;~ 0x6B3021 Cuddly Lamb
;~ 0xDE7573 Sea Snail
;~ 0xB56508 Little Deer - Elk
;~ 0x393894 Sailor Penguin
;~ 0x5265CE Naiad
;~ 0x84DF52 Oyster 0x636D5A <-- grey on green oyster Yellow--> 0xF7FF84
;~ 0xF77500 Horned Penguin
;~ 0x39FBBD Snowy Shroom
;~ Angelic Panda 0x181818 0x08B25A
;~ Smuggler 0x7B304A
;~ Meadow Deer 0x848E18
;~ Armored Crab 0xEF6D08-0xFFB263-0xF77921
;~ Seaweed 0x89B252 0x855E1F 0xA0844A 0x7CA140 0x675642 0x885E31
$Monsters = 0xDE7573; Pixel color being searched for
$lowhealth = 85 ; makes character auto sit if health is 40% left
$Shadevar = 0
$Attack = 0
While $Attack = 0
$coord = PixelSearch(1, 1, 780, 580, $Monsters, 1);$Shadevar) ; Looking for the Pixel "Left,Top,Right,Bottom"
If Not @error Then
;~ MsgBox(0, "Pixel", "monster " & $Shadevar, 6)
;~ MsgBox(0, "Location", "x coords " & $coord[0] & " y coords " & $coord[1],2)
MouseClick("left", $coord[0], $coord[1], 3, 4) ; clicking the pixel
Sleep(3000) ;wait 5 seconds before picking up items
;~ Call("PickupDrops")
Send("^a")
Sleep(1000)
Call("checkandheal")
$Shadevar = 0
If _IsPressed("23") Then $Attack = 1 ;if "end" is pressed then this will make $DryMystic=1 so the loop will stop
Else
$Shadevar = $Shadevar + 1 ;increase allowable shade variation by 1 until shade is found
EndIf
WEnd
MsgBox(0, "Bot Disabled", "You turned off the Bot!") ;Window name , text in the msgBox saying Bot is off !
Func checkandheal()
$coord = PixelSearch(75, 26, 183, 31, 0x538BA7, 5)
If Not @error Then
;~ MsgBox(0,"location","the x-location of the found pixelis "& $coord[0])
$healthlvl = (($coord[0] - 75) / (183 - 75)) * 100
If $healthlvl < $lowhealth Then
Send("{INS}")
$h = 0
$Attack = 1
While $h = 0
Sleep(33000); 30 seconds of heal time.
PixelSearch(75, 26, 183, 31, 0x538BA7)
If @error Then
$h = 1
Send("{INS}")
Sleep(1000)
$Attack = 0
EndIf
WEnd
EndIf
EndIf
EndFunc ;==>checkandheal
And here is the version we used with memory to detect if there was a target and some other cool stuff like Exp gained..
#include <GUIConstants.au3>
#Include <Misc.au3>
Opt("pixelcoordmode", 2)
Opt("mousecoordmode", 2)
Opt("WinTitleMatchMode", 4)
$title = "Pirate"
;~ $title = "PKO Trainer"
;~ $title_b = "PKO Trainer"
$title_b = "Pirate"
$Process = WinGetProcess($title_b, "")
;~ call("debugmm", 0xCD0000)
;~ call("debugfs", 0xBD9C0A)
;0xA4C16B - colour of level 1 enemey plant
;0xFAF544 - colour of item on ground
;0xFF0000 - colour of enemy in minimap
;0x7E2914 - colour of enemy in minimap
;722, 65, 737, 80 - area to search around guy to look for enemy on minimap
;------- enemy colour list
; 0xA4C16B - small ball cactus lvl 1
; 0xF0AE6B - tall cactus with flower on top lvl 4 - if this is the value of the colour then you need to click aprox 10 pixels lower
; 0xF2F9A4 - tortoise
;------- object colour list
;0x538BA7 - colour of gray area in health bar when there is no health
;75,183
;~ #region preset variables
global $failsafewait = 150
global $enemylvllower = 0xD9FF77
global $enemylvllow = 0x00FF0C
global $enemylvlverylow = 0xC0C0C0
global $enemy1 = 0xA4C16B ; lvl 1 plant in shaitan town
global $enemy2 = 0xC0D071 ;0xF0AE6B - flower part lvl 4
global $enemy3 = 0xF2F9A4 ;tortoise flower lvl 7
global $enemy4 = 0xDBD6B8 ; lv8 cuddly sheep
global $enemy5 = 0x57B9A9 ; lv9 marsh spirit
global $enemy6 = 0xCF973B ; bear cub lvl 12
global $enemy7 = 0xD5D5E7 ; lv17 angelic bear 0x00FF08
;~ call("debug",$enemy7)
;~ #endregion
global $maxrange = 60
global $lowhealth = 70
global $greatsword = 1634038343
global $Bow = 7827266
Global $maxwindowx=1024
Global $maxwindowy=768
Global $xcoord = 0
Global $ycoord = 0
Global $lastaction = 0
global $mem_xcoord = "006D13A4"
global $mem_ycoord = "006D13A8"
global $mem_lastaction = "006C27F8"
;~ $menu1 = GUICtrlCreateMenu("Start")
;~ GUICreate("PKO Trainer", 200, 50, -1, -1)
;~ GUICreate("PKO Trainer", 300, 200, -1, -1)
;~ Opt("GUIOnEventMode", 1)
;~ GUISetOnEvent($GUI_EVENT_CLOSE, "Quit")
;~ $menu1_item1 = GUICtrlCreateMenuitem("Exit", $menu1)
;~ GUICtrlSetOnEvent(-1, "Quit")
;~ GUICtrlCreateButton("Exit", 100, 30, 100, 20)
;~ GUICtrlCreateButton("Exit", 150, 170, 150, 30)
;~ GUICtrlSetOnEvent(-1, "Quit")
;~ GUICtrlCreateButton("Display lastaction value", 150, 140, 150, 30)
;~ GUICtrlSetOnEvent(-1, "checkengaged")
;~ GUICtrlCreateButton("Begin Loop", 150, 110, 150, 30)
;~ GUICtrlSetOnEvent(-1, "programloop")
;~ GUICtrlCreateButton("disengage", 150, 80, 150, 30)
;~ GUICtrlSetOnEvent(-1, "disengagesequence")
;~ GUISetState(@SW_SHOW)
HotKeySet("{END}","Quit")
WinActivate("Pirate King")
WinWaitActive("Pirate King")
;==============================================================================================================================================================
$loop=0
While $loop=0
;~ $Process = WinGetProcess($title_b, "")
;~ If WinExists("Pirate") Then
;~ $title = WinGetTitle("Pirate")
;~ WinSetTitle($title, "", $title_b)
;~ EndIf
;~ call("programloop")
;~ MsgBox(0,"title","loop is working")
Call("checkandheal")
Call("enemycoloursearchscript1")
Call("checkxpgain")
sleep(500)
Send("^a")
Send("^a")
;~ Sleep(500)
WEnd
;==============================================================================================================================================================
Func Quit()
;~ If WinExists($title_b) Then WinSetTitle($title_b, "", $title)
Exit
EndFunc ;==>Quit
Func checkandheal()
$coord = PixelSearch(75, 26, 183, 31, 0x538BA7)
If Not @error Then
$healthlvl= (($coord[0] - 75) / (183 - 75)) * 100
;~ MsgBox(0,"location","the x-location of the found pixelis "& $coord[0])
If $healthlvl < $lowhealth Then
Send("{INS}")
Local $h = 0
While $h = 0
$healthlvl1= (($coord[0] - 75) / (183 - 75)) * 100
$coord=PixelSearch(75, 26, 183, 31, 0x538BA7)
If @error Then
$h = 1
Send("{INS}")
EndIf
Sleep(100)
$coord = PixelSearch(75, 26, 183, 31, 0x538BA7)
if not @error then
$healthlvl2= (($coord[0] - 75) / (183 - 75)) * 100 ; here!!!!
if $healthlvl2<$healthlvl1 Then
call("disengagesequence")
EndIf
EndIf
WEnd
Endif
Endif
Endfunc
Func enemycoloursearchscript1()
Send("{shiftdown}")
Local $if=0
Local $s = 0
While $s = 0
Sleep(50)
Local $coord = PixelSearch(1, 1, 790, 560, $enemylvllower, 5)
If Not @error Then
Send("{shiftup}")
$s=1
$if=1
EndIf
if $if=0 then
Local $coord = PixelSearch(1, 1, 790, 560, $enemylvllow, 5)
If Not @error Then
Send("{shiftup}")
$s=1
$if=1
EndIf
EndIf
if $if=0 then
Local $coord = PixelSearch(1, 1, 790, 560, $enemylvlverylow, 5)
If Not @error Then
Send("{shiftup}")
$s = 1
$if=0
EndIf
EndIf
If $s = 1 Then
;~ Send("{f3}") ;send skill
Sleep(250)
MouseClick("left", $coord[0] + 52, $coord[1] + 5, 2, 0)
Call("checkengaged")
If @error Then
Send("{shiftdown}")
$s = 0
EndIf
EndIf
WEnd
EndFunc ;==>enemycoloursearchscript1
Func programloop()
WinActivate("Pirate King")
WinWaitActive("Pirate King")
;~ MsgBox(0,"title","loop is working")
while 1
Call("checkandheal")
Call("enemycoloursearchscript1")
Call("checkxpgain")
sleep(500)
Send("^a")
Send("^a")
Sleep(500)
WEnd
EndFunc
Func checkengaged()
Readlast()
If $lastaction <> 7827266 Then ; value for weapon
;~ msgbox(0,"not equal","error returned")
SetError(1)
EndIf
EndFunc ;==>checkengaged
Func checkxpgain()
Local $c=0
Local $w=0
While $w=0
Readlast()
if $lastaction = 1701869637 Then $w=1
;~ ^ Exsperiance gained
$c=$c+1
if $c>40 then $w=1
sleep(250)
WEnd
EndFunc ;==>checkxpgain
Func disengagesequence()
WinActivate("Pirate King")
WinWaitActive("Pirate King")
send("{ins}")
sleep(250)
mouseclick("left",$maxwindowx-($maxwindowx*.02),$maxwindowy*.5,5,0)
sleep(3000)
mouseclick("left",$maxwindowx-($maxwindowx*.02),$maxwindowy*.5,5,0)
sleep(6000)
MouseClick("left",$maxwindowx*.02,$maxwindowy*.5-50,5,0)
sleep(3000)
MouseClick("left",$maxwindowx*.02,$maxwindowy*.5-25,5,0)
sleep(3000)
send("{ins}")
EndFunc
Func display()
Readlast()
MsgBox(0,"value of $lastaction is",$lastaction)
EndFunc
#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
#cs
Func Score_p1_Write()
If $Score_p1_freeze_c1 = 1 Then
$Score_p1_Read = $freeze_score_p1
$Score_p1_freeze_c1 = 0
ConsoleWrite($freeze_score_p1 & @CR)
Else
$Score_p1_Read = GUICtrlRead($Input_p1_Score_edit)
EndIf
$M_open = _MemoryOpen($Process)
;~ msgbox(0,"value of $M_open is", $M_open[0])
_MemoryWrite($M_open, "0x" & $Mem_Score_p1, "0x" & Hex($Score_p1_Read))
_MemoryClose($M_open)
$freeze_score_p1 = $Score_p1_Read
EndFunc ;==>Score_p1_Write
#ce
#endregion