forked from aragan/ffxi-gearswap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRUN.lua
618 lines (543 loc) · 23.8 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
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
-- 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="Iron Gobbet",
neck="Moonlight Necklace",
left_ear="Cryptic Earring",
right_ear="Trux Earring",
}
--------------------------------------
-- 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'] = {ammo="Staunch Tathlum +1",
head={ name="Carmine Mask", augments={'Accuracy+15','Mag. Acc.+10','"Fast Cast"+3',}},
body="Nyame Mail",
hands="Nyame Gauntlets",
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
waist="Olympus Sash",
left_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
right_ear="Andoaa Earring",
left_ring="Stikini Ring +1",
right_ring="Stikini Ring +1",
back="Moonlight Cape",}
sets.precast.JA['One For All'] = {}
sets.precast.JA['Provoke'] = sets.enmity
-- Fast cast sets for spells
sets.precast.FC = {
ammo="Sapience Orb",
head={ name="Carmine Mask", augments={'Accuracy+15','Mag. Acc.+10','"Fast Cast"+3',}},
hands={ name="Leyline Gloves", augments={'Accuracy+15','Mag. Acc.+15','"Mag.Atk.Bns."+15','"Fast Cast"+3',}},
left_ear="Etiolation Earring",
right_ear="Loquac. Earring",
left_ring="Prolix Ring",
right_ring="Kishar Ring",}
sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {ammo="Staunch Tathlum +1",
head={ name="Carmine Mask", augments={'Accuracy+15','Mag. Acc.+10','"Fast Cast"+3',}},
body="Nyame Mail",
hands="Nyame Gauntlets",
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
waist="Olympus Sash",
left_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
right_ear="Andoaa Earring",
left_ring="Stikini Ring +1",
right_ring="Stikini Ring +1",
back="Moonlight Cape",})
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 = {
ammo="Knobkierrie",
head="Meghanada Visor +2",
body="Meg. Cuirie +2",
hands="Meg. Gloves +2",
legs={ name="Lustr. Subligar +1", augments={'Accuracy+20','DEX+8','Crit. hit rate+3%',}},
feet={ name="Herculean Boots", augments={'Accuracy+6','Weapon skill damage +3%','AGI+10',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear="Ishvara Earring",
right_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
left_ring="Epaminondas's Ring",
right_ring="Regal Ring",
back="Atheling Mantle",}
sets.precast.WS.Acc = {
ammo="Knobkierrie",
head="Meghanada Visor +2",
body="Meg. Cuirie +2",
hands="Meg. Gloves +2",
legs={ name="Lustr. Subligar +1", augments={'Accuracy+20','DEX+8','Crit. hit rate+3%',}},
feet={ name="Herculean Boots", augments={'Accuracy+6','Weapon skill damage +3%','AGI+10',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear="Ishvara Earring",
right_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
left_ring="Epaminondas's Ring",
right_ring="Regal Ring",
back="Atheling Mantle",}
sets.precast.WS['Resolution'] = { ammo={ name="Seeth. Bomblet +1", augments={'Path: A',}},
head={ name="Adhemar Bonnet +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
body={ name="Adhemar Jacket +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs="Meg. Chausses +2",
feet={ name="Herculean Boots", augments={'Attack+5','"Triple Atk."+4','AGI+4','Accuracy+1',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
right_ear="Sherida Earring",
left_ring="Niqmaddu Ring",
right_ring="Regal Ring",
back="Atheling Mantle",}
sets.precast.WS['Resolution'].Acc = set_combine(sets.precast.WS['Resolution'].Normal,
{})
sets.precast.WS['Dimidiation'] = { ammo="Knobkierrie",
head="Meghanada Visor +2",
body="Meg. Cuirie +2",
hands="Meg. Gloves +2",
legs="Nyame Flanchard",
feet={ name="Herculean Boots", augments={'Accuracy+6','Weapon skill damage +3%','AGI+10',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
right_ear="Sherida Earring",
left_ring="Epaminondas's Ring",
right_ring="Ilabrat Ring",
back="Atheling Mantle",}
sets.precast.WS['Dimidiation'].Acc = set_combine(sets.precast.WS['Dimidiation'].Normal,
{})
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, {})
sets.precast.WS['Ground Strike'] = set_combine(sets.precast.WS, { ammo="Knobkierrie",
head="Meghanada Visor +2",
body="Meg. Cuirie +2",
hands="Meg. Gloves +2",
legs={ name="Lustr. Subligar +1", augments={'Accuracy+20','DEX+8','Crit. hit rate+3%',}},
feet={ name="Herculean Boots", augments={'Accuracy+6','Weapon skill damage +3%','AGI+10',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear="Ishvara Earring",
right_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
left_ring="Epaminondas's Ring",
right_ring="Regal Ring",
back="Atheling Mantle",})
sets.precast.WS['Ground Strike'].Acc = set_combine(sets.precast.WS, { ammo="Knobkierrie",
head="Meghanada Visor +2",
body="Meg. Cuirie +2",
hands="Meg. Gloves +2",
legs={ name="Lustr. Subligar +1", augments={'Accuracy+20','DEX+8','Crit. hit rate+3%',}},
feet={ name="Herculean Boots", augments={'Accuracy+6','Weapon skill damage +3%','AGI+10',}},
neck="Fotia Gorget",
waist="Fotia Belt",
left_ear="Ishvara Earring",
right_ear={ name="Moonshade Earring", augments={'Accuracy+4','TP Bonus +250',}},
left_ring="Epaminondas's Ring",
right_ring="Regal Ring",
back="Atheling Mantle",})
--------------------------------------
-- Midcast sets
--------------------------------------
sets.midcast.FastRecast = { ammo="Staunch Tathlum +1",
head="Agwu's Cap",
body="Nyame Mail",
hands={ name="Rawhide Gloves", augments={'Mag. Acc.+15','INT+7','MND+7',}},
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck="Moonlight Necklace",
waist="Audumbla Sash",
left_ear="Halasz Earring",
right_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
left_ring="Epaminondas's Ring",
right_ring="Evanescence Ring",
back="Moonlight Cape",}
sets.midcast['Enhancing Magic'] = { ammo="Staunch Tathlum +1",
head={ name="Carmine Mask", augments={'Accuracy+15','Mag. Acc.+10','"Fast Cast"+3',}},
body="Nyame Mail",
hands="Nyame Gauntlets",
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
waist="Olympus Sash",
left_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
right_ear="Andoaa Earring",
left_ring="Stikini Ring +1",
right_ring="Stikini Ring +1",
back="Moonlight Cape",}
sets.midcast['Phalanx'] = set_combine(sets.midcast['Enhancing Magic'], {})
sets.midcast['Regen'] = set_combine(sets.midcast['Enhancing Magic'], { ammo="Staunch Tathlum +1",
head="Nyame Helm",
body="Nyame Mail",
hands="Nyame Gauntlets",
legs="Nyame Flanchard",
feet="Nyame Sollerets",
neck={ name="Unmoving Collar +1", augments={'Path: A',}},
waist="Flume Belt +1",
left_ear="Tuisto Earring",
right_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
left_ring={ name="Gelatinous Ring +1", augments={'Path: A',}},
right_ring="Moonlight Ring",
back="Moonlight Cape",})
sets.midcast['Stoneskin'] = {waist="Siegel Sash", ammo="Staunch Tathlum +1",
head={ name="Carmine Mask", augments={'Accuracy+15','Mag. Acc.+10','"Fast Cast"+3',}},
body="Nyame Mail",
hands="Nyame Gauntlets",
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
left_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
right_ear="Andoaa Earring",
left_ring="Stikini Ring +1",
right_ring="Stikini Ring +1",
back="Moonlight Cape",}
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="Staunch Tathlum +1",
head="Nyame Helm",
body="Nyame Mail",
hands="Nyame Gauntlets",
legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
waist="Carrier's Sash",
left_ear="Tuisto Earring",
right_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
left_ring="Epaminondas's Ring",
right_ring={ name="Gelatinous Ring +1", augments={'Path: A',}},
back="Moonlight Cape",}
sets.idle.Refresh = set_combine(sets.idle, { waist="Fucho-no-obi"})
sets.defense.PDT = { ammo="Staunch Tathlum +1",
head="Nyame Helm",
body="Nyame Mail",
hands="Nyame Gauntlets",
legs="Nyame Flanchard",
feet="Nyame Sollerets",
neck={ name="Loricate Torque +1", augments={'Path: A',}},
waist="Carrier's Sash",
left_ear="Tuisto Earring",
right_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
left_ring="Epaminondas's Ring",
right_ring={ name="Gelatinous Ring +1", augments={'Path: A',}},
back="Moonlight Cape",}
sets.defense.MDT = { ammo="Staunch Tathlum +1",
head="Nyame Helm",
body="Nyame Mail",
hands="Nyame Gauntlets",
legs="Nyame Flanchard",
feet="Nyame Sollerets",
neck={ name="Warder's Charm +1", augments={'Path: A',}},
waist="Carrier's Sash",
left_ear="Tuisto Earring",
right_ear={ name="Odnowa Earring +1", augments={'Path: A',}},
left_ring="Epaminondas's Ring",
right_ring="Shadow Ring",
back="Moonlight Cape",}
sets.Kiting = {legs={ name="Carmine Cuisses +1", augments={'Accuracy+20','Attack+12','"Dual Wield"+6',}},
}
--------------------------------------
-- Engaged sets
--------------------------------------
sets.engaged = { ammo="Coiste Bodhar",
head={ name="Adhemar Bonnet +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
body={ name="Adhemar Jacket +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs="Meg. Chausses +2",
feet={ name="Herculean Boots", augments={'Attack+5','"Triple Atk."+4','AGI+4','Accuracy+1',}},
neck="Anu Torque",
waist="Ioskeha Belt +1",
left_ear="Telos Earring",
right_ear="Sherida Earring",
left_ring="Niqmaddu Ring",
right_ring="Epona's Ring",
back="Atheling Mantle",}
sets.engaged.DD = { ammo="Coiste Bodhar",
head={ name="Adhemar Bonnet +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
body="Ayanmo Corazza +2",
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs="Meg. Chausses +2",
feet={ name="Herculean Boots", augments={'Attack+5','"Triple Atk."+4','AGI+4','Accuracy+1',}},
neck="Anu Torque",
waist="Ioskeha Belt +1",
left_ear="Telos Earring",
right_ear="Sherida Earring",
left_ring="Niqmaddu Ring",
right_ring="Moonlight Ring",
back="Atheling Mantle",}
sets.engaged.Acc = set_combine(sets.engaged.DD, { ammo="Yetshila +1",
head={ name="Blistering Sallet +1", augments={'Path: A',}},
body={ name="Adhemar Jacket +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs={ name="Zoar Subligar +1", augments={'Path: A',}},
feet="Thereoid Greaves",
neck="Nefarious Collar +1",
waist="Gerdr Belt",
left_ear="Sherida Earring",
right_ear="Brutal Earring",
left_ring="Niqmaddu Ring",
right_ring="Hetairoi Ring",
back="Atheling Mantle",})
sets.engaged.PDT = { ammo="Coiste Bodhar",
head={ name="Adhemar Bonnet +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
body="Ayanmo Corazza +2",
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs="Meg. Chausses +2",
feet={ name="Herculean Boots", augments={'Attack+5','"Triple Atk."+4','AGI+4','Accuracy+1',}},
neck="Anu Torque",
waist="Ioskeha Belt +1",
left_ear="Telos Earring",
right_ear="Sherida Earring",
left_ring="Niqmaddu Ring",
right_ring="Moonlight Ring",
back="Atheling Mantle",}
sets.engaged.MDT = {
ammo="Coiste Bodhar",
head={ name="Adhemar Bonnet +1", augments={'DEX+12','AGI+12','Accuracy+20',}},
body="Ayanmo Corazza +2",
hands={ name="Adhemar Wrist. +1", augments={'Accuracy+20','Attack+20','"Subtle Blow"+8',}},
legs="Meg. Chausses +2",
feet={ name="Herculean Boots", augments={'Attack+5','"Triple Atk."+4','AGI+4','Accuracy+1',}},
neck="Anu Torque",
waist="Ioskeha Belt +1",
left_ear="Telos Earring",
right_ear="Sherida Earring",
left_ring="Niqmaddu Ring",
right_ring="Moonlight Ring",
back="Atheling Mantle",}
sets.engaged.repulse = {}
sets.Doom = { neck="Nicander's Necklace",
waist="Gishdubar Sash",
left_ring="Purity Ring",
right_ring="Blenmot's Ring +1",}
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
function job_buff_change(buff,gain)
if buff == "doom" then
if gain then
equip(sets.Doom)
send_command('@input /p Doomed, please Cursna.')
send_command('@input /item "Holy Water" <me>')
disable('ring1','ring2','waist','neck')
else
enable('ring1','ring2','waist','neck')
send_command('input /p Doom removed.')
handle_equipping_gear(player.status)
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.
-------------------------------------------------------------------------------------------------------------------
add_to_chat(159,'Author Aragan RUN.Lua File (from Asura)')
add_to_chat(159,'For details, visit https://github.com/aragan/ffxi-lua-all-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)