-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
4934 lines (3905 loc) · 120 KB
/
init.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
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
--Tutorial.lua by Rouneq
--Based on Tutorial.mac by Chatwiththisname and Cannonballdex
--v0.99.2
--
--Purpose: Will conduct the tutorial for the current character
-- from immediately after character creation
-- to completing all steps (required and optional)
-- in both "Basic Training" and "The Revolt of Gloomingdeep"
--
--Usage: /lua run Tutorial [option]
--
-- where option can be "nopause" (sans double-quotes)
---@type Mq
local mq = require("mq")
---@type Note
local Note = require("ext.Note")
---@type ImGui
require("ImGui")
local ICON = require("inc.icons")
---@type Scribing
local Scribing = require("inc.Scribing")
Note.prefix = "tutorial"
Note.outfile = string.format("Tutorial_%s.log", mq.TLO.Me.CleanName())
Note.useOutfile = true
Note.appendToOutfile = false
Note.Info("Begin logging")
Note.appendToOutfile = true
Note.useOutfile = false
local TLO = mq.TLO
local Me = TLO.Me
local Cursor = TLO.Cursor
local Spawn = TLO.Spawn
local Target = TLO.Target
local Merchant = TLO.Merchant
local Ground = TLO.Ground
local Group = TLO.Group
local Window = TLO.Window
local Navigation = TLO.Navigation
local MoveTo = TLO.MoveTo
local Zone = TLO.Zone
local Mercenary = TLO.Mercenary
local Pet = TLO.Pet
local Math = TLO.Math
local EQ = TLO.EverQuest
require("inc.Global")
require("ext.ICaseTable")
local DebuggingText = {
[DebuggingRanks.None] = "None",
[DebuggingRanks.Basic] = "Basic",
[DebuggingRanks.Task] = "Task",
[DebuggingRanks.Detail] = "Detail",
[DebuggingRanks.Function] = "Function",
[DebuggingRanks.Deep] = "Deep",
}
local debuggingValues = {
---@type boolean|nil
StepProcessing = false,
---@type boolean|nil
SkipRemainingSteps = false,
LockStep = true,
WaitingForStep = false,
ActionTaken = false,
---@type boolean|nil
ShowTimingInConsole = Note.useTimestampConsole,
---@type boolean|nil
LogOutput = Note.useOutfile,
}
local currentDebugLevel = DebugLevel
local workSet = {
---@type boolean|nil
ResumeProcessing = true,
---@type boolean
LockContinue = true,
WaitingForResume = false,
---@type boolean|nil
UseGui = true,
---@type boolean|nil
DrawGui = true,
-- Edit Do you want to temporarily move away from mobs when hp gets lower than 50% true OR false
---@type boolean
MoveAway = true,
-- Edit At what pct HP do you want to move away
---@type integer
MoveAwayHP = 50,
---@type string[]
Targets = {},
---@type spawnType
TargetType = "NPC",
---@type integer
PullRange = 1000,
---@type integer
ZRadius = 1000,
---@type integer
HealAt = 70,
---@type integer
HealTill = 100,
---@type integer
MedAt = 30,
---@type integer
MedTill = 100,
---@type integer
DpsLImiter = 0,
---@type integer
MyTargetID = 0,
---@type string
FarmMob = "",
---@type integer
ReportTarget = os.time() + 5,
---@type string
Location = "",
---@type integer
PetGem = 8,
}
---@type table<string, Location>
local navLocs = {
RatBat = {Y = -520, X = -378, Z = -38 },
SpiderRoom = { Y = -658, X = -367, Z = -58 },
QueenRoom = { Y = -1046, X = -482, Z = 1 },
PitTop = { Y = -463, X = -812, Z = 2 },
}
---@type table<string, Location>
local safeSpace = {
SpiderRoom = { Y = -955, X = -658, Z = -23 },
QueenRoom = { Y = -1163, X = -536, Z = -8 },
PitTop = { Y = -226, X = -834, Z = 2 },
PitSteps = { Y = -226, X = -834, Z = 2 },
SlaveHall1 = { Y = -226, X = -834, Z = 2 },
SlaveHall2 = { Y = -87, X = -626, Z = 12 },
SlaveArea = { Y = -87, X = -626, Z = 12 },
JailEntry = { Y = -87, X = -626, Z = 12 },
JailHall1 = { Y = -87, X = -626, Z = 12 },
Jail1 = { Y = -201, X = -805, Z = 24 },
LocksmithHall = { Y = 598, X = -259, Z = -10 },
Jail2 = { Y = 598, X = -259, Z = -10 },
JailHall2 = { Y = 598, X = -259, Z = -10 },
SlaveMaster = { Y = 598, X = -259, Z = -10 },
}
---@type table<string, TargetInfo>
local knownTargets = {
infiltrator = {
Name = "Infiltrator",
Type = "NPC",
},
rufus = {
Name = "Rufus",
Type = "NPC",
Priority = 1
},
caveRat = {
Name = "a_cave_rat",
Type = "NPC",
},
caveBat = {
Name = "a_cave_bat",
Type = "NPC",
},
verminNest = {
Name = "a_vermin_nest",
Type = "Object",
},
venomfang = {
Name = "Venomfang",
Type = "NPC",
Priority = 1
},
gloomSpider = {
Name = "a_gloom_spider",
Type = "NPC",
},
lurkerSpider = {
Name = "a_gloomfang_lurker",
Type = "NPC",
},
spiderCocoon = {
Name = "a_spider_cocoon_cluster",
Type = "NPC",
},
gugan = {
Name = "Spider_Tamer_Gugan",
Type = "NPC",
},
gloomfang = {
Name = "Queen_Gloomfang",
Type = "NPC",
},
barrel = {
Name = "a_kobold_barrel",
Type = "Object",
},
goblinSlave = {
Name = "a_goblin_slave",
Type = "NPC",
},
rookfynn = {
Name = "Rookfynn",
Type = "NPC",
},
grunt = {
Name = "a_Gloomingdeep_grunt",
Type = "NPC",
},
warrior = {
Name = "a_Gloomingdeep_warrior",
Type = "NPC",
},
slaveWarden = {
Name = "a_Gloomingdeep_slave_warden",
Type = "NPC",
Priority = 14
},
spiritweaver = {
Name = "a_Gloomingdeep_spiritweaver",
Type = "NPC",
},
brokenclaw = {
Name = "Brokenclaw",
Type = "NPC",
Priority = 13
},
captain = {
Name = "a_Gloomingdeep_captain",
Type = "NPC",
},
selandoor = {
Name = "Selandoor",
Type = "NPC",
Priority = 1
},
silver = {
Name = "Silver",
Type = "NPC",
Priority = 1
},
diseasedRat = {
Name = "a_diseased_rat",
Type = "NPC",
},
ratasaurus = {
Name = "Ratasaurus",
Type = "NPC",
Priority = 1
},
gnikan = {
Name = "Overlord_Gnikan",
Type = "NPC",
},
locksmith = {
Name = "The_Gloomingdeep_Locksmith",
Type = "NPC",
},
plaguebearer = {
Name = "a_Gloomingdeep_plaguebearer",
Type = "NPC",
},
guard = {
Name = "Guard_of_Gloomingdeep",
Type = "NPC",
},
ruga = {
Name = "Slavemaster_Ruga",
Type = "NPC",
Priority = 1
},
pox = {
Name = "Pox",
Type = "NPC",
Priority = 2
},
krenshin = {
Name = "Krenshin",
Type = "NPC",
Priority = 2
},
}
local lootedItems = {}
local destroyList = {}
---@type table<integer, true>
local noPathList = {}
local function checkPlugin(plugin)
if (not TLO.Plugin(plugin)()) then
PrintDebugMessage(DebuggingRanks.Deep, "\aw%s\ar not detected! \aw This script requires it! Loading ...", plugin)
mq.cmdf("/squelch /plugin %s noauto", plugin)
Delay(1000, function()
return TLO.Plugin(plugin)()
end)
if (not TLO.Plugin(plugin)()) then
Note.Info("Required plugin \aw%s\ax did not load! \ar Ending the script", plugin)
mq.exit()
end
end
end
local function checkStep()
DebugLevel = currentDebugLevel
Note.useTimestampConsole = false
if (debuggingValues.StepProcessing and debuggingValues.ActionTaken) then
PrintDebugMessage(DebuggingRanks.None, "Pause before the next step, use \aw/step\ax to continue")
while (debuggingValues.LockStep) do
debuggingValues.WaitingForStep = true
mq.doevents()
Delay(100)
end
debuggingValues.LockStep = true
debuggingValues.WaitingForStep = false
end
debuggingValues.ActionTaken = false
end
local function checkContinue()
if (workSet.ResumeProcessing) then
PrintDebugMessage(DebuggingRanks.None, "Tutorial paused for spell/skill updates. Visit the approprate merchant to buy, scribe, and load or replace spells/skills. Use \aw/resume\ax to continue")
while (workSet.LockContinue) do
workSet.WaitingForResume = true
mq.doevents()
Delay(100)
end
workSet.LockContinue = true
workSet.WaitingForResume = false
end
end
---@param classes string[]
---@return boolean
local function isClassMatch(classes)
for _, class in ipairs(classes) do
if (Me.Class.ShortName() == class) then
return true
end
end
return false
end
---@param spawn spawn
local function targetSpawn(spawn)
FunctionEnter()
if (spawn.ID() > 0) then
spawn.DoTarget()
Delay(2000, function ()
return Target.ID() == spawn.ID()
end)
Delay(250)
end
FunctionDepart()
end
---@param targetId integer
local function targetSpawnById(targetId)
FunctionEnter()
PrintDebugMessage(DebuggingRanks.Detail, "Target spawn: \ay%s", targetId)
local spawn = Spawn("id " .. targetId)
targetSpawn(spawn)
FunctionDepart()
end
---@param targetName string
local function targetSpawnByName(targetName)
FunctionEnter()
PrintDebugMessage(DebuggingRanks.Detail, "Target spawn: \ay%s", targetName)
local spawn = Spawn(targetName)
targetSpawn(spawn)
FunctionDepart()
end
local function casting()
FunctionEnter()
Delay(1000, function ()
return Window("CastingWindow").Open()
end)
while ((Me.Casting.ID() and not isClassMatch({"BRD"})) or Window("CastingWindow").Open()) do
Delay(100)
end
FunctionDepart()
end
local function checkZone()
FunctionEnter()
if (Zone.ID() ~= 188 and Zone.ID() ~= 189) then
Note.Info("\arYou're not in the tutorial. Ending the macro!")
mq.exit()
end
FunctionDepart()
end
local function openTaskWnd()
FunctionEnter()
if (not Window("TaskWnd").Open()) then
mq.cmd.keypress("ALT+Q")
Delay(1000, function()
return Window("TaskWnd").Open()
end)
Delay(100)
end
FunctionDepart()
end
---@param itemName string
---@param action string
local function grabItem(itemName, action)
FunctionEnter()
---@type string
local keypress = ""
if (action == "left") then
keypress = "leftmouseup"
else
keypress = "rightmouseup"
end
local item = TLO.FindItem(itemName)
local baseCmd = "/squelch /nomodkey /ctrl /itemnotify"
local itemDetail
if (item.ItemSlot() < 23 or item.ItemSlot2() == nil or item.ItemSlot2() == -1) then
itemDetail = string.format("\"%s\"", item.Name())
else
itemDetail = string.format("in pack%s %s", item.ItemSlot() - 22, item.ItemSlot2() + 1)
end
mq.cmdf("%s %s %s", baseCmd, itemDetail, keypress)
FunctionDepart()
end
---@param itemName string
local function destroyItem(itemName)
FunctionEnter()
while (TLO.FindItemCount(itemName)() > 0) do
grabItem(itemName, "left")
mq.cmd.destroy()
Delay(1000, function ()
return not Cursor.ID()
end)
end
FunctionDepart()
end
--- Determine which top-level inventory slot is available for placing an item
---@return integer
local function getAvailableTopInvSlot()
FunctionEnter()
-- Find the first top-level inventory slot without anything in it
for i = 1, Me.NumBagSlots() do
local inv = TLO.InvSlot("pack" .. i).Item
if (not inv.Container() and not inv.ID()) then
return i
end
end
-- Find the first top-level inventory slot without a container in it
for i = 1, Me.NumBagSlots() do
local inv = TLO.InvSlot("pack" .. i).Item
if (not inv.Container()) then
return i
end
end
FunctionDepart()
return 0
end
--- Determine which bag has an available inventory slot for the size specified
---@param size integer
---@return integer
local function getAvailableBagInvSlot(size)
FunctionEnter()
-- Find the first container which can hold an item of the specified size
for i = 1, Me.NumBagSlots() do
local inv = TLO.InvSlot("pack" .. i).Item
if (inv.Container() and inv.SizeCapacity() >= size) then
return i
end
end
FunctionDepart()
return 0
end
--- Determine which inventory slot is available for placing items
---@param size integer
---@return integer
local function GetAvailableInvSlot(size)
FunctionEnter()
local slot = getAvailableTopInvSlot()
if (slot > 0) then
return slot
end
FunctionDepart()
return getAvailableBagInvSlot(size)
end
--- Either place the item in a specific location in inventory (if specified) or auto place it
---@param packname? string @Location in inventory to receive the item on the cursor
local function invItem(packname)
FunctionEnter()
PrintDebugMessage(DebuggingRanks.Detail, "packname: %s", packname)
PrintDebugMessage(DebuggingRanks.Deep, "Put %s in %s", Cursor.Name(), packname)
Delay(500, function ()
mq.cmdf("/ctrlkey /itemnotify %s leftmouseup", packname)
return Cursor.ID() == nil
end)
FunctionDepart()
end
---@param ItemToCast string
local function castItem(ItemToCast)
FunctionEnter()
mq.cmdf("/casting \"%s\"|Item", ItemToCast)
Delay(1000, function()
return Me.Casting.ID()
end)
Delay(TLO.FindItem("=" .. ItemToCast).CastTime.TotalSeconds() * 1000, function()
return not Me.Casting.ID()
end)
FunctionDepart()
end
---@param gem integer
local function castSpell(gem)
FunctionEnter()
if (not Me.Moving()) then
mq.cmd.cast(gem)
casting()
end
FunctionDepart()
end
---@param gem integer
local function castThenRetarget(gem)
FunctionEnter()
if (not Me.Moving()) then
local currentTarget = Target.ID()
mq.cmd.target(Me.CleanName())
mq.cmd.cast(gem)
casting()
targetSpawnById(currentTarget)
end
FunctionDepart()
end
---@return xtarget|nil
local function getNextXTarget()
FunctionEnter()
-- Pause to give the XTarget window a chance to update
Delay(250)
for i = 1, Me.XTarget() do
if (Me.XTarget(i).ID() > 0 and Me.XTarget(i).Type() ~= nil and Me.XTarget(i).Type() ~= "Corpse") then
PrintDebugMessage(DebuggingRanks.Detail, "Me.XTarget(%s) ID: %s, Name: %s, Type: %s", i, Me.XTarget(i).ID(), Me.XTarget(i).Name(), Me.XTarget(i).Type())
FunctionDepart()
return Me.XTarget(i)
end
end
FunctionDepart()
return nil
end
local function checkSwiftness()
FunctionEnter()
if (not TLO.InvSlot(19).Item.ID() and TLO.FindItemCount(67109)() == 1) then
grabItem("67109", "left")
Delay(1000)
if (Cursor.ID()) then
mq.cmd.autoinventory()
end
elseif (not TLO.InvSlot(19).Item.ID() and TLO.FindItemCount(67123)() == 1) then
grabItem("67123", "left")
Delay(1000)
if (Cursor.ID()) then
mq.cmd.autoinventory()
end
elseif (not TLO.InvSlot(19).Item.ID() and TLO.FindItemCount(67116)() == 1) then
grabItem("67116", "left")
Delay(1000)
if (Cursor.ID()) then
mq.cmd.autoinventory()
end
elseif (not TLO.InvSlot(19).Item.ID() and TLO.FindItemCount(67102)() == 1) then
grabItem("67102", "left")
Delay(1000)
if (Cursor.ID()) then
mq.cmd.autoinventory()
end
end
local xtarget = getNextXTarget()
if (not Me.Buff("Blessing of Swiftness").ID() and xtarget == nil) then
if (TLO.FindItemCount("=Worn Totem")() > 0 and Me.Buff(TLO.FindItem("=Worn Totem").Spell())() == nil and
TLO.FindItem("=Worn Totem").TimerReady() == 0 and not Me.Buff("Spirit of Wolf").ID()) then
if (Navigation.Active()) then
mq.cmd.nav("stop")
end
Delay(1500, function()
return not Me.Moving()
end)
castItem("Worn Totem")
end
end
if (isClassMatch({"BRD"}) and not Me.Buff("Selo's Accelerando").ID()) then
local seloGem = Me.Gem("Selo's Accelerando")()
if (seloGem) then
mq.cmd.stopsong()
mq.cmd.cast(seloGem)
casting()
end
elseif (isClassMatch({"SHM", "DRU"}) and not Me.Buff("Spirit of Wolf").ID() and xtarget == nil) then
local sowGem = Me.Gem("Spirit of Wolf")()
if (sowGem) then
if (Navigation.Active()) then
mq.cmd.nav("stop")
end
Delay(1500, function()
return not Me.Moving()
end)
castThenRetarget(sowGem)
end
end
FunctionDepart()
end
local function whereAmI()
FunctionEnter()
Delay(1000)
if (Zone.ID() == 188) then
if (workSet.Location ~= "JailBreak") then
workSet.Location = "JailBreak"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
FunctionDepart()
return
end
local y = Me.Y()
local x = Me.X()
local z = Me.Z()
if ((y >= -298 and y <= 154) and (x >= -309 and x <= 63)) then
if (workSet.Location ~= "StartArea") then
workSet.Location = "StartArea"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -447 and y <= -299) and (x >= -386 and x <= -99)) then
if (workSet.Location ~= "Hall1") then
workSet.Location = "Hall1"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -614 and y <= -448) and (x >= -430 and x <= -325)) then
if (workSet.Location ~= "RatBat") then
workSet.Location = "RatBat"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -685 and y <= -498) and (x >= -384 and x <= -361)) then
if (workSet.Location ~= "SpiderHall") then
workSet.Location = "SpiderHall"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -1025 and y <= -685) and (x >= -672 and x <= -204)) then
if (workSet.Location ~= "SpiderRoom") then
workSet.Location = "SpiderRoom"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -1238 and y <= -1025) and (x >= -586 and x <= -421)) then
if (workSet.Location ~= "QueenRoom") then
workSet.Location = "QueenRoom"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -552 and y <= -497) and (x >= -598 and x <= -431) and (z >= -40 and z <= 5)) then
if (workSet.Location ~= "Hall2") then
workSet.Location = "Hall2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -572 and y <= -420) and (x >= -711 and x <= -598) and (z >= -3 and z <= 10)) then
if (workSet.Location ~= "RatBat2") then
workSet.Location = "RatBat2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -491 and y <= -421) and (x >= -819 and x <= -711) and (z >= -3 and z <= 10)) then
if (workSet.Location ~= "Hall3") then
workSet.Location = "Hall3"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -640 and y <= -210) and (x >= -1079 and x <= -820) and (z >= -3 and z <= 10)) then
if (workSet.Location ~= "PitTop") then
workSet.Location = "PitTop"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -570 and y <= -444) and (x >= -994 and x <= -884) and (z >= -60 and z <= -2)) then
if (workSet.Location ~= "PitSteps") then
workSet.Location = "PitSteps"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -567 and y <= -383) and (x >= -889 and x <= -661) and (z >= -93 and z <= -54)) then
if (workSet.Location ~= "PitTunnel1") then
workSet.Location = "PitTunnel1"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -490 and y <= -322) and (x >= -797 and x <= -645) and (z >= -86 and z <= -69)) then
if (workSet.Location ~= "Rookfynn") then
workSet.Location = "Rookfynn"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -708 and y <= -563) and (x >= -971 and x <= -750) and (z >= -86 and z <= -53)) then
if (workSet.Location ~= "PitTunnel2") then
workSet.Location = "PitTunnel2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -857 and y <= -613) and (x >= -757 and x <= -628) and (z >= -81 and z <= -77)) then
if (workSet.Location ~= "PitMine") then
workSet.Location = "PitMine"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -456 and y <= -306) and (x >= -1166 and x <= -993) and (z >= -146 and z <= -114)) then
if (workSet.Location ~= "PitTunnel3") then
workSet.Location = "PitTunnel3"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -579 and y <= -415) and (x >= -1234 and x <= -1087) and (z >= -133 and z <= -116)) then
if (workSet.Location ~= "Krenshin") then
workSet.Location = "Krenshin"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -648 and y <= -446) and (x >= -1487 and x <= -1078) and (z >= -32 and z <= 4)) then
if (workSet.Location ~= "GloomingdeepMines") then
workSet.Location = "GloomingdeepMines"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -498 and y <= -231) and (x >= -1574 and x <= -1260) and (z >= -105 and z <= -26)) then
if (workSet.Location ~= "MiningHall") then
workSet.Location = "MiningHall"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -445 and y <= -79) and (x >= -1941 and x <= -1573)) then
if (workSet.Location ~= "GloomingdeepFort") then
workSet.Location = "GloomingdeepFort"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -217 and y <= -77) and (x >= -899 and x <= -857)) then
if (workSet.Location ~= "SlaveHall1") then
workSet.Location = "SlaveHall1"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -77 and y <= 68) and (x >= -960 and x <= -853)) then
if (workSet.Location ~= "SlaveArea") then
workSet.Location = "SlaveArea"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -58 and y <= -38) and (x >= -853 and x <= -739)) then
if (workSet.Location ~= "SlaveHall2") then
workSet.Location = "SlaveHall2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -61 and y <= -19) and (x >= -739 and x <= -658)) then
if (workSet.Location ~= "JailEntry") then
workSet.Location = "JailEntry"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -110 and y <= 12) and (x >= -658 and x <= -523)) then
if (workSet.Location ~= "ScoutArea") then
workSet.Location = "ScoutArea"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= -21 and y <= 77) and (x >= -712 and x <= -693)) then
if (workSet.Location ~= "JailHall1") then
workSet.Location = "JailHall1"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= 76 and y <= 326) and (x >= -812 and x <= -511)) then
if (workSet.Location ~= "Jail1") then
workSet.Location = "Jail1"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= 190 and y <= 417) and (x >= -512 and x <= -326)) then
if (workSet.Location ~= "LocksmithHall") then
workSet.Location = "LocksmithHall"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= 413 and y <= 522) and (x >= -491 and x <= -195)) then
if (workSet.Location ~= "Jail2") then
workSet.Location = "Jail2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= 413 and y <= 585) and (x >= -323 and x <= -361)) then
if (workSet.Location ~= "JailHall2") then
workSet.Location = "JailHall2"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
elseif ((y >= 582 and y <= 868) and (x >= -516 and x <= -170)) then
if (workSet.Location ~= "SlaveMaster") then
workSet.Location = "SlaveMaster"
Note.Info("\awLocation:\ag%s", workSet.Location)
end
else
if (workSet.Location ~= "Unknown") then
workSet.Location = "Unknown"
Note.Info("\awLocation:\ag%s (%.2f,%.2f,%.2f)", workSet.Location, y, x, z)
end
end
FunctionDepart()
end
local function checkSelfBuffs()
FunctionEnter()
if (Me.Gem(1).ID() and Me.GemTimer(1)() == 0) then
if (isClassMatch({ "NEC", "WIZ" }) and not Me.Buff("Shielding").ID() and Me.PctMana() > 20) then
castSpell(1)
elseif (isClassMatch({ "DRU" }) and not Me.Buff("Gloomingdeep Guard").ID() and not Me.Buff("Skin like Wood").ID() and
not Me.Buff("Inner Fire").ID() and Me.PctMana() > 20) then
castThenRetarget(1)
elseif (isClassMatch({ "CLR", "RNG", "PAL", "BST", "SHM" }) and Me.PctHPs() < 30 and Me.PctMana() > 20) then
castThenRetarget(1)
end
end
if (Me.Gem(2).ID() and Me.GemTimer(2)() == 0) then
if (isClassMatch({ "MAG", "ENC" }) and not Me.Buff("Shielding").ID() and Me.PctMana() > 20) then
castSpell(2)
elseif (isClassMatch({ "SHM" }) and not Me.Buff("Gloomingdeep Guard").ID() and not Me.Buff("Skin like Wood").ID() and
not Me.Buff("Inner Fire").ID() and Me.PctMana() > 20) then
castThenRetarget(2)
elseif (isClassMatch({ "CLR" }) and not Me.Buff("Gloomingdeep Guard").ID() and not Me.Buff("Courage").ID()) then
castThenRetarget(2)
end
end
FunctionDepart()
end
local function checkCombatCasting()
FunctionEnter()
if (Me.Gem(1).ID() and Me.GemTimer(1)() == 0) then
if (isClassMatch({ "MAG", "ENC", "SHD" }) and Target.ID() > 0 and Target.Type() ~= "Object" and Target.Distance() < 30 and Me.PctMana() > 20 and os.time() > workSet.DpsLImiter) then
castSpell(1)
workSet.DpsLImiter = os.time() + 10
elseif (isClassMatch({ "CLR", "RNG", "PAL", "BST", "SHM" }) and Me.PctHPs() < 30 and Me.PctMana() > 20) then
castThenRetarget(1)
elseif (isClassMatch({ "BRD" }) and not Me.Song("Chant of Battle").ID()) then
mq.cmd.stopsong()
mq.cmd.cast(1)
casting()
end
end
if (Me.Gem(2).ID() and Me.GemTimer(2)() == 0) then
if (isClassMatch({ "WIZ" }) and Target.ID() > 0 and Target.Type() ~= "Object" and Target.Distance() < 30 and Me.PctMana() > 20 and os.time() > workSet.DpsLImiter) then
castSpell(2)
workSet.DpsLImiter = os.time() + 10
elseif (isClassMatch({ "NEC" }) and Target.ID() > 0 and Target.Type() ~= "Object" and Target.Distance() < 30 and Me.PctMana() > 20 and os.time() > workSet.DpsLImiter) then
castSpell(2)
workSet.DpsLImiter = os.time() + 10
elseif (isClassMatch({ "DRU" }) and Me.PctHPs() < 30 and Me.PctMana() > 20) then
castThenRetarget(2)
end
end
if (Me.Gem(3).ID() and Me.GemTimer(3)() == 0) then
if (isClassMatch({ "CLR" }) and not Me.Buff("Yaulp").ID() and Me.PctMana() > 20) then
castSpell(3)
end
end
FunctionDepart()
end
local function closeDialog()
FunctionEnter()
Delay(1000, function()
return Window("LargeDialogWindow").Open()
end)
if (Window("LargeDialogWindow").Open()) then
Window("LargeDialogWindow").Child("LDW_OkButton").LeftMouseUp()
Delay(1000, function()
return not Window("LargeDialogWindow").Open()
end)
Delay(100)
end
FunctionDepart()
end
---@param checkFor string
---@return boolean
local function tutorialCheck(checkFor)
PrintDebugMessage(DebuggingRanks.Function, "\attutorialCheck enter")
PrintDebugMessage(DebuggingRanks.Function, "checkFor: \ag%s", checkFor)
local returnValue = false
local taskList = Window("TaskWND").Child("Task_TaskList")
PrintDebugMessage(DebuggingRanks.Deep, "Number of tasks: %s", taskList.Items())
for i = 1, taskList.Items() do
PrintDebugMessage(DebuggingRanks.Deep, "Checking task: \at%s", taskList.List(i, 3)())
PrintDebugMessage(DebuggingRanks.Deep, "Task = checkFor: \ay%s", taskList.List(i, 3)() == checkFor)
if (taskList.List(i, 3)() == checkFor) then
returnValue = true
break
end
end
PrintDebugMessage(DebuggingRanks.Function, "\attutorialCheck depart")
return returnValue
end
---@param checkFor string
---@return boolean
local function tutorialSelect(checkFor)
PrintDebugMessage(DebuggingRanks.Function, "\attutorialSelect enter")
PrintDebugMessage(DebuggingRanks.Function, "checkFor: \ag%s", checkFor)
local returnValue = false
local taskList = Window("TaskWND").Child("Task_TaskList")
PrintDebugMessage(DebuggingRanks.Deep, "Number of tasks: %s", taskList.Items())
for i = 1, taskList.Items() do