forked from Celther-FFXI/GearSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSel-Include.lua
2507 lines (2091 loc) · 87.9 KB
/
Sel-Include.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
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- __________.__ ________ __ .__.__ __ __ .__ .__ _____.__.__
-- \______ | | ____ _____ ______ ____ \______ \ ____ ____ _____/ |_ ____ __| _|___/ |_ _/ |_| |__ |__| ______ _/ ____|__| | ____
-- | ___| | _/ __ \\__ \ / ____/ __ \ | | \ / _ \ / \ / _ \ __\ _/ __ \ / __ || \ __\ \ __| | \| |/ ___/ \ __\| | | _/ __ \
-- | | | |_\ ___/ / __ \_\___ \\ ___/ | ` ( <_> ) | | ( <_> | | \ ___// /_/ || || | | | | 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 | |\___ \ | | | | |_\ ___/
-- |____| |____/\___ (____ /____ >\___ > /_______ /\____/ |___| /\____/|__| \___ \____ ||__||__| |__| |___| |__/____ > |__| |__|____/\___ > /\
-- \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/ \/
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- Much of these files have been adapted from Motenten's base files, much credit goes to him,
-- I have started to rename his files so that they don't get modified whenever the Windower
-- team very rarely decides to update his old files.
-- Common variables and functions to be included in job scripts, for general default handling.
--
-- Include this file in the get_sets() function with the command:
-- include('Sel-Include.lua')
--
-- It will then automatically run its own init_include() function.
--
-- IMPORTANT: This include requires supporting include files:
-- Sel-Utility
-- Sel-Mappings
-- Sel-SelfCommands
-- Sel-Globals
--
-- Place the include() directive at the start of a job's get_sets() function.
--
-- Included variables and functions are considered to be at the same scope level as
-- the job script itself, and can be used as such.
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- Initialization function that defines variables to be used.
-- These are accessible at the including job lua script's scope.
--
-- Auto-initialize after defining this function.
-------------------------------------------------------------------------------------------------------------------
function init_include()
extdata = require('extdata')
require('queues')
res = require('resources')
packets = require('packets')
--Snaps's Rnghelper extension for automatic ranged attacks that should be superior to my implementation.
require('Snaps-RngHelper')
-- Used to define various types of data mappings. These may be used in the initialization, so load it up front.
include('Sel-Mappings')
-- Modes is the include for a mode-tracking variable class. Used for state vars, below.
include('Sel-Modes')
-- Adding Organizer for gear management.
include('organizer-lib.lua')
-- Var for tracking state values
state = {}
--My Auto-Stun/Reaction module for gearswap, must come after state is defined.
include('Sel-Stahp.lua')
--Making Extdata/Resources dependant functions work
cp_delay = 20
-- General melee offense/defense modes, allowing for hybrid set builds, as well as idle/resting/weaponskill.
-- This just defines the vars and sets the descriptions. List modes with no values automatically
-- get assigned a 'Normal' default value.
state.OffenseMode = M{['description'] = 'Offense Mode'}
state.HybridMode = M{['description'] = 'Hybrid Mode'}
state.RangedMode = M{['description'] = 'Ranged Mode'}
state.WeaponskillMode = M{['description'] = 'Weaponskill Mode','Match'}
state.CastingMode = M{['description'] = 'Casting Mode'}
state.IdleMode = M{['description'] = 'Idle Mode'}
state.RestingMode = M{['description'] = 'Resting Mode'}
state.DefenseMode = M{['description'] = 'Defense Mode', 'None', 'Physical', 'Magical', 'Resist'}
state.PhysicalDefenseMode = M{['description'] = 'Physical Defense Mode', 'PDT'}
state.MagicalDefenseMode = M{['description'] = 'Magical Defense Mode', 'MDT'}
state.ResistDefenseMode = M{['description'] = 'Resistance Defense Mode', 'MEVA'}
state.Passive = M{['description'] = 'Passive Mode','None'}
state.Kiting = M(false, 'Kiting')
state.SelectNPCTargets = M(false, 'Select NPC Targets')
state.Capacity = M(false, 'Capacity Mode')
state.ReEquip = M(false, 'ReEquip Mode')
state.AutoArts = M(false, 'AutoArts Mode')
state.AutoLockstyle = M(false, 'AutoLockstyle Mode')
state.AutoTrustMode = M(false, 'Auto Trust Mode')
state.RngHelper = M(false, 'RngHelper')
state.RngHelperQuickDraw = M(false, 'RngHelperQuickDraw')
state.AutoTankMode = M(false, 'Auto Tank Mode')
state.AutoAcceptRaiseMode = M(false, 'Auto Accept Raise Mode')
state.AutoNukeMode = M(false, 'Auto Nuke Mode')
state.AutoRuneMode = M(false, 'Auto Rune Mode')
state.AutoShadowMode = M(false, 'Auto Shadow Mode')
state.AutoContradanceMode = M(true, 'Auto Contradance Mode')
state.AutoHolyWaterMode = M(true, 'Auto Holy Water Mode')
state.AutoRemoveDoomMode = M(true, 'Auto Remove Doom Mode')
state.AutoWSMode = M(false, 'Auto Weaponskill Mode')
state.AutoWSRestore = M(true, 'Auto Weaponskill Restore Mode')
state.AutoFoodMode = M(false, 'Auto Food Mode')
state.AutoSubMode = M(false, 'Auto Sublimation Mode')
state.AutoCleanupMode = M(false, 'Auto Cleanup Mode')
state.DisplayMode = M(true, 'Display Mode')
state.UseCustomTimers = M(true, 'Use Custom Timers')
state.CancelStoneskin = M(true, 'Auto Cancel Stoneskin')
state.BlockMidaction = M(true, 'Block Midaction')
state.MaintainAftermath = M(true, 'Maintain Aftermath')
state.RefineWaltz = M(true, 'RefineWaltz')
state.ElementalWheel = M(false, 'Elemental Wheel')
state.MaintainDefense = M(false, 'Maintain Defense')
state.SkipProcWeapons = M(false, 'Skip Proc Weapons')
state.NotifyBuffs = M(false, 'Notify Buffs')
state.UnlockWeapons = M(false, 'Unlock Weapons')
state.SelfWarp2Block = M(true, 'Block Warp2 on Self')
state.AutoBuffMode = M{['description'] = 'Auto Buff Mode','Off','Auto'}
state.RuneElement = M{['description'] = 'Rune Element','Ignis','Gelus','Flabra','Tellus','Sulpor','Unda','Lux','Tenebrae'}
state.ElementalMode = M{['description'] = 'Elemental Mode', 'Fire','Ice','Wind','Earth','Lightning','Water','Light','Dark'}
state.AutoSambaMode = M{['description']= 'Auto Samba Mode', 'Off', 'Haste Samba', 'Aspir Samba', 'Drain Samba II'}
state.MagicBurstMode = M{['description'] = 'Magic Burst Mode', 'Off', 'Single', 'Lock'}
state.SkillchainMode = M{['description'] = 'Skillchain Mode', 'Off', 'Single', 'Lock'}
state.PCTargetMode = M{['description'] = 'PC Target Mode', 'default', 'stpt', 'stal', 'stpc'}
state.EquipStop = M{['description'] = 'Stop Equipping Gear', 'off', 'precast', 'midcast', 'pet_midcast'}
state.CombatWeapon = M{['description']='Combat Weapon', ['string']=''}
state.CombatForm = M{['description']='Combat Form', ['string']=''}
NotifyBuffs = S{}
if data.jobs.mage_jobs:contains(player.main_job) then
state.Weapons = M{['description'] = 'Weapons','None','Weapons'}
else
state.Weapons = M{['description'] = 'Weapons','Weapons','None'}
end
-- Non-mode vars that are used for state tracking.
state.MaxWeaponskillDistance = 0
state.Buff = {}
--Tracking these here because required quick actions on multiple jobs.
state.Buff['Light Arts'] = buffactive['Light Arts'] or false
state.Buff['Addendum: White'] = buffactive['Addendum: White'] or false
state.Buff['Dark Arts'] = buffactive['Dark Arts'] or false
state.Buff['Addendum: Black'] = buffactive['Addendum: Black'] or false
state.Buff['Accession'] = buffactive['Accession'] or false
state.Buff['Manifestation'] = buffactive['Manifestation'] or false
state.Buff['Warcry'] = buffactive['Warcry'] or false
state.Buff['SJ Restriction'] = buffactive['SJ Restriction'] or false
-- Classes describe a 'type' of action. They are similar to state, but
-- may have any free-form value, or describe an entire table of mapped values.
classes = {}
-- Basic spell mappings are based on common spell series.
-- EG: 'Cure' for Cure, Cure II, Cure III, Cure IV, Cure V, or Cure VI.
classes.SpellMaps = spell_maps
-- List of spells and spell maps that don't benefit from greater skill (though
-- they may benefit from spell-specific augments, such as improved regen or refresh).
-- Spells that fall under this category will be skipped when searching for
-- spell.skill sets.
classes.NoSkillSpells = data.spells.no_skill
classes.SkipSkillCheck = false
-- Custom, job-defined class, like the generic spell mappings.
-- Takes precedence over default spell maps.
-- Is reset at the end of each spell casting cycle (ie: at the end of aftercast).
classes.JAMode = nil
classes.CustomClass = nil
-- Custom groups used for defining melee and idle sets. Persists long-term.
classes.CustomMeleeGroups = L{}
classes.CustomRangedGroups = L{}
classes.CustomIdleGroups = L{}
classes.CustomDefenseGroups = L{}
-- Class variables for time-based flags
classes.Daytime = false
classes.DuskToDawn = false
-- Var for tracking misc info
info = {}
options = {}
-- Special control flags.
mote_vars = {}
mote_vars.set_breadcrumbs = L{}
mote_vars.res_buffs = S{}
for index,struct in pairs(gearswap.res.buffs) do
mote_vars.res_buffs:add(struct.en)
end
-- Define and default variables for global functions that can be overwritten.
useItem = false
useItemName = ''
useItemSlot = ''
petWillAct = 0
autonuke = 'Fire'
autows = ''
smartws = nil
rangedautows = ''
autowstp = 1000
rangedautowstp = 1000
latency = .7
spell_latency = nil
buffup = ''
curecheat = false
lastincombat = player.in_combat
next_cast = 0
delayed_cast = ''
delayed_target = ''
equipped = 0
time_test = false
selindrile_warned = false
utsusemi_cancel_delay = .5
conserveshadows = true
filtered_st_command = false
-- Buff tracking that buffactive can't detect
lastshadow = "Utsusemi: San"
lastwarcry = ''
lasthaste = 1
lastflurry = 1
-- Sub-tables within the sets table that we expect to exist, and are annoying to have to
-- define within each individual job file. We can define them here to make sure we don't
-- have to check for existence. The job file should be including this before defining
-- any sets, so any changes it makes will override these anyway.
sets.precast = {}
sets.precast.FC = {}
sets.precast.JA = {}
sets.precast.WS = {}
sets.precast.RA = {}
sets.precast.Item = {}
sets.midcast = {}
sets.midcast.RA = {}
sets.midcast.Pet = {}
sets.idle = {}
sets.resting = {}
sets.engaged = {}
sets.defense = {}
sets.buff = {}
sets.element = {}
sets.passive = {}
sets.weapons = {}
sets.DuskIdle = {}
sets.DayIdle = {}
sets.NightIdle = {}
gear = {}
gear.default = {}
gear.ElementalGorget = {name=""}
gear.ElementalBelt = {name=""}
gear.ElementalObi = {name=""}
gear.ElementalCape = {name=""}
gear.ElementalRing = {name=""}
gear.FastcastStaff = {name=""}
gear.RecastStaff = {name=""}
-- Include general user globals, such as custom binds or gear tables.
-- Load Sel-Libs first, followed by User-Globals, followed by <character>-Globals.
-- Any functions re-defined in the later includes will overwrite the earlier versions.
-- Load externally-defined information (info that we don't want to change every time this file is updated).
-- Used to define misc utility functions that may be useful for this include or any job files.
include('Sel-Utility')
-- Used for all self-command handling.
include('Sel-SelfCommands')
include('Sel-TreasureHunter')
-- User based files.
optional_include('user-globals.lua')
optional_include(player.name..'-globals.lua')
optional_include(player.name..'-items.lua')
optional_include(player.name..'_Crafting.lua')
include(player.name..'_'..player.main_job..'_gear.lua') -- Required Gear file.
-- New Display functions, needs to come after globals for user settings.
include('Sel-Display.lua')
-- Controls for handling our autmatic functions.
tickdelay = os.clock() + 5
style_delay = os.clock() + 15
style_lock = true
if spell_latency == nil then
spell_latency = (latency * 60) + 18
end
--Certain Checks
global_on_load()
-- General var initialization and setup.
if job_setup then
job_setup()
end
-- User-specific var initialization and setup.
if user_setup then
user_setup()
end
if character_setup then
character_setup()
end
-- Job-User-specific var initialization and setup.
if user_job_setup then
user_job_setup()
end
if extra_user_setup then
extra_user_setup()
end
if not selindrile_warned then
naughty_list = {'lua ','gearswap',' gs ','file','windower','plugin','addon','program','hack','bot ','bots ','botting','easyfarm'}
windower.raw_register_event('outgoing chunk', function(id, data, modified, injected, blocked)
if id == 0x0B6 and res.servers[windower.ffxi.get_info().server].en == 'Asura' then
local p = packets.parse('outgoing',data)
if p['Target Name'] == 'Selindrile' then
for i in pairs(naughty_list) do
if p['Message']:contains(naughty_list[i]) then
windower.add_to_chat(123,'Message Aborted: Please do not message me about anything third party ingame.')
windower.add_to_chat(123,'Contact me on Discord: KalesAndRancor#5410 or https://discord.gg/ug6xtvQ')
return true
end
end
end
end
end)
end
-- Event register to watch incoming items.
windower.raw_register_event('add item', function(bag, index, id, count)
if id == 4146 and world.area == "Ghoyu's Reverie" then --4146 Revitalizer ID
useItem = true
useItemName = 'Revitalizer'
useItemSlot = 'item'
add_to_chat(217,"Revitalizer added to inventory, using, /heal to cancel.")
end
end)
-- Event register for <st> actions
windower.raw_register_event('outgoing chunk', function(id, data, modified, injected, blocked)
if id == 0x05d and st_command then
local p = packets.parse('outgoing',data)
if p['Emote'] == 31 and p['Type'] == 2 then
if p['Target ID'] == 0 then
windower.send_command('gs c '..st_command..' '..player.id..'')
else
windower.send_command('gs c '..st_command..' '..p['Target ID']..'')
end
st_command = false
return true
end
end
end)
-- New implementation of tick.
windower.raw_register_event('prerender', function()
if not (os.clock() > tickdelay) then return end
gearswap.refresh_globals(false)
if (player ~= nil) and (player.status == 'Idle' or player.status == 'Engaged') and not (delayed_cast ~= '' or check_midaction() or moving or buffactive['Sneak'] or buffactive['Invisible'] or silent_check_disable()) then
if pre_tick then
if pre_tick() then return end
end
if user_job_tick then
if user_job_tick() then return end
end
if user_tick then
if user_tick() then return end
end
if job_tick then
if job_tick() then return end
end
if default_tick then
if default_tick() then return end
end
if extra_user_job_tick then
if extra_user_job_tick() then return end
end
if extra_user_tick then
if extra_user_tick() then return end
end
end
tickdelay = os.clock() + .5
if lastincombat == true and not player.in_combat then
being_attacked = false
if player.status == 'Idle' and not midaction() and not (pet_midaction() or ((petWillAct + 2) > os.clock())) then
handle_equipping_gear(player.status)
end
if state.AutoDefenseMode.value and state.DefenseMode.value ~= 'None' then
state.DefenseMode:reset()
if state.DisplayMode.value then update_job_states() end
end
end
lastincombat = player.in_combat
end)
-- Load up all the gear sets.
init_gear_sets()
-- Load generic items into sets and determine settings after checking what is owned as needed.
include('Sel-GlobalItems')
end
-- Function to perform actions on new targets.
function target_change(new)
if state.RngHelper.value then
send_command('gs rh clear')
end
local target = windower.ffxi.get_mob_by_target('t')
local sub= windower.ffxi.get_mob_by_target('st')
if (target ~= nil) and (sub == nil) then
if state.AutoCleanupMode.value and math.sqrt(target.distance) < 7 then
if target.name == "Runje Desaali" and bayld_items then
for i in pairs(bayld_items) do
if player.inventory[bayld_items[i]] then
windower.chat.input('/item "'..bayld_items[i]..'" <t>')
windower.chat.input:schedule(2,'/targetnpc')
return
end
end
elseif target.name == "Sturdy Pyxis" and player.inventory['Forbidden Key'] then
windower.chat.input('/item "Forbidden Key" <t>') return
end
end
end
if user_job_target_change then
if user_job_target_change(target) then return end
end
if user_target_change then
if user_job_target_change(target) then return end
end
end
-- Function to reset things after zoning.
function zone_change(new_id,old_id)
if user_zone_change then
user_zone_change(new_id,old_id)
end
if job_zone_change then
job_zone_change(new_id,old_id)
end
if user_job_zone_change then
user_job_zone_change(new_id,old_id)
end
default_zone_change(new_id,old_id)
end
function default_zone_change(new_id,old_id)
tickdelay = os.clock() + 10
state.AutoBuffMode:reset()
state.AutoSubMode:reset()
state.AutoTrustMode:reset()
state.AutoTankMode:reset()
state.AutoRuneMode:reset()
state.AutoFoodMode:reset()
state.AutoWSMode:reset()
state.AutoNukeMode:reset()
send_command('gs rh disable')
state.RngHelper:reset()
useItem = false
useItemName = ''
useItemSlot = ''
lastincombat = false
being_attacked = false
if world.area:contains('Abyssea') or data.areas.proc:contains(world.area) then
state.SkipProcWeapons:set('False')
else
state.SkipProcWeapons:reset()
end
if state.DisplayMode.value then update_job_states() end
end
function time_change(new_time, old_time)
local was_daytime = classes.Daytime
local was_dusktime = classes.DuskToDawn
if new_time and (new_time >= 6*60 and new_time < 18*60) then
classes.Daytime = true
else
classes.Daytime = false
end
if new_time and (new_time >= 17*60 or new_time < 7*60) then
classes.DuskToDawn = true
else
classes.DuskToDawn = false
end
if was_daytime ~= classes.Daytime or was_dusktime ~= classes.DuskToDawn then
if job_time_change then
job_time_change(new_time, old_time)
end
handle_update({'auto'})
end
end
-- Called when this job file is unloaded (eg: job change)
-- Conditional definition so that it doesn't overwrite explicit user
-- versions of this function.
if not file_unload then
file_unload = function()
if user_job_unload then
user_job_unload()
end
if user_unload then
user_unload()
end
if job_unload then
job_unload()
end
global_unload()
end
end
-- Non item-based global settings to check on load.
function global_on_load()
if world.area then
set_dual_wield()
if world.area:contains('Abyssea') or data.areas.proc:contains(world.area) then
state.SkipProcWeapons:set('False')
else
state.SkipProcWeapons:reset()
end
if state.Weapons.value == 'None' then
enable('main','sub','range','ammo')
else
send_command('@wait 3;gs c weapons Default')
end
end
end
-- Function to revert binds when unloading.
function global_unload()
send_command('unbind ^f8')
send_command('unbind !f8')
send_command('unbind @f8')
send_command('unbind f9')
send_command('unbind ^f9')
send_command('unbind !f9')
send_command('unbind @f9')
send_command('unbind f10')
send_command('unbind ^f10')
send_command('unbind !f10')
send_command('unbind @f10')
send_command('unbind f11')
send_command('unbind ^f11')
send_command('unbind !f11')
send_command('unbind @f11')
send_command('unbind f12')
send_command('unbind ^f12')
send_command('unbind !f12')
send_command('unbind @f12')
send_command('unbind ^@!pause')
send_command('unbind ^pause')
send_command('unbind !pause')
send_command('unbind @pause')
send_command('unbind ^@!pause')
send_command('unbind ^\\\\')
send_command('unbind @\\\\')
send_command('unbind !\\\\')
send_command('unbind ^`')
send_command('unbind !`')
send_command('unbind @`')
send_command('unbind ^backspace')
send_command('unbind !backspace')
send_command('unbind @backspace')
send_command('unbind ^r')
send_command('unbind !r')
send_command('unbind @r')
send_command('unbind ^y')
send_command('unbind !y')
send_command('unbind @y')
send_command('unbind ^q')
send_command('unbind !q')
send_command('unbind @q')
send_command('unbind ^-')
send_command('unbind !-')
send_command('unbind @-')
send_command('unbind ^=')
send_command('unbind !=')
send_command('unbind @=')
send_command('unbind ^delete')
send_command('unbind !delete')
send_command('unbind @delete')
if clear_job_states then
clear_job_states()
end
end
-------------------------------------------------------------------------------------------------------------------
-- Generalized functions for handling precast/midcast/aftercast for player-initiated actions.
-- This depends on proper set naming.
-- Global hooks can be written as user_xxx() to override functions at a global level.
-- Each job can override any of these general functions using job_xxx() hooks.
-------------------------------------------------------------------------------------------------------------------
----------------------------------- -------------------------------------
-- Generic function to map a set processing order to all action events.
------------------------------------------------------------------------
-- Process actions in a specific order of events:
-- Filter - filter_xxx() functions determine whether to run any of the code for this action.
-- Global - user_xxx() functions get called first. Define in Sel-Globals or User-Globals.
-- Local - job_xxx() functions get called next. Define in JOB.lua file.
-- Default - default_xxx() functions get called next. Defined in this file.
-- Cleanup - cleanup_xxx() functions always get called before exiting.
--
-- Parameters:
-- spell - standard spell table passed in by GearSwap
-- action - string defining the function mapping to use (precast, midcast, etc)
function handle_actions(spell, action)
-- Init an eventArgs that allows cancelling.
local eventArgs = {handled = false, cancel = false}
mote_vars.set_breadcrumbs:clear()
-- Get the spell mapping, since we'll be passing it to various functions and checks.
local spellMap = get_spell_map(spell)
gearswap.refresh_globals(false)
-- General filter checks to see whether this function should be run.
-- If eventArgs.cancel is set, cancels this function, not the spell.
if _G['user_filter_'..action] then
_G['user_filter_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
if _G['user_job_filter_'..action] and not eventArgs.cancel then
_G['user_job_filter_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
if _G['job_filter_'..action] and not eventArgs.cancel then
_G['job_filter_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
if _G['filter_'..action] and not eventArgs.cancel then
_G['filter_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
-- If filter didn't cancel it, process user and default actions.
if not eventArgs.cancel then
-- Global user handling of this action
if _G['user_'..action] then
_G['user_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
-- Job-specific handling of this action
if not eventArgs.cancel and not eventArgs.handled and _G['job_'..action] then
_G['job_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
if not eventArgs.cancel and not eventArgs.handled and _G['user_job_'..action] then
_G['user_job_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
-- Default handling of this action
if not eventArgs.cancel and not eventArgs.handled and _G['default_'..action] then
_G['default_'..action](spell, spellMap, eventArgs)
display_breadcrumbs(spell, spellMap, action)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
-- Global user handling of this action
if _G['extra_user_'..action] then
_G['extra_user_'..action](spell, spellMap, eventArgs)
if eventArgs.cancel and (action == 'pretarget' or action == 'precast') then
cancel_spell()
return
end
end
-- Global post-handling of this action
if not eventArgs.cancel and _G['user_post_'..action] then
_G['user_post_'..action](spell, spellMap, eventArgs)
end
-- Job-specific post-handling of this action
if not eventArgs.cancel and _G['job_post_'..action] then
_G['job_post_'..action](spell, spellMap, eventArgs)
end
if not eventArgs.cancel and _G['user_job_post_'..action] then
_G['user_job_post_'..action](spell, spellMap, eventArgs)
end
if not eventArgs.cancel and _G['default_post_'..action] then
_G['default_post_'..action](spell, spellMap, eventArgs)
end
if not eventArgs.cancel and _G['extra_user_post_'..action] then
_G['extra_user_post_'..action](spell, spellMap, eventArgs)
end
end
-- Cleanup once this action is done
if _G['cleanup_'..action] then
_G['cleanup_'..action](spell, spellMap, eventArgs)
end
end
--------------------------------------
-- Action hooks called by GearSwap.
--------------------------------------
function filtered_action(spell, eventArgs)
local eventArgs = {cancel = false}
-- Check users action filtering
if not eventArgs.cancel and user_filtered_action then
user_filtered_action(spell, eventArgs)
end
-- Check jobs action filtering
if not eventArgs.cancel and user_job_filtered_action then
user_job_filtered_action(spell, eventArgs)
end
-- Check jobs action filtering
if not eventArgs.cancel and job_filtered_action then
job_filtered_action(spell, eventArgs)
end
-- Check users action filtering
if not eventArgs.cancel and default_filtered_action then
default_filtered_action(spell, eventArgs)
end
-- Final user for filtering and error reporting.
if not eventArgs.cancel and extra_user_filtered_action then
extra_user_filtered_action(spell, eventArgs)
end
-- Final pass for filtering and error reporting.
if not eventArgs.cancel and extra_default_filtered_action then
extra_default_filtered_action(spell, eventArgs)
end
end
function pretarget(spell)
handle_actions(spell, 'pretarget')
end
function precast(spell)
handle_actions(spell, 'precast')
end
function midcast(spell)
if spell.type == 'WeaponSkill' or spell.type == 'JobAbility' then return end
handle_actions(spell, 'midcast')
end
function aftercast(spell)
if state.Buff[spell.english:ucfirst()] ~= nil and spell.target.type == 'SELF' then
state.Buff[spell.english:ucfirst()] = not spell.interrupted or buffactive[spell.english] or false
end
handle_actions(spell, 'aftercast')
end
function pet_midcast(spell)
handle_actions(spell, 'pet_midcast')
end
function pet_aftercast(spell)
handle_actions(spell, 'pet_aftercast')
end
--------------------------------------
-- Default code for each action.
--------------------------------------
function default_filtered_action(spell, eventArgs)
if spell.english == 'Warp' then
useItem = true
useItemName = 'Warp Ring'
useItemSlot = 'ring2'
add_to_chat(217,"You can't cast warp, attempting to use Warp Ring instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Retrace' then
useItem = true
useItemName = 'Instant Retrace'
useItemSlot = 'item'
add_to_chat(217,"You can't cast Retrace, attempting to use a Retrace Scroll instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Teleport-Holla' then
useItem = true
useItemName = 'Dim. Ring (Holla)'
useItemSlot = 'ring2'
add_to_chat(217,"You can't cast Teleport-Holla, attempting to use Dimensional Ring instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Reraise' then
useItem = true
useItemName = 'Dusty Reraise'
useItemSlot = 'item'
add_to_chat(217,"You can't cast Reraise, attempting to use Instant Reraise instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Teleport-Dem' then
useItem = true
useItemName = 'Dim. Ring (Dem)'
useItemSlot = 'ring2'
add_to_chat(217,"You can't cast Teleport-Dem, attempting to use Dimensional Ring instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Teleport-Mea' then
useItem = true
useItemName = 'Dim. Ring (Mea)'
useItemSlot = 'ring2'
add_to_chat(217,"You can't cast Teleport-Mea, attempting to use Dimensional Ring instead, /heal to cancel.")
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Invisible' then
if player.main_job == 'DNC' or player.sub_job == 'DNC' then
windower.chat.input('/ja "Spectral Jig" <me>')
add_to_chat(217,"You can't cast Invisible, attempting to use Spectral Jig instead.")
elseif player.main_job == 'NIN' or player.sub_job == 'NIN' then
windower.chat.input('/ma "Tonko: Ni" <me>')
add_to_chat(217,"You can't cast Invisible, attempting to use Tonko: Ni instead.")
elseif item_available('Prism Powder') then
windower.chat.input('/item "Prism Powder" <me>')
add_to_chat(217,"You can't cast Invisible, attempting to use Prism Powder instead.")
elseif item_available('Rainbow Powder') then
windower.chat.input('/item "Rainbow Powder" <me>')
add_to_chat(217,"You can't cast Invisible, attempting to use Prism Powder instead.")
end
cancel_spell()
eventArgs.cancel = true
elseif spell.english == 'Sneak' then
if player.main_job == 'DNC' or player.sub_job == 'DNC' then
windower.chat.input('/ja "Spectral Jig" <me>')
add_to_chat(217,"You can't cast Sneak, attempting to use Spectral Jig instead.")
elseif player.main_job == 'NIN' or player.sub_job == 'NIN' then
windower.chat.input('/ma "Monomi: Ichi" <me>')
add_to_chat(217,"You can't cast Sneak, attempting to use Monomi: Ichi instead.")
elseif item_available('Silent Oil') then
windower.chat.input('/item "Silent Oil" <me>')
add_to_chat(217,"You can't cast Sneak, attempting to use Silent Oil instead.")
end
cancel_spell()
eventArgs.cancel = true
end
end
function extra_default_filtered_action(spell, eventArgs)
if spell.action_type == 'Item' and world.area == "Mog Garden" then
return
elseif spell.action_type == 'Magic' and not silent_can_use(spell.recast_id) and stepdown(spell, eventArgs) then
elseif not can_use(spell) then
end
cancel_spell()
eventArgs.cancel = true
end
function default_pretarget(spell, spellMap, eventArgs)
if spell.english == 'Warp II' and spell.target.name == player.name and state.SelfWarp2Block.value then
eventArgs.cancel = true
cancel_spell()
add_to_chat(123,'Blocking Warp2 on self, use Warp instead or disable the SelfWarp2Block state.')
return
end
end
function default_precast(spell, spellMap, eventArgs)
if eventArgs.cancel then
cancel_spell()
return
else
equip(get_precast_set(spell, spellMap))
end
cancel_conflicting_buffs(spell, spellMap, eventArgs)
if spell.action_type == 'Magic' then
next_cast = os.clock() + (spell.cast_time/4) + 3.35 - latency
elseif spell.type == 'WeaponSkill' then
next_cast = os.clock() + 2.5 - latency