forked from Celther-FFXI/GearSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSAM.lua
328 lines (282 loc) · 17.1 KB
/
SAM.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
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- __________.__ ________ __ .__.__ __ __ .__ .__ _____.__.__
-- \______ | | ____ _____ ______ ____ \______ \ ____ ____ _____/ |_ ____ __| _|___/ |_ _/ |_| |__ |__| ______ _/ ____|__| | ____
-- | ___| | _/ __ \\__ \ / ____/ __ \ | | \ / _ \ / \ / _ \ __\ _/ __ \ / __ || \ __\ \ __| | \| |/ ___/ \ __\| | | _/ __ \
-- | | | |_\ ___/ / __ \_\___ \\ ___/ | ` ( <_> ) | | ( <_> | | \ ___// /_/ || || | | | | 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.
-------------------------------------------------------------------------------------------------------------------
-- 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.Sekkanoki = buffactive.Sekkanoki or false
state.Buff.Sengikori = buffactive.Sengikori or false
state.Buff['Meikyo Shisui'] = buffactive['Meikyo Shisui'] or false
state.Buff['Aftermath: Lv.3'] = buffactive['Aftermath: Lv.3'] or false
state.Buff['Third Eye'] = buffactive['Third Eye'] or false
state.Buff.Hasso = buffactive.Hasso or false
state.Buff.Seigan = buffactive.Seigan or false
state.Stance = M{['description']='Stance','Hasso','Seigan','None'}
autows = 'Tachi: Fudo'
rangedautows = "Apex Arrow"
autofood = 'Soy Ramen'
update_melee_groups()
init_job_states({"Capacity","AutoRuneMode","AutoTrustMode","AutoWSMode","AutoShadowMode","AutoFoodMode","AutoStunMode","AutoDefenseMode",},{"AutoBuffMode","AutoSambaMode","Weapons","OffenseMode","WeaponskillMode","Stance","IdleMode","Passive","RuneElement","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_precast(spell, spellMap, eventArgs)
if spell.type == 'WeaponSkill' and state.AutoBuffMode.value ~= 'Off' then
local abil_recasts = windower.ffxi.get_ability_recasts()
if player.tp > 1850 and abil_recasts[140] < latency then
eventArgs.cancel = true
windower.chat.input('/ja "Sekkanoki" <me>')
windower.chat.input:schedule(1,'/ws "'..spell.english..'" '..spell.target.raw..'')
tickdelay = os.clock() + 1.25
return
elseif abil_recasts[134] < latency then
eventArgs.cancel = true
windower.chat.input('/ja "Meditate" <me>')
windower.chat.input:schedule(1,'/ws "'..spell.english..'" '..spell.target.raw..'')
tickdelay = os.clock() + 1.25
return
elseif player.tp < 1500 and not buffactive['Sekkanoki'] and abil_recasts[54] < latency then
eventArgs.cancel = true
windower.chat.input('/ja "Hagakure" <me>')
windower.chat.input:schedule(1,'/ws "'..spell.english..'" '..spell.target.raw..'')
tickdelay = os.clock() + 1.25
return
end
end
end
function job_filtered_action(spell, eventArgs)
if spell.type == 'WeaponSkill' then
local available_ws = S(windower.ffxi.get_abilities().weapon_skills)
-- WS 112 is Double Thrust, meaning a Spear is equipped.
if available_ws:contains(112) then
if spell.english == "Tachi: Fudo" then
windower.chat.input('/ws "Stardiver" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
elseif spell.english == "Tachi: Shoha" then
send_command('@input /ws "Impulse Drive" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
elseif spell.english == "Tachi: Rana" then
send_command('@input /ws "Penta Thrust" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
elseif spell.english == "Tachi: Gekko" then
send_command('@input /ws "Sonic Thrust" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
elseif spell.english == "Tachi: Hobaku" then
send_command('@input /ws "Leg Sweep" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
end
end
end
end
function job_post_precast(spell, spellMap, eventArgs)
if spell.type == 'WeaponSkill' then
local WSset = standardize_set(get_precast_set(spell, spellMap))
local wsacc = check_ws_acc()
if (WSset.ear1 == "Moonshade Earring" or WSset.ear2 == "Moonshade Earring") then
-- Replace Moonshade Earring if we're at cap TP
if get_effective_player_tp(spell, WSset) > 3200 then
if spell.skill == 25 then
if wsacc:contains('Acc') and sets.RangedAccMaxTP then
equip(sets.RangedAccMaxTP)
elseif sets.RangedMaxTP then
equip(sets.RangedMaxTP)
else
end
else
if wsacc:contains('Acc') and not buffactive['Sneak Attack'] and sets.AccMaxTP then
local AccMaxTPset = standardize_set(sets.AccMaxTP)
if (AccMaxTPset.ear1:startswith("Lugra Earring") or AccMaxTPset.ear2:startswith("Lugra Earring")) and not classes.DuskToDawn and sets.AccDayMaxTPWSEars then
equip(sets.AccDayMaxTPWSEars[spell.english] or sets.AccDayMaxTPWSEars)
else
equip(sets.AccMaxTP[spell.english] or sets.AccMaxTP)
end
elseif sets.MaxTP then
local MaxTPset = standardize_set(sets.MaxTP)
if (MaxTPset.ear1:startswith("Lugra Earring") or MaxTPset.ear2:startswith("Lugra Earring")) and not classes.DuskToDawn and sets.DayMaxTPWSEars then
equip(sets.DayMaxTPWSEars[spell.english] or sets.DayMaxTPWSEars)
else
equip(sets.MaxTP[spell.english] or sets.MaxTP)
end
else
end
end
else
if wsacc:contains('Acc') and not buffactive['Sneak Attack'] and (WSset.ear1:startswith("Lugra Earring") or WSset.ear2:startswith("Lugra Earring")) and not classes.DuskToDawn and sets.AccDayWSEars then
equip(sets.AccDayWSEars[spell.english] or sets.AccDayWSEars)
elseif (WSset.ear1:startswith("Lugra Earring") or WSset.ear2:startswith("Lugra Earring")) and not classes.DuskToDawn and sets.DayWSEars then
equip(sets.DayWSEars[spell.english] or sets.DayWSEars)
end
end
elseif (WSset.ear1:startswith("Lugra Earring") or WSset.ear2:startswith("Lugra Earring")) and not classes.DuskToDawn then
if wsacc:contains('Acc') and not buffactive['Sneak Attack'] and sets.AccDayWSEars then
equip(sets.AccDayWSEars[spell.english] or sets.AccDayWSEars)
elseif sets.DayWSEars then
equip(sets.DayWSEars[spell.english] or sets.DayWSEars)
end
end
if state.Buff.Sekkanoki then
equip(sets.buff.Sekkanoki)
end
if state.Buff.Sengikori then
equip(sets.buff.Sengikori)
end
end
end
-- Modify the default melee set after it was constructed.
function job_customize_melee_set(meleeSet)
if state.Buff.Hasso and state.DefenseMode.value == 'None' and state.OffenseMode.value ~= 'FullAcc' then
meleeSet = set_combine(meleeSet, sets.buff.Hasso)
elseif state.Buff.Seigan and state.Buff['Third Eye'] and not state.OffenseMode.value:contains('Acc') then
meleeSet = set_combine(meleeSet, sets.buff['Third Eye'])
end
return meleeSet
end
-- Run after the default midcast() is done.
-- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
function job_post_midcast(spell, spellMap, eventArgs)
-- Effectively lock these items in place.
if state.HybridMode.value == 'Reraise' or
(state.DefenseMode.value == 'Physical' and state.PhysicalDefenseMode.value == 'PDTReraise') or
(state.DefenseMode.value == 'Magical' and state.MagicalDefenseMode.value == 'MDTReraise') then
equip(sets.Reraise)
end
end
function job_aftercast(spell, spellMap, eventArgs)
if spell.type == 'WeaponSkill' then
if player.tp < 750 and state.Buff['Meikyo Shisui'] then
send_command('cancel Meikyo Shisui')
end
elseif spell.english == "Meikyo Shisui" and not spell.interrupted and sets.buff['Meikyo Shisui'] then
equip(sets.buff['Meikyo Shisui'])
disable('feet')
end
end
function job_self_command(commandArgs, eventArgs)
end
function job_tick()
if check_hasso() then return true end
if check_buff() then return true end
return false
end
function job_buff_change(buff, gain)
if buff == 'Meikyo Shisui' and not gain then
enable('feet')
end
update_melee_groups()
end
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
-- 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(cmdParams, eventArgs)
update_melee_groups()
end
-- Set eventArgs.handled to true if we don't want the automatic display to be run.
function display_current_job_state(eventArgs)
end
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
function update_melee_groups()
classes.CustomMeleeGroups:clear()
if data.areas.adoulin:contains(world.area) and buffactive.Ionis then
classes.CustomMeleeGroups:append('Adoulin')
end
if player.equipment.main then
if player.equipment.main == "Kogarasumaru" and state.Buff['Aftermath: Lv.3'] then
classes.CustomMeleeGroups:append('AM')
end
end
end
function check_hasso()
if not (state.Stance.value == 'None' or state.Buff.Hasso or state.Buff.Seigan) and player.status == 'Engaged' and not silent_check_amnesia() then
local abil_recasts = windower.ffxi.get_ability_recasts()
if state.Stance.value == 'Hasso' and abil_recasts[138] < latency then
windower.chat.input('/ja "Hasso" <me>')
tickdelay = os.clock() + 1.1
return true
elseif state.Stance.value == 'Seigan' and abil_recasts[139] < latency then
windower.chat.input('/ja "Seigan" <me>')
tickdelay = os.clock() + 1.1
return true
else
return false
end
end
return false
end
function check_buff()
if state.AutoBuffMode.value ~= 'Off' and player.in_combat and not state.Buff['SJ Restriction'] then
local abil_recasts = windower.ffxi.get_ability_recasts()
if player.sub_job == 'DRK' and not buffactive['Last Resort'] and abil_recasts[87] < latency then
windower.chat.input('/ja "Last Resort" <me>')
tickdelay = os.clock() + 1.1
return true
elseif player.sub_job == 'WAR' and not buffactive.Berserk and abil_recasts[1] < latency then
windower.chat.input('/ja "Berserk" <me>')
tickdelay = os.clock() + 1.1
return true
elseif player.sub_job == 'WAR' and not buffactive.Aggressor and abil_recasts[4] < latency then
windower.chat.input('/ja "Aggressor" <me>')
tickdelay = os.clock() + 1.1
return true
else
return false
end
end
return false
end