Code:
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.14.2
Author: CrayonCode
Version: Alpha 0.12
Contact: http://www.elitepvpers.com/forum/black-desert/4268940-autoit-crayoncode-bot-project-opensource-free.html
#ce ----------------------------------------------------------------------------
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Compile_Both=y ;required for ImageSearch.au3
#AutoIt3Wrapper_UseX64=y ;required for ImageSearch.au3
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#RequireAdmin
#include "ImageSearch.au3"
#include "FastFind.au3"
#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#Region ### START Koda GUI section ### Form=C:\Program Files (x86)\AutoIt3\SciTE\Koda\Forms\NewFish1.kxf
$CrayonCode = GUICreate("CrayonCode", 401, 401, 190, 321, -1, BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
$Tab = GUICtrlCreateTab(0, 0, 400, 400)
$Tab_Main = GUICtrlCreateTabItem("Main")
$Group4 = GUICtrlCreateGroup("Stats (Press F9 to QUIT)", 32, 96, 329, 281)
$Label7 = GUICtrlCreateLabel("Status:", 48, 128, 37, 17)
$Edit1 = GUICtrlCreateEdit("", 112, 128, 233, 17, BitOR($ES_CENTER, $ES_NOHIDESEL, $ES_READONLY))
$Label6 = GUICtrlCreateLabel("Inventory:", 48, 176, 51, 17)
$Edit2 = GUICtrlCreateEdit("", 112, 176, 137, 17, BitOR($ES_CENTER, $ES_NOHIDESEL, $ES_READONLY))
GUICtrlSetTip(-1, "Number of looted items / Avaible Inventory Slots ( Reserved Slots). Stops fishing when limit is reached.")
$ButtonClear = GUICtrlCreateButton("Clear [F5]", 264, 168, 75, 33)
GUICtrlSetTip(-1, "Sets looted items to back zero.")
$ListView1 = GUICtrlCreateListView("Type|Session|Total", 48, 208, 298, 158, BitOR($GUI_SS_DEFAULT_LISTVIEW, $WS_VSCROLL), $LVS_EX_FULLROWSELECT)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 90)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 100)
$ListView1_0 = GUICtrlCreateListViewItem("White", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("Green", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("Blue", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("Gold", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("Silver Key", $ListView1)
$ListView1_5 = GUICtrlCreateListViewItem("Ancient Relic", $ListView1)
$ListView1_6 = GUICtrlCreateListViewItem("Coelacanth", $ListView1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button1 = GUICtrlCreateButton("Start/Stop [F4]", 64, 40, 115, 49)
GUICtrlSetTip(-1, "Starts/Stops fishing. Shortcut is F4.")
$Button2 = GUICtrlCreateButton("Reset Session [F8]", 208, 40, 115, 49)
GUICtrlSetTip(-1, "Sets Inventory and Session stats back to zero. Shortcut is F8.")
$Tab_Settings = GUICtrlCreateTabItem("Settings")
$Loot_Settings = GUICtrlCreateGroup("Loot Settings", 16, 56, 177, 217)
$LSpecial = GUICtrlCreateLabel("Special Items:", 36, 151, 70, 17)
$LRarity = GUICtrlCreateLabel("Minimum Rarity:", 36, 87, 78, 17)
$CRarity = GUICtrlCreateCombo("", 44, 111, 82, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Gold|Blue|Green|White|Specials Only", "Blue")
$CBSpecial1 = GUICtrlCreateCheckbox("Silver Key", 44, 175, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$CBSpecial2 = GUICtrlCreateCheckbox("Ancient Relic", 44, 207, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$CBSpecial3 = GUICtrlCreateCheckbox("Coelacanth", 44, 239, 97, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Inventory_Settings = GUICtrlCreateGroup("Inventory Settings", 208, 56, 177, 217)
$Label1 = GUICtrlCreateLabel("Free Inventory Slots:", 224, 80, 101, 17)
$Input1 = GUICtrlCreateInput("64", 232, 104, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlSetLimit(-1, 3)
GUICtrlSetTip(-1, "Avaible space for Loot specified by Loot Settings.")
$Label2 = GUICtrlCreateLabel("Reserved Slots:", 224, 144, 79, 17)
GUICtrlSetTip(-1, "When the free inventory slots are full, these slots will be reserved for Ancient Relics and Coelacanths.")
$Input2 = GUICtrlCreateInput("8", 232, 168, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlSetTip(-1, "Additional space restricted to selected Special Items.")
$Checkbox1 = GUICtrlCreateCheckbox("Discard", 232, 232, 97, 17)
GUICtrlSetTip(-1, "Throw away fishingrods with zero durability. ")
$Label3 = GUICtrlCreateLabel("Empty Rods:", 224, 208, 64, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group3 = GUICtrlCreateGroup("Buff Food", 16, 288, 265, 97)
$Checkbox2 = GUICtrlCreateCheckbox("Use Buff Food", 32, 336, 97, 17)
$Combo1 = GUICtrlCreateCombo("", 144, 336, 33, 25, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9|0", "0")
GUICtrlSetTip(-1, "Put your food on one of the hotkeys.")
$Label4 = GUICtrlCreateLabel("Hotkey:", 136, 312, 41, 17)
$Label5 = GUICtrlCreateLabel("Interval:", 216, 312, 42, 17)
$Input3 = GUICtrlCreateInput("30", 224, 336, 41, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_NUMBER))
GUICtrlSetLimit(-1, 3)
GUICtrlSetTip(-1, "Interval in minutes.")
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Button3 = GUICtrlCreateButton("Save", 304, 304, 75, 73)
$Tab_Info = GUICtrlCreateTabItem("Info")
$Credits = GUICtrlCreateEdit("", 32, 72, 337, 289, BitOR($ES_CENTER, $ES_READONLY))
GUICtrlSetData(-1, "Author: CrayonCode")
$Tab_Settings2 = GUICtrlCreateTabItem("Advanced")
$GRestock_Settings = GUICtrlCreateGroup("Restock Settings", 16, 40, 369, 345)
$CBSell = GUICtrlCreateCheckbox("Trade Fish", 32, 136, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$CBRepair = GUICtrlCreateCheckbox("Repair Inventory", 32, 160, 113, 17)
$CBBroker = GUICtrlCreateCheckbox("Auction Relics", 32, 184, 113, 17)
$CBBank = GUICtrlCreateCheckbox("Store Relics/Money", 32, 208, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$ISell = GUICtrlCreateInput("", 152, 136, 209, 21)
$IRepair = GUICtrlCreateInput("", 152, 160, 209, 21)
$IBroker = GUICtrlCreateInput("", 152, 184, 209, 21)
$IBank = GUICtrlCreateInput("", 152, 208, 209, 21)
$Input5 = GUICtrlCreateInput("Input5", 360, 88, 1, 21)
$RHorse = GUICtrlCreateRadio("Horse", 32, 88, 113, 17)
GUICtrlSetState(-1, $GUI_CHECKED)
$RBoat = GUICtrlCreateRadio("Boat", 32, 104, 113, 17)
$LNPCName = GUICtrlCreateLabel("NPC Name (Leave empty for nearest):", 160, 112, 183, 17)
$Label8 = GUICtrlCreateLabel("Walk back to mount:", 32, 72, 103, 17)
$BSave = GUICtrlCreateButton("Save", 292, 303, 75, 49)
$BTestRestock = GUICtrlCreateButton("Test Restock", 196, 303, 75, 49)
$GRestock = GUICtrlCreateGroup("", 184, 56, 145, 41)
$CBRestock = GUICtrlCreateCheckbox("Enable Auto-Restock", 198, 70, 121, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
#Region - 1920x1080 Values for DetectState()
; Press 'Space' near a body of water to start fishing.
;~ 679, 57, 15000804, E4E4E4 ;P
;~ 1233, 59, 15000804, E4E4E4 ;g
;~ Local $R[5] = [679, 60, 1233, 64, 15000804] ; FishingStandby
; You are currently fishing. Please wait until you feel a bite.
;~ 642, 60, 15000804, E4E4E4 ; Y
;~ 1256, 64, 15000804, E4E4E4 ; t
;~ Local $C[5] = [642, 60, 1256, 64, 15000804] ; FishingCurrently
; You feel a bite. Press 'Space' bar to start.
;~ 733, 60, 15000804, E4E4E4
;~ 1179, 60, 15000804, E4E4E4
;~ Local $B[5] = [733, 60, 1179, 64, 15000804] ; FishingBite
; Press it at the right time
;~ 849, 368, 16777215, FFFFFF
;~ 1068, 372, 16777215, FFFFFF
;~ Local $P[5] = [849, 368, 1068, 372, 16777215]
#EndRegion - 1920x1080 Values for DetectState()
OnAutoItExitRegister(_ImageSearchShutdown)
Opt("MouseClickDownDelay", 100)
Opt("MouseClickDelay", 50)
Opt("SendKeyDelay", 50)
Global $Fish = False
Global $Bufftimer
Global $Breaktimer
HotKeySet("{F5}", "ClearInv")
HotKeySet("{F4}", "Fish")
HotKeySet("{F8}", "ResetSession")
Func _terminate()
Exit (0)
EndFunc ;==>_terminate
Func CoSe($key, $raw = 0)
$hwnd = WinActive("BLACK DESERT -")
If $hwnd = 0 Then $hwnd = WinActivate("BLACK DESERT -")
If MouseGetPos(0) < 0 Or MouseGetPos(0) > 1920 Or MouseGetPos(1) < 0 Or MouseGetPos(1) > 1080 Then MouseMove(100, 100, 0)
ControlSend($hwnd, "", "", $key, $raw)
EndFunc ;==>CoSe
Func DetectState(ByRef $C)
Local $SSN = 1
FFSnapShot($C[0], $C[1], $C[2], $C[3], $SSN)
For $i = 0 To 3 Step 1
$FF = FFGetPixel($C[0], $C[1] + $i, $SSN)
$FF2 = FFGetPixel($C[2], $C[3] - $i, $SSN)
If $FF <> $C[4] Or $FF2 <> $C[4] Then Return False
Next
Return True
EndFunc ;==>DetectState
Func GetState()
Local $R[5] = [679, 60, 1233, 64, 15000804] ; FishingStandby
Local $C[5] = [642, 60, 1256, 64, 15000804] ; FishingCurrently
Local $B[5] = [733, 60, 1179, 64, 15000804] ; FishingBite
If DetectState($B) = True Then Return (30)
If DetectState($C) = True Then Return (20)
If DetectState($R) = True Then Return (10)
Return False
EndFunc ;==>GetState
Func ReelIn()
Local Const $C[5] = [1030, 405, 1095, 424, 5933000] ; left, top, right, bottom, color
Local $P[5] = [849, 368, 1068, 372, 16777215]
Local $SSN = 1
ConsoleWrite(@CRLF & "ReelIn")
CoSe("{SPACE}")
For $i = 0 To 20 Step 1
Sleep(100)
If DetectState($P) = True Then ExitLoop
Next
Local $timer = TimerInit()
While TimerDiff($timer) / 1000 <= 5 And $Fish
FFSnapShot($C[0], $C[1], $C[2], $C[3], $SSN)
For $i = 0 To $C[2] - $C[0] Step 1
For $j = 0 To $C[3] - $C[1] Step 1
$FF = FFGetPixel($C[0] + $i, $C[1] + $j, $SSN)
If $FF > $C[4] - 3000 And $FF < $C[4] Then
CoSe("{SPACE}")
Return True
EndIf
Next
Next
WEnd
Return False
EndFunc ;==>ReelIn
Func FindRiddleAnchor()
Local $timer = TimerInit()
Local $C[2] = [-1, -1]
While TimerDiff($timer) / 1000 <= 4 And $Fish
If _ImageSearchArea("res/reference_timeline.bmp", 0, 690, 300, 1150, 580, $C[0], $C[1], 0, 0) = 1 Then
Return ($C)
EndIf
WEnd
Return ($C)
EndFunc ;==>FindRiddleAnchor
Func Riddle($iAnchorX, $iAnchorY, $AnchorColor, $SSN)
Local Const $WordsX[8] = [-2, +3, +3, -2, -2, -2, +3, +3] ; SSWWDDAA
Local Const $WordsY[8] = [-3, -3, +2, +2, +3, -3, +2, -2] ; SSWWDDAA
Local $ai[8], $iL = 4
For $i = 0 To 7 Step 1
If FFGetPixel($iAnchorX + $WordsX[$i], $iAnchorY + $WordsY[$i], $SSN) = $AnchorColor Then
$ai[$i] = 1
Else
$ai[$i] = 0
EndIf
Next
For $j = 3 To 0 Step -1
If $ai[$j * 2] + $ai[$j * 2 + 1] = 2 Then $iL = $j
Next
Return ($iL)
EndFunc ;==>Riddle
Func Riddler()
Local Const $COffset[2] = [60, 55] ; relative position to Anchor (pointing to center of the arrow beneath each letter)
Local Const $L[5] = ["s", "w", "d", "a", "."] ; basic minigame letters ("." for unidentified)
Local Const $Spacing = 35 ; Space between each Letter
Local $SSN = 1
Local $Word[10], $LetterColor, $Riddle, $Wordlength = 0
Local $C = FindRiddleAnchor()
If $C[0] = -1 Or $C[1] = -1 Then Return False
FFSnapShot($C[0] - 90, $C[1] - 90, $C[0] + $Spacing * 10 + 90, $C[1], $SSN)
$LetterColor = FFGetPixel($C[0] - 90 + $COffset[0], $C[1] - 90 + $COffset[1], $SSN)
Local $AnchorC[2] = [$C[0] - 90 + $COffset[0], $C[1] - 90 + $COffset[1]]
For $i = 0 To 9 Step 1
$Riddle = Riddle($AnchorC[0] + $Spacing * $i, $AnchorC[1], $LetterColor, $SSN)
If $Riddle = 4 Then ; If unidentified exit loop
$Word[$i] = $L[$Riddle]
ExitLoop
Else
$Word[$i] = $L[$Riddle]
$Wordlength += 1
EndIf
Next
If $Wordlength < 2 Then
Return (False)
Else
For $i = 0 To 9 Step 1
If $Word[$i] <> "." Then
ConsoleWrite($Word[$i])
CoSe($Word[$i])
EndIf
Sleep(100)
Next
Return (True)
EndIf
EndFunc ;==>Riddler
Func DocLoot(ByRef $Loot)
Local $TotalStats = IniReadSection("config/data.ini", "TotalStats")
Switch $Loot[0]
Case 0 ;White
$TotalStats[1][1] += 1
Case 1 ;Green
$TotalStats[2][1] += 1
Case 2 ;Blue
$TotalStats[3][1] += 1
Case 3 ;Gold
$TotalStats[4][1] += 1
EndSwitch
If $Loot[1] = True Then $TotalStats[5][1] += 1
If $Loot[2] = True Then $TotalStats[6][1] += 1
If $Loot[3] = True Then $TotalStats[7][1] += 1
IniWriteSection("config/data.ini", "TotalStats", $TotalStats)
Local $SessionStats = IniReadSection("config/data.ini", "SessionStats")
Switch $Loot[0]
Case 0 ;White
$SessionStats[1][1] += 1
Case 1 ;Green
$SessionStats[2][1] += 1
Case 2 ;Blue
$SessionStats[3][1] += 1
Case 3 ;Gold
$SessionStats[4][1] += 1
EndSwitch
If $Loot[1] = True Then $SessionStats[5][1] += 1
If $Loot[2] = True Then $SessionStats[6][1] += 1
If $Loot[3] = True Then $SessionStats[7][1] += 1
IniWriteSection("config/data.ini", "SessionStats", $SessionStats)
GUICtrlSetData($ListView1_0, $SessionStats[1][0] & "|" & $SessionStats[1][1] & "|" & $TotalStats[1][1], "")
GUICtrlSetData($ListView1_1, $SessionStats[2][0] & "|" & $SessionStats[2][1] & "|" & $TotalStats[2][1], "")
GUICtrlSetData($ListView1_2, $SessionStats[3][0] & "|" & $SessionStats[3][1] & "|" & $TotalStats[3][1], "")
GUICtrlSetData($ListView1_3, $SessionStats[4][0] & "|" & $SessionStats[4][1] & "|" & $TotalStats[4][1], "")
GUICtrlSetData($ListView1_4, $SessionStats[5][0] & "|" & $SessionStats[5][1] & "|" & $TotalStats[5][1], "")
GUICtrlSetData($ListView1_5, $SessionStats[6][0] & "|" & $SessionStats[6][1] & "|" & $TotalStats[6][1], "")
GUICtrlSetData($ListView1_6, $SessionStats[7][0] & "|" & $SessionStats[7][1] & "|" & $TotalStats[7][1], "")
EndFunc ;==>DocLoot
Func DetectLoot()
Local Const $aRarityIdentifier[4] = ["", "res/loot_rarity_green.bmp", "res/loot_rarity_blue.bmp", "res/loot_rarity_gold.bmp"]
Local Const $SpecialLootIdentifier[4] = ["", "res/loot_silverkey.bmp", "res/loot_ancientrelic.bmp", "res/loot_coelacanth.bmp"]
Local Const $LootWindowRegion[4] = [1535, 590, 1725, 733] ; left, top, right, bottom
Local $Loot[4] = [0, False, False, False] ; Rarity, silverkey, piece, 250k
Local $LFx, $LFy
For $i = 1 To UBound($aRarityIdentifier) - 1 Step 1
If _ImageSearchArea($aRarityIdentifier[$i], 0, $LootWindowRegion[0], $LootWindowRegion[1], $LootWindowRegion[2], $LootWindowRegion[3], $LFx, $LFy, 10, 0) = 1 Then $Loot[0] = $i
Next
For $i = 1 To UBound($SpecialLootIdentifier) - 1 Step 1
If _ImageSearchArea($SpecialLootIdentifier[$i], 0, $LootWindowRegion[0], $LootWindowRegion[1], $LootWindowRegion[2], $LootWindowRegion[3], $LFx, $LFy, 20, 0) = 1 Then
$Loot[$i] = True
EndIf
Next
Return $Loot
EndFunc ;==>DetectLoot
Func HandleLoot($Rarity = 1, $Silverkey = True, $AncientRelic = True, $Coelacanth = True, $Reserved = False)
Local $Pick = 0
Local $Loot = DetectLoot()
ConsoleWrite(@CRLF & "[LOOT]Rarity: " & $Loot[0] & ", Silverkey: " & $Loot[1] & ", AncientRelic: " & $Loot[2] & ", Coelacanth: " & $Loot[3] & @CRLF)
DocLoot($Loot)
If $Reserved = False Then
If $Loot[0] >= $Rarity Then $Pick += 1
EndIf
If $Loot[1] = True And $Silverkey = True Then $Pick += 1000
If $Loot[2] = True And $AncientRelic = True Then $Pick += 10
If $Loot[3] = True And $Coelacanth = True Then $Pick += 100
ConsoleWrite($Pick)
If $Pick > 0 Then
CoSe("r")
Sleep(50)
CoSe("r")
If $Pick < 1000 Then Return True
EndIf
Return False
EndFunc ;==>HandleLoot
Func SetGUIStatus($data)
GUICtrlSetData($Edit1, $data, "")
EndFunc ;==>SetGUIStatus
Func SetGUIInventory($PickedLoot)
Local $InventorySettings[3] = [Int(IniRead("config/data.ini", "InventorySettings", "FreeSlots", 16)), Int(IniRead("config/data.ini", "InventorySettings", "ReservedSlots", 8)), Int(IniRead("config/data.ini", "InventorySettings", "DiscardRods", 0))]
GUICtrlSetData($Edit2, $PickedLoot & " / " & $InventorySettings[0] + $InventorySettings[1] & " (" & $InventorySettings[1] & ")", "")
IniWrite("config/data.ini", "CurrentStats", "PickedLoot", $PickedLoot)
Return ($PickedLoot)
EndFunc ;==>SetGUIInventory
Func ResetSession()
Local $SessionStats = IniReadSection("config/data.ini", "SessionStats")
For $i = 1 To UBound($SessionStats) - 1 Step 1
$SessionStats[$i][1] = 0
Next
IniWriteSection("config/data.ini", "SessionStats", $SessionStats)
SetGUIInventory(0)
InitGUI()
EndFunc ;==>ResetSession
Func ClearInv()
SetGUIInventory(0)
EndFunc ;==>ClearInv
Func InitGUI()
Local $LootSettings = IniReadSection("config/data.ini", "LootSettings")
Switch $LootSettings[1][1]
Case 0
GUICtrlSetData($CRarity, "|Gold|Blue|Green|White|Specials Only", "White")
Case 1
GUICtrlSetData($CRarity, "|Gold|Blue|Green|White|Specials Only", "Green")
Case 2
GUICtrlSetData($CRarity, "|Gold|Blue|Green|White|Specials Only", "Blue")
Case 3
GUICtrlSetData($CRarity, "|Gold|Blue|Green|White|Specials Only", "Gold")
Case 4
GUICtrlSetData($CRarity, "|Gold|Blue|Green|White|Specials Only", "Specials Only")
EndSwitch
If $LootSettings[2][1] = 1 Then
GUICtrlSetState($CBSpecial1, 1)
Else
GUICtrlSetState($CBSpecial1, 4)
EndIf
If $LootSettings[3][1] = 1 Then
GUICtrlSetState($CBSpecial2, 1)
Else
GUICtrlSetState($CBSpecial2, 4)
EndIf
If $LootSettings[4][1] = 1 Then
GUICtrlSetState($CBSpecial3, 1)
Else
GUICtrlSetState($CBSpecial3, 4)
EndIf
Local $InventorySettings = IniReadSection("config/data.ini", "InventorySettings")
GUICtrlSetData($Input1, $InventorySettings[1][1])
GUICtrlSetData($Input2, $InventorySettings[2][1])
If $InventorySettings[3][1] = 1 Then
GUICtrlSetState($Checkbox1, 1)
Else
GUICtrlSetState($Checkbox1, 4)
EndIf
Local $FoodSettings = IniReadSection("config/data.ini", "FoodSettings")
If $FoodSettings[1][1] = 1 Then
GUICtrlSetState($Checkbox2, 1)
Else
GUICtrlSetState($Checkbox2, 4)
EndIf
GUICtrlSetData($Combo1, $FoodSettings[2][1])
GUICtrlSetData($Input3, $FoodSettings[3][1])
Local $SessionStats = IniReadSection("config/data.ini", "SessionStats")
Local $TotalStats = IniReadSection("config/data.ini", "TotalStats")
GUICtrlSetData($ListView1_0, $SessionStats[1][0] & "|" & $SessionStats[1][1] & "|" & $TotalStats[1][1], "")
GUICtrlSetData($ListView1_1, $SessionStats[2][0] & "|" & $SessionStats[2][1] & "|" & $TotalStats[2][1], "")
GUICtrlSetData($ListView1_2, $SessionStats[3][0] & "|" & $SessionStats[3][1] & "|" & $TotalStats[3][1], "")
GUICtrlSetData($ListView1_3, $SessionStats[4][0] & "|" & $SessionStats[4][1] & "|" & $TotalStats[4][1], "")
GUICtrlSetData($ListView1_4, $SessionStats[5][0] & "|" & $SessionStats[5][1] & "|" & $TotalStats[5][1], "")
GUICtrlSetData($ListView1_5, $SessionStats[6][0] & "|" & $SessionStats[6][1] & "|" & $TotalStats[6][1], "")
GUICtrlSetData($ListView1_6, $SessionStats[7][0] & "|" & $SessionStats[7][1] & "|" & $TotalStats[7][1], "")
Local $CurrentStats = IniReadSection("config/data.ini", "CurrentStats")
GUICtrlSetData($Edit2, $CurrentStats[1][1] & " / " & $InventorySettings[1][1] + $InventorySettings[2][1] & " (" & $InventorySettings[2][1] & ")", "")
GUICtrlSetData($Edit1, "Please equip a fishing rod. Then start.", "")
Local $data = "Author: CrayonCode" & @CRLF & @CRLF
$data &= "This project is specifically made for the english Black Desert EU/NA client." & @CRLF & @CRLF
$data &= "Requirements are 1920x1080 Windowed Fullscreen and the default font." & @CRLF & @CRLF
$data &= "This project is Open Source and serves for educational purposes only." & @CRLF & @CRLF
$data &= "Contact & Feedback @ http://www.elitepvpers.com/forum/black-desert/4268940-autoit-crayoncode-bot-project-opensource-free.html"
GUICtrlSetData($Credits, $data)
GUICtrlSetData($ListView1_0, $SessionStats[1][0] & "|" & $SessionStats[1][1] & "|" & $TotalStats[1][1], "")
Local $RestockSettings = IniReadSection("config/data.ini", "RestockSettings")
If $RestockSettings[1][1] = 1 Then ; Enable Auto-Restock
GUICtrlSetState($CBRestock, 1)
Else
GUICtrlSetState($CBRestock, 4)
EndIf
If $RestockSettings[2][1] = 0 Then ; Enable Auto-Restock
GUICtrlSetState($RHorse, 1)
Else
GUICtrlSetState($RBoat, 1)
EndIf
If $RestockSettings[3][1] = 1 Then ; Trade Fish
GUICtrlSetState($CBSell, 1)
Else
GUICtrlSetState($CBSell, 4)
EndIf
GUICtrlSetData($ISell, $RestockSettings[4][1])
If $RestockSettings[5][1] = 1 Then ; Repair Inventory
GUICtrlSetState($CBRepair, 1)
Else
GUICtrlSetState($CBRepair, 4)
EndIf
GUICtrlSetData($IRepair, $RestockSettings[6][1])
If $RestockSettings[7][1] = 1 Then ; Auction Relics
GUICtrlSetState($CBBroker, 1)
Else
GUICtrlSetState($CBBroker, 4)
EndIf
GUICtrlSetData($IBroker, $RestockSettings[8][1])
If $RestockSettings[9][1] = 1 Then ; Store Relics/Money
GUICtrlSetState($CBBank, 1)
Else
GUICtrlSetState($CBBank, 4)
EndIf
GUICtrlSetData($IBank, $RestockSettings[10][1])
EndFunc ;==>InitGUI
Func StoreGUI()
Local $LootSettings = IniReadSection("config/data.ini", "LootSettings")
Switch GUICtrlRead($CRarity)
Case "White"
$LootSettings[1][1] = 0
Case "Green"
$LootSettings[1][1] = 1
Case "Blue"
$LootSettings[1][1] = 2
Case "Gold"
$LootSettings[1][1] = 3
Case "Specials Only"
$LootSettings[1][1] = 4
EndSwitch
If GUICtrlRead($CBSpecial1) = 1 Then
$LootSettings[2][1] = 1
Else
$LootSettings[2][1] = 0
EndIf
If GUICtrlRead($CBSpecial2) = 1 Then
$LootSettings[3][1] = 1
Else
$LootSettings[3][1] = 0
EndIf
If GUICtrlRead($CBSpecial3) = 1 Then
$LootSettings[4][1] = 1
Else
$LootSettings[4][1] = 0
EndIf
IniWriteSection("config/data.ini", "LootSettings", $LootSettings)
Local $InventorySettings = IniReadSection("config/data.ini", "InventorySettings")
$InventorySettings[1][1] = Int(GUICtrlRead($Input1))
$InventorySettings[2][1] = Int(GUICtrlRead($Input2))
If GUICtrlRead($Checkbox1) = 1 Then
$InventorySettings[3][1] = 1
Else
$InventorySettings[3][1] = 0
EndIf
IniWriteSection("config/data.ini", "InventorySettings", $InventorySettings)
Local $FoodSettings = IniReadSection("config/data.ini", "FoodSettings")
If GUICtrlRead($Checkbox2) = 1 Then
$FoodSettings[1][1] = 1
Else
$FoodSettings[1][1] = 0
EndIf
$FoodSettings[2][1] = GUICtrlRead($Combo1)
$FoodSettings[3][1] = GUICtrlRead($Input3)
IniWriteSection("config/data.ini", "FoodSettings", $FoodSettings)
Local $RestockSettings = IniReadSection("config/data.ini", "RestockSettings")
If GUICtrlRead($CBRestock) = 1 Then
$RestockSettings[1][1] = 1
Else
$RestockSettings[1][1] = 0
EndIf
If GUICtrlRead($RHorse) = 1 Then
$RestockSettings[2][1] = 0
Else
$RestockSettings[2][1] = 1
EndIf
If GUICtrlRead($CBSell) = 1 Then
$RestockSettings[3][1] = 1
Else
$RestockSettings[3][1] = 0
EndIf
$RestockSettings[4][1] = GUICtrlRead($ISell)
If GUICtrlRead($CBRepair) = 1 Then
$RestockSettings[5][1] = 1
Else
$RestockSettings[5][1] = 0
EndIf
$RestockSettings[6][1] = GUICtrlRead($IRepair)
If GUICtrlRead($CBBroker) = 1 Then
$RestockSettings[7][1] = 1
Else
$RestockSettings[7][1] = 0
EndIf
$RestockSettings[8][1] = GUICtrlRead($IBroker)
If GUICtrlRead($CBBank) = 1 Then
$RestockSettings[9][1] = 1
Else
$RestockSettings[9][1] = 0
EndIf
$RestockSettings[10][1] = GUICtrlRead($IBank)
IniWriteSection("config/data.ini", "RestockSettings", $RestockSettings)
EndFunc ;==>StoreGUI
Func Fish()
$Fish = Not $Fish
If $Fish = False Then
SetGUIStatus("Pausing.")
Else
SetGUIStatus("Starting.")
EndIf
EndFunc ;==>Fish
Func GUILoopSwitch()
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $Button3 ;Save
StoreGUI()
Case $Button2
ResetSession()
Case $Button1
Fish()
Case $ButtonClear
ClearInv()
Case $BSave
StoreGUI()
Case $BTestRestock
Restock()
EndSwitch
EndFunc ;==>GUILoopSwitch
Func OCInventory($open = True)
Local Const $InventoryRegion = [1095, 226, 1919, 855]
Local $SRx, $SRy, $IS = False
Local $timer = TimerInit()
While Not $IS And $Fish
Sleep(250)
$IS = _ImageSearchArea("res/reference_inventory.bmp", 0, $InventoryRegion[0], $InventoryRegion[1], $InventoryRegion[2], $InventoryRegion[3], $SRx, $SRy, 10, 0)
Sleep(250)
If $IS = True Then
If $open = True Then
Return (True)
ElseIf $open = False Then
CoSe("i")
Sleep(500)
EndIf
ElseIf $IS = False Then
If $open = True Then
CoSe("i")
Sleep(500)
ElseIf $open = True Then
Return (True)
EndIf
EndIf
If TimerDiff($timer) / 1000 >= 3 Then Return False
WEnd
EndFunc ;==>OCInventory
Func InspectFishingrod()
Local Const $WeaponRegion = [1200, 584, 1250, 628]
Local $SRx, $SRy, $IS = False
OCInventory(True)
If MouseGetPos(0) >= $WeaponRegion[0] And MouseGetPos(0) <= $WeaponRegion[2] And MouseGetPos(1) >= $WeaponRegion[1] And MouseGetPos(1) <= $WeaponRegion[3] Then MouseMove(10, 10) ; Keep mouse out of detection range
$IS = _ImageSearchArea("res/rod_empty.bmp", 0, $WeaponRegion[0], $WeaponRegion[1], $WeaponRegion[2], $WeaponRegion[3], $SRx, $SRy, 50, 0)
If $IS = True Then
Return True
ElseIf $IS = False Then
OCInventory(False)
Return False
EndIf
EndFunc ;==>InspectFishingrod
Func SwapFishingrod($discard = False)
Local Const $InvS[3] = [1528, 350, 48] ; X,Y,OFFSET
Local $SRx, $SRy, $IS = False
Local $Fishingrods[5] = ["res/rod_default.bmp", "res/rod_balenos.bmp", "res/rod_calpheon.bmp", "res/rod_epheria.bmp", "res/rod_mediah.bmp"]
OCInventory(True)
If MouseGetPos(0) >= $InvS[0] And MouseGetPos(0) <= $InvS[0] + 500 And MouseGetPos(1) >= $InvS[1] And MouseGetPos(1) <= $InvS[1] + 500 Then MouseMove(10, 10) ; Keep mouse out of detection range
For $j = 0 To 7 Step 1
For $i = 0 To 7 Step 1
For $k = 0 To UBound($Fishingrods) - 1 Step 1
$IS = _ImageSearchArea($Fishingrods[$k], 0, $InvS[0] - 30 + $i * $InvS[2], $InvS[1] - 30 + $j * $InvS[2], $InvS[0] + 30 + $i * $InvS[2], $InvS[1] + 30 + $j * $InvS[2], $SRx, $SRy, 10, 0)
If $IS = True Then
MouseMove($InvS[0] + $i * $InvS[2], $InvS[1] + $j * $InvS[2])
Sleep(50)
MouseClick("right", $InvS[0] + $i * $InvS[2], $InvS[1] + $j * $InvS[2])
If $discard = True Then DiscardEmptyRod()
OCInventory(False)
Return True
EndIf
Next
Next
Next
If $discard = True Then DiscardEmptyRod()
OCInventory(False)
Return False
EndFunc ;==>SwapFishingrod
Func DiscardEmptyRod()
Local Const $InvS[3] = [1528, 350, 48] ; X,Y,OFFSET
Local Const $TrashCan[2] = [1862, 780] ; X,Y
Local $SRx, $SRy, $IS = False
OCInventory(True)
If MouseGetPos(0) >= $InvS[0] And MouseGetPos(0) <= $InvS[0] + 500 And MouseGetPos(1) >= $InvS[1] And MouseGetPos(1) <= $InvS[1] + 500 Then MouseMove(10, 10) ; Keep mouse out of detection range
For $j = 0 To 7 Step 1
For $i = 0 To 7 Step 1
$IS = _ImageSearchArea("res/rod_default_discard.bmp", 0, $InvS[0] - 20 + $i * $InvS[2], $InvS[1] - 20 + $j * $InvS[2], $InvS[0] + 20 + $i * $InvS[2], $InvS[1] + 20 + $j * $InvS[2], $SRx, $SRy, 20, 0)
If $IS = True Then
MouseMove($InvS[0] + $i * $InvS[2], $InvS[1] + $j * $InvS[2])
Sleep(150)
MouseClickDrag("left", $InvS[0] + $i * $InvS[2], $InvS[1] + $j * $InvS[2], $InvS[0] + $i * $InvS[2] + 30, $InvS[1] + $j * $InvS[2], 500)
MouseMove($TrashCan[0], $TrashCan[1])
MouseClick("left", $TrashCan[0], $TrashCan[1])
Sleep(350)
CoSe("{SPACE}")
Sleep(200)
OCInventory(False)
Return True
EndIf
Next
Next
OCInventory(False)
Return False
EndFunc ;==>DiscardEmptyRod
Func Cast()
Local $C[5] = [642, 60, 1256, 64, 15000804] ; FishingCurrently
If Buff($Bufftimer) = True Then $Bufftimer = TimerInit()
Sleep(1000)
CoSe("{SPACE}")
$timer = TimerInit()
While DetectState($C) = False And $Fish
Sleep(500)
If TimerDiff($timer) / 1000 >= 12 Then Return False
WEnd
Return True
EndFunc ;==>Cast
Func Buff($timer)
Local $FoodSettings = IniReadSection("config/data.ini", "FoodSettings")
If $FoodSettings[1][1] = 1 And TimerDiff($timer) / 1000 / 60 > Int($FoodSettings[3][1]) Then
CoSe($FoodSettings[2][1])
Return True
EndIf
Return False
EndFunc ;==>Buff
Func CheckClientResolution()
Local $CCR = WinGetClientSize("BLACK DESERT -")
If @error Then
Return False
ElseIf $CCR[0] = 1920 And $CCR[1] = 1080 Then
Return True
EndIf
Return False
EndFunc ;==>CheckClientResolution
Func Main()
Local $LootSettings[4] = [Int(IniRead("config/data.ini", "LootSettings", "Rarity", 2)), Int(IniRead("config/data.ini", "LootSettings", "Silverkey", True)), Int(IniRead("config/data.ini", "LootSettings", "AncientRelic", True)), Int(IniRead("config/data.ini", "LootSettings", "Coelacanth", True))]
Local $InventorySettings[3] = [Int(IniRead("config/data.ini", "InventorySettings", "FreeSlots", 16)), Int(IniRead("config/data.ini", "InventorySettings", "ReservedSlots", 8)), Int(IniRead("config/data.ini", "InventorySettings", "DiscardRods", 0))]
Global $PickedLoot = Int(IniRead("config/data.ini", "CurrentStats", "PickedLoot", 0))
Global $SwappedRods = 0
Local $fishingtimer = 0
Local $Reserved = False
Local $CorrectRes = False
Local $ScreenSaver = TimerInit()
$Fish = False
InitGUI()
While True
GUILoopSwitch()
While $Fish
If $CorrectRes = False Then $CorrectRes = CheckClientResolution()
If $CorrectRes = False Then
SetGUIStatus("E: must be 1920x1080 Windowed Fullscreen")
$Fish = False
ExitLoop
EndIf
GUILoopSwitch()
Switch GetState()
Case 30 ; You feel a bite. Press 'Space' bar to start.
$Breaktimer = 0
SetGUIStatus("Reeling in.")
If ReelIn() = True Then
SetGUIStatus("Solving riddle.")
Riddler()
SetGUIStatus("Evaluating loot.")
Sleep(3000)
$PickedLoot = Int(IniRead("config/data.ini", "CurrentStats", "PickedLoot", 0))
$LootSettings[0] = Int(IniRead("config/data.ini", "LootSettings", "Rarity", 2))
$LootSettings[1] = Int(IniRead("config/data.ini", "LootSettings", "Silverkey", True))
$LootSettings[2] = Int(IniRead("config/data.ini", "LootSettings", "AncientRelic", True))
$LootSettings[3] = Int(IniRead("config/data.ini", "LootSettings", "Coelacanth", True))
If HandleLoot($LootSettings[0], $LootSettings[1], $LootSettings[2], $LootSettings[3], $Reserved) = True Then $PickedLoot += 1
SetGUIInventory($PickedLoot)
$InventorySettings[0] = Int(IniRead("config/data.ini", "InventorySettings", "FreeSlots", 16))
$InventorySettings[1] = Int(IniRead("config/data.ini", "InventorySettings", "ReservedSlots", 8))
$InventorySettings[2] = Int(IniRead("config/data.ini", "InventorySettings", "DiscardRods", 0))
If $InventorySettings[0] - $PickedLoot <= 0 Then
If $InventorySettings[1] > 0 Then $Reserved = True
If $InventorySettings[0] + $InventorySettings[1] - $PickedLoot <= 0 Then
SetGUIStatus("Inventory full. Stopping.")
$Fish = False
If IniRead("config/data.ini", "RestockSettings", "EnableRestock", 0) Then Restock() ; EXPERIMENTAL
ExitLoop
EndIf
EndIf
EndIf
Case 20 ; You are currently fishing. Please wait until you feel a bite.
If TimerDiff($ScreenSaver) / 1000 / 60 >= 2 Then ; To fix ScreenSaver messing up
MouseMove(MouseGetPos(0) + 10, MouseGetPos(1))
MouseMove(MouseGetPos(0) - 10, MouseGetPos(1))
$ScreenSaver = TimerInit()
EndIf
$Breaktimer = 0
If $fishingtimer <> 0 Then
SetGUIStatus("Currently fishing. (" & Round(TimerDiff($fishingtimer) / 1000, 0) & "s)")
Else
SetGUIStatus("Currently fishing.")
EndIf
Case 10 ; Press 'Space' near a body of water to start fishing.
$Breaktimer = 0
SetGUIStatus("Ready for fishing.")
If Cast() = False Then
SetGUIStatus("Cast failed. Inspecting equipped fishingrod.")
If InspectFishingrod() = True Then
SetGUIStatus("Swapping fishingrods.")
If SwapFishingrod($InventorySettings[2]) = True Then
$SwappedRods += 1
Else
SetGUIStatus("No fishingrods found. Stopping.")
$Fish = False
If IniRead("config/data.ini", "RestockSettings", "EnableRestock", 0) Then Restock() ; EXPERIMENTAL
ExitLoop
EndIf
EndIf
EndIf
$fishingtimer = TimerInit()
Case Else
SetGUIStatus("Unidentified state.")
If $Breaktimer = 0 Then
$Breaktimer = TimerInit()
ElseIf TimerDiff($Breaktimer) / 1000 > 10 Then
SetGUIStatus("Unidentified state. Trying to equip fishingrod.")
If SwapFishingrod() = False Then
SetGUIStatus("Detection Error. UI Scale must be at 100%")
$Fish = False
ExitLoop
Else
Sleep(3000)
EndIf
EndIf
EndSwitch
Sleep(100)
If $Fish = False Then
SetGUIStatus("Fishing stopped.")
$fishingtimer = 0
EndIf
WEnd
WEnd
EndFunc ;==>Main
Func UnequipRod()
Local Const $WeaponRegion = [1200, 584, 1250, 628]
Local $SRx, $SRy, $IS = False
OCInventory(True)
MouseClick("right", 1225, 600)
OCInventory(False)
Return True
EndFunc ;==>UnequipRod
Func TrackNPC($npcname)
Local Const $NPCSearchIcon[2] = [1556, 30]
Local Const $NPCs[4] = ["res/npc_bank.bmp", "res/npc_repair.bmp", "res/npc_trade.bmp", "res/npc_broker.bmp"]
Local Const $Offset[2] = [515, 345]
Local $C[2] = [-1, -1]
Local $IS, $counter = 3
While $Fish
UnequipRod()
CoSe("{LCTRL}")
Sleep(250)
MouseClick("left", $NPCSearchIcon[0], $NPCSearchIcon[1])
Sleep(250)
$IS = _ImageSearchArea($NPCs[1], 1, 1175, 50, 1600, 676, $C[0], $C[1], 50, 0)
If $IS = True Then
MouseMove($C[0], $C[1] + $Offset[0])
MouseClick("left")
Sleep(250)
Send($npcname) ; Send instead of CoSe because of trouble with > key
CoSe("{ENTER}")
MouseMove($C[0], $C[1] + $Offset[1])
MouseClick("left")
Sleep(250)
CoSe("t")
CoSe("{ESC}")
CoSe("{LCTRL}")
Return True
Else
$counter -= 1
If $counter <= 0 Then Return False
EndIf
WEnd
EndFunc ;==>TrackNPC
Func NearbyNPC($npc_type) ; 0 = bank, 1 = repair, 2 = trader, 3 = broker
Local Const $NPCSearchIcon[2] = [1556, 30]
Local Const $NPCs[4] = ["res/npc_bank.bmp", "res/npc_repair.bmp", "res/npc_trade.bmp", "res/npc_broker.bmp"]
Local $x, $y, $IS, $counter = 3
While $Fish
UnequipRod()
CoSe("{LCTRL}")
Sleep(250)
MouseClick("left", $NPCSearchIcon[0], $NPCSearchIcon[1])
Sleep(250)
$IS = _ImageSearchArea($NPCs[$npc_type], 1, 1175, 50, 1600, 676, $x, $y, 50, 0)
If $IS = True Then
MouseMove($x, $y)
Sleep(50)
MouseClick("left", $x, $y)
Sleep(50)
MouseClick("right", $x, $y)
Sleep(50)
CoSe("{ESC}")
CoSe("{LCTRL}")
Return True
Else
$counter -= 1
If $counter <= 0 Then Return False
EndIf
WEnd
EndFunc ;==>NearbyNPC
Func MapMovement()
Local Const $MapRegion = [1815, 48, 1830, 50]
Local $FF[6][2]
Local $dif = 0, $SSN = 1
Local $timer = TimerInit()
SetGUIStatus("Autopathing...")
While TimerDiff($timer) / 1000 <= 180 And $Fish
Sleep(250)
FFSnapShot($MapRegion[0], $MapRegion[1], $MapRegion[2], $MapRegion[3], $SSN)
For $i = 0 To UBound($FF) - 1 Step 1
$FF[$i][0] = FFGetPixel($MapRegion[0] + 2 * $i, $MapRegion[1], $SSN)
Next
Sleep(500)
FFSnapShot($MapRegion[0], $MapRegion[1], $MapRegion[2], $MapRegion[3], $SSN)
For $i = 0 To UBound($FF) - 1 Step 1
$FF[$i][1] = FFGetPixel($MapRegion[0] + 2 * $i, $MapRegion[1], $SSN)
If $FF[$i][0] = $FF[$i][1] Then $dif += 1
Next
If $dif >= 3 Then
Return True
Else
$dif = 0
Sleep(4000)
MouseMove(MouseGetPos(0) + 10, MouseGetPos(1)) ; Stop Screensaver
MouseMove(MouseGetPos(0) - 10, MouseGetPos(1))
Sleep(1000)
EndIf
WEnd
ConsoleWrite("MapMovement failed.")
Return False
EndFunc ;==>MapMovement
Func NPCType($type, $npcname) ; bank, repair, trade, broker
Local Const $ButtonRegion = [431, 822, 1522, 906]
Local Const $NPCs[4][2] = [["res/npc_bank.bmp", "res/npc_bank_button.bmp"], ["res/npc_repair.bmp", "res/npc_repair_button.bmp"], ["res/npc_trade.bmp", "res/npc_trade_button.bmp"], ["res/npc_broker.bmp", "res/npc_broker_button.bmp"]]
Local $IS, $x, $y, $SSN = 1, $counter = 10
If $npcname <> "" Then
TrackNPC($npcname)
Else
NearbyNPC($type)
EndIf
MapMovement()
While $counter >= 0
CoSe("r") ; Talk to NPC
Sleep(750)
$IS = _ImageSearchArea($NPCs[$type][1], 1, $ButtonRegion[0], $ButtonRegion[1], $ButtonRegion[2], $ButtonRegion[3], $x, $y, 20, 0)
If $IS = True Then ; Check for correct dialogue
MouseClick("left", $x, $y, 2)
Sleep(500)
Return True
Else
; Close dialog and slowly pan camera to the right in case multiple npcs are overlapping
CoSe("{ESC}")
Sleep(500)
MouseMove(MouseGetPos(0) + 500, MouseGetPos(1), 50)
EndIf
$counter -= 1
If $counter <= 0 Then Return False
WEnd
EndFunc ;==>NPCType
Func BankRelics($npcname = "")
Local Const $Relic = "res/loot_ancientrelic.bmp"
Local Const $InvS[3] = [1528, 350, 48] ; X,Y,OFFSET
Local Const $Money[2] = [1534, 795]
Local $IS, $x, $y
If NPCType(0, $npcname) = True Then
SetGUIStatus("Storing Relics & Money.")
For $k = 0 To 1 Step 1
If MouseGetPos(0) >= $InvS[0] And MouseGetPos(0) <= $InvS[0] + 500 And MouseGetPos(1) >= $InvS[1] And MouseGetPos(1) <= $InvS[1] + 500 Then MouseMove($InvS[0] - 50, $InvS[1]) ; Keep mouse out of detection range
For $i = 0 To 7 Step 1
For $j = 0 To 7 Step 1
$IS = _ImageSearchArea($Relic, 0, $InvS[0] - 30 + $i * $InvS[2], $InvS[1] - 30 + $j * $InvS[2], $InvS[0] + 30 + $i * $InvS[2], $InvS[1] + 30 + $j * $InvS[2], $x, $y, 20, 0)
If $IS = True Then MouseClick("right", $x, $y, 2)
Next
Next
MouseMove($InvS[0], $InvS[1])
Sleep(50)
MouseWheel("down", 8)
Sleep(150)
Next
MouseClick("left", $Money[0], $Money[1], 2)
Sleep(150)
CoSe("f")
CoSe("{SPACE}")
Sleep(250)
CoSe("{ESC}")
CoSe("{ESC}")
Return True
Else
Return False
; TODO ERROR HANDLING
EndIf
EndFunc ;==>BankRelics
Func RepairInv($npcname = "")
Local Const $RepairInven[3] = [1151, 1036, 10569571]
If NPCType(1, $npcname) = True Then
SetGUIStatus("Repairing.")
MouseClick("left", $RepairInven[0], $RepairInven[1], 2)
Sleep(250)
CoSe("{SPACE}")
Sleep(250)
CoSe("{ESC}")
CoSe("{ESC}")
Return True
Else
Return False
; TODO ERROR HANDLING
EndIf
EndFunc ;==>RepairInv
Func BrokerRelics($npcname = "")
Local Const $MyListingsButton[3] = [819, 1039, 460812]
Local Const $RegisterItemButton[2] = [1314, 304]
Local Const $ConfirmButton[2] = [1212, 399]
Local $InvS[3] = [1528, 350, 48] ; X,Y,OFFSET
Local Const $Relic = "res/broker_ancientrelic.bmp"
Local $IS, $x, $y
If NPCType(3, $npcname) = True Then
SetGUIStatus("Auctioning Relics.")
MouseClick("left", $MyListingsButton[0], $MyListingsButton[1], 2)
Sleep(500)
MouseClick("left", $RegisterItemButton[0], $RegisterItemButton[1], 2)
Sleep(500)
For $k = 0 To 1 Step 1
If MouseGetPos(0) >= $InvS[0] And MouseGetPos(0) <= $InvS[0] + 500 And MouseGetPos(1) >= $InvS[1] And MouseGetPos(1) <= $InvS[1] + 500 Then MouseMove($InvS[0] - 50, $InvS[1]) ; Keep mouse out of detection range
For $i = 0 To 7 Step 1
For $j = 0 To 7 Step 1
$IS = _ImageSearchArea($Relic, 0, $InvS[0] - 30 + $i * $InvS[2], $InvS[1] - 30 + $j * $InvS[2], $InvS[0] + 30 + $i * $InvS[2], $InvS[1] + 30 + $j * $InvS[2], $x, $y, 20, 0)
If $IS = True Then
MouseClick("right", $x, $y, 2)
Sleep(250)
MouseClick("left", $ConfirmButton[0], $ConfirmButton[1], 2)
Sleep(250)
CoSe("{SPACE}")
CoSe("{SPACE}")
EndIf
Next
Next
MouseMove($InvS[0], $InvS[1])
Sleep(50)
MouseWheel("down", 8)
Sleep(150)
Next
CoSe("{ESC}")
CoSe("{ESC}")
CoSe("{ESC}")
Return True
Else
Return False
; TODO ERROR HANDLING
EndIf
EndFunc ;==>BrokerRelics
Func SellFish($npcname = "")
Local Const $SellAllButton[2] = [1782, 753]
If NPCType(2, $npcname) = True Then
SetGUIStatus("Selling Fish.")
MouseClick("left", $SellAllButton[0], $SellAllButton[1])
Sleep(500)
CoSe("{SPACE}")
Sleep(500)
CoSe("{ESC}")
CoSe("{ESC}")
Sleep(500)
Return True
Else
Return False
; TODO ERROR HANDLING
EndIf
EndFunc ;==>SellFish
Func BackToMount($Boat = 0)
Local Const $Mount[2][2] = [[39, 128], [98, 122]]
Local Const $NPCSearchIcon[2] = [1556, 30]
Local Const $NPCs[4] = ["res/npc_bank.bmp", "res/npc_repair.bmp", "res/npc_trade.bmp", "res/npc_broker.bmp"]
Local $x, $y, $IS
Sleep(500)
UnequipRod()
CoSe("{LCTRL}")
;Workaround to improve correct pathing to mount
Sleep(250)
MouseClick("left", $NPCSearchIcon[0], $NPCSearchIcon[1])
Sleep(750)
$IS = _ImageSearchArea($NPCs[1], 1, 1175, 50, 1600, 676, $x, $y, 50, 0)
If $IS = True Then
MouseMove($x, $y)
Sleep(50)
MouseClick("right", $x, $y)
Sleep(50)
MouseClick("left", $x, $y)
Sleep(50)
MouseMove($Mount[$Boat][0], $Mount[$Boat][1])
Sleep(250)
MouseClick("right", $Mount[$Boat][0], $Mount[$Boat][1])
Sleep(250)
MouseClick("right", $Mount[$Boat][0], $Mount[$Boat][1])
Sleep(500)
CoSe("t")
CoSe("{ESC}")
CoSe("{LCTRL}")
MapMovement()
Return True
EndIf
Return False
EndFunc ;==>BackToMount
Func Restock()
Local $RestockSettings = IniReadSection("config/data.ini", "RestockSettings")
If $RestockSettings[1][1] = 0 Then Return False
SetGUIStatus("Restocking...")
WinActivate("BLACK DESERT - ")
Sleep(500)
$Fish = True
If $RestockSettings[3][1] = 1 Then
SetGUIStatus("Selling Fish.")
If SellFish($RestockSettings[4][1]) = True Then SetGUIInventory(0)
EndIf
If $RestockSettings[5][1] = 1 Then
SetGUIStatus("Repairing.")
RepairInv($RestockSettings[6][1])
EndIf
If $RestockSettings[7][1] = 1 Then
SetGUIStatus("Auctioning Relics.")
BrokerRelics($RestockSettings[6][1])
EndIf
If $RestockSettings[9][1] = 1 Then
SetGUIStatus("Storing Relics & Money.")
If BankRelics($RestockSettings[6][1]) = True Then SetGUIInventory(0)
EndIf
SetGUIStatus("Autopathing to mount.")
BackToMount($RestockSettings[2][1])
SetGUIStatus("Autopath to mount complete.")
Return True
EndFunc ;==>Restock
Main()
If Time = 30 minutes Then
If RemoteStorageNPC.checked = True Then
StopFishing()
OpenRemoteStorage()
StoreRelic()
CountInventorySlot()
ResumeFishing()
Else
StopFishing()
OpenRemoteAuction()
AuctionRelic()
CountInventorySlot()
ResumeFishing()
End If
End If