forked from Kinematics/GearSwap-Jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RUN.lua
364 lines (290 loc) · 14.7 KB
/
RUN.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
-- NOTE: I do not play run, so this will not be maintained for 'active' use.
-- It is added to the repository to allow people to have a baseline to build from,
-- and make sure it is up-to-date with the library API.
-------------------------------------------------------------------------------------------------------------------
-- Setup functions for this job. Generally should not be modified.
-------------------------------------------------------------------------------------------------------------------
-- Initialization function for this job file.
function get_sets()
mote_include_version = 2
-- Load and initialize the include file.
include('Mote-Include.lua')
end
-- Setup vars that are user-independent.
function job_setup()
-- Table of entries
rune_timers = T{}
-- entry = rune, index, expires
if player.main_job_level >= 65 then
max_runes = 3
elseif player.main_job_level >= 35 then
max_runes = 2
elseif player.main_job_level >= 5 then
max_runes = 1
else
max_runes = 0
end
end
-------------------------------------------------------------------------------------------------------------------
-- User setup functions for this job. Recommend that these be overridden in a sidecar file.
-------------------------------------------------------------------------------------------------------------------
function user_setup()
state.OffenseMode:options('Normal', 'DD', 'Acc', 'PDT', 'MDT')
state.WeaponskillMode:options('Normal', 'Acc')
state.PhysicalDefenseMode:options('PDT')
state.IdleMode:options('Regen', 'Refresh')
select_default_macro_book()
end
function init_gear_sets()
sets.enmity = {ammo="Aqreqaq Bomblet", hands="Futhark Gloves +1", back="Mubvumbamiri mantle", waist="Warwolf Belt"}
--------------------------------------
-- Precast sets
--------------------------------------
-- Precast sets to enhance JAs
sets.precast.JA['Vallation'] = {body="Runeist coat +1", legs="Futhark trousers +1"}
sets.precast.JA['Valiance'] = sets.precast.JA['Vallation']
sets.precast.JA['Pflug'] = {feet="Runeist bottes +1"}
sets.precast.JA['Battuta'] = {head="Futhark Bandeau +1"}
sets.precast.JA['Liement'] = {body="Futhark Coat +1"}
sets.precast.JA['Lunge'] = {head="Thaumas Hat", neck="Eddy Necklace", ear1="Novio Earring", ear2="Friomisi Earring",
body="Vanir Cotehardie", ring1="Acumen Ring", ring2="Omega Ring",
back="Evasionist's Cape", waist="Yamabuki-no-obi", legs="Iuitl Tights +1", feet="Qaaxo Leggings"}
sets.precast.JA['Swipe'] = sets.precast.JA['Lunge']
sets.precast.JA['Gambit'] = {hands="Runeist Mitons +1"}
sets.precast.JA['Rayke'] = {feet="Futhark Bottes +1"}
sets.precast.JA['Elemental Sforzo'] = {body="Futhark Coat 1"}
sets.precast.JA['Swordplay'] = {hands="Futhark Mitons +1"}
sets.precast.JA['Embolden'] = {}
sets.precast.JA['Vivacious Pulse'] = {}
sets.precast.JA['One For All'] = {}
sets.precast.JA['Provoke'] = sets.enmity
-- Fast cast sets for spells
sets.precast.FC = {
head="Runeist bandeau +1", ear1="Loquacious Earring",
body="Dread Jupon", hands="Thaumas gloves", ring2="Prolix Ring",
legs="Orvail Pants +1"}
sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {waist="Siegel Sash", legs="Futhark Trousers +1"})
sets.precast.FC['Utsusemi: Ichi'] = set_combine(sets.precast.FC, {neck='Magoraga beads', back="Mujin Mantle"})
sets.precast.FC['Utsusemi: Ni'] = set_combine(sets.precast.FC['Utsusemi: Ichi'], {})
-- Weaponskill sets
sets.precast.WS['Resolution'] = {ammo="Aqreqaq Bomblet",
head="Whirlpool Mask", neck="Thunder Gorget", ear1="Bladeborn Earring", ear2="Steelflash Earring",
body="Manibozho Jerkin", hands="Futhark Mitons +1", ring1="Epona's Ring", ring2="Rajas Ring",
back="Buquwik Cape", waist="Thunder Belt", legs="Quiahuiz Trousers", feet="Qaaxo Leggings"}
sets.precast.WS['Resolution'].Acc = set_combine(sets.precast.WS['Resolution'].Normal,
{ammo="Honed Tathlum", body="Dread Jupon", hands="Umuthi Gloves", back="Evasionist's Cape", legs="Manibozho Legs"})
sets.precast.WS['Dimidiation'] = {ammo="Thew Bomblet",
head="Felistris Mask", neck="Thunder Gorget", ear1="Bladeborn Earring", ear2="Steelflash Earring",
body="Dread Jupon", hands="Futhark Mitons +1", ring1="Epona's Ring", ring2="Rajas Ring",
back="Atheling Mantle", waist="Windbuffet Belt", legs="Manibozho Brais", feet="Qaaxo Leggings"}
sets.precast.WS['Dimidiation'].Acc = set_combine(sets.precast.WS['Dimidiation'].Normal,
{ammo="Honed Tathlum", head="Whirlpool Mask", hands="Buremte Gloves", back="Evasionist's Cape", waist="Thunder Belt"})
sets.precast.WS['Herculean Slash'] = set_combine(sets.precast['Lunge'], {hands="Umuthi Gloves"})
sets.precast.WS['Herculean Slash'].Acc = set_combine(sets.precast.WS['Herculean Slash'].Normal, {})
--------------------------------------
-- Midcast sets
--------------------------------------
sets.midcast.FastRecast = {}
sets.midcast['Enhancing Magic'] = {neck="Colossus's torque", ear1="Andoaa Earring", hands="Runeist mitons +1", waist="Olympus Sash", legs="Futhark Trousers +1"}
sets.midcast['Phalanx'] = set_combine(sets.midcast['Enhancing Magic'], {head="Futhark Bandeau +1"})
sets.midcast['Regen'] = {head="Runeist Bandeau +1", legs="Futhark Trousers +1"}
sets.midcast['Stoneskin'] = {waist="Siegel Sash"}
sets.midcast.Cure = {neck="Colossus's Torque", hands="Buremte Gloves", ring1="Ephedra Ring", feet="Futhark Boots +1"}
--------------------------------------
-- Idle/resting/defense/etc sets
--------------------------------------
sets.idle = {ammo='Inlamvuyeso',
head="Ocelomeh Headpiece +1", neck="Wiglen Gorget", ear1="Ethereal earring", ear2="Moonshade earring",
body="Futhark Coat +1", hands="Umuthi Gloves", ring1="Sheltered Ring", ring2="Paguroidea ring",
back="Evasionist's Cape", waist="Flume Belt", legs="Runeist Trousers +1", feet="Skadi's jambeaux +1"}
sets.idle.Refresh = set_combine(sets.idle, {body="Runeist Coat +1", waist="Fucho-no-obi"})
sets.defense.PDT = {}
sets.defense.MDT = {}
sets.Kiting = {feet="Skadi's Jambeaux +1"}
--------------------------------------
-- Engaged sets
--------------------------------------
sets.engaged = {ammo="Honed Tathlum",
head="Futhark Bandeau +1", neck="Twilight Torque", ear1="Bladeborn Earring", ear2="Steelflash Earring",
body="Futhark Coat +1", hands="Umuthi Gloves", ring1="Dark Ring", ring2="Dark Ring",
back="Mollusca Mantle", waist="Anguinus Belt", legs="Runeist Trousers +1", feet="Iuitl Gaiters +1"}
sets.engaged.DD = {ammo="Ginsen",
head="Felistris Mask", neck="Asperity Necklace", ear1="Bladeborn Earring", ear2="Steelflash Earring",
body="Thaumas Coat", hands="Futhark Mitons +1", ring1="Epona's Ring", ring2="Rajas Ring",
back="Atheling Mantle", waist="Windbuffet Belt", legs="Quiahuiz Trousers", feet="Qaaxo Leggings"}
sets.engaged.Acc = set_combine(sets.engaged.DD, {sub="Tzacab Grip", ammo="Honed Tathlum", head="Whirlpool Mask",
neck="Iqabi Necklace", hands="Buremte Gloves", waist="Anguinus Belt", legs="Manibozho Brais"})
sets.engaged.PDT = {ammo="Aqreqaq Bomblet",
head="Futhark Bandeau +1", neck="Twilight Torque", ear1="Ethereal Earring", ear2="Colossus's earring",
body="Futhark Coat +1", hands="Umuthi Gloves", ring1="Dark Ring", ring2="Dark Ring",
back="Mollusca Mantle", waist="Flume Belt", legs="Runeist Trousers +1", feet="Iuitl Gaiters +1"}
sets.engaged.MDT = {
head="Futhark Bandeau +1", neck="Twilight Torque", ear1="Ethereal Earring", ear2="Sanare Earring",
body="Runeist Coat +1", hands="Umuthi Gloves", ring1="Dark Ring", ring2="Dark Ring",
back="Mubvumbamiri mantle", waist="Flume Belt", legs="Runeist Trousers +1", feet="Iuitl Gaiters +1"}
sets.engaged.repulse = {back="Repulse Mantle"}
end
------------------------------------------------------------------
-- Action events
------------------------------------------------------------------
-- 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, action, spellMap, eventArgs)
if spell.english == 'Lunge' or spell.english == 'Swipe' then
local obi = get_obi(get_rune_obi_element())
if obi then
equip({waist=obi})
end
end
end
function job_aftercast(spell)
if not spell.interrupted then
if spell.type == 'Rune' then
update_timers(spell)
elseif spell.name == "Lunge" or spell.name == "Gambit" or spell.name == 'Rayke' then
reset_timers()
elseif spell.name == "Swipe" then
send_command(trim(1))
end
end
end
-------------------------------------------------------------------------------------------------------------------
-- Customization hooks for idle and melee sets, after they've been automatically constructed.
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- General hooks for other events.
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- User code that supplements self-commands.
-------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------
-- Utility functions specific to this job.
-------------------------------------------------------------------------------------------------------------------
-- Select default macro book on initial load or subjob change.
function select_default_macro_book()
-- Default macro set/book
if player.sub_job == 'WAR' then
set_macro_page(3, 20)
elseif player.sub_job == 'NIN' then
set_macro_page(1, 20)
elseif player.sub_job == 'SAM' then
set_macro_page(2, 20)
else
set_macro_page(5, 20)
end
end
function get_rune_obi_element()
weather_rune = buffactive[elements.rune_of[world.weather_element] or '']
day_rune = buffactive[elements.rune_of[world.day_element] or '']
local found_rune_element
if weather_rune and day_rune then
if weather_rune > day_rune then
found_rune_element = world.weather_element
else
found_rune_element = world.day_element
end
elseif weather_rune then
found_rune_element = world.weather_element
elseif day_rune then
found_rune_element = world.day_element
end
return found_rune_element
end
function get_obi(element)
if element and elements.obi_of[element] then
return (player.inventory[elements.obi_of[element]] or player.wardrobe[elements.obi_of[element]]) and elements.obi_of[element]
end
end
------------------------------------------------------------------
-- Timer manipulation
------------------------------------------------------------------
-- Add a new run to the custom timers, and update index values for existing timers.
function update_timers(spell)
local expires_time = os.time() + 300
local entry_index = rune_count(spell.name) + 1
local entry = {rune=spell.name, index=entry_index, expires=expires_time}
rune_timers:append(entry)
local cmd_queue = create_timer(entry).. ';wait 0.05;'
cmd_queue = cmd_queue .. trim()
add_to_chat(123,'cmd_queue='..cmd_queue)
send_command(cmd_queue)
end
-- Get the command string to create a custom timer for the provided entry.
function create_timer(entry)
local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
local duration = entry.expires - os.time()
return 'timers c ' .. timer_name .. ' ' .. tostring(duration) .. ' down'
end
-- Get the command string to delete a custom timer for the provided entry.
function delete_timer(entry)
local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
return 'timers d ' .. timer_name .. ''
end
-- Reset all timers
function reset_timers()
local cmd_queue = ''
for index,entry in pairs(rune_timers) do
cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
end
rune_timers:clear()
send_command(cmd_queue)
end
-- Get a count of the number of runes of a given type
function rune_count(rune)
local count = 0
local current_time = os.time()
for _,entry in pairs(rune_timers) do
if entry.rune == rune and entry.expires > current_time then
count = count + 1
end
end
return count
end
-- Remove the oldest rune(s) from the table, until we're below the max_runes limit.
-- If given a value n, remove n runes from the table.
function trim(n)
local cmd_queue = ''
local to_remove = n or (rune_timers:length() - max_runes)
while to_remove > 0 and rune_timers:length() > 0 do
local oldest
for index,entry in pairs(rune_timers) do
if oldest == nil or entry.expires < rune_timers[oldest].expires then
oldest = index
end
end
cmd_queue = cmd_queue .. prune(rune_timers[oldest].rune)
to_remove = to_remove - 1
end
return cmd_queue
end
-- Drop the index of all runes of a given type.
-- If the index drops to 0, it is removed from the table.
function prune(rune)
local cmd_queue = ''
for index,entry in pairs(rune_timers) do
if entry.rune == rune then
cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
entry.index = entry.index - 1
end
end
for index,entry in pairs(rune_timers) do
if entry.rune == rune then
if entry.index == 0 then
rune_timers[index] = nil
else
cmd_queue = cmd_queue .. create_timer(entry) .. ';wait 0.05;'
end
end
end
return cmd_queue
end
------------------------------------------------------------------
-- Reset events
------------------------------------------------------------------
windower.raw_register_event('zone change',reset_timers)
windower.raw_register_event('logout',reset_timers)
windower.raw_register_event('status change',function(new, old)
if gearswap.res.statuses[new].english == 'Dead' then
reset_timers()
end
end)