Code:
#NoEnv
SendMode Event
SetWorkingDir %A_ScriptDir%
#SingleInstance, Force
#WinActivateForce
ShowTooltip := 1
Width := 576
Height := 432
FirstRun := 0
EachSec = Each Second
EachFish = Each Fish
SplitPath, A_ScriptName,,,, ScriptName
plik = %A_ScriptDir%\%ScriptName%.ini
plikmain = %A_ScriptDir%\FishBot.ini
ifnotexist,%plik%
{
FirstRun := 1
IniWrite,NumPad7,%plik%,Hotkeys,HotkeyToStart
IniWrite,Numpad9,%plik%,Hotkeys,HotkeyToStop
IniWrite,1,%plik%,Boots,DropBoots
IniWrite,Each Fish,%plik%,Boots,DropType
IniWrite,1,%plik%,Notify,Full
}
ifnotexist,%plikmain%
{
IniWrite,"0x00964DDC+0x144+0xe4+0x70",%plikmain%,Pointers,WaterPointer
IniWrite,"0x00964DDC+0x144+0xe4+0x514",%plikmain%,Pointers,LavaPointer
IniWrite,"0x00964DDC+0x144+0xe4+0x2c0",%plikmain%,Pointers,ChocoPointer
}
IniRead,HotkeyToStart,%plik%,Hotkeys,HotkeyToStart
IniRead,HotkeyToStop,%plik%,Hotkeys,HotkeyToStop
IniRead,DropBoots,%plik%,Boots,DropBoots
IniRead,DropType,%plik%,Boots,DropType
IniRead,Full,%plik%,Notify,Full
IniRead,ShowTooltip,%plik%,Notify,Stats
IniRead,WaterPointer,%plikmain%,Pointers,WaterPointer
IniRead,LavaPointer,%plikmain%,Pointers,LavaPointer
IniRead,ChocoPointer,%plikmain%,Pointers,ChocoPointer
If FirstRun = 1
{
;Logo = %A_ScriptDir%\logo.png
Gui, Add, Picture, x1 y1, %Logo%
Gui, font, s10, Verdana
Gui, Add, GroupBox, x10 y55 w165 h164, FishBot Settings
Gui, font
Gui, Add, text, x20 y80 , Start Hotkey
Gui, Add, ComboBox, vSettings_Start w88 x82 y76, CapsLock|Space|Tab|Enter|Escape|Backspace|ScrollLock|Delete|Insert|Home|End|PgUp|PgDn|Numpad0|NumpadIns|Numpad1|NumpadEnd|Numpad2|NumpadDown|Numpad3|NumpadPgDn|Numpad4|NumpadLeft|Numpad5|NumpadClear|Numpad6|NumpadRight|Numpad7||NumpadHome|Numpad8|NumpadUp|Numpad9|NumpadPgUp|NumpadDot|NumpadDel|NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12
Gui, Add, text, x20 y104 , Stop Hotkey
Gui, Add, ComboBox, vSettings_Stop w88 x82 y100, CapsLock|Space|Tab|Enter|Escape|Backspace|ScrollLock|Delete|Insert|Home|End|PgUp|PgDn|Numpad0|NumpadIns|Numpad1|NumpadEnd|Numpad2|NumpadDown|Numpad3|NumpadPgDn|Numpad4|NumpadLeft|Numpad5|NumpadClear|Numpad6|NumpadRight|Numpad7|NumpadHome|Numpad8|NumpadUp|Numpad9||NumpadPgUp|NumpadDot|NumpadDel|NumpadDiv|NumpadMult|NumpadAdd|NumpadSub|NumpadEnter|F1|F2|F3|F4|F5|F6|F7|F8|F9|F10|F11|F12
Gui, Add, text, x20 y128, Drop Boots
Gui, Add, CheckBox, x83 y128 vButy
Gui, Add, text, x20 y152, Drop Type
Gui, Add, DropDownList, vDropType w88 x82 y148, Each Second|Each Fish||
Gui, Add, text, x20 y176, Full Notify
Gui, Add, CheckBox, x83 y176 vFull checked
Gui, Add, text, x20 y200, Show Stats
Gui, Add, CheckBox, x83 y200 vStats checked
Gui, Add, Button, x25 y224 w140 h22 default gSaveSettings, Save and Start
Gui, Show, x386 y200 h255 w185, FishBot
return
}
Sleep, 2000
WaterArray := StrSplit(WaterPointer, "+")
LavaArray := StrSplit(LavaPointer, "+")
ChocoArray := StrSplit(ChocoPointer, "+")
Hotkey,~%HotkeyToStart%,StartButton
Hotkey,~%HotkeyToStop%,StopButton
IfExist,C:\Program Files (x86)\Glyph\GlyphClient.cfg
{
FileReadLine,user,C:\Program Files (x86)\Glyph\GlyphClient.cfg,6
array := strsplit(user, "=")
}
Gui, +AlwaysOnTop +Disabled -SysMenu +Owner
Gui, Add, Text,, Status:
Gui, Add, Text,, Start Key:
Gui, Add, Text,, Stop Key:
Gui, Add, Text,, Trove PID:
Gui, Add, Text,, Email:
Gui, Add, Text,, Script/Exe:
Gui, Add, Text,, Total Time:
Gui, Add, Text,, Total Fish Caught:
Gui, Add, Text,, Fishing Time:
Gui, Add, Text,, Boots Dropped:
Gui, Add, Text,, CaughtWater:
Gui, Add, Edit, ReadOnly w100 ym vSta,
Gui, Add, Edit, ReadOnly, %HotkeyToStart%
Gui, Add, Edit, ReadOnly, %HotkeyToStop%
Gui, Add, Edit, ReadOnly, %pidn%
Gui, Add, Edit, ReadOnly, % array[2]
Gui, Add, Edit, ReadOnly, %A_ScriptName%
Gui, Add, Edit, ReadOnly w100 vTim,0
Gui, Add, Edit, ReadOnly w100 vFis,0
Gui, Add, Edit, ReadOnly w100 vFisTim,0
Gui, Add, Edit, ReadOnly w100 vBoo,0
Gui, Add, Edit, ReadOnly w100 vWC,0
Gui, Show, NoActivate x0 y0, Fish Stats
GuiControl,, Sta, Not Started
WinActivate , ahk_exe Trove.exe
WinWaitActive, ahk_exe Trove.exe
return
If FirstRun = 0
{
ToolTip, %ToolTipTextRun%, %winX%, %winY%, 1s
Sleep,3000
ToolTip
}
return
SaveSettings:
Gui, Submit
IniWrite,%Settings_Start%,%plik%,Hotkeys,HotkeyToStart
IniWrite,%Settings_Stop%,%plik%,Hotkeys,HotkeyToStop
IniWrite,%Buty%,%plik%,Boots,DropBoots
IniWrite,%DropType%,%plik%,Boots,DropType
IniWrite,%Full%,%plik%,Notify,Full
IniWrite,%Stats%,%plik%,Notify,Stats
ToolTip, %ToolTipTextRun%, %winX%, %winY%, 1s
Sleep,3000
ToolTip
Reload
return
StartButton:
SoundBeep
if !(pid){
if WinActive("Trove"){
IniRead,HotkeyToStart,%plik%,Hotkeys,HotkeyToStart
IniRead,HotkeyToStop,%plik%,Hotkeys,HotkeyToStop
IniRead,DropBoots,%plik%,Boots,DropBoots
IniRead,Full,%plik%,Notify,Full
WinGet, pidn, PID, A
pid := pidn
WinGet, hwnds, ID, A
Handle := hwnds
if (DropBoots = 1){
WinGetPos, X1, Y1,,, ahk_pid %pid%
WinMove, ahk_pid %pid%,, X1, Y1, Width, Height
}
CoordMode, ToolTip, Screen
WinGetPos, winX, winY, winW, winH, ahk_pid %pid%
} else {
MsgBox, Couldn't find the Trove window.`n Make sure its Active when u press NumPad7`nProgram will now exit.
ExitApp
}
Sleep, 2000
CoordMode, ToolTip, Screen
WinGetPos, winX, winY, winW, winH, ahk_pid %pid%
Sleep, 3000
Base := getProcessBaseAddress()
WaterAddress := GetAddress(Base,WaterArray*)
LavaAddress := GetAddress(Base,LavaArray*)
ChocoAddress := GetAddress(Base,ChocoArray*)
Time_Start := A_TickCount
Time := 0
Fish := 0
ShouldFish := 0
Timer := 0
Boots := 0
Loop
{
GuiControl,, Sta, Fishing
ControlSend, , {f down}, ahk_pid %pid%
RandSleep(86,100)
ControlSend, , {f up}, ahk_pid %pid%
If (DropBoots = 1)
{
RandSleep(100,120)
ControlSend, , {b down}, ahk_pid %pid%
RandSleep(86,100)
ControlSend, , {b up}, ahk_pid %pid%
RandSleep(100,120)
ControlSend, , {b down}, ahk_pid %pid%
RandSleep(86,100)
ControlSend, , {b up}, ahk_pid %pid%
}
Timer := 0
While Timer = 0
{
Loop
{
If ProcessExist(pid) = 0
ExitApp
WinGet, WinState, MinMax, ahk_pid %PID%
CoordMode, ToolTip, Screen
WinGetPos, winX, winY, winW, winH, ahk_pid %PID%
Time := FormatSeconds(Round((A_TickCount - Time_Start)/1000))
If (DropBoots = 1)
{
GuiControl,, Tim, %Time%
GuiControl,, Fis, %Fish%
GuiControl,, FisTim, %Timer% s
GuiControl,, Boo, %Boots%
GuiControl,,WC, %WaterAddress%/%CaughtWater%
} else {
GuiControl,, Tim, %Time%
GuiControl,, Fis, %Fish%
GuiControl,, FisTim, %Timer% s
GuiControl,, Boo, %Boots%
GuiControl,,WC, %WaterAddress%/%CaughtWater%
}
If (ShowTooltip = 1)
{
If (WinState != -1)
ToolTip, %ToolTipText%, %winX%, %winY%, 1s
Else
ToolTip
} else
ToolTip
CaughtWater := ReadMemory(WaterAddress)
CaughtLava := ReadMemory(LavaAddress)
CaughtChoco := ReadMemory(ChocoAddress)
If (CaughtWater = 1 or CaughtLava = 1 or CaughtChoco = 1)
{
Fish := Fish + 1
ShouldFish := Fish
Break
}
if Timer >= 45
{
ControlSend, , {f down}, ahk_pid %pid%
RandSleep(86,100)
ControlSend, , {f up}, ahk_pid %pid%
Break
}
Sleep, 1000
Timer := Timer + 1
If (DropType == EachSec){
If (DropBoots = 1){
Loop, 17
{
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, X1+Width-200, Y1, X1+Width, Y1+Height, *50 %A_ScriptDir%\data\%a_index%.png
if ErrorLevel = 0
{
Sleep, 86
WinActivate, ahk_pid %pid%
CoordMode, Mouse, Screen
MouseClickDrag, Left, FoundX, FoundY, FoundX-200, FoundY, 7
Sleep, 90
Boots := Boots + 1
Break
}
}
}
}
}
If (DropType == EachFish){
If (DropBoots = 1){
Loop, 17
{
CoordMode, Pixel, Screen
ImageSearch, FoundX, FoundY, X1+Width-200, Y1, X1+Width, Y1+Height, *50 %A_ScriptDir%\data\%a_index%.png
if ErrorLevel = 0
{
Sleep, 86
WinActivate, ahk_pid %pid%
CoordMode, Mouse, Screen
MouseClickDrag, Left, FoundX, FoundY, FoundX-200, FoundY, 7
Sleep, 90
Boots := Boots + 1
Break
}
}
}
}
}
Timer := 0
ShouldFish := ShouldFish + 1
ControlSend, , {f down}, ahk_pid %pid%
RandSleep(86,100)
ControlSend, , {f up}, ahk_pid %pid%
RandSleep(2000,2500)
if Full = 1
{
if (ShouldFish >= (Fish + 2)){
ShouldFish := Fish
SplashTextOn ,300 ,133 , Error, `nError!`n`nYour Fishing Bot "%A_ScriptName%" got stuck?`nEither your inventory is full,`nor you are no longer fishing!
Sleep, 7000
SplashTextOff
}
}
}
return
StopButton:
SoundBeep
Sleep, 1000
Reload
}
return
GetAddress(start,offsets*)
{
base := offsets.Remove(1) + start
if offsets.maxIndex() = 1
pointer := offsets[1] + ReadMemory(base)
else For index, offset in offsets
{
If (A_Index = 1)
pointer := ReadMemory(offset + ReadMemory(base))
Else If (index = offsets.MaxIndex())
pointer += offset
Else pointer := ReadMemory(pointer + offset)
}
return offsets.maxIndex() ? pointer : base
}
getProcessBaseAddress()
{
Global Handle
return DllCall( A_PtrSize = 4
? "GetWindowLong"
: "GetWindowLongPtr"
, "Ptr", Handle
, "Int", -6
, "Int64")
}
ReadMemory(MADDRESS)
{
Global pid
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint",4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}
FormatSeconds(NumberOfSeconds)
{
time = 19990101
time += %NumberOfSeconds%, seconds
FormatTime, mmss, %time%, mm:ss
return NumberOfSeconds//3600 ":" mmss
}
RandSleep(x,y) {
Random, rand, %x%, %y%
Sleep %rand%
}
ProcessExist(Name){
Process,Exist,%Name%
return Errorlevel
}