forked from Celther-FFXI/GearSwap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOR.lua
456 lines (403 loc) · 21.7 KB
/
COR.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
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- __________.__ ________ __ .__.__ __ __ .__ .__ _____.__.__
-- \______ | | ____ _____ ______ ____ \______ \ ____ ____ _____/ |_ ____ __| _|___/ |_ _/ |_| |__ |__| ______ _/ ____|__| | ____
-- | ___| | _/ __ \\__ \ / ____/ __ \ | | \ / _ \ / \ / _ \ __\ _/ __ \ / __ || \ __\ \ __| | \| |/ ___/ \ __\| | | _/ __ \
-- | | | |_\ ___/ / __ \_\___ \\ ___/ | ` ( <_> ) | | ( <_> | | \ ___// /_/ || || | | | | 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.
-------------------------------------------------------------------------------------------------------------------
--[[
gs c toggle LuzafRing -- Toggles use of Luzaf Ring on and off
Offense mode is melee or ranged. Used ranged offense mode if you are engaged
for ranged weaponskills, but not actually meleeing.
Weaponskill mode, if set to 'Normal', is handled separately for melee and ranged weaponskills.
--]]
-- 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()
-- Whether to use Compensator under a certain threshhold even when weapons are locked.
state.CompensatorMode = M{'Never','300','1000','Always'}
-- Whether to automatically generate bullets.
state.AutoAmmoMode = M(true,'Auto Ammo Mode')
state.UseDefaultAmmo = M(true,'Use Default Ammo')
state.Buff['Triple Shot'] = buffactive['Triple Shot'] or false
-- Whether to use Luzaf's Ring
state.LuzafRing = M(true, "Luzaf's Ring")
-- Whether a warning has been given for low ammo
autows = 'Leaden Salute'
rangedautows = 'Last Stand'
autofood = 'Sublime Sushi'
ammostock = 198
define_roll_values()
init_job_states({"Capacity","AutoRuneMode","AutoTrustMode","AutoWSMode","AutoShadowMode","AutoFoodMode","RngHelper","AutoStunMode","AutoDefenseMode","LuzafRing",},{"AutoBuffMode","AutoSambaMode","Weapons","OffenseMode","RangedMode","WeaponskillMode","ElementalMode","IdleMode","Passive","RuneElement","CompensatorMode","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)
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(16) then
if spell.english == "Savage Blade" then
windower.chat.input('/ws "Evisceration" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
elseif spell.english == "Circle Blade" then
windower.chat.input('/ws "Aeolian Edge" '..spell.target.raw)
cancel_spell()
eventArgs.cancel = true
end
end
end
end
function job_pretarget(spell, spellMap, eventArgs)
end
function job_precast(spell, spellMap, eventArgs)
if spell.action_type == 'Ranged Attack' then
state.CombatWeapon:set(player.equipment.range)
-- Check that proper ammo is available if we're using ranged attacks or similar.
elseif spell.type == 'CorsairShot' then
if not player.inventory['Trump Card'] and player.satchel['Trump Card'] then
send_command('get "Trump Card" satchel')
eventArgs.cancel = true
windower.chat.input:schedule(1,'/ja "'..spell.english..'" '..spell.target.raw..'')
return
end
end
if spell.action_type == 'Ranged Attack' or spell.name == 'Shadowbind' or (spell.type == 'WeaponSkill' and spell.skill == 'Marksmanship') then
do_bullet_checks(spell, spellMap, eventArgs)
end
end
function job_post_midcast(spell, spellMap, eventArgs)
if spell.action_type == 'Ranged Attack' then
if state.Buff['Triple Shot'] and sets.buff['Triple Shot'] then
if sets.buff['Triple Shot'][state.RangedMode.value] then
equip(sets.buff['Triple Shot'][state.RangedMode.value])
else
equip(sets.buff['Triple Shot'])
end
end
if state.Buff.Barrage and sets.buff.Barrage then
equip(sets.buff.Barrage)
end
end
end
function job_self_command(commandArgs, eventArgs)
if commandArgs[1]:lower() == 'elemental' and commandArgs[2]:lower() == 'quickdraw' then
windower.chat.input('/ja "'..data.elements.quickdraw_of[state.ElementalMode.Value]..' Shot" <t>')
eventArgs.handled = true
end
end
function job_midcast(spell, action, spellMap, eventArgs)
--Probably overkill but better safe than sorry.
if spell.action_type == 'Ranged Attack' then
if player.equipment.ammo:startswith('Hauksbok') or player.equipment.ammo == "Animikii Bullet" then
enable('ammo')
equip({ammo=empty})
add_to_chat(123,"Abort Ranged Attack: Don't shoot your good ammo!")
return
end
end
end
-- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
function job_aftercast(spell, spellMap, eventArgs)
if spell.type == 'CorsairRoll' and not spell.interrupted then
if state.CompensatorMode.value ~= 'Never' then
if (player.equipment.range and player.equipment.range == 'Compensator') and sets.weapons[state.Weapons.value] and sets.weapons[state.Weapons.value].range then
equip({range=sets.weapons[state.Weapons.value].range})
disable('range')
end
if sets.precast.CorsairRoll.main and sets.weapons[state.Weapons.value] and sets.weapons[state.Weapons.value].main then
equip({main=sets.weapons[state.Weapons.value].main})
disable('main')
end
end
display_roll_info(spell)
end
if state.UseDefaultAmmo.value then
equip({ammo=gear.RAbullet})
end
end
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements standard library decisions.
-------------------------------------------------------------------------------------------------------------------
function job_buff_change(buff, gain)
if player.equipment.Ranged and buff:contains('Aftermath') then
classes.CustomRangedGroups:clear()
if (player.equipment.Ranged == 'Death Penalty' and buffactive['Aftermath: Lv.3']) then
classes.CustomRangedGroups:append('AM')
end
end
end
-- Modify the default melee set after it was constructed.
function job_customize_melee_set(meleeSet)
return meleeSet
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(cmdParams, eventArgs)
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 data.weaponskills.elemental:contains(spell.english) then
if wsacc:contains('Acc') and sets.MagicalAccMaxTP then
equip(sets.MagicalAccMaxTP[spell.english] or sets.MagicalAccMaxTP)
elseif sets.MagicalMaxTP then
equip(sets.MagicalMaxTP[spell.english] or sets.MagicalMaxTP)
else
end
elseif spell.skill == 26 then
if wsacc:contains('Acc') and sets.RangedAccMaxTP then
equip(sets.RangedAccMaxTP[spell.english] or sets.RangedAccMaxTP)
elseif sets.RangedMaxTP then
equip(sets.RangedMaxTP[spell.english] or sets.RangedMaxTP)
else
end
else
if wsacc:contains('Acc') and not buffactive['Sneak Attack'] and sets.AccMaxTP then
equip(sets.AccMaxTP[spell.english] or sets.AccMaxTP)
elseif sets.MaxTP then
equip(sets.MaxTP[spell.english] or sets.MaxTP)
else
end
end
end
end
elseif spell.type == 'CorsairShot' and not (spell.english == 'Light Shot' or spell.english == 'Dark Shot') then
if (state.WeaponskillMode.value == "Proc" or state.CastingMode.value == "Proc") and sets.precast.CorsairShot.Proc then
equip(sets.precast.CorsairShot.Proc)
elseif state.CastingMode.value == 'Fodder' and sets.precast.CorsairShot.Damage then
equip(sets.precast.CorsairShot.Damage)
local distance = spell.target.distance - spell.target.model_size
local single_obi_intensity = 0
local orpheus_intensity = 0
local hachirin_intensity = 0
if item_available("Orpheus's Sash") then
orpheus_intensity = (0.16 - (distance <= 1 and 1 or distance >= 15 and 15 or distance)/100) or 0
end
if item_available(data.elements.obi_of[spell.element]) then
if spell.element == world.weather_element then
single_obi_intensity = single_obi_intensity + data.weather_bonus_potency[world.weather_intensity]
end
if spell.element == world.day_element then
single_obi_intensity = single_obi_intensity + 10
end
end
if item_available('Hachirin-no-Obi') then
if spell.element == world.weather_element then
hachirin_intensity = hachirin_intensity + data.weather_bonus_potency[world.weather_intensity]
elseif spell.element == data.elements.weak_to[world.weather_element] then
hachirin_intensity = hachirin_intensity - data.weather_bonus_potency[world.weather_intensity]
end
if spell.element == world.day_element then
hachirin_intensity = hachirin_intensity + 10
elseif spell.element == data.elements.weak_to[world.day_element] then
hachirin_intensity = hachirin_intensity - 10
end
end
if orpheus_intensity > hachirin_intensity and orpheus_intensity > single_obi_intensity and orpheus_intensity > 5 then
equip({waist="Orpheus's Sash"})
elseif single_obi_intensity >= hachirin_intensity and single_obi_intensity > 5 then
equip({waist=data.elements.obi_of[spell.element]})
elseif hachirin_intensity > 5 then
equip({waist="Hachirin-no-Obi"})
end
end
elseif spell.action_type == 'Ranged Attack' then
if buffactive.Flurry then
if sets.precast.RA.Flurry and lastflurry == 1 then
equip(sets.precast.RA.Flurry)
elseif sets.precast.RA.Flurry2 and lastflurry == 2 then
equip(sets.precast.RA.Flurry2)
end
end
elseif spell.type == 'CorsairRoll' or spell.english == "Double-Up" then
if state.LuzafRing.value and item_available("Luzaf's Ring") then
equip(sets.precast.LuzafRing)
end
if spell.type == 'CorsairRoll' and state.CompensatorMode.value ~= 'Never' and (state.CompensatorMode.value == 'Always' or tonumber(state.CompensatorMode.value) > player.tp) then
if item_available("Compensator") then
enable('range')
equip({range="Compensator"})
end
if sets.precast.CorsairRoll.main and sets.precast.CorsairRoll.main ~= player.equipment.main then
enable('main')
equip({main=sets.precast.CorsairRoll.main})
end
end
elseif spell.english == 'Fold' and buffactive['Bust'] == 2 and sets.precast.FoldDoubleBust then
equip(sets.precast.FoldDoubleBust)
end
end
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
function define_roll_values()
rolls = {
["Corsair's Roll"] = {lucky=5, unlucky=9, bonus="Experience Points"},
["Ninja Roll"] = {lucky=4, unlucky=8, bonus="Evasion"},
["Hunter's Roll"] = {lucky=4, unlucky=8, bonus="Accuracy"},
["Chaos Roll"] = {lucky=4, unlucky=8, bonus="Attack"},
["Magus's Roll"] = {lucky=2, unlucky=6, bonus="Magic Defense"},
["Healer's Roll"] = {lucky=3, unlucky=7, bonus="Cure Potency Received"},
["Puppet Roll"] = {lucky=3, unlucky=7, bonus="Pet Magic Accuracy/Attack"},
["Choral Roll"] = {lucky=2, unlucky=6, bonus="Spell Interruption Rate"},
["Monk's Roll"] = {lucky=3, unlucky=7, bonus="Subtle Blow"},
["Beast Roll"] = {lucky=4, unlucky=8, bonus="Pet Attack"},
["Samurai Roll"] = {lucky=2, unlucky=6, bonus="Store TP"},
["Evoker's Roll"] = {lucky=5, unlucky=9, bonus="Refresh"},
["Rogue's Roll"] = {lucky=5, unlucky=9, bonus="Critical Hit Rate"},
["Warlock's Roll"] = {lucky=4, unlucky=8, bonus="Magic Accuracy"},
["Fighter's Roll"] = {lucky=5, unlucky=9, bonus="Double Attack Rate"},
["Drachen Roll"] = {lucky=4, unlucky=8, bonus="Pet Accuracy"},
["Gallant's Roll"] = {lucky=3, unlucky=7, bonus="Defense"},
["Wizard's Roll"] = {lucky=5, unlucky=9, bonus="Magic Attack"},
["Dancer's Roll"] = {lucky=3, unlucky=7, bonus="Regen"},
["Scholar's Roll"] = {lucky=2, unlucky=6, bonus="Conserve MP"},
["Bolter's Roll"] = {lucky=3, unlucky=9, bonus="Movement Speed"},
["Caster's Roll"] = {lucky=2, unlucky=7, bonus="Fast Cast"},
["Courser's Roll"] = {lucky=3, unlucky=9, bonus="Snapshot"},
["Blitzer's Roll"] = {lucky=4, unlucky=9, bonus="Attack Delay"},
["Tactician's Roll"] = {lucky=5, unlucky=8, bonus="Regain"},
["Allies' Roll"] = {lucky=3, unlucky=10, bonus="Skillchain Damage"},
["Miser's Roll"] = {lucky=5, unlucky=7, bonus="Save TP"},
["Companion's Roll"] = {lucky=2, unlucky=10, bonus="Pet Regain and Regen"},
["Avenger's Roll"] = {lucky=4, unlucky=8, bonus="Counter Rate"},
["Naturalist's Roll"] = {lucky=3, unlucky=7, bonus="Enhancing Duration"},
["Runeist's Roll"] = {lucky=4, unlucky=8, bonus="Magic Evasion"},
}
end
function display_roll_info(spell)
rollinfo = rolls[spell.english]
local rollsize = (state.LuzafRing.value and 'Large') or 'Small'
if rollinfo then
add_to_chat(217, spell.english..' provides a bonus to '..rollinfo.bonus..'. Roll size: '..rollsize)
add_to_chat(217, 'Lucky roll is '..tostring(rollinfo.lucky)..', Unlucky roll is '..tostring(rollinfo.unlucky)..'.')
end
end
-- Determine whether we have sufficient ammo for the action being attempted.
function do_bullet_checks(spell, spellMap, eventArgs)
if (player.equipment.ammo == 'Animikii Bullet' or player.equipment.ammo == 'Hauksbok Bullet') then
cancel_spell()
eventArgs.cancel = true
enable('ammo')
if sets.weapons[state.Weapons.value].ammo and item_available(sets.weapons[state.Weapons.value].ammo) then
equip({ammo=sets.weapons[state.Weapons.value].ammo})
disable('ammo')
elseif item_available(gear.RAbullet) then
equip({ammo=gear.RAbullet})
else
equip({ammo=empty})
end
add_to_chat(123,"Abort: Don't shoot your good ammo!")
return
end
local bullet_name
local bullet_min_count = 1
if spell.type == 'WeaponSkill' then
if spell.skill == "Marksmanship" then
if data.weaponskills.elemental:contains(spell.english) then
-- magical weaponskills
bullet_name = gear.MAbullet
else
-- physical weaponskills
bullet_name = gear.WSbullet
end
else
-- Ignore non-ranged weaponskills
return
end
elseif spell.type == 'CorsairShot' then
bullet_name = gear.QDbullet
elseif spell.action_type == 'Ranged Attack' then
bullet_name = gear.RAbullet
if state.Buff['Triple Shot'] then
bullet_min_count = 3
end
end
local available_bullets = count_available_ammo(bullet_name)
-- If no ammo is available, give appropriate warning and cancel.
if not (available_bullets > 0) then
if spell.type == 'CorsairShot' and player.equipment.ammo ~= 'empty' then
add_to_chat(217, 'No Quick Draw ammo available, using equipped ammo: ('..player.equipment.ammo..')')
return
elseif spell.type == 'WeaponSkill' and (player.equipment.ammo == gear.RAbullet or player.equipment.ammo == gear.WSbullet or player.equipment.ammo == gear.MAbullet) then
add_to_chat(217, 'No weaponskill ammo available, using equipped ammo: ('..player.equipment.ammo..')')
return
else
add_to_chat(217, 'No ammo ('..tostring(bullet_name)..') available for that action.')
eventArgs.cancel = true
return
end
end
-- Don't allow shooting or weaponskilling with ammo reserved for quick draw.
if spell.type ~= 'CorsairShot' and bullet_name == gear.QDbullet and (available_bullets <= bullet_min_count) then
add_to_chat(217, 'No ammo will be left for Quick Draw. Cancelling.')
eventArgs.cancel = true
return
end
-- Low ammo warning.
if spell.type ~= 'CorsairShot' and (available_bullets > 0) and (available_bullets <= options.ammo_warning_limit) then
local msg = '**** LOW AMMO WARNING: '..bullet_name..' ****'
--local border = string.repeat("*", #msg)
local border = ""
for i = 1, #msg do
border = border .. "*"
end
add_to_chat(217, border)
add_to_chat(217, msg)
add_to_chat(217, border)
end
end
function job_tick()
if check_ammo() then return true end
return false
end