-
Notifications
You must be signed in to change notification settings - Fork 13
/
TroveAutoFish.ahk
315 lines (269 loc) · 8.37 KB
/
TroveAutoFish.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#WinActivateForce
; Script config. Do NOT change value here, might working inproperly!
global Version := "v20150909" ; The version number of this script
global FishAddress := "0x00A43F04" ; The memory address for fishing
; Tooltip settings
global TooltipX := 80 ; Tooltip's X position
global TooltipY := 150 ; Tooltip's Y position
; Hotkeys settings, change the hotkeys here
global HK_AutoFish := "F11" ; Hotkey for auto fishing
global HK_AutoBoot := "F10" ; Hotkey for auto boot throw
global HK_AntiAFK := "F9" ; Hotkey for anti-AFK
global HK_Info := "F8" ; Hotkey for info tooltip toggle
global HK_Exit := "F6" ; Hotkey for exit the script
; Auto Boot Throw settings
global Interval_Boot := 2000 ; Auto Throw Boot trigger interval in milliseconds. The default is 2000ms. Set longer interval to save CPU usage. Set shorter interval to throw boot faster.
global BootImgPath := "c:\boot.bmp" ; set your Old Bood image path here
global FastABTDelay := 0.5 ; Long press delay before triggering Fast ABT. The default is 0.5 seconds
; Anti-AFK settings
global Interval_AFK := 10000 ; Anti-AFK trigger interval in milliseconds. The default is 10 seconds (10000ms)
global AFK_Key := "End" ; The key to send to prevent AFK by Anti-AFK. The default is "End" key which will not effect Trove gameplay
; Flags startup settings. Do NOT change value here, might working inproperly!
global Flag_ABT := false ; Auto boot throw default setting, 1 is on, 0 is off
global Flag_AFK := false ; Anti-AFK default setting, 1 is on, 0 is off
global Flag_Tooltip := true ; 1 for showing tooltip, 0 for hiding tooltip
global Flag_Fishing := false ; If auto fishing started, set to 1
; Fishing info settings. Do NOT change value here, might working inproperly!
global TimerS := 0 ; Fishing timer seconds
global TimerM := 0 ; Fishing timer minutes
global TimerH := 0 ; Fishing timer hours
global LureCount := 0 ; Used lure count
CoordMode, ToolTip, Screen
UpdateTooltip()
Hotkey, %HK_AutoFish%, L_AutoFish
Hotkey, %HK_AutoBoot%, L_AutoBoot
Hotkey, %HK_AntiAFK%, L_AntiAFK
Hotkey, %HK_Info%, L_Info
Hotkey, %HK_Exit%, L_Exit
Return
L_AutoFish: ; Auto Fishing
if (Flag_Fishing) {
Flag_Fishing := false
TimerS := 0
TimerM := 0
TimerH := 0
LureCount := 0
; Stop fishing timer
SetTimer, UpdateTimer, Off
UpdateTooltip()
} else {
Flag_Fishing := true
SetTimer, AutoFish, -1
; Start fishing timer
SetTimer, UpdateTimer, 1000
}
Return
AutoFish:
WinGet, pidn, PID, A
pid := pidn
WinGet, hwnds, ID, A
Handle := hwnds
Lure := 9999 ; Set max lure
Base := getProcessBaseAddress()
WaterAddress := GetAddressWater(Base,FishAddress) ; Water memory address
LavaAddress := GetAddressLava(Base,FishAddress) ; Lava memory address
ChocoAddress := GetAddressChoco(Base,FishAddress) ; Choco memory address
Loop %Lure% {
; If still have lure (by counting)
if (!Flag_Fishing)
break
NatualPress("b", pid) ; Open backpack to prevent camera rotate while moving mouse, and also for ImageSearch to find the Old Boot
LureCount := LureCount +1
UpdateTooltip()
; Anti-AFK
Gosub, AntiAFK
NatualPress("f", pid) ; Casting the line
Sleep, 15000 ; Check for bite after 15 seconds. Players must wait for 20-30 seconds for the lure to start splashing in order to reel in a fish. Reduce the pole checking loop.
FishingTimeCount := 0
Loop {
; Line casted and pole checking loop, 1 second per check
if (!Flag_Fishing)
break
UpdateTooltip()
; Already cast and checking for biting
CaughtWater := ReadMemory(WaterAddress)
CaughtLava := ReadMemory(LavaAddress)
CaughtChoco := ReadMemory(ChocoAddress)
if (CaughtWater || CaughtLava || CaughtChoco) {
; Fish caught, reel in
NatualPress("f", pid)
Random, Wait, 2000, 3500 ; Wait a few seconds
Sleep, %Wait%
NatualPress("b", pid)
break
}
; caught nothing, wait 1 second and continue checking
Sleep, 1000
if (FishingTimeCount++ > 20) { ; If waiting time is over 35 seconds, it must be a miss or something wrong. Re-cast.
NatualPress("b", pid)
break
}
}
}
Return
L_AutoBoot: ; Toggle auto boot throw
KeyWait, %HK_AutoBoot%, T%FastABTDelay% ;Detect how long HK_AutoBoot has been pressed. Set 0.5 second
if (errorlevel) {
loop {
UpdateTooltip()
if (!GetKeyState(HK_AutoBoot, "P"))
Break
Gosub, AutoBootThrow
Random, Wait, 10, 50 ; Wait a few milliseconds
Sleep, %Wait%
}
} else {
if (Flag_ABT) {
Flag_ABT := false
UpdateTooltip()
SetTimer, AutoBootThrow, Off
} else {
Flag_ABT := true
UpdateTooltip()
Gosub, AutoBootThrow
SetTimer, AutoBootThrow, %Interval_Boot%
}
}
Return
L_AntiAFK: ; Anti-AFK
if (Flag_AFK) {
SetTimer, AntiAFK, Off
Flag_AFK := false
} else {
WinGet, pidn, PID, A
pid := pidn
SetTimer, AntiAFK, %Interval_AFK%
Flag_AFK := true
}
UpdateTooltip()
Return
L_Info: ; Toggle tooltip
if (Flag_Tooltip) {
Flag_Tooltip := false
ToolTip
} else {
Flag_Tooltip := true
UpdateTooltip()
}
Return
L_Exit: ; Stop the script
ExitApp
AutoBootThrow:
Imagesearch, FoundX, FoundY, 0, 0, A_ScreenWidth, A_ScreenHeight, *70 %BootImgPath%
if (errorlevel = 0) {
if (GetKeyState(HK_AutoBoot, "P")) {
DragSpeed = 2 ; Fast ABT
} else {
Random, DragSpeed, 4, 10 ; Throw naturally
}
MouseClickDrag, Left, %FoundX%, %FoundY%, FoundX-450, %FoundY% ,%DragSpeed%
}
Return
AntiAFK:
; Sending key to prevent AFK
NatualPress(AFK_Key, pid)
Return
UpdateTimer:
if (TimerS = 59) {
TimerS = 0
TimerM += 1
}
if (TimerM = 60) {
TimerM = 0
TimerH += 1
UpdateTooltip()
Return
}
TimerS += 1
UpdateTooltip()
Return
GetAddressWater(Base, Address) {
pointerBase := Base + Address
y1 := ReadMemory(pointerBase)
y2 := ReadMemory(y1 + 0x144)
y3 := ReadMemory(y2 + 0xe4)
Return WaterAddress := (y3 + 0x70)
}
GetAddressLava(Base, Address) {
pointerBase := Base + Address
y1 := ReadMemory(pointerBase)
y2 := ReadMemory(y1 + 0x144)
y3 := ReadMemory(y2 + 0xe4)
Return LavaAddress := (y3 + 0x514)
}
GetAddressChoco(Base, Address) {
pointerBase := Base + Address
y1 := ReadMemory(pointerBase)
y2 := ReadMemory(y1 + 0x144)
y3 := ReadMemory(y2 + 0xe4)
Return ChocoAddress := (y3 + 0x2c0)
}
getProcessBaseAddress() {
global Handle
return DllCall( A_PtrSize = 4
? "GetWindowLong"
: "GetWindowLongPtr"
, "Ptr", Handle
, "Int", -6
, "Int64") ; Use Int64 to prevent negative overflow when AHK is 32 bit and target process is 64bit
; if DLL call fails, returned value will = 0
}
ReadMemory(MADDRESS) {
global pid
VarSetCapacity(MVALUE,4,0)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
;DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS, "Str", MVALUE, "UInt", 4, "UInt *", 0)
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "Ptr", MADDRESS, "Ptr", &MVALUE, "Uint", 4)
Loop 4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return, result
}
NatualSleep() {
Random, SleepTime, 66, 122
Sleep, %SleepTime%
}
NatualPress(npbtn, nppid) {
ControlSend, , {%npbtn% down}, ahk_pid %nppid%
NatualSleep()
ControlSend, , {%npbtn% up}, ahk_pid %nppid%
NatualSleep()
}
UpdateTooltip() {
if (!Flag_Tooltip) {
return
}
Info_Tips := "`n[" . HK_Info . "] Toggle this info."
Info_Exit := "`n[" . HK_Exit . "] Exit script."
Info_Lure := "`nLure used - " . (LureCount - 1)
if (!Flag_Fishing) {
Info_Fish := "`n[" . HK_AutoFish . "] Auto Fishing is OFF."
} else if (Flag_Fishing) {
Info_Fish := "`n[" . HK_AutoFish . "] Auto Fishing is ON."
}
if (GetKeyState(HK_AutoBoot, "P")) {
Info_Boot := "`n[FAST] Auto Boot Throw is ON."
} else {
if (!Flag_ABT) {
Info_Boot := "`n[" . HK_AutoBoot . "] Auto Boot Throw is OFF."
} else if (Flag_ABT) {
Info_Boot := "`n[" . HK_AutoBoot . "] Auto Boot Throw is ON."
}
}
if (!Flag_AFK) {
Info_AFK := "`n[" . HK_AntiAFK . "] Anti-AFK is OFF."
} else if (Flag_AFK) {
Info_AFK := "`n[" . HK_AntiAFK . "] Anti-AFK is ON."
}
TimerS := SubStr("0" . TimerS, -1)
TimerM := SubStr("0" . TimerM, -1)
Timerinfo := "`nFishing Time - " . TimerH . ":" . TimerM . ":" . TimerS
HeaderTip := "<AutoFish>`n--- " . Version . " by Howar31"
FuncTip := Info_Fish . Info_Boot . Info_AFK
StatusTip := "`n---" . Info_Lure . Timerinfo
FooterTip := "`n---" . Info_Tips . Info_Exit
if (!Flag_Fishing) {
ToolTip, %HeaderTip%%FuncTip%%FooterTip%, TooltipX, TooltipY
} else if (Flag_Fishing) {
ToolTip, %HeaderTip%%FuncTip%%StatusTip%%FooterTip%, TooltipX, TooltipY
}
}