-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCH_Lib.lua
413 lines (366 loc) · 18.5 KB
/
SCH_Lib.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
version = "3.0"
pName = player.name
-- Saying hello
windower.add_to_chat(8,'----- Welcome back to your SCH.lua, '..pName..' -----')
runspeedslot = 'feet'
--------------------------------------------------------------------------------------------------------------
-- HUD STUFF
--------------------------------------------------------------------------------------------------------------
wantedSc = tier1sc[elements.current]
scTier2 = M(false)
meleeing = M('AUTO', 'OFF', 'ON')
lock = M('OFF', 'ON')
mBurst = M(false)
runspeed = M('OFF', 'ON')
oldElement = elements.current
mBurstOldValue = mBurst.value
matchsc = M('AUTO', 'OFF', 'ON')
MB_Window = 0
time_start = 0
setupTextWindow()
Buff =
{
['Ebullience'] = false,
['Rapture'] = false,
['Perpetuance'] = false,
['Immanence'] = false,
['Penury'] = false,
['Parsimony'] = false,
['Celerity'] = false,
['Alacrity'] = false,
['Klimaform'] = false,
['Sublimation: Activated'] = false
}
-- Reset the state vars tracking strategems.
function update_active_strategems(name, gain)
Buff['Ebullience'] = buffactive['Ebullience'] or false
Buff['Rapture'] = buffactive['Rapture'] or false
Buff['Perpetuance'] = buffactive['Perpetuance'] or false
Buff['Immanence'] = buffactive['Immanence'] or false
Buff['Penury'] = buffactive['Penury'] or false
Buff['Parsimony'] = buffactive['Parsimony'] or false
Buff['Celerity'] = buffactive['Celerity'] or false
Buff['Alacrity'] = buffactive['Alacrity'] or false
Buff['Klimaform'] = buffactive['Klimaform'] or false
end
function update_sublimation()
Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
if Buff['Sublimation: Activated'] then
refreshType = "sublimation"
else
refreshType = "refresh"
end
if midaction() then
return
else
idle()
end
end
function buff_refresh(name,buff_details)
-- Update SCH statagems when a buff refreshes.
update_active_strategems()
update_sublimation()
validateTextInformation()
end
function buff_change(name,gain,buff_details)
-- Update SCH statagems when a buff is gained or lost.
update_active_strategems()
update_sublimation()
validateTextInformation()
end
function precast(spell)
local spell_recasts = windower.ffxi.get_spell_recasts()
-- Auto use Echo Drops if you are trying to cast while silenced --
if spell.action_type == 'Magic' and buffactive['Silence'] then
cancel_spell()
send_command('input /item "Echo Drops" <me>')
add_to_chat(8, '****** ['..spell.name..' CANCELED - Using Echo Drops] ******')
return
end
if spell.action_type == 'Magic' and spell_recasts[spell.recast_id] > 0 then
cancel_spell()
downgradenuke(spell)
add_to_chat(8, '****** ['..spell.name..' CANCELED - Spell on Cooldown, Downgrading spell] ******')
return
end
-- Moving on to other types of magic
if spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
-- Stoneskin Precast
if spell.name == 'Stoneskin' then
windower.ffxi.cancel_buff(37)--[[Cancels stoneskin, not delayed incase you get a Quick Cast]]
equip(sets.precast.stoneskin)
-- Cure Precast
elseif spell.name:match('Cure') or spell.name:match('Cura') then
equip(sets.precast.cure)
-- Enhancing Magic
elseif spell.skill == 'Magic' then
equip(sets.precast.enhancing)
if spell.name == 'Sneak' then
windower.ffxi.cancel_buff(71)--[[Cancels Sneak]]
end
else
-- For everything else we go with max fastcast
equip(sets.precast.casting)
end
end
-- Job Abilities
-- We use a cat
-- catch all here, if the set exists for an ability, use it
-- This way we don't need to write a load of different code for different abilities, just make a set
if sets.precast[spell.name] then
equip(sets.precast[spell.name])
end
-- extends Fast cast set with Grimoire recast aligned
if buffactive['addendum: black'] or buffactive['dark arts'] then
if spell.type == 'BlackMagic' then
equip(sets.precast.grimoire)
end
elseif buffactive['addendum: white'] or buffactive['light arts'] then
if spell.type == 'WhiteMagic' then
equip(sets.precast.grimoire)
end
end
end
function midcast(spell)
-- Get the spell mapping, since we'll be passing it to various functions and checks.
local spellMap = get_spell_map(spell)
-- No need to annotate all this, it's fairly logical. Just equips the relevant sets for the relevant magic
if spell.name:match('Cure') or spell.name:match('Cura') then
if spell.element == world.weather_element or spell.element == world.day_element then
equip(sets.midcast.cure.weather)
else
equip(sets.midcast.cure.normal)
end
elseif spell.skill == 'Enhancing Magic' then
equip(sets.midcast.enhancing)
if spellMap == 'Storm' then
equip(sets.midcast.storm)
elseif spell.name:match('Protect') or spell.name:match('Shell') then
equip({rring="Sheltered Ring"})
elseif spell.name:match('Refresh') then
equip(sets.midcast.refresh)
elseif spell.name:match('Regen') then
equip(sets.midcast.regen[regenModes.current])
elseif spell.name:match('Aquaveil') then
equip(sets.midcast.aquaveil)
elseif spell.name:match('Stoneskin') then
equip(sets.midcast.stoneskin)
end
elseif spell.skill == 'Enfeebling Magic' and spell.type == 'BlackMagic' then -- to do: better rule for this.
equip(sets.midcast.IntEnfeebling)
elseif spell.skill == 'Enfeebling Magic' and spell.type == 'WhiteMagic' then -- to do: better rule for this.
equip(sets.midcast.MndEnfeebling)
elseif spell.type == 'BlackMagic' then
if mBurst.value == true then
equip(sets.midcast.MB[nukeModes.current])
else
equip(sets.midcast.nuking[nukeModes.current])
end
else
equip(sets.midcast.casting)
end
-- And our catch all, if a set exists for this spell name, use it
if sets.midcast[spell.name] then
equip(sets.midcast[spell.name])
-- Catch all for tiered spells (use mapping), basically if no set for spell name, check set for spell mapping. AKA Drain works for all Drain tiers.
elseif sets.midcast[spellMap] then
equip(sets.midcast[spellMap])
-- Remember those WS Sets we defined? :) sets.me["Insert Weaponskill"] are basically how I define any non-magic spells sets, aka, WS, JA, Idles, etc.
elseif sets.me[spell.name] then
equip(sets.me[spell.name])
end
-- Put the JSE in place.
if spell.action_type == 'Magic' then
apply_grimoire_bonuses(spell, action, spellMap)
end
-- Obi up for matching weather / day
if spell.element == world.weather_element and spell.skill ~= 'Enhancing Magic' and spellMap ~= 'Helix' then
equip(sets.midcast.Obi)
end
if spell.element == world.day_element and spell.skill ~= 'Enhancing Magic' and spellMap ~= 'Helix' then
equip(sets.midcast.Obi)
end
-- Dark based Helix gets "pixie hairpin +1"
if spellMap == 'DarkHelix'then
equip(sets.midcast.DarkHelix)
end
if spellMap == 'Helix' then
equip(sets.midcast.Helix)
end
end
function aftercast(spell)
-- Then initiate idle function to check which set should be equipped
update_active_strategems()
update_sublimation()
idle()
end
function idle()
-- This function is called after every action, and handles which set to equip depending on what we're doing
-- We check if we're meleeing because we don't want to idle in melee gear when we're only engaged for trusts
if (meleeing.value == 'ON' and player.status=='Engaged') then
-- We're engaged and meleeing
equip(sets.me.melee)
else
-- If we are building sublimation, then we swap refresh to sublimation style idle.
if buffactive['Sublimation: Activated'] then
if idleModes.value == 'refresh' then
equip(sets.me.idle.sublimation)
else
equip(sets.me.idle[idleModes.value])
end
-- We don't have sublimation ticking.
else
equip(sets.me.idle[idleModes.value])
end
end
-- Checks MP for Fucho-no-Obi
if player.mpp < 51 then
equip(sets.me.latent_refresh)
end
end
function status_change(new,old)
if new == 'Engaged' then
-- If we engage check our meleeing status
idle()
elseif new=='Resting' then
-- We're resting
equip(sets.me.resting)
else
idle()
end
end
function self_command(command)
hud_command(command)
local commandArgs = command
if #commandArgs:split(' ') >= 2 then
commandArgs = T(commandArgs:split(' '))
if commandArgs[1] == 'toggle' then
if commandArgs[2] == 'melee' then
-- //gs c toggle melee will toggle melee mode on and off.
-- This basically locks the slots that will cause you to lose TP if changing them,
-- As well as equip your melee set if you're engaged
meleeing:cycle()
lockMainHand(meleeing.value)
elseif commandArgs[2] == 'mb' then
-- //gs c toggle mb will toggle mb mode on and off.
-- You need to toggle prioritisation yourself
mBurst:toggle()
updateMB(mBurst.value)
elseif commandArgs[2] == 'runspeed' then
runspeed:cycle()
updateRunspeedGear(runspeed.value, runspeedslot)
elseif commandArgs[2] == 'idlemode' then
idleModes:cycle()
idle()
if buffactive['Sublimation: Activated'] then
update_sublimation()
validateTextInformation()
-- We don't have sublimation ticking.
else
validateTextInformation()
end
elseif commandArgs[2] == 'regenmode' then
regenModes:cycle()
validateTextInformation()
elseif commandArgs[2] == 'nukemode' then
nukeModes:cycle()
validateTextInformation()
elseif commandArgs[2] == 'matchsc' then
matchsc:cycle()
validateTextInformation()
end
end
if commandArgs[1]:lower() == 'scholar' then
handle_strategems(commandArgs)
elseif commandArgs[1]:lower() == 'nuke' then
if not commandArgs[2] then
windower.add_to_chat(123,'No element type given.')
return
end
local nuke = commandArgs[2]:lower()
if (nuke == 'cycle' or nuke == 'cycledown') then
if nuke == 'cycle' then
elements:cycle()
oldElement = elements.current
elseif nuke == 'cycledown' then
elements:cycleback()
oldElement = elements.current
end
updateSC(elements.current, scTier2.value)
validateTextInformation()
elseif (nuke == 'air' or nuke == 'ice' or nuke == 'fire' or nuke == 'water' or nuke == 'lightning' or nuke == 'earth' or nuke == 'light' or nuke == 'dark') then
local newType = commandArgs[2]
elements:set(newType)
updateSC(elements.current, scTier2.value)
validateTextInformation()
elseif not nukes[nuke] then
windower.add_to_chat(123,'Unknown element type: '..tostring(commandArgs[2]))
return
else
-- Leave out target; let Shortcuts auto-determine it.
send_command('@input /ma "'..nukes[nuke][elements.current]..'"')
end
elseif commandArgs[1]:lower() == 'sc' then
if not commandArgs[2] then
windower.add_to_chat(123,'No element type given.')
return
end
local arg = commandArgs[2]:lower()
if arg == 'tier' then
scTier2:toggle()
updateSC(elements.current, scTier2.value )
end
if arg == 'castsc' then
if wantedSc == 'Scission' then
send_command('input /p Opening SC: Scission MB: Stone; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Fire" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Scission MB: Stone; input /ma "Geohelix" <t>')
elseif wantedSc == 'Reverberation' then
send_command('input /p Opening SC: Reverberation MB: Water; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Stone" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Reverberation MB: Water; input /ma "Hydrohelix" <t>')
elseif wantedSc == 'Detonation' then
send_command('input /p Opening SC: Detonation MB: Air; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Thunder" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Detonation MB: Air; input /ma "Anemohelix" <t>')
elseif wantedSc == 'Liquefaction' then
send_command('input /p Opening SC: Liquefaction MB: Fire; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Thunder" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Liquefaction MB: Fire; input /ma "Pyrohelix" <t>')
elseif wantedSc == 'Induration' then
send_command('input /p Opening SC: Induration MB: Ice; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Water" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Induration MB: Ice; input /ma "Cryohelix" <t>')
elseif wantedSc == 'Impaction' then
send_command('input /p Opening SC: Impaction MB: Lightning; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Blizzard" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Impaction MB: Lightning; input /ma "Ionohelix" <t>')
elseif wantedSc == 'Compression' then
send_command('input /p Opening SC: Compression MB: Dark; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Blizzard" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Compression MB: Dark; input /ma "Noctohelix" <t>')
elseif wantedSc == 'Distortion' then
send_command('input /p Opening SC: Distortion MB: Water / Ice; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Luminohelix" <t>; wait 6.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Distortion MB: Water / Ice; input /ma "Geohelix" <t>')
elseif wantedSc == 'Fragmentation' then
send_command('input /p Opening SC: Fragmentation MB: Lightning / Wind; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Blizzard" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Fragmentation MB: Wind / Lightning; input /ma "Hydrohelix" <t>')
elseif wantedSc == 'Fusion' then
send_command('input /p Opening SC: Fusion MB: Light / Fire; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Fire" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Fusion MB: Light / Fire; input /ma "Ionohelix" <t>')
elseif wantedSc == 'Gravitation' then
send_command('input /p Opening SC: Gravitation MB: Dark / Stone; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Aero" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Gravitation MB: Dark / Stone; input /ma "Noctohelix" <t>')
elseif wantedSc == 'Transfixion' then
send_command('input /p Opening SC: Transfixion MB: Light; wait .1; input /ja "Immanence" <me>; wait 1.5; input /ma "Noctohelix" <t>; wait 4.0; input /ja "Immanence" <me>; wait 1.5; input /p Closing SC: Transfixion MB: Light; input /ma "Luminohelix" <t>')
end
end
end
end
end
-- Equip sets appropriate to the active buffs, relative to the spell being cast.
function apply_grimoire_bonuses(spell, action, spellMap)
if Buff['Perpetuance'] and spell.type =='WhiteMagic' and spell.skill == 'Enhancing Magic' then
equip(sets.buff['Perpetuance'])
end
if Buff['Rapture'] and (spellMap == 'Cure' or spellMap == 'Curaga') then
equip(sets.buff['Rapture'])
end
if spell.skill == 'Elemental Magic' and spellMap ~= 'ElementalEnfeeble' then
if Buff['Ebullience'] and spell.english ~= 'Impact' then
equip(sets.buff['Ebullience'])
end
if Buff['Immanence'] then
equip(sets.buff['Immanence'])
end
if Buff['Klimaform'] and spell.element == world.weather_element then
equip(sets.buff['Klimaform'])
end
end
if Buff['Penury'] then equip(sets.buff['Penury']) end
if Buff['Parsimony'] then equip(sets.buff['Parsimony']) end
if Buff['Celerity'] then equip(sets.buff['Celerity']) end
if Buff['Alacrity'] then equip(sets.buff['Alacrity']) end
end