forked from Celther-FFXI/GearSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSMN.lua
943 lines (813 loc) · 41.5 KB
/
SMN.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
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- __________.__ ________ __ .__.__ __ __ .__ .__ _____.__.__
-- \______ | | ____ _____ ______ ____ \______ \ ____ ____ _____/ |_ ____ __| _|___/ |_ _/ |_| |__ |__| ______ _/ ____|__| | ____
-- | ___| | _/ __ \\__ \ / ____/ __ \ | | \ / _ \ / \ / _ \ __\ _/ __ \ / __ || \ __\ \ __| | \| |/ ___/ \ __\| | | _/ __ \
-- | | | |_\ ___/ / __ \_\___ \\ ___/ | ` ( <_> ) | | ( <_> | | \ ___// /_/ || || | | | | Y | |\___ \ | | | | |_\ ___/
-- |____| |____/\___ (____ /____ >\___ > /_______ /\____/ |___| /\____/|__| \___ \____ ||__||__| |__| |___| |__/____ > |__| |__|____/\___ > /\
-- \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
--
-- Please do not edit this file! Please do not edit this file! Please do not edit this file!
--
-- Editing this file will cause you to be unable to use Github Desktop to update!
--
-- Any changes you wish to make in this file you should be able to make by overloading. That is Re-Defining the same variables or functions in another file, by copying and
-- pasting them to a file that is loaded after the original file, all of my library files, and then job files are loaded first.
-- The last files to load are the ones unique to you. User-Globals, Charactername-Globals, Charactername_Job_Gear, in that order, so these changes will take precedence.
--
-- You may wish to "hook" into existing functions, to add functionality without losing access to updates or fixes I make, for example, instead of copying and editing
-- status_change(), you can instead use the function user_status_change() in the same manner, which is called by status_change() if it exists, most of the important
-- gearswap functions work like this in my files, and if it's unique to a specific job, user_job_status_change() would be appropriate instead.
--
-- Variables and tables can be easily redefined just by defining them in one of the later loaded files: autofood = 'Miso Ramen' for example.
-- States can be redefined as well: state.HybridMode:options('Normal','PDT') though most of these are already redefined in the gear files for editing there.
-- Commands can be added easily with: user_self_command(commandArgs, eventArgs) or user_job_self_command(commandArgs, eventArgs)
--
-- If you're not sure where is appropriate to copy and paste variables, tables and functions to make changes or add them:
-- User-Globals.lua - This file loads with all characters, all jobs, so it's ideal for settings and rules you want to be the same no matter what.
-- Charactername-Globals.lua - This file loads with one character, all jobs, so it's ideal for gear settings that are usable on all jobs, but unique to this character.
-- Charactername_Job_Gear.lua- This file loads only on one character, one job, so it's ideal for things that are specific only to that job and character.
--
--
-- If you still need help, feel free to contact me on discord or ask in my chat for help: https://discord.gg/ug6xtvQ
-- !Please do NOT message me in game about anything third party related, though you're welcome to message me there and ask me to talk on another medium.
--
-- Please do not edit this file! Please do not edit this file! Please do not edit this file!
-- __________.__ ________ __ .__.__ __ __ .__ .__ _____.__.__
-- \______ | | ____ _____ ______ ____ \______ \ ____ ____ _____/ |_ ____ __| _|___/ |_ _/ |_| |__ |__| ______ _/ ____|__| | ____
-- | ___| | _/ __ \\__ \ / ____/ __ \ | | \ / _ \ / \ / _ \ __\ _/ __ \ / __ || \ __\ \ __| | \| |/ ___/ \ __\| | | _/ __ \
-- | | | |_\ ___/ / __ \_\___ \\ ___/ | ` ( <_> ) | | ( <_> | | \ ___// /_/ || || | | | | Y | |\___ \ | | | | |_\ ___/
-- |____| |____/\___ (____ /____ >\___ > /_______ /\____/ |___| /\____/|__| \___ \____ ||__||__| |__| |___| |__/____ > |__| |__|____/\___ > /\
-- \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job. Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------
-- Also, you'll need the Shortcuts addon to handle the auto-targetting of the custom pact commands.
--[[
Custom commands:
gs c petweather
Automatically casts the storm appropriate for the current avatar, if possible.
gs c siphon
Automatically run the process to: dismiss the current avatar; cast appropriate
weather; summon the appropriate spirit; Elemental Siphon; release the spirit;
and re-summon the avatar.
Will not cast weather you do not have access to.
Will not re-summon the avatar if one was not out in the first place.
Will not release the spirit if it was out before the command was issued.
gs c pact [PactType]
Attempts to use the indicated pact type for the current avatar.
PactType can be one of:
cure
curaga
buffOffense
buffDefense
buffSpecial
buffSpecial2
debuff1
debuff2
sleep
nuke2
nuke4
bp70
bp75 (merits and lvl 75-80 pacts)
bp99 (newly released offensive pacts)
physical (most commonly used physical pact by avatar)
magical (most commonly used magical pact by avatar)
astralflow
--]]
-- Initialization function for this job file.
function get_sets()
-- Load and initialize the include file.
include('Sel-Include.lua')
end
-- Setup vars that are user-independent. state.Buff vars initialized here will automatically be tracked.
function job_setup()
state.Buff["Avatar's Favor"] = buffactive["Avatar's Favor"] or false
state.Buff["Astral Conduit"] = buffactive["Astral Conduit"] or false
state.Buff['Aftermath: Lv.3'] = buffactive['Aftermath: Lv.3'] or false
avatars = S{"Carbuncle", "Fenrir", "Diabolos", "Ifrit", "Titan", "Leviathan", "Garuda", "Shiva", "Ramuh", "Odin", "Alexander", "Cait Sith", "Siren"}
spirits = S{"LightSpirit", "DarkSpirit", "FireSpirit", "EarthSpirit", "WaterSpirit", "AirSpirit", "IceSpirit", "ThunderSpirit"}
spirit_of = {['Light']="Light Spirit", ['Dark']="Dark Spirit", ['Fire']="Fire Spirit", ['Earth']="Earth Spirit",
['Water']="Water Spirit", ['Wind']="Air Spirit", ['Ice']="Ice Spirit", ['Lightning']="Thunder Spirit"}
magicalRagePacts = S{
'Inferno','Earthen Fury','Tidal Wave','Aerial Blast','Diamond Dust','Judgment Bolt','Searing Light','Howling Moon','Ruinous Omen','Clarsach Call','Impact',
'Fire II','Stone II','Water II','Aero II','Blizzard II','Thunder II',
'Fire IV','Stone IV','Water IV','Aero IV','Blizzard IV','Thunder IV',
'Thunderspark','Burning Strike','Meteorite','Nether Blast','Flaming Crush',
'Meteor Strike','Conflag Strike','Heavenly Strike','Wind Blade','Geocrush','Grand Fall','Thunderstorm',
'Holy Mist','Lunar Bay','Night Terror','Level ? Holy','Tornado II','Sonic Buffet'}
pacts = {}
pacts.cure = {['Carbuncle']='Healing Ruby'}
pacts.curaga = {['Carbuncle']='Healing Ruby II', ['Garuda']='Whispering Wind', ['Leviathan']='Spring Water'}
pacts.buffoffense = {['Carbuncle']='Glittering Ruby', ['Ifrit']='Crimson Howl', ['Garuda']='Hastega II', ['Ramuh']='Rolling Thunder',
['Fenrir']='Ecliptic Growl', ['Siren']='Katabatic Blades'}
pacts.buffdefense = {['Carbuncle']='Shining Ruby', ['Shiva']='Frost Armor', ['Garuda']='Aerial Armor', ['Titan']='Earthen Ward',
['Ramuh']='Lightning Armor', ['Fenrir']='Ecliptic Howl', ['Diabolos']='Noctoshield', ['Cait Sith']='Reraise II', ['Siren']="Wind's Blessing"}
pacts.buffspecial = {['Ifrit']='Inferno Howl', ['Garuda']='Fleet Wind', ['Titan']='Earthen Armor', ['Diabolos']='Dream Shroud',
['Carbuncle']='Soothing Ruby', ['Fenrir']='Heavenward Howl', ['Cait Sith']='Raise II', ['Siren']='Chinook'}
pacts.buffspecial2 = {['Carbuncle']='Pacifying Ruby',['Leviathan']='Soothing Current',['Shiva']='Crystal Blessing'}
pacts.debuff1 = {['Shiva']='Diamond Storm', ['Ramuh']='Shock Squall', ['Leviathan']='Tidal Roar', ['Fenrir']='Lunar Cry',
['Diabolos']='Pavor Nocturnus', ['Cait Sith']='Eerie Eye', ['Siren']='Lunatic Voice'}
pacts.debuff2 = {['Shiva']='Sleepga', ['Leviathan']='Slowga', ['Fenrir']='Lunar Roar', ['Diabolos']='Somnolence', ['Ramuh']='Thunderspark',
['Siren']='Bitter Elegy'}
pacts.sleep = {['Shiva']='Sleepga', ['Diabolos']='Nightmare', ['Cait Sith']='Mewing Lullaby'}
pacts.nuke2 = {['Ifrit']='Fire II', ['Shiva']='Blizzard II', ['Garuda']='Aero II', ['Titan']='Stone II',
['Ramuh']='Thunder II', ['Leviathan']='Water II', ['Siren']='Tornado II'}
pacts.nuke4 = {['Ifrit']='Fire IV', ['Shiva']='Blizzard IV', ['Garuda']='Aero IV', ['Titan']='Stone IV',
['Ramuh']='Thunder IV', ['Leviathan']='Water IV', ['Siren']='Torando II'}
pacts.bp70 = {['Ifrit']='Flaming Crush', ['Shiva']='Rush', ['Garuda']='Predator Claws', ['Titan']='Mountain Buster',
['Ramuh']='Chaotic Strike', ['Leviathan']='Spinning Dive', ['Carbuncle']='Meteorite', ['Fenrir']='Eclipse Bite',
['Diabolos']='Nether Blast',['Cait Sith']='Regal Scratch'}
pacts.bp75 = {['Ifrit']='Meteor Strike', ['Shiva']='Heavenly Strike', ['Garuda']='Wind Blade', ['Titan']='Geocrush',
['Ramuh']='Thunderstorm', ['Leviathan']='Grand Fall', ['Carbuncle']='Holy Mist', ['Fenrir']='Lunar Bay',
['Diabolos']='Night Terror', ['Cait Sith']='Level ? Holy'}
pacts.bp99 = {['Ifrit']='Conflag Strike',['Titan']='Crag Throw',['Ramuh']='Volt Strike', ['Siren']='Hysteric Assault'}
pacts.astralflow = {['Ifrit']='Inferno', ['Shiva']='Diamond Dust', ['Garuda']='Aerial Blast', ['Titan']='Earthen Fury',
['Ramuh']='Judgment Bolt', ['Leviathan']='Tidal Wave', ['Carbuncle']='Searing Light', ['Fenrir']='Howling Moon',
['Diabolos']='Ruinous Omen', ['Cait Sith']="Altana's Favor"}
--Most commonly used offensive pacts by avatar split into two categories.
pacts.physical = {['Carbuncle']='Poison Nails',['Fenrir']='Eclipse Bite',['Ifrit']='Flaming Crush',['Titan']='Mountain Buster',
['Leviathan']='Spinning Dive',['Garuda']='Predator Claws',['Shiva']='Rush',['Ramuh']='Volt Strike',['Diabolos']='Blindside',
['Cait Sith']='Regal Gash',['Siren']='Hysteric Assault'}
pacts.magical = {['Carbuncle']='Holy Mist',['Fenrir']='Lunar Bay',['Ifrit']='Meteor Strike',['Titan']='Geocrush',
['Leviathan']='Grand Fall',['Garuda']='Wind Blade',['Shiva']='Heavenly Strike',['Ramuh']='Thunderstorm',['Diabolos']='Nether Blast',
['Cait Sith']='Level ? Holy',['Siren']='Sonic Buffet'}
ConduitLock = true
ConduitLocked = nil
state.PactSpamMode = M(false, 'Pact Spam Mode')
state.AutoFavor = M(true, 'Auto Favor')
state.AutoConvert = M(true, 'Auto Convert')
autows = 'Spirit Taker'
autofood = 'Akamochi'
init_job_states({"Capacity","AutoRuneMode","AutoTrustMode","AutoNukeMode","PactSpamMode","AutoWSMode","AutoShadowMode","AutoFoodMode","AutoStunMode","AutoDefenseMode"},{"AutoBuffMode","Weapons","OffenseMode","WeaponskillMode","IdleMode","Passive","RuneElement","ElementalMode","CastingMode","TreasureMode",})
end
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for standard casting events.
-------------------------------------------------------------------------------------------------------------------
-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
-- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
function job_filtered_action(spell, eventArgs)
end
function job_pretarget(spell, spellMap, eventArgs)
end
function job_filter_precast(spell, spellMap, eventArgs)
if pet.name == spell.english and pet.hpp > 50 then
add_to_chat(122, "You already have that avatar active!")
eventArgs.cancel = true
elseif avatars:contains(spell.english) and pet.isvalid then
eventArgs.cancel = true
windower.chat.input('/pet Release <me>')
windower.chat.input:schedule(2,'/ma "'..spell.english..'" <me>')
end
if state.Buff['Astral Conduit'] and spell.type:startswith('BloodPact') and player.mp < (actual_cost(spell) + actual_cost(spell)) then
local abil_recasts = windower.ffxi.get_ability_recasts()
local available_ws = S(windower.ffxi.get_abilities().weapon_skills)
if player.tp > 999 and available_ws:contains(190) then
add_to_chat(122,'Not enough MP to Pact while using Conduit, using Myrkr!')
windower.chat.input('/ws Myrkr <me>')
elseif player.sub_job == 'SCH' and not state.Buff['SJ Restriction'] and buffactive['Sublimation: Complete'] then
add_to_chat(122,'Not enough MP to Pact while using Conduit, using Sublimation!')
windower.chat.input('/ja Sublimation <me>')
elseif player.sub_job == 'RDM' and not state.Buff['SJ Restriction'] and abil_recasts[49] < latency and player.mp > 0 and player.hp > 400 and state.AutoConvert.value then
add_to_chat(122,'Not enough MP to Pact while using Conduit, Converting!')
eventArgs.cancel = true
windower.chat.input('/ja Convert <me>')
end
end
end
function job_precast(spell, spellMap, eventArgs)
if spell.action_type == 'Magic' then
if state.CastingMode.value == 'Proc' then
classes.CustomClass = 'Proc'
elseif state.CastingMode.value == 'OccultAcumen' then
classes.CustomClass = 'OccultAcumen'
end
end
end
function job_post_precast(spell, spellMap, eventArgs)
if spell.type == 'WeaponSkill' then
local WSset = standardize_set(get_precast_set(spell, spellMap))
if (WSset.ear1 == "Moonshade Earring" or WSset.ear2 == "Moonshade Earring") then
-- Replace Moonshade Earring if we're at cap TP
if sets.MaxTP and get_effective_player_tp(spell, WSset) > 3200 then
equip(sets.MaxTP[spell.english] or sets.MaxTP)
end
end
end
end
function job_midcast(spell, spellMap, eventArgs)
end
function job_post_midcast(spell, spellMap, eventArgs)
if spell.skill == 'Elemental Magic' and default_spell_map ~= 'ElementalEnfeeble' and spell.english ~= 'Impact' then
if state.MagicBurstMode.value ~= 'Off' then equip(sets.MagicBurst) end
if spell.element == world.weather_element or spell.element == world.day_element then
if state.CastingMode.value == 'Fodder' then
if spell.element == world.day_element then
if item_available('Zodiac Ring') then
sets.ZodiacRing = {ring2="Zodiac Ring"}
equip(sets.ZodiacRing)
end
end
end
end
if spell.element and sets.element[spell.element] then
equip(sets.element[spell.element])
end
end
end
function job_aftercast(spell, spellMap, eventArgs)
if not spell.interrupted then
if state.UseCustomTimers.value and spell.english == 'Sleep' or spell.english == 'Sleepga' then
send_command('@timers c "'..spell.english..' ['..spell.target.name..']" 60 down spells/00220.png')
elseif spell.skill == 'Elemental Magic' and state.MagicBurstMode.value == 'Single' then
state.MagicBurstMode:reset()
if state.DisplayMode.value then update_job_states() end
elseif type(spell.type) == 'string' and spell.type:startswith('BloodPact') and state.DefenseMode.value == 'None' then
petWillAct = os.clock()
if ConduitLocked and ConduitLocked ~= spell.english then
ConduitLocked = nil
if state.Weapons.value == 'None' then
enable('main','sub','range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
else
enable('range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
end
end
equip(get_pet_midcast_set(spell, spellMap))
if state.Buff['Aftermath: Lv.3'] then
if sets.midcast.Pet[spell.english] and sets.midcast.Pet[spell.english].AM then
equip(sets.midcast.Pet[spell.english].AM)
elseif spellMap == 'PhysicalBloodPactRage' and sets.midcast.Pet.PhysicalBloodPactRage.AM then
equip(sets.midcast.Pet.PhysicalBloodPactRage.AM)
end
end
if state.CastingMode.value == 'Resistant' then
if sets.midcast.Pet[spell.english] and sets.midcast.Pet[spell.english].Acc then
equip(sets.midcast.Pet[spell.english].Acc)
elseif spellMap == 'PhysicalBloodPactRage' and sets.midcast.Pet.PhysicalBloodPactRage.Acc then
equip(sets.midcast.Pet.PhysicalBloodPactRage.Acc)
elseif spellMap == 'MagicalBloodPactRage' and sets.midcast.Pet.MagicalBloodPactRage.Acc then
equip(sets.midcast.Pet.MagicalBloodPactRage.Acc)
end
end
if spellMap == 'PhysicalBloodPactRage' then
if sets.midcast.Pet.PhysicalBloodPactRage[pet.name] then
equip(sets.midcast.Pet.PhysicalBloodPactRage[pet.name])
end
elseif spellMap == 'MagicalBloodPactRage' then
if sets.midcast.Pet.MagicalBloodPactRage[pet.name] then
equip(sets.midcast.Pet.MagicalBloodPactRage[pet.name])
end
elseif spellMap == 'DebuffBloodPactWard' then
if sets.midcast.Pet.BloodPactWard[pet.name] then
equip(sets.midcast.Pet.BloodPactWard[pet.name])
end
end
if state.Buff['Astral Conduit'] and ConduitLock and ConduitLocked == nil then
ConduitLocked = spell.english
disable('main','sub','range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
add_to_chat(217, "Astral Conduit on, locking your "..spell.english.." set.")
end
eventArgs.handled = true
elseif pet_midaction() or avatars:contains(spell.english) then
eventArgs.handled = true
end
end
end
-- Called when pet is about to perform an action
function job_pet_midcast(spell, spellMap, eventArgs)
if spirits:contains(pet.name) and spell.action_type == 'Magic' then --Limiting getting midcast to magic.
equip(get_pet_midcast_set(spell, spellMap))
end
end
-- Runs when pet completes an action.
function job_pet_aftercast(spell, spellMap, eventArgs)
if state.PactSpamMode.value == true and spell.type == 'BloodPactRage'then
abil_recasts = windower.ffxi.get_ability_recasts()
if abil_recasts[173] == 0 then
windower.chat.input('/pet "'..spell.name..'" <t>')
end
end
end
-------------------------------------------------------------------------------------------------------------------
-- Job-specific hooks for non-casting events.
-------------------------------------------------------------------------------------------------------------------
-- Called when a player gains or loses a buff.
-- buff == buff gained or lost
-- gain == true if the buff was gained, false if it was lost.
function job_buff_change(buff, gain)
if buff == 'Astral Conduit' and ConduitLocked ~= nil and not gain then
ConduitLocked = nil
add_to_chat(217, "Astral Conduit has worn, enabling all slots.")
if state.Weapons.value == 'None' then
enable('main','sub','range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
else
enable('range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
end
end
end
-- Called when the player's pet's status changes.
-- This is also called after pet_change after a pet is released. Check for pet validity.
function job_pet_status_change(newStatus, oldStatus, eventArgs)
if pet.isvalid and not midaction() and not pet_midaction() and (newStatus == 'Engaged' or oldStatus == 'Engaged') then
handle_equipping_gear(player.status, newStatus)
end
end
-- Called when a player gains or loses a pet.
-- pet == pet structure
-- gain == true if the pet was gained, false if it was lost.
function job_pet_change(petparam, gain)
classes.CustomIdleGroups:clear()
if gain then
if avatars:contains(pet.name) then
classes.CustomIdleGroups:append('Avatar')
elseif spirits:contains(pet.name) then
classes.CustomIdleGroups:append('Spirit')
end
else
if ConduitLocked ~= nil then
ConduitLocked = nil
add_to_chat(217, "No Avatar summoned, enabling slots.")
if state.OffenseMode.value == 'None' then
enable('main','sub','range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
else
enable('range','ammo','head','neck','lear','rear','body','hands','lring','rring','back','waist','legs','feet')
end
end
end
end
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
-- Custom spell mapping.
function job_get_spell_map(spell)
if spell.type == 'BloodPactRage' then
if magicalRagePacts:contains(spell.english) then
return 'MagicalBloodPactRage'
else
return 'PhysicalBloodPactRage'
end
elseif spell.type == 'BloodPactWard' then
if spell.target.type == 'MONSTER' then
return 'DebuffBloodPactWard'
else
return 'BloodPactWard'
end
end
end
-- Modify the default idle set after it was constructed.
function job_customize_idle_set(idleSet)
if buffactive['Sublimation: Activated'] then
if (state.IdleMode.value == 'Normal' or state.IdleMode.value:contains('Sphere')) and sets.buff.Sublimation then
idleSet = set_combine(idleSet, sets.buff.Sublimation)
elseif state.IdleMode.value:contains('DT') and sets.buff.DTSublimation then
idleSet = set_combine(idleSet, sets.buff.DTSublimation)
end
end
if state.IdleMode.value == 'Normal' or state.IdleMode.value:contains('Sphere') then
if player.mpp < 51 then
if sets.latent_refresh then
idleSet = set_combine(idleSet, sets.latent_refresh)
end
if (state.Weapons.value == 'None' or state.UnlockWeapons.value) and idleSet.main then
local main_table = get_item_table(idleSet.main)
if main_table and main_table.skill == 12 and sets.latent_refresh_grip then
idleSet = set_combine(idleSet, sets.latent_refresh_grip)
end
if player.tp > 10 and sets.TPEat then
idleSet = set_combine(idleSet, sets.TPEat)
end
end
end
end
if pet.isvalid then
if pet.element == world.day_element then
idleSet = set_combine(idleSet, sets.perp.Day)
end
if pet.element == world.weather_element then
idleSet = set_combine(idleSet, sets.perp.Weather)
end
if sets.perp[pet.name] then
idleSet = set_combine(idleSet, sets.perp[pet.name])
end
if state.Buff["Avatar's Favor"] and avatars:contains(pet.name) then
idleSet = set_combine(idleSet, sets.idle.Avatar.Favor)
end
if pet.status == 'Engaged' then
idleSet = set_combine(idleSet, sets.idle.Avatar.Engaged)
if sets.idle.Avatar.Engaged[pet.name] then
idleSet = set_combine(idleSet, sets.idle.Avatar.Engaged[pet.name])
end
end
end
return idleSet
end
-- Called by the 'update' self-command, for common needs.
-- Set eventArgs.handled to true if we don't want automatic equipping of gear.
function job_update(commandArgs, eventArgs)
classes.CustomIdleGroups:clear()
if pet.isvalid then
if avatars:contains(pet.name) then
classes.CustomIdleGroups:append('Avatar')
elseif spirits:contains(pet.name) then
classes.CustomIdleGroups:append('Spirit')
end
end
end
-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
end
-------------------------------------------------------------------------------------------------------------------
-- User self-commands.
-------------------------------------------------------------------------------------------------------------------
-- Called for custom player commands.
function job_self_command(commandArgs, eventArgs)
if commandArgs[1]:lower() == 'petweather' then
handle_petweather()
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'siphon' then
handle_siphoning()
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'pact' then
handle_pacts(commandArgs)
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'elemental' then
handle_elemental(commandArgs)
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'conduitlock' then
if ConduitLock == true then
ConduitLock = false
add_to_chat(122, "Astral Conduit no longer locks gear.")
elseif ConduitLock == false then
ConduitLock = true
add_to_chat(122, "Astral Conduit now locks gear.")
end
end
end
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
-- Cast the appopriate storm for the currently summoned avatar, if possible.
function handle_petweather()
if player.sub_job ~= 'SCH' then
add_to_chat(123, "You can not cast storm spells.")
return
end
if not pet.isvalid then
add_to_chat(123, "You do not have an active avatar.")
return
end
local element = pet.element
if element == 'Thunder' then
element = 'Lightning'
end
local storm = data.elements.storm_of[element]
if storm then
windower.chat.input('/ma "'..data.elements.storm_of[element]..'" <me>')
else
add_to_chat(123, 'Error: Unknown element ('..tostring(element)..')')
end
end
-- Custom uber-handling of Elemental Siphon
function handle_siphoning()
local abil_recasts = windower.ffxi.get_ability_recasts()
if data.areas.cities:contains(world.area) then
add_to_chat(122, 'Cannot use Elemental Siphon in a city area.')
return
elseif abil_recasts[175] > 0 then
add_to_chat(123,'Abort: [Elemental Siphon] waiting on recast. ('..seconds_to_clock(abil_recasts[175])..')')
return
end
local siphonElement
local stormElementToUse
local releasedAvatar
local dontRelease
-- If we already have a spirit out, just use that.
if pet.isvalid and spirits:contains(pet.name) then
siphonElement = pet.element
dontRelease = true
-- If current weather doesn't match the spirit, but the spirit matches the day, try to cast the storm.
if player.sub_job == 'SCH' and pet.element == world.day_element and pet.element ~= world.weather_element then
if not S{'Light','Dark','Lightning'}:contains(pet.element) then
stormElementToUse = pet.element
end
end
-- If we're subbing /sch, there are some conditions where we want to make sure specific weather is up.
-- If current (single) weather is opposed by the current day, we want to change the weather to match
-- the current day, if possible.
elseif player.sub_job == 'SCH' and world.weather_element ~= 'None' then
-- We can override single-intensity weather; leave double weather alone, since even if
-- it's partially countered by the day, it's not worth changing.
if world.weather_intensity == 1 then
-- If current weather is weak to the current day, it cancels the benefits for
-- siphon. Change it to the day's weather if possible (+0 to +20%), or any non-weak
-- weather if not.
-- If the current weather matches the current avatar's element (being used to reduce
-- perpetuation), don't change it; just accept the penalty on Siphon.
if world.weather_element == data.elements.weak_to[world.day_element] and (not pet.isvalid or world.weather_element ~= pet.element) then
stormElementToUse = world.day_element
end
end
end
-- If we decided to use a storm, set that as the spirit element to cast.
if stormElementToUse then
siphonElement = stormElementToUse
elseif world.weather_element ~= 'None' and (world.weather_intensity == 2 or world.weather_element ~= data.elements.weak_to[world.day_element]) then
siphonElement = world.weather_element
else
siphonElement = world.day_element
end
local command = ''
local releaseWait = 0
if pet.isvalid and avatars:contains(pet.name) then
command = command..'input /pet "Release" <me>;wait 1.1;'
releasedAvatar = pet.name
releaseWait = 10
end
if stormElementToUse then
command = command..'input /ma "'..data.elements.storm_of[stormElementToUse]..'" <me>;wait 4;'
releaseWait = releaseWait - 4
end
if not (pet.isvalid and spirits:contains(pet.name)) then
command = command..'input /ma "'..spirit_of[siphonElement]..'" <me>;wait 4;'
releaseWait = releaseWait - 4
end
command = command..'input /ja "Elemental Siphon" <me>;'
releaseWait = releaseWait - 1
releaseWait = releaseWait + 0.1
if not dontRelease then
if releaseWait > 0 then
command = command..'wait '..tostring(releaseWait)..';'
else
command = command..'wait 1.1;'
end
command = command..'input /pet "Release" <me>;'
end
if releasedAvatar then
command = command..'wait 1.1;input /ma "'..releasedAvatar..'" <me>'
end
send_command(command)
end
-- Handles executing blood pacts in a generic, avatar-agnostic way.
-- commandArgs is the split of the self-command.
-- gs c [pact] [pacttype]
function handle_pacts(commandArgs)
if data.areas.cities:contains(world.area) then
add_to_chat(123, 'Abort:You cannot use pacts in town.')
return
end
if not pet.isvalid then
add_to_chat(123,'Abort: You do not have an Avatar summoned.')
return
end
if spirits:contains(pet.name) then
add_to_chat(123,'Abort: Spirits cannot use blood pacts.')
return
end
if not commandArgs[2] then
add_to_chat(123,'Abort: No blood pact type given.')
return
end
local pact = commandArgs[2]:lower()
if not pacts[pact] then
add_to_chat(123,'Abort: Unknown blood pact type: '..tostring(pact))
return
end
if pacts[pact][pet.name] then
if pact == 'astralflow' and not buffactive['astral flow'] then
add_to_chat(123,'Abort: Astral Flow not active.')
return
end
-- Leave out target; let Shortcuts auto-determine it.
windower.chat.input('/pet "'..pacts[pact][pet.name]..'"')
else
add_to_chat(123,'Abort: '..pet.name..' does not have a pact of type ['..pact..'].')
end
end
--[[ Pact buffs now handled by timers plugin, no need for this code.
-- Flags for code to get around the issue of slow skill updates.
wards.flag = false
wards.spell = ''
-- Wards table for creating custom timers
wards = {}
-- Base duration for ward pacts.
wards.durations = {
['Crimson Howl'] = 60, ['Earthen Armor'] = 60, ['Inferno Howl'] = 60, ['Heavenward Howl'] = 60,
['Rolling Thunder'] = 120, ['Fleet Wind'] = 120,
['Shining Ruby'] = 180, ['Frost Armor'] = 180, ['Lightning Armor'] = 180, ['Ecliptic Growl'] = 180,
['Glittering Ruby'] = 180, ['Hastega'] = 180, ['Noctoshield'] = 180, ['Ecliptic Howl'] = 180,
['Dream Shroud'] = 180,
['Reraise II'] = 3600
}
-- Icons to use when creating the custom timer.
wards.icons = {
['Earthen Armor'] = 'spells/00299.png', -- 00299 for Titan
['Shining Ruby'] = 'spells/00043.png', -- 00043 for Protect
['Dream Shroud'] = 'spells/00304.png', -- 00304 for Diabolos
['Noctoshield'] = 'spells/00106.png', -- 00106 for Phalanx
['Inferno Howl'] = 'spells/00298.png', -- 00298 for Ifrit
['Hastega'] = 'spells/00358.png', -- 00358 for Hastega
['Rolling Thunder'] = 'spells/00104.png', -- 00358 for Enthunder
['Frost Armor'] = 'spells/00250.png', -- 00250 for Ice Spikes
['Lightning Armor'] = 'spells/00251.png', -- 00251 for Shock Spikes
['Reraise II'] = 'spells/00135.png', -- 00135 for Reraise
['Fleet Wind'] = 'abilities/00074.png', --
}
windower.raw_register_event('incoming chunk',
function (id)
if id == 0x62 then
if wards.flag then
create_pact_timer(wards.spell)
wards.flag = false
wards.spell = ''
end
end
end)
-- Function to create custom timers using the Timers addon. Calculates ward duration
-- based on player skill and base pact duration (defined in job_setup).
function create_pact_timer(spell_name)
-- Create custom timers for ward pacts.
if wards.durations[spell_name] then
local ward_duration = wards.durations[spell_name]
if ward_duration < 181 then
local skill = player.skills.summoning_magic
if skill > 300 then
skill = skill - 300
if skill > 200 then skill = 200 end
ward_duration = ward_duration + skill
end
end
local timer_cmd = 'timers c "'..spell_name..'" '..tostring(ward_duration)..' down'
if wards.icons[spell_name] then
timer_cmd = timer_cmd..' '..wards.icons[spell_name]
end
send_command(timer_cmd)
end
end
-- Runs when pet completes an action.
function job_pet_aftercast(spell, spellMap, eventArgs)
if not spell.interrupted and spell.type == 'BloodPactWard' and spellMap ~= 'DebuffBloodPactWard' then
wards.flag = true
wards.spell = spell.english
send_command('wait 4; gs c reset_ward_flag')
end
end
-- Called for custom player commands.
function job_self_command(commandArgs, eventArgs)
if commandArgs[1]:lower() == 'petweather' then
handle_petweather()
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'siphon' then
handle_siphoning()
eventArgs.handled = true
elseif commandArgs[1]:lower() == 'pact' then
handle_pacts(commandArgs)
eventArgs.handled = true
elseif commandArgs[1] == 'reset_ward_flag' then
wards.flag = false
wards.spell = ''
eventArgs.handled = true
end
end
--]]
function job_tick()
if check_favor() then return true end
if check_buff() then return true end
if check_buffup() then return true end
return false
end
function check_favor()
if state.AutoFavor.value and pet.isvalid and not buffactive["Avatar's Favor"] and not (buffactive.amnesia or buffactive.impairment) then
local abil_recasts = windower.ffxi.get_ability_recasts()
if abil_recasts[176] < latency then
windower.chat.input('/pet "Avatar\'s Favor" <me>')
tickdelay = os.clock() + 1.1
return true
end
end
return false
end
function handle_elemental(cmdParams)
-- cmdParams[1] == 'elemental'
-- cmdParams[2] == ability to use
if not cmdParams[2] then
add_to_chat(123,'Error: No elemental command given.')
return
end
local command = cmdParams[2]:lower()
if command == 'spikes' then
windower.chat.input('/ma "'..data.elements.spikes_of[state.ElementalMode.value]..' Spikes" <me>')
return
elseif command == 'enspell' then
windower.chat.input('/ma "En'..data.elements.enspell_of[state.ElementalMode.value]..'" <me>')
return
--Leave out target, let shortcuts auto-determine it.
elseif command == 'weather' then
if player.sub_job == 'RDM' then
windower.chat.input('/ma "Phalanx" <me>')
else
local spell_recasts = windower.ffxi.get_spell_recasts()
if (player.target.type == 'SELF' or not player.target.in_party) and buffactive[data.elements.storm_of[state.ElementalMode.value]] and not buffactive['Klimaform'] and spell_recasts[287] < spell_latency then
windower.chat.input('/ma "Klimaform" <me>')
else
windower.chat.input('/ma "'..data.elements.storm_of[state.ElementalMode.value]..'"')
end
end
return
end
local target = '<t>'
if cmdParams[3] then
if tonumber(cmdParams[3]) then
target = tonumber(cmdParams[3])
else
target = table.concat(cmdParams, ' ', 3)
target = get_closest_mob_id_by_name(target) or '<t>'
end
end
if command == 'nuke' or command == 'smallnuke' then
local spell_recasts = windower.ffxi.get_spell_recasts()
local tiers = {' II',''}
for k in ipairs(tiers) do
if spell_recasts[get_spell_table_by_name(data.elements.nuke_of[state.ElementalMode.value]..''..tiers[k]..'').id] < spell_latency and actual_cost(get_spell_table_by_name(data.elements.nuke_of[state.ElementalMode.value]..''..tiers[k]..'')) < player.mp then
windower.chat.input('/ma "'..data.elements.nuke_of[state.ElementalMode.value]..''..tiers[k]..'" '..target..'')
windower.add_to_chat(7,'/ma "'..data.elements.nuke_of[state.ElementalMode.value]..''..tiers[k]..'" '..target..'')
return
end
end
add_to_chat(123,'Abort: All '..data.elements.nuke_of[state.ElementalMode.value]..' nukes on cooldown or or not enough MP.')
elseif command:contains('tier') then
local spell_recasts = windower.ffxi.get_spell_recasts()
local tierlist = {['tier1']='',['tier2']=' II',['tier3']=' III',['tier4']=' IV',['tier5']=' V',['tier6']=' VI'}
windower.chat.input('/ma "'..data.elements.nuke_of[state.ElementalMode.value]..tierlist[command]..'" '..target..'')
elseif command == 'ara' then
windower.chat.input('/ma "'..data.elements.nukera_of[state.ElementalMode.value]..'ra" '..target..'')
elseif command == 'aga' then
windower.chat.input('/ma "'..data.elements.nukega_of[state.ElementalMode.value]..'ga" '..target..'')
elseif command == 'helix' then
windower.chat.input('/ma "'..data.elements.helix_of[state.ElementalMode.value]..'helix" '..target..'')
elseif command == 'enfeeble' then
windower.chat.input('/ma "'..data.elements.elemental_enfeeble_of[state.ElementalMode.value]..'" '..target..'')
elseif command == 'bardsong' then
windower.chat.input('/ma "'..data.elements.threnody_of[state.ElementalMode.value]..' Threnody" '..target..'')
else
add_to_chat(123,'Unrecognized elemental command.')
end
end
function check_buff()
if state.AutoBuffMode.value ~= 'Off' and not data.areas.cities:contains(world.area) then
local spell_recasts = windower.ffxi.get_spell_recasts()
for i in pairs(buff_spell_lists[state.AutoBuffMode.Value]) do
if not buffactive[buff_spell_lists[state.AutoBuffMode.Value][i].Buff] and (buff_spell_lists[state.AutoBuffMode.Value][i].When == 'Always' or (buff_spell_lists[state.AutoBuffMode.Value][i].When == 'Combat' and (player.in_combat or being_attacked)) or (buff_spell_lists[state.AutoBuffMode.Value][i].When == 'Engaged' and player.status == 'Engaged') or (buff_spell_lists[state.AutoBuffMode.Value][i].When == 'Idle' and player.status == 'Idle') or (buff_spell_lists[state.AutoBuffMode.Value][i].When == 'OutOfCombat' and not (player.in_combat or being_attacked))) and spell_recasts[buff_spell_lists[state.AutoBuffMode.Value][i].SpellID] < spell_latency and silent_can_use(buff_spell_lists[state.AutoBuffMode.Value][i].SpellID) then
windower.chat.input('/ma "'..buff_spell_lists[state.AutoBuffMode.Value][i].Name..'" <me>')
tickdelay = os.clock() + 2
return true
end
end
else
return false
end
end
function check_buffup()
if buffup ~= '' then
local needsbuff = false
for i in pairs(buff_spell_lists[buffup]) do
if not buffactive[buff_spell_lists[buffup][i].Buff] and silent_can_use(buff_spell_lists[buffup][i].SpellID) then
needsbuff = true
break
end
end
if not needsbuff then
add_to_chat(217, 'All '..buffup..' buffs are up!')
buffup = ''
return false
end
local spell_recasts = windower.ffxi.get_spell_recasts()
for i in pairs(buff_spell_lists[buffup]) do
if not buffactive[buff_spell_lists[buffup][i].Buff] and silent_can_use(buff_spell_lists[buffup][i].SpellID) and spell_recasts[buff_spell_lists[buffup][i].SpellID] < spell_latency then
windower.chat.input('/ma "'..buff_spell_lists[buffup][i].Name..'" <me>')
tickdelay = os.clock() + 2
return true
end
end
return false
else
return false
end
end
buff_spell_lists = {
Auto = {--Options for When are: Always, Engaged, Idle, OutOfCombat, Combat
{Name='Reraise', Buff='Reraise', SpellID=113, When='Always'},
{Name='Haste', Buff='Haste', SpellID=57, When='Always'},
{Name='Refresh', Buff='Refresh', SpellID=109, When='Always'},
{Name='Stoneskin', Buff='Stoneskin', SpellID=54, When='Always'},
},
Default = {
{Name='Reraise', Buff='Reraise', SpellID=113, Reapply=false},
{Name='Haste', Buff='Haste', SpellID=57, Reapply=false},
{Name='Refresh', Buff='Refresh', SpellID=109, Reapply=false},
{Name='Aquaveil', Buff='Aquaveil', SpellID=55, Reapply=false},
{Name='Stoneskin', Buff='Stoneskin', SpellID=54, Reapply=false},
{Name='Blink', Buff='Blink', SpellID=53, Reapply=false},
{Name='Regen', Buff='Regen', SpellID=108, Reapply=false},
{Name='Phalanx', Buff='Phalanx', SpellID=106, Reapply=false},
},
}