forked from Asoziales/LUA-Scripting
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsoCacher.lua
376 lines (337 loc) · 10.8 KB
/
AsoCacher.lua
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
--[[
@title AsoCacher
@description Gathers from Material Caches
@author Asoziales <discord@Asoziales>
@date 01/10/2024
@version 2.1
@Changelog
2.1 <discord@dea.d>
- Added UI to select hotspot when multiple matching exist
2.0 <discord@dea.d>
- Auto select cache from area
- Doesn't interact with depleted caches
- Gathers from closest cache
- Porters checkbox from UI has been moved to a boolean `usePorters`
1.2 <discord@Asoziales>
- Added Third Age Iron
Message on Discord for any Errors or Bugs
Make sure you are wearing a Grace of the Elves and have any porters in inventory if using porters or memory shards
--]]
local API = require("api")
local UTILS = require("utils")
-- variables
local startXp = API.GetSkillXP("ARCHAEOLOGY")
local MAX_IDLE_TIME_MINUTES = 5
local afk = os.time()
local skill = "ARCHAEOLOGY"
startXp = API.GetSkillXP(skill)
local version = "2.0"
local Material = ""
local targets = {}
local selectedCache
local matcount = 0
local startTime = os.time()
local usePorters = true
local runScript = false
API.logWarn("Started AsoCacher - (v" .. tostring(version) .. ") by Asoziales")
print("Started AsoCacher - (v" .. tostring(version) .. ") by Asoziales")
local aioSelectC = API.CreateIG_answer()
local CacheData = { {
label = "Vulcanized rubber",
CACHEID = 116387,
MATERIALID = 49480
}, {
label = "Ancient vis",
CACHEID = 116432,
MATERIALID = 49506
}, {
label = "Blood of Orcus",
CACHEID = 116435,
MATERIALID = 49508
}, {
label = "Hellfire metal",
CACHEID = 116426,
MATERIALID = 49504
}, {
label = "Third Age Iron",
CACHEID = 115426,
MATERIALID = 49460
} }
ID = {
CACHE = {
CLAY_CACHE = 116391
},
AUTO_SCREENER = 50161,
ELVEN_SHARD = 43358,
PORTERS = { 29281, 29283, 29285, 51490 }
}
local function setupOptions()
btnStop = API.CreateIG_answer()
btnStop.box_start = FFPOINT.new(120, 149, 0)
btnStop.box_name = " STOP "
btnStop.box_size = FFPOINT.new(90, 50, 0)
btnStop.colour = ImColor.new(255, 0, 0)
btnStop.string_value = "STOP"
btnStart = API.CreateIG_answer()
btnStart.box_start = FFPOINT.new(20, 149, 0)
btnStart.box_name = " START "
btnStart.box_size = FFPOINT.new(90, 50, 0)
btnStart.colour = ImColor.new(0, 255, 0)
btnStart.string_value = "START"
IG_Text = API.CreateIG_answer()
IG_Text.box_name = "TEXT"
IG_Text.box_start = FFPOINT.new(16, 79, 0)
IG_Text.colour = ImColor.new(196, 141, 59);
IG_Text.string_value = "AsoCacher (v" .. version .. ") by Asoziales"
IG_Back = API.CreateIG_answer()
IG_Back.box_name = "back"
IG_Back.box_start = FFPOINT.new(5, 64, 0)
IG_Back.box_size = FFPOINT.new(226, 200, 0)
IG_Back.colour = ImColor.new(15, 13, 18, 255)
IG_Back.string_value = ""
tickPorters = API.CreateIG_answer()
tickPorters.box_ticked = usePorters
tickPorters.box_name = "Porters"
tickPorters.box_start = FFPOINT.new(69, 122, 0);
tickPorters.colour = ImColor.new(0, 255, 0);
tickPorters.tooltip_text = "Use Porters in inv."
aioSelectC.box_name = "###Cache"
aioSelectC.box_start = FFPOINT.new(32, 94, 0)
aioSelectC.box_size = FFPOINT.new(240, 0, 0)
aioSelectC.stringsArr = {}
aioSelectC.tooltip_text = "Select a Cache to gather from."
table.insert(aioSelectC.stringsArr, "Select a Cache")
API.DrawSquareFilled(IG_Back)
API.DrawTextAt(IG_Text)
API.DrawBox(btnStart)
API.DrawBox(btnStop)
API.DrawCheckbox(tickPorters)
API.DrawComboBox(aioSelectC, false)
end
local function formatNumber(num)
if num >= 1e6 then
return string.format("%.1fM", num / 1e6)
elseif num >= 1e3 then
return string.format("%.1fK", num / 1e3)
else
return tostring(num)
end
end
local function checkXpIncrease()
local newXp = API.GetSkillXP("ARCHAEOLOGY")
if newXp == startXp then
API.logError("no xp increase")
API.Write_LoopyLoop(false)
else
startXp = newXp
end
end
local function idleCheck()
local timeDiff = os.difftime(os.time(), afk)
local randomTime = math.random((MAX_IDLE_TIME_MINUTES * 60) * 0.6, (MAX_IDLE_TIME_MINUTES * 60) * 0.9)
if timeDiff > randomTime then
API.PIdle2()
afk = os.time()
-- comment this check xp if 200M
checkXpIncrease()
return true
end
end
local function isMoving()
return API.ReadPlayerMovin()
end
local function keepGOTEcharged()
if not usePorters then return end
local buffStatus = API.Buffbar_GetIDstatus(51490, false)
local stacks = tonumber(buffStatus.text)
local function findporters()
local portersIds = { 51490, 29285, 29283, 29281, 29279, 29277, 29275 }
local porters = API.CheckInvStuff3(portersIds)
local foundIdx = -1
for i, value in ipairs(porters) do
if tostring(value) == '1' then
foundIdx = i
break
end
end
if foundIdx ~= -1 then
local foundId = portersIds[foundIdx]
if foundId <= 51490 then
return foundId
else
return nil
end
else
return nil
end
end
if stacks and stacks <= 50 and findporters() then
print("Recharging GOTE")
API.DoAction_Interface(0xffffffff, 0xae06, 6, 1464, 15, 2, API.OFF_ACT_GeneralInterface_route2)
API.RandomSleep2(600, 600, 600)
return
end
if stacks and stacks <= 50 and findporters() == nil then
API.DoAction_Inventory1(39488, 0, 1, API.OFF_ACT_GeneralInterface_route)
API.RandomSleep2(600, 300, 600)
API.DoAction_Interface(0xffffffff, 0xffffffff, 1, 1371, 22, 13, API.OFF_ACT_GeneralInterface_route)
API.RandomSleep2(600, 200, 600)
API.DoAction_Interface(0xffffffff, 0xffffffff, 0, 1370, 30, -1, API.OFF_ACT_GeneralInterface_Choose_option)
API.RandomSleep2(600, 300, 500)
::loop::
if API.isProcessing() then
API.RandomSleep2(200, 300, 200)
goto loop
end
API.DoAction_Interface(0xffffffff, 0xae06, 6, 1464, 15, 2, API.OFF_ACT_GeneralInterface_route2)
return
end
end
local function excavate()
local caches = API.ReadAllObjectsArray({ 0, 12 }, { selectedCache.CACHEID }, {})
local valid = {}
for i = 1, #caches, 1 do
local cache = caches[i]
if cache.Bool1 == 0 then
table.insert(valid, cache)
end
end
if #valid > 0 then
local target = API.Math_SortAODist(valid)
if API.DoAction_Object_Direct(0x2, API.OFF_ACT_GeneralObject_route0, target) then
UTILS.countTicks(2)
end
end
end
local function MaterialCounter()
local chatEvents = API.GatherEvents_chat_check()
if chatEvents then
for k, v in pairs(chatEvents) do
if string.find(v.text, "the following item to your") or string.find(v.text, "perk transports your items") then
matcount = matcount + 1
end
if string.find(v.text, "sash brush perfectly") then
matcount = matcount + 1
end
end
end
end
local function formatElapsedTime(startTime)
local currentTime = os.time()
local elapsedTime = currentTime - startTime
local hours = math.floor(elapsedTime / 3600)
local minutes = math.floor((elapsedTime % 3600) / 60)
local seconds = elapsedTime % 60
return string.format("[%02d:%02d:%02d]", hours, minutes, seconds)
end
local function gameStateChecks()
local gameState = API.GetGameState2()
if (gameState ~= 3) then
API.logError('Not ingame with state:' .. tostring(gameState))
API.Write_LoopyLoop(false)
return
end
if not API.PlayerLoggedIn() then
API.logError('Not Logged In')
API.Write_LoopyLoop(false)
return;
end
end
local function hasElvenRitualShard()
return API.InvItemcount_1(ID.ELVEN_SHARD) > 0
end
local function useElvenRitualShard()
if not (API.InvItemcount_1(ID.ELVEN_SHARD) > 0) then return end
local prayer = API.GetPrayPrecent()
local elvenCD = API.DeBuffbar_GetIDstatus(ID.ELVEN_SHARD, false)
if prayer < 50 and not elvenCD.found then
API.logDebug("Using Elven Shard")
API.DoAction_Inventory1(ID.ELVEN_SHARD, 0, 1, API.OFF_ACT_GeneralInterface_route)
UTILS.randomSleep(600)
end
end
local function populateDropdown()
for key, cache in pairs(CacheData) do
if (#API.ReadAllObjectsArray({ 0, 12 }, { cache.CACHEID }, {}) > 0) then
table.insert(targets, cache)
end
end
if #targets > 0 then
local valueStrings = {}
for i = 1, #targets, 1 do
local item = targets[i]
table.insert(valueStrings, item.label)
end
aioSelectC.stringsArr = valueStrings
aioSelectC.int_value = 0
end
end
local function onStart()
setupOptions()
API.SetDrawLogs(true)
API.SetDrawTrackedSkills(true)
populateDropdown()
startTime = os.time()
MAX_IDLE_TIME_MINUTES = 15
selectedCache = targets[aioSelectC.int_value + 1]
Material = selectedCache.label
end
local function guiLoop()
if aioSelectC.return_click then
local currentHotspot = Material
local selected = aioSelectC.stringsArr[aioSelectC.int_value + 1]
if selected == nil then return end
selectedCache = targets[aioSelectC.int_value + 1]
print(selectedCache.label)
if currentHotspot ~= selected then
Material = selected
excavate()
end
aioSelectC.return_click = false
end
usePorters = tickPorters.box_ticked
if btnStart.return_click then
btnStart.return_click = false
usePorters = tickPorters.box_ticked
if btnStart.box_name == " PAUSE " then
runScript = false
btnStart.box_name = " START "
else
runScript = true
btnStart.box_name = " PAUSE "
end
end
if btnStop.return_click then
API.Write_LoopyLoop(false)
API.SetDrawLogs(false)
btnStop.return_click = false
end
end
onStart()
while (API.Read_LoopyLoop()) do
MaterialCounter()
local metrics = {
{ "Script", "AsoCacher - (v" .. version .. ") by Asoziales" },
{ "Selected:", Material },
{ "Runtime:", formatElapsedTime(startTime) },
{ "Mats:", formatNumber(matcount) }
}
API.DrawTable(metrics)
gameStateChecks()
API.DoRandomEvents()
idleCheck()
guiLoop()
if hasElvenRitualShard() then useElvenRitualShard() end
if selectedCache ~= nil then
if runScript then
if not isMoving() and not API.CheckAnim(40) then
if keepGOTEcharged() then
API.RandomSleep2(600, 200, 300)
else
excavate()
end
end
end
end
UTILS.rangeSleep(200, 0, 0)
end