forked from pot0to/pot0to-SND-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFishingGathererScrips.lua
931 lines (840 loc) · 37.8 KB
/
FishingGathererScrips.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
--[[
********************************************************************************
* Fishing Gatherer Scrips *
* Version 1.2.8 *
********************************************************************************
Created by: pot0to (https://ko-fi.com/pot0to)
Loosely based on Ahernika's NonStopFisher
-> 1.2.8 Tree
Fixed materia extraction bug p2
Fixed repair
Fixed teleport errors
Fixed purple scrips
Fixed MinInventoryFreeSlots
Updated algorithm to randomly choose any fishing spot in a line
along the coast, fixed self repair
********************************************************************************
* Required Plugins *
********************************************************************************
AutoHook
VnavMesh
Lifestream
Teleporter
********************************************************************************
* Settings *
********************************************************************************
]]
ScripColorToFarm = "Orange"
SwitchLocationsAfter = 10 --Number of minutes to fish at this spot before changing spots.
Retainers = true --If true, will do AR (autoretainers)
GrandCompanyTurnIn = true --If true, will do GC deliveries using deliveroo everytime retainers are processed
ReturnToGCTown = true --if true will use fast return to GC town for retainers and scrip exchange (that assumes you set return location to your gc town else turn it false), else falase
--needs a yesalready set up like "/Return to New Gridania/"
Food = "" --what food to eat (false if none)
Potion = "Superior Spiritbond Potion <hq>" --what potion to use (false if none)
--things you want to enable
ExtractMateria = true --If true, will extract materia if possible
ReduceEphemerals = true --If true, will reduce ephemerals if possible
SelfRepair = true --If true, will do repair if possible set repair amount below
RepairAmount = 1 --repair threshold, adjust as needed
MinInventoryFreeSlots = 1 --set !!!carefully how much inventory before script stops gathering and does additonal tasks!!!
HubCity = "Solution Nine" --options:Limsa/Gridania/Ul'dah/Solution Nine
--[[
********************************************************************************
* Code: Don't touch this unless you know what you're doing *
********************************************************************************
]]
HubCities =
{
{
zoneName="Limsa",
zoneId = 129,
aethernet = {
aethernetZoneId = 129,
aethernetName = "Hawkers' Alley",
x=-213.61108, y=16.739136, z=51.80432
},
retainerBell = { x=-123.88806, y=17.990356, z=21.469421, requiresAethernet=false },
scripExchange = { x=-258.52585, y=16.2, z=40.65883, requiresAethernet=true }
},
{
zoneName="Gridania",
zoneId = 132,
aethernet = {
aethernetZoneId = 133,
aethernetName = "Sapphire Avenue Exchange",
x=131.9447, y=4.714966, z=-29.800903
},
retainerBell = { x=168.72, y=15.5, z=-100.06, requiresAethernet=true },
scripExchange = { x=142.15, y=13.74, z=-105.39, requiresAethernet=true },
},
{
zoneName="Ul'dah",
zoneId = 130,
aethernet = {
aethernetZoneId = 131,
aethernetName = "Leatherworkers' Guild & Shaded Bower",
x=101, y=9, z=-112
},
retainerBell = { x=171, y=15, z=-102, requiresAethernet=true },
scripExchange = { x=142.68, y=13.75, z=-104.59, requiresAethernet=true },
},
{
zoneName="Solution Nine",
zoneId = 1186,
aethernet = {
aethernetZoneId = 1186,
aethernetName = "Nexus Arcade",
x=-161, y=-1, z=21
},
retainerBell = { x=-152.465, y=0.660, z=-13.557, requiresAethernet=true },
scripExchange = { x=-158.019, y=0.922, z=-37.884, requiresAethernet=true }
}
}
OrangeGathererScripId = 41785
FishTable =
{
{
fishName = "Zorgor Condor",
fishId = 43761,
baitName = "Versatile Lure",
zoneId = 1190,
zoneName = "Shaaloani",
autohookPreset = "AH4_H4sIAAAAAAAACu1Yy27jNhT9FVfrsNCD1CM7j5ukKfLCOG2BDrqgyCtbiCx6KGqSdDD/3kvJSiRbTpCBF+0gO+ny8tyHDg9JfXWmtVEzXplqli2c46/OScnTAqZF4RwbXcORYwcv8hKeB2U3dI5PfpwcOTc6Vzo3j86xh9bq5EEUtQT5bLb+31qsS6XE0oI1D759anDC+Mg5W98uNVRLVaDFc90B8svQDUYSDWa4ryYzW9arLgPqufSVFLpZqihAmD0dQRyvP8t/PQulZc6LPXihRwd4dDPrNK+WJ49Q9fJnW/kzNsg/7D4Bv4P5Ms/MB543VVhD1Rnmhos7REWwzYfZxe2jJhvUG25yKAX08gm354XDfvrdVJ3/AzNuWmKMsQyT2Abztz5OsAG7XfIi53fVKf+itMUbGLrqgqOh/SMI9QXQ37M925MCHQTs2vkhX5zxVVP3tFwUoKsuiN9ODSKX7mQ/gIq/IdbJg9F8swzth7hV83u+Pi9NnZtclWc8L7veEmTERa3hEqqKLzC04xw5V00SzpXCxXrUIjyu0WIbM4J3oSrz3Xg3WAiMZ+gQZ894G7EZf85nvsalpHkxq7WG0hyoyi3Ug9U6mu1OxaPRG69TpQU0qwzdOno1RmmtGxXzUMdaKs2NWtuFnpeLuQGc4fWr3NBtqg9TXB+uyfb3Mv9cg8V1PD+mSZBIkgZhRCi4PkkBXEIz4FkQJ9wD30G8i7wy15mNgfz/1BLZFvCk8211+3L8A+OjjhQwsR4W8ErpFS9+VerOQnQi8yfw5t3aMf+n9ZrxosKOtu+bwX6rN6a2fupFVrw6zLnRquxtgnum3+Yr0FsCcZmXT0P4jZKf3Z1QbtALdQELKCXXjweooQH+RdXovNWV1sMPkyeH5xL3uoyl1ve61fl6X6SI+cGTy75YA6cXom387AqYZgb0jNeLJR5FVnbPQpqPLY3msILEaTZF+9CT+xnHxhdTY2C1Nl0vrc8t1wtoMa/L4rHBsKbOZ2QzCCKW7B4WXtjo7Qmlk8GOyx/hc51rkJijqe2Ga49Aewj+CmHfyrV37ryNOweiQE9PwQWRMghJwiMgNBAe4TRKiZ/4WZrEwuehi/K3K6A0iFmwX0BnXJia68lv+eJ/rZ6X/KFnC+i7or4r6rui/ji78QEkNGR+knLwiQSXEyokJzwVLuEMhTRG6ChACf27O5Nufjx8ejK0qopn1KG8YlL75fUvpRdKT+ZC6TVu5YPjtPdSf84lXgRygXcCbIoN1jpMV6ouB26YAku2b4vB8CIf20i1zjjKbmH1dfxHBEvYK3dmhkD/mR8yz/ea777N2MnWMrNdbRrav99sbjX2sTU/u43Rt0c1EaWSutIjLk9iQmkMhMs0JOBJxqQrMoCo2a23qBTuFDCd3GMMkJNqyaW6n+i8gmqSabXCAYPxJ2YJkxUS9Kcd1s1UKfGXxqE5N06dt1PwnXMH5VzMQgEgGGFuEhDqUUYSwVwSBowlQZoETMpRzrkvXK/5QvPSTJAQgsvh+nmXrx9WvgIuaCQTICkubEKlZISHCSdZTLPIozJMXNHslC3umOpMyOQaqbMA3PvwrFAN/w7FMfViDpTEIqaERjQiCUsF/iIKYg/vK6EfIVf/BUp1IuxuGAAA",
fishingSpots = {
maxHeight = 1024,
waypoints = {
{ x=-115.85, y=-27.7, z=723.95 },
{ x=-11.04, y=-7.64, z=746.06 },
{ x=64.24, y=1.78, z=729.25 }, -- tree
{ x=135.71, y=6.12, z=715.0 },
{ x=212.5, y=12.2, z=739.26 },
},
pointToFace = { x=134.07, y=6.07, z=10000 }
},
scripColor = "Orange",
scripId = 39,
collectiblesTurnInListIndex = 6
},
{
fishName = "Fleeting Brand",
fishId = 36473,
baitName = "Versatile Lure",
zoneId = 959,
zoneName = "Mare Lamentorum",
autohookPreset = "AH4_H4sIAAAAAAAACu1YTVPjOBD9Kymf4yl/f3ALGWCpCgxFwu5hag+y3U5UOFZGllmyU/z3adlWYicOmZoiFAculGlJr59aT63u/NRGpWBjUohinM61s5/aRU6iDEZZpp0JXsJQk4MTmsN2MFFD1/hlBeFQu+OUcSrW2pmJ1uLiOc7KBJKtWc5/qbFuGIsXEqz6sORXheMFQ+1qNVtwKBYsQ4tpGB3k16ErjNDvrDCOkhkvyqVi4JiGc4SCWsWyDGJxICKIY7ZXWcdZMJ5QklVE8ifgytCdPOxzZlqeF+6wdrqsu5saRewJzzIlWaHcX9JicbGGohUIdwfSdTuQnjpL8gjTBU3FOaFVOKShUIapIPEjoiJYc8L7uG3UsEG9I4JCHh9SHNLzdmG87jlZConT/2FMRC04RWJ3tbVzynazerYgGSWPxSV5YlwCdAxqd/awa7+HGCOM800Zs74bgxR2hWZ3CKjwntP5FVlWcRjl8wx4oZxKTcllvuHs7aYDFbwg1sWz4KS53/JgZmz6H1ld56KkgrL8itBcxUdH6U5KDjdQFGSOrjVtqN1WJLRbhllgWCOsV2iRgerBm7BC/DHeHW4E+hlqunZgvPZYjW/5TFd4RznJxiXnkIs32uUO6pvttZft3o57vVezaoFMBVvJ60zz+VTAqsrHW+6NiEb8bSi34SoODzn9UYLE1dIoiAkEhm7GIdEdN0j00I4iPTUAwtBMzBBsDfEmtBDfUukDVf29lqfcwOa+hr7pH+b4N/rHbJHBQM6QgLeML0n2F2OPEkKlkn+AVP9LO/Lf3MoqDapb2gzKran7Kk0zugS+c49vaL4Zkk/TF+R4Q57btvALXv8Gso6fY/oyxSlOU8FZ3npzT+/esFvuJzCHPCF8/QHiUhH7ykqEOnJSb+rY8sKN3+1pnMzF70T8BM5nnK7eOa6+a9kbz6eKbMfJ+8e2cS8z7igVwMeknC+wUl7KSgjTal8qrmppTFRVqSU/WkVE/Z674X4N2n3QX6kmZRmsnkSVAe/hR0k5JOhJlLIYk3V2X1o8fZp712z2mZ0+s9Nndvpg2alVIAYGpF5CUt02A093jNjUie/HumcHsW8Zielaifbyr6oQm18Nvm8MdZGIFWO7WrQ9x7cPV4uXGYDAHQ/OOcmTTm1rHgyW7OKuEyy2aYx1N4ZIOvuWZ+uHAh7yBPi2XVU/mMjVoyUr81bA+xpZN9xt3mzp7SvLxZggYtbsunm/tvEMJNuSpwTTayarsqZxd0P3SG/r4soP8wvMtjP5435ELpaWsYx2Feh2h9L0JfKzNm+n7V8Ao6NPK3LtwLAsPY3sQHcSYuhR4Nq6ZXmuATZxIyPCfmNff+7hHdzDnAlGC/hN6Zk9yutX12tyelU2/bLsVdFxWX6q67C6OuJyIhL6jk/0xI8c3Qk90EmCMkvD1DNMMwwTB5tZzHW1anvT10Af3JUcS9/BNMYSuOj234GUrRekOknNSHeISzC9Ehf/uIGTgOO4JNZefgEjD0ty/xUAAA==",
fishingSpots = {
maxHeight = 35,
waypoints = {
{ x=10.05, y=26.89, z=448.99 },
{ x=37.71, y=22.36, z=481.05 },
{ x=58.87, y=22.22, z=487.95 }, --orange balls
{ x=71.79, y=22.39, z=477.65 },
},
pointToFace = { x=37.71, y=22.36, z=600 }
},
scripColor = "Purple",
scripId = 38,
collectiblesTurnInListIndex = 10
}
}
ScripExchangeItem =
{
scripExchangeMenu1=4,
scripExchangeMenu2=8,
scripExchangeRow=6,
scripExchangePrice=1000
}
CharacterCondition = {
mounted=4,
gathering=6,
casting=27,
occupiedInEvent=31,
occupiedInQuestEvent=32,
occupied=33,
boundByDutyDiadem=34,
occupiedMateriaExtractionAndRepair=39,
gathering42=42,
fishing=43,
betweenAreas=45,
jumping48=48,
occupiedSummoningBell=50,
jumping61=61,
betweenAreasForDuty=51,
boundByDuty56=56,
mounting57=57,
mounting64=64,
beingMoved=70,
flying=77
}
--#region Fishing
function InterpolateCoordinates(startCoords, endCoords, n)
local x = startCoords.x + n * (endCoords.x - startCoords.x)
local y = startCoords.y + n * (endCoords.y - startCoords.y)
local z = startCoords.z + n * (endCoords.z - startCoords.z)
return {waypointX=x, waypointY=y, waypointZ=z}
end
function GetWaypoint(coords, n)
local total_distance = 0
local distances = {}
-- Calculate distances between each pair of coordinates
for i = 1, #coords - 1 do
local dx = coords[i + 1].x - coords[i].x
local dy = coords[i + 1].y - coords[i].y
local dz = coords[i + 1].z - coords[i].z
local distance = math.sqrt(dx * dx + dy * dy + dz * dz)
table.insert(distances, distance)
total_distance = total_distance + distance
end
-- Find the target distance
local target_distance = n * total_distance
-- Walk through the coordinates to find the target coordinates
local accumulated_distance = 0
for i = 1, #coords - 1 do
if accumulated_distance + distances[i] >= target_distance then
local remaining_distance = target_distance - accumulated_distance
local t = remaining_distance / distances[i]
return InterpolateCoordinates(coords[i], coords[i + 1], t)
end
accumulated_distance = accumulated_distance + distances[i]
end
-- If n is 1 (100%), return the last coordinate
return { waypointX=coords[#coords].x, waypointY=coords[#coords].y, waypointZ=coords[#coords].z }
end
function SelectNewFishingHole()
LogInfo("[FishingGatherer] Selecting new fishing hole")
if SelectedFish.fishingSpots.waypoints ~= nil then
SelectedFishingSpot = GetWaypoint(SelectedFish.fishingSpots.waypoints, math.random())
SelectedFishingSpot.waypointY = QueryMeshPointOnFloorY(SelectedFishingSpot.waypointX, SelectedFish.fishingSpots.maxHeight, SelectedFishingSpot.waypointZ, false, 50)
SelectedFishingSpot.x = SelectedFish.fishingSpots.pointToFace.x
SelectedFishingSpot.y = SelectedFish.fishingSpots.pointToFace.y
SelectedFishingSpot.z = SelectedFish.fishingSpots.pointToFace.z
else
local n = math.random(1, #SelectedFish.fishingSpots)
SelectedFishingSpot = SelectedFish.fishingSpots[n]
end
SelectedFishingSpot.startTime = os.clock()
end
function TeleportToFishingZone()
if not IsInZone(SelectedFish.zoneId) then
TeleportTo(SelectedFish.closestAetheryte.aetheryteName)
elseif not GetCharacterCondition(CharacterCondition.betweenAreas) then
yield("/wait 3")
SelectNewFishingHole()
State = CharacterState.goToFishingHole
LogInfo("[FishingGatherer] GoToFishingHole")
end
end
function GoToFishingHole()
if not IsInZone(SelectedFish.zoneId) then
State = CharacterState.teleportToFishingZone
LogInfo("[FishingGatherer] TeleportToFishingZone")
return
end
if GetDistanceToPoint(SelectedFishingSpot.waypointX, SelectedFishingSpot.waypointY, SelectedFishingSpot.waypointZ) > 1 then
if not GetCharacterCondition(CharacterCondition.mounted) then
State = CharacterState.mounting
LogInfo("State Change: Mounting")
elseif not (PathfindInProgress() or PathIsRunning()) then
PathfindAndMoveTo(SelectedFishingSpot.waypointX, SelectedFishingSpot.waypointY, SelectedFishingSpot.waypointZ, true)
end
yield("/wait 1")
return
end
if GetCharacterCondition(CharacterCondition.mounted) then
State = CharacterState.dismounting
LogInfo("State Change: Dismount")
return
end
State = CharacterState.fishing
LogInfo("State Change: Fishing")
end
function Fishing()
if GetItemCount(29717) == 0 then
State = CharacterState.buyFishingBait
LogInfo("State Change: Buy Fishing Bait")
return
end
if GetInventoryFreeSlotCount() <= MinInventoryFreeSlots then
if GetCharacterCondition(CharacterCondition.gathering) then
yield("/ac Quit")
yield("/wait 1")
SelectNewFishingHole()
else
State = CharacterState.turnIn
LogInfo("State Change: TurnIn")
end
return
end
if (SelectedFishingSpot.startTime + (SwitchLocationsAfter*60)) < os.clock() then
if GetCharacterCondition(CharacterCondition.gathering) then
if not GetCharacterCondition(CharacterCondition.fishing) then
yield("/ac Quit")
yield("/wait 1")
end
else
SelectNewFishingHole()
State = CharacterState.ready
LogInfo("State Change: Ready")
end
return
end
yield("/ahbait "..SelectedFish.baitName)
if GetCharacterCondition(CharacterCondition.gathering) then
if (PathfindInProgress() or PathIsRunning()) then
yield("/vnav stop")
end
yield("/wait 1")
return
end
if GetDistanceToPoint(SelectedFishingSpot.x, SelectedFishingSpot.y, SelectedFishingSpot.z) > 1 then
if not PathfindInProgress() and not PathIsRunning() then
PathMoveTo(SelectedFishingSpot.x, SelectedFishingSpot.y, SelectedFishingSpot.z)
end
yield("/ac Cast")
yield("/wait 0.5")
return
end
end
FishingBaitMerchant =
{
npcName = "Merchant & Mender",
x=-398, y=3, z=80,
zoneId = 129,
aetheryte = "Limsa Lominsa",
aethernet = {
name = "Arcanists' Guild",
x=-336, y=12, z=56
}
}
function BuyFishingBait()
if GetItemCount(29717) >= 1 then
if IsAddonVisible("Shop") then
yield("/callback Shop true -1")
else
State = CharacterState.goToFishingHole
LogInfo("State Change: GoToFishingHole")
end
return
end
if not IsInZone(FishingBaitMerchant.zoneId) then
TeleportTo(FishingBaitMerchant.aetheryte)
return
end
local distanceToMerchant = GetDistanceToPoint(FishingBaitMerchant.x, FishingBaitMerchant.y, FishingBaitMerchant.z)
local distanceViaAethernet = DistanceBetween(FishingBaitMerchant.aethernet.x, FishingBaitMerchant.aethernet.y, FishingBaitMerchant.aethernet.z, FishingBaitMerchant.x, FishingBaitMerchant.y, FishingBaitMerchant.z)
if distanceToMerchant > distanceViaAethernet + 20 then
if not LifestreamIsBusy() then
yield("/li "..FishingBaitMerchant.aethernet.name)
end
return
end
if IsAddonVisible("TelepotTown") then
yield("/callback TelepotTown true -1")
return
end
if distanceToMerchant > 5 then
if not PathfindInProgress() and not PathIsRunning() then
PathfindAndMoveTo(FishingBaitMerchant.x, FishingBaitMerchant.y, FishingBaitMerchant.z)
end
return
end
if PathfindInProgress() or PathIsRunning() then
yield("/vnav stop")
return
end
if not HasTarget() or GetTargetName() ~= FishingBaitMerchant.npcName then
yield("/target "..FishingBaitMerchant.npcName)
return
end
if IsAddonVisible("SelectIconString") then
yield("/callback SelectIconString true 0")
elseif IsAddonVisible("SelectYesno") then
yield("/callback SelectYesno true 0")
elseif IsAddonVisible("Shop") then
yield("/callback Shop true 0 3 99 0")
else
yield("/interact")
end
end
--#endregion Fishing
--#region Movement
function GetClosestAetheryte(x, y, z, zoneId, teleportTimePenalty)
local closestAetheryte = nil
local closestTravelDistance = math.maxinteger
local zoneAetherytes = GetAetherytesInZone(zoneId)
for i=0, zoneAetherytes.Count-1 do
local aetheryteId = zoneAetherytes[i]
local aetheryteRawPos = GetAetheryteRawPos(aetheryteId)
LogInfo(aetheryteRawPos)
local distanceAetheryteToPoint = DistanceBetween(aetheryteRawPos.Item1, y, aetheryteRawPos.Item2, x, y, z)
local comparisonDistance = distanceAetheryteToPoint + teleportTimePenalty
local aetheryteName = GetAetheryteName(aetheryteId)
LogInfo("[FishingGatherer] Distance via "..aetheryteName.." adjusted for tp penalty is "..tostring(comparisonDistance))
if comparisonDistance < closestTravelDistance then
LogInfo("[FishingGatherer] Updating closest aetheryte to "..aetheryteName)
closestTravelDistance = comparisonDistance
closestAetheryte = {
aetheryteId = aetheryteId,
aetheryteName = aetheryteName
}
end
end
return closestAetheryte
end
function TeleportTo(aetheryteName)
yield("/tp "..aetheryteName)
yield("/wait 1") -- wait for casting to begin
while GetCharacterCondition(CharacterCondition.casting) do
LogInfo("[FishingGatherer] Casting teleport...")
yield("/wait 1")
end
yield("/wait 1") -- wait for that microsecond in between the cast finishing and the transition beginning
while GetCharacterCondition(CharacterCondition.betweenAreas) do
LogInfo("[FishingGatherer] Teleporting...")
yield("/wait 1")
end
yield("/wait 1")
end
function Mount()
if GetCharacterCondition(CharacterCondition.flying) then
State = CharacterState.goToFishingHole
LogInfo("[FATE] State Change: GoToFishingHole")
elseif GetCharacterCondition(CharacterCondition.mounted) then
yield("/gaction jump")
else
yield('/gaction "mount roulette"')
end
yield("/wait 1")
end
function Dismount()
if PathIsRunning() or PathfindInProgress() then
yield("/vnav stop")
return
end
if GetCharacterCondition(CharacterCondition.flying) then
yield('/ac dismount')
elseif GetCharacterCondition(CharacterCondition.mounted) then
yield('/ac dismount')
else
State = CharacterState.fishing
LogInfo("State Change: Fishing")
end
yield("/wait 1")
end
function GoToHubCity()
if not IsPlayerAvailable() then
yield("/wait 1")
elseif not IsInZone(SelectedHubCity.zoneId) then
TeleportTo(SelectedHubCity.aetheryte)
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
end
--#endregion Movement
--#region Collectables
function TurnIn()
if GetItemCount(SelectedFish.fishId) == 0 then
if IsAddonVisible("CollectablesShop") then
yield("/callback CollectablesShop true -1")
else
State = CharacterState.ready
LogInfo("[FishingGatherer] State Change: Ready")
end
elseif not IsInZone(SelectedHubCity.zoneId) then
State = CharacterState.goToHubCity
LogInfo("State Change: GoToHubCity")
elseif SelectedHubCity.scripExchange.requiresAethernet and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) + 10) then
if not LifestreamIsBusy() then
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 1")
elseif IsAddonVisible("TelepotTown") then
LogInfo("TelepotTown open")
yield("/callback TelepotTown false -1")
elseif GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("Path not running")
PathfindAndMoveTo(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z)
end
elseif GetItemCount(OrangeGathererScripId) >= 3800 then
if IsAddonVisible("CollectablesShop") then
yield("/callback CollectablesShop true -1")
else
State = CharacterState.scripExchange
LogInfo("State Change: ScripExchange")
end
else
if PathfindInProgress() or PathIsRunning() then
yield("/vnav stop")
end
if not IsAddonVisible("CollectablesShop") then
yield("/target Collectable Appraiser")
yield("/wait 0.5")
yield("/interact")
else
yield("/callback CollectablesShop true 12 "..SelectedFish.collectiblesTurnInListIndex)
yield("/wait 0.1")
yield("/callback CollectablesShop true 15 0")
yield("/wait 1")
end
end
end
function KupoVoucherLottery()
if GetItemCount(OrangeGathererScripId) < 3800 then
if IsAddonVisible("InclusionShop") then
yield("/callback InclusionShop true -1")
elseif GetItemCount(SelectedFish.fishId) > 0 then
State = CharacterState.turnIn
LogInfo("State Change: TurnIn")
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
elseif not IsInZone(SelectedHubCity.zoneId) then
State = CharacterState.goToHubCity
LogInfo("State Change: GoToHubCity")
elseif not LogInfo("[FishingGatherer] /li aethernet") and SelectedHubCity.scripExchange.requiresAethernet and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) + 10) then
if not LifestreamIsBusy() then
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 1")
elseif not LogInfo("[FishingGatherer] close telepottown") and IsAddonVisible("TelepotTown") then
LogInfo("TelepotTown open")
yield("/callback TelepotTown false -1")
elseif not LogInfo("[FishingGatherer] move to scrip exchange") and GetDistanceToPoint(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("Path not running")
PathfindAndMoveTo(SelectedHubCity.scripExchange.x, SelectedHubCity.scripExchange.y, SelectedHubCity.scripExchange.z)
end
elseif IsAddonVisible("ShopExchangeItemDialog") then
yield("/callback ShopExchangeItemDialog true 0")
yield("/wait 1")
elseif IsAddonVisible("SelectIconString") then
yield("/callback SelectIconString true 0")
elseif IsAddonVisible("InclusionShop") then
yield("/callback InclusionShop true 12 "..ScripExchangeItem.scripExchangeMenu1)
yield("/wait 1")
yield("/callback InclusionShop true 13 "..ScripExchangeItem.scripExchangeMenu2)
yield("/wait 1")
yield("/callback InclusionShop true 14 "..ScripExchangeItem.scripExchangeRow.." "..GetItemCount(OrangeGathererScripId)//ScripExchangeItem.scripExchangePrice)
else
yield("/wait 1")
yield("/target Scrip Exchange")
yield("/wait 0.5")
yield("/interact")
end
end
--#endregion Collectables
-- #region Other Tasks
function ProcessRetainers()
CurrentFate = nil
LogInfo("[FishingGatherer] Handling retainers...")
if not LogInfo("[FishingGatherer] check retainers ready") and not ARRetainersWaitingToBeProcessed() or GetInventoryFreeSlotCount() <= 1 then
if IsAddonVisible("RetainerList") then
yield("/callback RetainerList true -1")
elseif not GetCharacterCondition(CharacterCondition.occupiedSummoningBell) then
State = CharacterState.ready
LogInfo("[FishingGatherer] State Change: Ready")
end
elseif not LogInfo("[FishingGatherer] is in hub city zone?") and
not (IsInZone(SelectedHubCity.zoneId) or IsInZone(SelectedHubCity.aethernet.aethernetZoneId))
then
TeleportTo(SelectedHubCity.aetheryte)
elseif not LogInfo("[FishingGatherer] use aethernet?") and
SelectedHubCity.retainerBell.requiresAethernet and not LogInfo("abc") and (not IsInZone(SelectedHubCity.aethernet.aethernetZoneId) or
(GetDistanceToPoint(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) > (DistanceBetween(SelectedHubCity.aethernet.x, SelectedHubCity.aethernet.y, SelectedHubCity.aethernet.z, SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) + 10)))
then
if not LifestreamIsBusy() then
yield("/li "..SelectedHubCity.aethernet.aethernetName)
end
yield("/wait 1")
elseif not LogInfo("[FishingGatherer] close telepot town") and IsAddonVisible("TelepotTown") then
LogInfo("TelepotTown open")
yield("/callback TelepotTown false -1")
elseif not LogInfo("[FishingGatherer] move to summoning bell") and GetDistanceToPoint(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z) > 1 then
if not (PathfindInProgress() or PathIsRunning()) then
LogInfo("Path not running")
PathfindAndMoveTo(SelectedHubCity.retainerBell.x, SelectedHubCity.retainerBell.y, SelectedHubCity.retainerBell.z)
end
elseif PathfindInProgress() or PathIsRunning() then
return
elseif not HasTarget() or GetTargetName() ~= "Summoning Bell" then
yield("/target Summoning Bell")
return
elseif not GetCharacterCondition(CharacterCondition.occupiedSummoningBell) then
yield("/interact")
elseif IsAddonVisible("RetainerList") then
yield("/ays e")
if Echo == "All" then
yield("/echo [FishingGatherer] Processing retainers")
end
yield("/wait 1")
end
end
function ExecuteGrandCompanyTurnIn()
if GetInventoryFreeSlotCount() <= MinInventoryFreeSlots then
local playerGC = GetPlayerGC()
local gcZoneIds = {
129, --Limsa Lominsa
132, --New Gridania
130 --"Ul'dah - Steps of Nald"
}
if not IsInZone(gcZoneIds[playerGC]) then
yield("/li gc")
yield("/wait 1")
elseif DeliverooIsTurnInRunning() then
return
else
yield("/deliveroo enable")
end
else
State = CharacterState.ready
LogInfo("State Change: Ready")
end
end
function ExecuteRepair()
if IsAddonVisible("SelectYesno") then
yield("/callback SelectYesno true 0")
return
end
if IsAddonVisible("Repair") then
if not NeedsRepair(RepairAmount) then
yield("/callback Repair true -1") -- if you don't need repair anymore, close the menu
else
yield("/callback Repair true 0") -- select repair
end
return
end
-- if occupied by repair, then just wait
if GetCharacterCondition(CharacterCondition.occupiedMateriaExtractionAndRepair) then
LogInfo("[FATE] Repairing...")
yield("/wait 1")
return
end
local hawkersAlleyAethernetShard = { x=-213.95, y=15.99, z=49.35 }
if SelfRepair then
if GetItemCount(33916) > 0 then
if NeedsRepair(RepairAmount) then
if not IsAddonVisible("Repair") then
LogInfo("[FishingGatherer] Opening repair menu...")
yield("/generalaction repair")
end
else
State = CharacterState.ready
LogInfo("[FishingGatherer] State Change: Ready")
end
elseif ShouldAutoBuyDarkMatter then
if not IsInZone(129) then
if Echo == "All" then
yield("/echo Out of Dark Matter! Purchasing more from Limsa Lominsa.")
end
TeleportTo("Limsa Lominsa Lower Decks")
return
end
local darkMatterVendor = { npcName="Unsynrael", x=-257.71, y=16.19, z=50.11, wait=0.08 }
if GetDistanceToPoint(darkMatterVendor.x, darkMatterVendor.y, darkMatterVendor.z) > (DistanceBetween(hawkersAlleyAethernetShard.x, hawkersAlleyAethernetShard.y, hawkersAlleyAethernetShard.z,darkMatterVendor.x, darkMatterVendor.y, darkMatterVendor.z) + 10) then
yield("/li Hawkers' Alley")
yield("/wait 1") -- give it a moment to register
elseif IsAddonVisible("TelepotTown") then
yield("/callback TelepotTown false -1")
elseif GetDistanceToPoint(darkMatterVendor.x, darkMatterVendor.y, darkMatterVendor.z) > 5 then
if not (PathfindInProgress() or PathIsRunning()) then
PathfindAndMoveTo(darkMatterVendor.x, darkMatterVendor.y, darkMatterVendor.z)
end
else
if not HasTarget() or GetTargetName() ~= darkMatterVendor.npcName then
yield("/target "..darkMatterVendor.npcName)
elseif not GetCharacterCondition(CharacterCondition.occupiedInQuestEvent) then
yield("/interact")
elseif IsAddonVisible("SelectYesno") then
yield("/callback SelectYesno true 0")
elseif IsAddonVisible("Shop") then
yield("/callback Shop true 0 40 99")
end
end
else
if Echo == "All" then
yield("/echo Out of Dark Matter and ShouldAutoBuyDarkMatter is false. Switching to Limsa mender.")
end
SelfRepair = false
end
else
if NeedsRepair(RepairAmount) then
if not IsInZone(129) then
TeleportTo("Limsa Lominsa Lower Decks")
return
end
local mender = { npcName="Alistair", x=-246.87, y=16.19, z=49.83 }
if GetDistanceToPoint(mender.x, mender.y, mender.z) > (DistanceBetween(hawkersAlleyAethernetShard.x, hawkersAlleyAethernetShard.y, hawkersAlleyAethernetShard.z, mender.x, mender.y, mender.z) + 10) then
yield("/li Hawkers' Alley")
yield("/wait 1") -- give it a moment to register
elseif IsAddonVisible("TelepotTown") then
yield("/callback TelepotTown false -1")
elseif GetDistanceToPoint(mender.x, mender.y, mender.z) > 5 then
if not (PathfindInProgress() or PathIsRunning()) then
PathfindAndMoveTo(mender.x, mender.y, mender.z)
end
else
if not HasTarget() or GetTargetName() ~= mender.npcName then
yield("/target "..mender.npcName)
elseif not GetCharacterCondition(CharacterCondition.occupiedInQuestEvent) then
yield("/interact")
end
end
else
State = CharacterState.ready
LogInfo("[FATE] State Change: Ready")
end
end
end
function ExecuteExtractMateria()
if GetCharacterCondition(CharacterCondition.mounted) then
Dismount()
LogInfo("[FATE] State Change: Dismounting")
return
end
if GetCharacterCondition(CharacterCondition.occupiedMateriaExtractionAndRepair) then
return
end
if CanExtractMateria(100) and GetInventoryFreeSlotCount() > 1 then
if not IsAddonVisible("Materialize") then -- open material window
yield("/generalaction \"Materia Extraction\"")
yield("/wait 1") -- give it a second to stick
return
end
LogInfo("[FATE] Extracting materia...")
if IsAddonVisible("MaterializeDialog") then
yield("/callback MaterializeDialog true 0")
else
yield("/callback Materialize true 2 0")
end
else
if IsAddonVisible("Materialize") then
yield("/callback Materialize true -1")
else
State = CharacterState.ready
LogInfo("[FATE] State Change: Ready")
end
end
end
function FoodCheck()
--food usage
if not HasStatusId(48) and Food ~= "" then
yield("/item " .. Food)
end
end
function PotionCheck()
--pot usage
if not HasStatusId(49) and Potion ~= "" then
yield("/item " .. Potion)
end
end
-- #endregion
function SelectFishTable()
for _, fishTable in ipairs(FishTable) do
if ScripColorToFarm == fishTable.scripColor then
return fishTable
end
end
end
function Ready()
FoodCheck()
PotionCheck()
if not LogInfo("[FishingGatherer] Ready -> IsPlayerAvailable()") and not IsPlayerAvailable() then
-- do nothing
elseif not LogInfo("[FishingGatherer] Ready -> Repair") and RepairAmount > 0 and NeedsRepair(RepairAmount) and
(not shouldWaitForBonusBuff or (SelfRepair and GetItemCount(33916) > 0)) then
State = CharacterState.repair
LogInfo("[FishingGatherer] State Change: Repair")
elseif not LogInfo("[FishingGatherer] Ready -> ExtractMateria") and ExtractMateria and CanExtractMateria(100) and GetInventoryFreeSlotCount() > 1 then
State = CharacterState.extractMateria
LogInfo("[FishingGatherer] State Change: ExtractMateria")
elseif not LogInfo("[FishingGatherer] Ready -> ProcessRetainers") and
Retainers and ARRetainersWaitingToBeProcessed() and GetInventoryFreeSlotCount() > 1
then
State = CharacterState.processRetainers
LogInfo("[FishingGatherer] State Change: ProcessingRetainers")
elseif not LogInfo("GetInventoryFreeSlotCount() <= MinInventoryFreeSlots"..tostring(GetInventoryFreeSlotCount() <= MinInventoryFreeSlots)) and GetInventoryFreeSlotCount() <= MinInventoryFreeSlots and GetItemCount(SelectedFish.fishId) > 0 then
State = CharacterState.turnIn
LogInfo("State Change: TurnIn")
elseif not LogInfo("[FishingGatherer] Ready -> GC TurnIn") and GrandCompanyTurnIn and
GetInventoryFreeSlotCount() <= MinInventoryFreeSlots
then
State = CharacterState.gcTurnIn
LogInfo("[FishingGatherer] State Change: GCTurnIn")
elseif GetInventoryFreeSlotCount() <= MinInventoryFreeSlots and GetItemCount(SelectedFish.fishId) > 0 then
State = CharacterState.goToHubCity
LogInfo("[FishingGatherer] State Change: GoToSolutionNine")
elseif GetItemCount(29717) == 0 then
State = CharacterState.buyFishingBait
LogInfo("State Change: Buy Fishing Bait")
else
State = CharacterState.goToFishingHole
LogInfo("State Change: GoToFishingHole")
end
end
CharacterState = {
ready = Ready,
mounting = Mount,
dismounting = Dismount,
teleportToFishingZone = TeleportToFishingZone,
goToFishingHole = GoToFishingHole,
extractMateria = ExecuteExtractMateria,
repair = ExecuteRepair,
exchangingVouchers = ExchangeVouchers,
processRetainers = ProcessRetainers,
gcTurnIn = ExecuteGrandCompanyTurnIn,
fishing = Fishing,
turnIn = TurnIn,
scripExchange = KupoVoucherLottery,
goToHubCity = GoToHubCity,
buyFishingBait = BuyFishingBait
}
StopMain = false
LastStuckCheckTime = os.clock()
LastStuckCheckPosition = {x=GetPlayerRawXPos(), y=GetPlayerRawYPos(), z=GetPlayerRawZPos()}
SelectedFish = SelectFishTable()
if SelectedFish.fishingSpots.waypoints == nil then
SelectedFish.closestAetheryte = GetClosestAetheryte(
SelectedFishingSpot.waypointX,
SelectedFishingSpot.waypointY,
SelectedFishingSpot.waypointZ,
SelectedFish.zoneId,
0)
else
SelectedFish.closestAetheryte = GetClosestAetheryte(
SelectedFish.fishingSpots.waypoints[1].x,
SelectedFish.fishingSpots.waypoints[1].y,
SelectedFish.fishingSpots.waypoints[1].z,
SelectedFish.zoneId,
0)
end
if IsInZone(SelectedFish.zoneId) then
SelectNewFishingHole()
end
yield("/ahon")
DeleteAllAutoHookAnonymousPresets()
UseAutoHookAnonymousPreset(SelectedFish.autohookPreset)
for _, city in ipairs(HubCities) do
if city.zoneName == HubCity then
SelectedHubCity = city
SelectedHubCity.aetheryte = GetAetheryteName(GetAetherytesInZone(city.zoneId)[0])
end
end
if SelectedHubCity == nil then
yield("/echo Could not find hub city: "..HubCity)
yield("/vnav stop")
end
if GetClassJobId() ~= 18 then
yield("/gs change Fisher")
yield("/wait 1")
end
State = CharacterState.ready
while not StopMain do
State()
yield("/wait 0.1")
end