If you cant script don't bother.
Edit for clarity: There is no file, scripts are in the code blocks.Put together your own config.ini from actually reading the code. See [Only registered and activated users can see links. Click Here To Register...]
This is all the functions my bot uses. Two of the functions don't work, one because of a font change and one because I haven't finished rewriting it.
File contains the folder structure for the code and some images. You will need your own images for everything else. The functions use a config.ini file and there are variables you need to set in the code.
In config.ini there are two sections. One for mobs, one for items. If you only ever use the function to attack anything the first section can be ignored. To have the itemsearch function look for items you have to add a line for each item into the ini. The format is filename=X. Where X is a 1 to turn on or 0 to turn off.
The script uses _ImageSearchArea and its included in the code so you do not need to include imagesearch in your bot.
Your mileage may vary.
Update:
Previous versions saw 59 views.
New file uploaded.
New functions:
_startUp is required to use my functions more or less. All functions had a slight rename for readability. Most new functions have some comments. Haven't had time to test _brokenCheck() but it was just a port from another script. I don't think I broke anything.
Scripts are in the code blocks below.
This could be used to auto use a skill and advance it when possible, presuming you have the skill window for that skill open. Useful for afk instrument leveling.
Simple bot example.
Core.au3, copy and paste the below code into
Didn't take time to test the bot sample, it probably works as is.
Edit for clarity: There is no file, scripts are in the code blocks.
This is all the functions my bot uses. Two of the functions don't work, one because of a font change and one because I haven't finished rewriting it.
In config.ini there are two sections. One for mobs, one for items. If you only ever use the function to attack anything the first section can be ignored. To have the itemsearch function look for items you have to add a line for each item into the ini. The format is filename=X. Where X is a 1 to turn on or 0 to turn off.
The script uses _ImageSearchArea and its included in the code so you do not need to include imagesearch in your bot.
Your mileage may vary.
Update:
Previous versions saw 59 views.
New file uploaded.
New functions:
Code:
_startUp() _advanceSkill() _useSkill($num,$time,$unit) _dialogue() _brokenCheck()
Scripts are in the code blocks below.
This could be used to auto use a skill and advance it when possible, presuming you have the skill window for that skill open. Useful for afk instrument leveling.
Code:
#include <core.au3> $result = _checkProcess() If $result = 0 Then Exit(0) EndIf _startUp(1,0) _setTimers(1) While 1 $result = _logCheck() Select Case $result = 0 ;logged in. $result = _advanceSkill() If $result Then Else _useSkill(10,45,1,0) EndIf Case $result = 1 ;disconnected. _exit() EndSelect WEnd
Code:
#include <core.au3>
$result = _checkProcess()
If $result = 0 Then
Exit(0)
EndIf
_startUp(1,1)
While 1
$result = _logCheck()
Select
Case $result = 0
;logged in.
_setsearchcoords("fullscreen")
_itemsearch()
_attackanything()
Sleep(1000)
Case $result = 1
;disconnected.
_exit()
EndSelect
WEnd
Core.au3, copy and paste the below code into
Code:
#include-once
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Global $x1,$y1,$result,$topleftcorner[2],$bottomrightcorner[2],$searchbox[4]
Global $broken,$brokenhex = 0xb20502,$variation=10
Global $box,$temparray,$count,$runonce
Global $ITEMSEARCH = 1,$MOBSEARCH = 0,$FINDGOLD = 1,$FINDITEMS = 0
;=======================================================================================
Func _advanceSkill()
Local $delay = 2000
_setSearchCoords("fullscreen")
$result = _ImageSearchArea("images\buttons\advance.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,75,"transcyan")
If $result Then
MouseMove($x1,$y1,1)
MouseClick("primary")
Sleep($delay)
$result = _ImageSearchArea("images\buttons\advance2.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,75,"transcyan")
If $result Then
MouseMove($x1,$y1,1)
MouseClick("primary")
Sleep($delay)
EndIf
$result = _ImageSearchArea("images\buttons\ok.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,75,"transcyan")
If $result Then
MouseMove($x1,$y1,1)
MouseClick("primary")
Sleep($delay)
EndIf
Return(1)
EndIf
Return(0)
EndFunc
;=======================================================================================
Func _attackAnything()
local $mouseorigin = MouseGetPos()
Send("{CTRLDOWN}")
Sleep(100)
MouseClick("left",$mouseorigin[0],$mouseorigin[1],4,50)
Sleep(100)
Send("{CTRLUP}")
EndFunc
;=======================================================================================
Func _brokenCheck()
;Quick rewrite, inventory open to view weapons in lower right, make sure "gold" below game ui.
;script will exit if main and aux are broke. Only show right hand.
Local $coords
If Not $broken Then $broken = 0
_setSearchCoords("four")
$coords = PixelSearch($searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$brokenhex,$variation)
If Not @error Then
; found broken
Send("{ALTUP}")
Send("{TAB}")
$broken +=1
Sleep(100)
Send("{ALTDOWN}")
EndIf
If $broken >= 2 Then
_exit()
EndIf
EndFunc
;=======================================================================================
Func _checkProcess()
If ProcessExists("Client.exe") Then
Return 1
Else
Return 0
EndIf
EndFunc
;=======================================================================================
Func _cleanUp()
ControlSend("", "", "", "text", 0)
_WinAPI_UnhookWindowsHookEx($hHook)
DllCallbackFree($hFunc)
EndFunc
;=======================================================================================
Func _ctrlTarget($x1,$y1)
local $mouseorigin = MouseGetPos()
Sleep(20)
MouseMove($x1,$y1,1)
Send("{CTRLDOWN}")
Sleep(20)
MouseMove($mouseorigin[0],$mouseorigin[1],1)
Sleep(20)
MouseClick("left",$mouseorigin[0],$mouseorigin[1],2)
Sleep(20)
Send("{CTRLUP}")
Sleep(200)
EndFunc
;=======================================================================================
Func _deathCheck()
;needs fixed.
_setSearchCoords("fullscreen")
$result = _ImageSearchArea("images\buttons\dead.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,80)
If $result = 1 Then
$result = _ImageSearchArea("images\buttons\revivehere.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,80)
If $result = 1 Then
MouseMove($x1,$y1,1)
MouseClick("left",$x1,$y1,2)
EndIf
Return 1
EndIf
Return 0
EndFunc
;=======================================================================================
Func _dialogue()
;Click through Trefors dialogue if you bot near him.
Local $coords,$variation=0,$colorhex=0x896B75
_setSearchCoords("three")
Do
$coords = PixelSearch($searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$colorhex,$variation)
If Not @error Then
;found
MouseMove($coords[0]+50,$coords[1],1)
MouseClick("left")
Sleep(500)
EndIf
Until @error
EndFunc
;=======================================================================================
Func _exit()
Send("{ALTUP}")
Send("{CTRLUP}")
Exit(0)
EndFunc
;=======================================================================================
Func _findGold()
$result = 0
Do
If $result = 1 Then
_pickUpItem($x1,$y1)
EndIf
$result = _ImageSearchArea("images\items\gold.gif",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,75,"transblack")
Until $result = 0
EndFunc
;=======================================================================================
Func _findItems()
Local $imagefile
$result = 0
For $quantity = 1 To $ITEMLISTING[0][0] Step 1
If $ITEMLISTING[$quantity][1] = 1 Then
$imagefile = "images\items\" & $ITEMLISTING[$quantity][0] & ".bmp"
Do
If $result = 1 Then
_pickUpItem($x1,$y1)
EndIf
$result = _ImageSearchArea($imagefile,1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,100,"transblack")
Until $result = 0
EndIf
Next
EndFunc
;=======================================================================================
Func _ImageSearchArea($findImage,$resultPosition,$x1,$y1,$right,$bottom,ByRef $x, ByRef $y, $tolerance, $transparency)
Local $array
;MsgBox(0,"asd","" & $x1 & " " & $y1 & " " & $right & " " & $bottom)
If $tolerance>0 Then $findImage = "*" & $tolerance & " " & $findImage
If $transparency Then $findImage = "*" & $transparency & " " & $findImage
$result = DllCall("ImageSearchDLL.dll","str","ImageSearch","int",$x1,"int",$y1,"int",$right,"int",$bottom,"str",$findImage)
; If error exit
If $result[0]="0" Then Return 0
; Otherwise get the x,y location of the match and the size of the image to
; compute the centre of search
$array = StringSplit($result[0],"|")
$x=Int(Number($array[2]))
$y=Int(Number($array[3]))
If $resultPosition=1 Then
$x=$x + Int(Number($array[4])/2)
$y=$y + Int(Number($array[5])/2)
EndIf
Return 1
EndFunc
;=======================================================================================
Func _itemSearch()
Select
Case $ITEMSEARCH = 0
;Do nothing.
Case $ITEMSEARCH = 1
If $FINDGOLD = 1 Then
_findGold()
Endif
If $FINDITEMS = 1 Then
_findItems()
Endif
Endselect
EndFunc
;=======================================================================================
Func _KeyboardHook($iCode, $iwParam, $ilParam)
Local $tKBDLLHS = DllStructCreate($tagKBDLLHOOKSTRUCT, $ilParam)
Local $iVkCode
If $iCode > -1 Then
$iVkCode = DllStructGetData($tKBDLLHS, 'vkCode')
If $iwParam = $WM_KEYUP Then
Switch $iVkCode
Case $VK_ESCAPE
;Exits.
_exit()
Case $VK_DELETE
;Short pause.
Sleep(10000)
EndSwitch
EndIf
EndIf
Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc
;=======================================================================================
Func _lifeCheck()
Local $colorhex,$variation,$percent,$lifebar[3],$damaged,$coords
$colorhex = 0xCD398D
$damaged = 0x630b25
$lifebar[0] = 206 ; 206 at 113 life, 198 sub 66. 162-262 total bar.
$lifebar[1] = 736
$lifebar[2] = 258
$variation = 0
$coords = PixelSearch($lifebar[0],$lifebar[1],$lifebar[2],$lifebar[1],0x000000,$variation)
If Not @error Then
$maxbar = $coords[0]
Else
$maxbar = $lifebar[2]
EndIf
$coords = PixelSearch($lifebar[0],$lifebar[1],$lifebar[2],$lifebar[1],$damaged,$variation)
If Not @error Then
$percent = 95 - ($maxbar - $coords[0])
Return $percent
ElseIf @error Then
$percent = (100 - ($lifebar[2] - $maxbar))- 4
Return $percent
EndIf
EndFunc
;=======================================================================================
Func _logCheck()
_setSearchCoords("login")
$result = _ImageSearchArea("images\buttons\windowicon.bmp",1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,75,"transblack")
If $result Then
Return 1
EndIf
Return 0
EndFunc
;=======================================================================================
Func _login()
;needs finished(again).
Local $account, $password,$coords[6]
$account = ""
$password = ""
$coords[0] = 650 ;account
$coords[1] = 470 ;account
$coords[2] = 650 ;password
$coords[3] = 505 ;password
$coords[4] = 637 ;login
$coords[5] = 573 ;login
;If $result Then
MouseMove($coords[0],$coords[1],1)
MouseClick("left",$coords[0],$coords[1],1)
Sleep(100)
Send($account)
Sleep(500)
;EndIf
;If $result Then
MouseMove($coords[2],$coords[3],1)
MouseClick("left",$coords[2],$coords[3],1)
Sleep(100)
Send($password)
Sleep(500)
;EndIf
MouseMove($coords[4],$coords[5],1)
MouseClick("left",$coords[4],$coords[5],1)
EndFunc
;=======================================================================================
Func _mobSearch()
Local $imagefile
If $MOBSEARCH = 0 Then
; Not searching for mobs.
ElseIf $MOBSEARCH = 1 Then
; Searching for mobs.
$result = 0
For $quantity = 1 To $MOBLISTING[0][0] Step 1
If $MOBLISTING[$quantity][1] = 1 Then
$imagefile = "images\mob\" & $MOBLISTING[$quantity][0] & ".bmp"
Do
If $result = 1 Then
_ctrlTarget($x1,$y1)
Return 1
EndIf
$result = _ImageSearchArea($imagefile,1,$searchbox[0],$searchbox[1],$searchbox[2],$searchbox[3],$x1,$y1,110)
Until $result = 0
EndIf
Next
Return 0
Endif
EndFunc
;=======================================================================================
Func _mover()
;dont use, imo.
Local $center[2]
$randomnumber = Random(50,150,1)
$center[0] = ($topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])/2)) + $randomnumber
$center[1] = ($topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])/2)) + $randomnumber
MouseMove($center[0],$center[1],1)
MouseClick("left",$center[0],$center[1],1)
Sleep(500)
MouseMove($center[0],$center[1],1)
MouseClick("left",$center[0],$center[1],1)
EndFunc
;=======================================================================================
Func _pickUpItem($x1,$y1)
local $mouseorigin = MouseGetPos()
MouseMove($x1,$y1,0)
Sleep(100)
MouseClick("primary",$x1,$y1,2,0)
Sleep(400)
MouseMove($mouseorigin[0],$mouseorigin[1],0)
Sleep(1000)
EndFunc
;=======================================================================================
Func _setSearchCoords($box)
; Define the coords for the search areas.
If $box = "one" Then
$searchbox[0] = $topleftcorner[0]
$searchbox[1] = $topleftcorner[1]
$searchbox[2] = $topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])/2)
$searchbox[3] = $topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])/2)
ElseIf $box = "two" Then
$searchbox[0] = $topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])/2)
$searchbox[1] = $topleftcorner[1]
$searchbox[2] = $bottomrightcorner[0]
$searchbox[3] = $topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])/2)
ElseIf $box = "three" Then
$searchbox[0] = $topleftcorner[0]
$searchbox[1] = $topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])/2)
$searchbox[2] = $topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])/2)
$searchbox[3] = $bottomrightcorner[1]
ElseIf $box = "four" Then
$searchbox[0] = $topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])/2)
$searchbox[1] = $topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])/2)
$searchbox[2] = $bottomrightcorner[0]
$searchbox[3] = $bottomrightcorner[1]
ElseIf $box = "center" Then
$searchbox[0] = $topleftcorner[0] + (($bottomrightcorner[0] - $topleftcorner[0])*.25)
$searchbox[1] = $topleftcorner[1] + (($bottomrightcorner[1] - $topleftcorner[1])*.25)
$searchbox[2] = $bottomrightcorner[0] - (($bottomrightcorner[0] - $topleftcorner[0])*.25)
$searchbox[3] = $bottomrightcorner[1] - (($bottomrightcorner[1] - $topleftcorner[1])*.25)
ElseIf $box = "fullscreen" Then
$searchbox[0] = $topleftcorner[0]
$searchbox[1] = $topleftcorner[1]
$searchbox[2] = $bottomrightcorner[0]
$searchbox[3] = $bottomrightcorner[1]
ElseIf $box = "login" Then
$searchbox[0] = 540
$searchbox[1] = 425
$searchbox[2] = 739
$searchbox[3] = 604
ElseIf $box = "connectmsg" Then
$searchbox[0] = 522
$searchbox[1] = 332
$searchbox[2] = 756
$searchbox[3] = 435
EndIF
EndFunc
;=======================================================================================
Func _setTimers($quant)
;Worthless function but it's how I roll.
Global $timers[$quant]
EndFunc
;=======================================================================================
Func _splashImage()
;for the lulz.
Local $delay = 2000
If Not WinActive("Mabinogi") Then WinActivate("Mabinogi")
GuiCreate("MyCA",500,500,-1,-1,$WS_POPUP,BitOR($WS_EX_LAYERED, $WS_EX_TOPMOST))
GuiCtrlCreatePic("images\splash\splash.gif",0,0,500,500)
GuiSetState()
Sleep($delay)
GuiDelete()
EndFunc
;=======================================================================================
Func _startUp($keys,$ini)
;$keys to 1 to turn hotkeys on or 0 to turn off. More hotkeys to come.
;$ini to 1 to turn config.ini loading/pruning on. 0 = off.
;_startUp required to use core functions.
If $runonce = 1 Then Return(0)
;=======================================================================================
;Opt("MouseCoordMode",0) ;Mouse coords by active window.
Opt("PixelCoordMode",0) ;Pixel coords by active window.
Opt("MustDeclareVars",1) ;Must declare variables.
Opt("TrayOnEventMode",1) ;Tray events on.
Opt("TrayMenuMode",1) ;No tray menu.
Opt("OnExitFunc","_cleanUp") ;Function to call on exit.
TraySetIcon("C:\Nexon\Mabinogi\Mabinogi.exe", -2) ;Set tray icon.
TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"_exit") ;Tray function on double click.
TraySetState() ;Turns the tray on.
;=======================================================================================
If $keys Then
Global Const $VK_DELETE = 0x2E
Global Const $VK_ESCAPE = 0x1B
Global $hFunc,$pFunc,$hHook,$hMod,$pause
$hFunc = DllCallbackRegister('_KeyboardHook', 'lresult', 'int;uint;uint')
$pFunc = DllCallbackGetPtr($hFunc)
$hMod = _WinAPI_GetModuleHandle(0)
$hHook = _WinAPI_SetWindowsHookEx($WH_KEYBOARD_LL, $pFunc, $hMod)
EndIf
;=======================================================================================
If $ini Then
$temparray = IniReadSection("config.ini","Mob List")
If @error Then
Exit
EndIf
For $quantity = 1 To $temparray[0][0] Step 1
If $temparray[$quantity][1] = 1 Then
$count +=1
Endif
Next
Global $MOBLISTING[$count+1][2],$arrayitems
$arrayitems = $count
$count = 1
$MOBLISTING[0][0] = $arrayitems
For $quantity = 1 To $temparray[0][0] Step 1
If $temparray[$quantity][1] = 1 Then
$MOBLISTING[$count][0] = $temparray[$quantity][0]
$MOBLISTING[$count][1] = $temparray[$quantity][1]
$count +=1
EndIf
Next
$temparray = ""
$temparray = IniReadSection("config.ini","Item List")
If @error Then
Exit
EndIf
For $quantity = 1 To $temparray[0][0] Step 1
If $temparray[$quantity][1] = 1 Then
$count +=1
Endif
Next
Global $ITEMLISTING[$count+1][2]
$arrayitems = $count
$count = 1
$ITEMLISTING[0][0] = $arrayitems
For $quantity = 1 To $temparray[0][0] Step 1
If $temparray[$quantity][1] = 1 Then
$ITEMLISTING[$count][0] = $temparray[$quantity][0]
$ITEMLISTING[$count][1] = $temparray[$quantity][1]
$count +=1
Endif
Next
$temparray = ""
EndIf
;=======================================================================================
If Not WinActive("Mabinogi") Then WinActivate("Mabinogi")
$box = WinGetPos("[active]")
$topleftcorner[0] = 0
$topleftcorner[1] = 0
$bottomrightcorner[0] = $box[2]
$bottomrightcorner[1] = $box[3]
$runonce = 1
Return(1)
EndFunc
;=======================================================================================
Func _useSkill($num,$time,$unit,$spot)
;$num = number of hotkey,$time = delay between uses, $unit is a 0 to measure in minutes and 1 to measure in seconds, $spot = timer spot
Local $difference
If $unit = 1 Then
;seconds
$time = $time * 1000
ElseIf $unit = 0 Then
;minutes
$time = $time * 60000
EndIf
$difference = TimerDiff($timers[$spot])
If $difference > $time Then
Send("{F"&$num&"}")
$timers[$spot] = TimerInit()
EndIf
EndFunc