midash

Orangebear_RUN

Mar 5th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.79 KB | None | 0 0
  1. -- NOTE: I do not play run, so this will not be maintained for 'active' use.
  2. -- It is added to the repository to allow people to have a baseline to build from,
  3. -- and make sure it is up-to-date with the library API.
  4.  
  5.  
  6. -------------------------------------------------------------------------------------------------------------------
  7. -- Setup functions for this job. Generally should not be modified.
  8. -------------------------------------------------------------------------------------------------------------------
  9.  
  10. -- Initialization function for this job file.
  11. function get_sets()
  12. mote_include_version = 2
  13.  
  14. -- Load and initialize the include file.
  15. include('Mote-Include.lua')
  16. end
  17.  
  18. include('organizer-lib')
  19.  
  20. -- Setup vars that are user-independent.
  21. function job_setup()
  22. -- Table of entries
  23. rune_timers = T{}
  24. -- entry = rune, index, expires
  25.  
  26. if player.main_job_level >= 65 then
  27. max_runes = 3
  28. elseif player.main_job_level >= 35 then
  29. max_runes = 2
  30. elseif player.main_job_level >= 5 then
  31. max_runes = 1
  32. else
  33. max_runes = 0
  34. end
  35. end
  36.  
  37. -------------------------------------------------------------------------------------------------------------------
  38. -- User setup functions for this job. Recommend that these be overridden in a sidecar file.
  39. -------------------------------------------------------------------------------------------------------------------
  40.  
  41. function user_setup()
  42. state.OffenseMode:options('Normal', 'DD', 'Acc', 'PDT', 'MDT', 'BDT')
  43. state.WeaponskillMode:options('Normal', 'Acc')
  44. state.PhysicalDefenseMode:options('PDT')
  45. state.IdleMode:options('Regen', 'Refresh')
  46.  
  47. select_default_macro_book()
  48.  
  49. gear.tp_HercHead = {name="Herculean Helm", augments={'Accuracy+19 Attack+19','Accuracy+15','Attack+10',}}
  50. gear.tp_HercBody = {name="Herculean Vest", augments={'Accuracy+30','"Triple Atk."+2','DEX+13',}}
  51. gear.tp_HercHands = {name="Herculean Gloves", augments={'Accuracy+23 Attack+23','Crit.hit rate+2','DEX+8','Attack+5',}}
  52. gear.tp_HercLegs = {name="Herculean Trousers", augments={'Accuracy+16 Attack+16','Accuracy+14','Attack+9',}}
  53. gear.tp_HercFeet = {name="Herculean Boots", augments={'Accuracy+25 Attack+25','Crit. hit damage +2%','STR+9','Accuracy+7','Attack+8',}}
  54. gear.ws_HercHead = {name="Herculean Helm", augments={'Accuracy+21','Weapon skill damage +4%','AGI+6',}}
  55. gear.ws_HercBody = {name="Herculean Vest", augments={'Accuracy+18 Attack+18','Weapon skill damage +2%','STR+5','Accuracy+11',}}
  56. gear.ws_HercHands = {name="Herculean Gloves", augments={'Accuracy+27','"Waltz" potency +6%','STR+14','Attack+14',}}
  57. gear.ws_HercLegs = {}
  58. gear.ws_HercFeet = {name="Herculean Boots", augments={'Weapon skill damage +3%','STR+11','Accuracy+6',}}
  59. gear.mab_HercHead = {name="Herculean Helm", augments={'Mag. Acc.+5','Magic burst mdg.+5%','INT+5','"Mag.Atk.Bns."+12',}}
  60. gear.mab_HercBody = {}
  61. gear.mab_HercHands = {name="Herculean Gloves", augments={'Mag. Acc.+19 "Mag.Atk.Bns."+19','STR+1','"Mag.Atk.Bns."+10',}}
  62. gear.mab_HercLegs = {name="Herculean Trousers", augments={'"Mag.Atk.Bns."+16','Magic burst mdg.+6%','MND+1','Mag. Acc.+13',}}
  63. gear.mab_HercFeet = {}
  64.  
  65. info.RuneEnchantment = S{"Tellus", "Unda", "Flabra", "Ignis", "Gelus", "Sulpor", "Lux", "Tenebrae"}
  66.  
  67. end
  68.  
  69.  
  70. function init_gear_sets()
  71. sets.enmity = {ammo="Aqreqaq Bomblet",
  72. head="Halitus Helm", neck="Warder's Charm +1", ear1="Trux Earring", ear2="Cryptic Earring",
  73. body="Emet Harness +1", hands="Kurys Gloves", ring1="Pernicious ring", ring2="Supershear Ring",
  74. back="Evasionist's Cape", waist="Goading Belt", legs="Eri. Leg Guards +1", feet="Erilaz Greaves +1"}
  75.  
  76. --------------------------------------
  77. -- Precast sets
  78. --------------------------------------
  79.  
  80. -- Precast sets to enhance JAs
  81. sets.precast.JA['Vallation'] =set_combine(sets.enmity, {body="Runeist coat +1", legs="Futhark trousers +1"})
  82. sets.precast.JA['Valiance'] = sets.precast.JA['Vallation']
  83. sets.precast.JA['Pflug'] = set_combine(sets.enmity, {feet="Runeist bottes +1"})
  84. sets.precast.JA['Battuta'] = set_combine(sets.enmity, {head="Futhark Bandeau +1"})
  85. sets.precast.JA['Liement'] = set_combine(sets.enmity, {body="Futhark Coat +1"})
  86. sets.precast.JA['Lunge'] = {ammo="Ghastly Tathlum +1",
  87. head=gear.mab_HercHead, neck="Eddy Necklace", ear1="Crematio Earring", ear2="Friomisi Earring",
  88. body="Samnuha Coat", hands="Leyline Gloves", ring1="Fenrir Ring +1", ring2="Shiva Ring +1",
  89. back="Argocham. Mantle", waist="Eschan Stone", legs=gear.mab_HercLegs, feet="Manabyss Pigaches"}
  90.  
  91. sets.precast.JA['Swipe'] = sets.precast.JA['Lunge']
  92. sets.precast.JA['Gambit'] = set_combine(sets.enmity, {hands="Runeist Mitons +1"})
  93. sets.precast.JA['Rayke'] = set_combine(sets.enmity, {feet="Futhark Boots +1"})
  94. sets.precast.JA['Elemental Sforzo'] = set_combine(sets.enmity, {body="Futhark Coat +1"})
  95. sets.precast.JA['Swordplay'] = set_combine(sets.enmity, {hands="Futhark Mitons +1"})
  96. sets.precast.JA['Embolden'] = set_combine(sets.enmity, {back="Evasionist's Cape"})
  97. sets.precast.JA['Vivacious Pulse'] = set_combine(sets.enmity, {head="Erilaz Galea +1", legs="Rune. Trousers +1"})
  98. sets.precast.JA['One For All'] = set_combine(sets.enmity, {})
  99. sets.precast.JA['Provoke'] = sets.enmity
  100. sets.precast.JA['Sekkanoki'] = sets.enmity
  101. sets.precast.JA['Meditate'] = sets.enmity
  102. sets.precast.JA['Warding Circle'] = sets.enmity
  103. sets.precast.JA['Seigan'] = sets.enmity
  104. sets.precast.JA['Third Eye'] = sets.enmity
  105. sets.precast.JA['Hasso'] = sets.enmity
  106.  
  107. -- Fast cast sets for spells
  108. sets.precast.FC = {ammo="Impatiens",
  109. head="Runeist bandeau +1", neck="Orunmila's Torque", ear1="Loquacious Earring", ear2="Enchntr. Earring +1",
  110. body="Dread Jupon", hands="Leyline Gloves", ring1="Weather. Ring", ring2="Prolix Ring",
  111. legs="Rawhide Trousers", feet="Chelona Boots +1"}
  112.  
  113. sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {waist="Siegel Sash", legs="Futhark Trousers +1"})
  114. sets.precast.FC['Utsusemi: Ichi'] = set_combine(sets.precast.FC, {neck='Magoraga beads'})
  115. sets.precast.FC['Utsusemi: Ni'] = set_combine(sets.precast.FC['Utsusemi: Ichi'], {})
  116.  
  117.  
  118. -- Weaponskill sets
  119. sets.precast.WS = {ammo="Floestone",
  120. head=gear.ws_HercHead, neck="Fotia Gorget", ear1="Vulcan's Pearl", ear2="Moonshade Earring",
  121. body=gear.ws_HercBody, hands=gear.ws_HercHands, ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  122. back="Buquwik Cape", waist="Fotia Belt", legs="Taeon Tights", feet=gear.ws_HercFeet}
  123.  
  124. sets.precast.WS['Resolution'] = {ammo="Floestone",
  125. head=gear.ws_HercHead, neck="Fotia Gorget", ear1="Vulcan's Pearl", ear2="Moonshade Earring",
  126. body="Rawhide Vest", hands="Erilaz Gauntlets +1", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  127. back="Buquwik Cape", waist="Fotia Belt", legs="Taeon Tights", feet=gear.ws_HercFeet}
  128.  
  129. sets.precast.WS['Resolution'].Acc = set_combine(sets.precast.WS['Resolution'].Normal,
  130. {ammo="Amar Cluster",
  131. ear1="Cessance Earring",
  132. body=gear.ws_HercBody, ring1="Rufescent Ring",
  133. back="Grounded Mantle +1", feet=gear.ws_HercFeet})
  134.  
  135. sets.precast.WS['Ground Strike'] = {ammo="Floestone",
  136. head=gear.ws_HercHead, neck="Fotia Gorget", ear1="Ishvara Earring", ear2="Moonshade Earring",
  137. body=gear.ws_HercBody, hands="Erilaz Gauntlets +1", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  138. back="Buquwik Cape", waist="Fotia Belt", legs="Taeon Tights", feet=gear.ws_HercFeet}
  139.  
  140. sets.precast.WS['Ground Strike'].Acc = set_combine(sets.precast.WS['Ground Strike'].Normal,
  141. {ammo="Amar Cluster",
  142. ear1="Cessance Earring",
  143. body=gear.ws_HercBody, ring1="Rufescent Ring",
  144. back="Grounded Mantle +1", feet=gear.ws_HercFeet})
  145.  
  146. sets.precast.WS['Savage Blade'] = {ammo="Floestone",
  147. head=gear.ws_HercHead, neck="Fotia Gorget", ear1="Vulcan's Pearl", ear2="Moonshade Earring",
  148. body="Rawhide Vest", hands=gear.ws_HercHands, ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  149. back="Buquwik Cape", waist="Fotia Belt", legs="Taeon Tights", feet=gear.ws_HercFeet}
  150.  
  151. sets.precast.WS['Savage Blade'].Acc = set_combine(sets.precast.WS['Savage Blade'].Normal,
  152. {ammo="Amar Cluster",
  153. ear1="Cessance Earring",
  154. body=gear.ws_HercBody, ring1="Rufescent Ring",
  155. back="Grounded Mantle +1", feet=gear.ws_HercFeet})
  156.  
  157. sets.precast.WS['Dimidiation'] = {ammo="Jukukik Feather",
  158. head=gear.ws_HercHead, neck="Fotia Gorget", ear1="Ishvara Earring", ear2="Moonshade Earring",
  159. body="Rawhide Vest", hands="Rawhide Gloves", ring1="Ramuh Ring +1", ring2="Ramuh Ring +1",
  160. back="Kayapa Cape", waist="Fotia Belt", legs="Taeon Tights", feet=gear.ws_HercFeet}
  161.  
  162. sets.precast.WS['Dimidiation'].Acc = set_combine(sets.precast.WS['Dimidiation'].Normal,
  163. {ammo="Honed Tathlum", head=gear.ws_HercHead, ear1="Cessance Earring",})
  164.  
  165. sets.precast.WS['Herculean Slash'] = set_combine(sets.precast['Lunge'], {})
  166. sets.precast.WS['Herculean Slash'].Acc = set_combine(sets.precast.WS['Herculean Slash'].Normal, {})
  167.  
  168. sets.precast.WS['Sanguine Blade'] = set_combine(sets.precast['Lunge'], {ring1="Archon Ring"})
  169. sets.precast.WS['Sanguine Blade'].Acc = set_combine(sets.precast.WS['Sanguine Blade'].Normal, {})
  170.  
  171.  
  172. --------------------------------------
  173. -- Midcast sets
  174. --------------------------------------
  175.  
  176. sets.midcast.FastRecast = {}
  177. sets.midcast['Enhancing Magic'] = {head="Erilaz Galea +1", neck="Colossus's torque", ear1="Andoaa Earring",
  178. hands="Runeist mitons +1", waist="Olympus Sash",
  179. back="Merciful Cape", legs="Futhark Trousers +1"}
  180. sets.midcast['Phalanx'] = set_combine(sets.midcast['Enhancing Magic'], {head="Futhark Bandeau +1"})
  181. sets.midcast['Regen'] = {head="Runeist Bandeau +1", legs="Futhark Trousers +1"}
  182. sets.midcast['Refresh'] = set_combine(sets.enmity, {head="Erilaz Galea +1"})
  183. sets.midcast['Stoneskin'] = {waist="Siegel Sash"}
  184. sets.midcast.Cure = set_combine(sets.enmity, {neck="Colossus's Torque", feet="Futhark Boots +1"})
  185. sets.midcast['Flash'] = {ammo="Aqreqaq Bomblet",
  186. head="Halitus Helm", neck="Warder's Charm +1", ear1="Trux Earring", ear2="Cryptic Earring",
  187. body="Emet Harness +1", hands="Kurys Gloves", ring1="Pernicious ring", ring2="Supershear Ring",
  188. back="Evasionist's Cape", waist="Goading Belt", legs="Eri. Leg Guards +1", feet="Erilaz Greaves +1"}
  189. sets.midcast['Foil'] = sets.midcast['Flash']
  190. sets.midcast['Crusade'] = sets.midcast['Flash']
  191.  
  192. --------------------------------------
  193. -- Idle/resting/defense/etc sets
  194. --------------------------------------
  195.  
  196. sets.idle = {ammo="Vanir Battery",
  197. head="Rawhide Mask", neck="Sanctity Necklace", ear1="Genmei earring", ear2="Etiolation earring",
  198. body="Runeist Coat +1", hands="Runeist Mitons +1", ring1="Sheltered Ring", ring2="Paguroidea ring",
  199. back="Reiki Cloak", waist="Fucho-no-Obi", legs="Rawhide Trousers", feet="Hermes' Sandals"}
  200.  
  201. sets.idle.Refresh = set_combine(sets.idle, {body="Runeist Coat +1", waist="Fucho-no-obi"})
  202.  
  203. sets.defense.PDT = {ammo="Aqreqaq Bomblet",
  204. head="Lithelimb Cap", neck="Twilight Torque", ear1="Genmei Earring", ear2={ name="Black Earring", augments={'Phys. dmg. taken -2%','"Resist Poison"+2',}},
  205. body="Erilaz Surcoat +1", hands="Runeist Mitons +1", ring1="Defending Ring", ring2={ name="Dark Ring", augments={'Enemy crit. hit rate -2','Magic dmg. taken -3%','Phys. dmg. taken -6%',}},
  206. waist="Flume Belt", legs="Eri. Leg Guards +1", feet="Erilaz Greaves +1",
  207. back="Evasionist's Cape",}
  208.  
  209. sets.defense.MDT = {ammo="Vanir Battery",
  210. head="Erilaz Galea +1", neck="Warder's Charm +1", ear1="Sanare Earring", ear2="Etiolation Earring",
  211. body="Runeist Coat +1", hands="Runeist Mitons +1", ring1="Defending Ring", ring2="Shadow Ring",
  212. back="Reiki Cloak", waist="Lieutenant's Sash", legs="Mes'yohi Slacks", feet="Erilaz Greaves +1",}
  213.  
  214. sets.defense.BDT = {ammo="Vanir Battery",
  215. head="Erilaz Galea +1", neck="Twilight Torque", ear1="Genmei Earring", ear2="Sanare Earring",
  216. body="Futhark Coat +1", hands="Kurys Gloves", ring1="Defending Ring", ring2="Dark Ring",
  217. back="Mollusca Mantle", waist="Lieutenant's Sash", legs="Mes'yohi Slacks", feet="Erilaz Greaves +1",}
  218.  
  219.  
  220. sets.Kiting = {feet="Hermes' Sandals"}
  221.  
  222.  
  223. --------------------------------------
  224. -- Engaged sets
  225. --------------------------------------
  226.  
  227. sets.engaged = {ammo="Ginsen",
  228. head="Dampening Tam", neck="Asperity Necklace", ear1="Trux Earring", ear2="Brutal Earring",
  229. body=gear.tp_HercBody, hands=gear.tp_HercHands, ring1="Epona's Ring", ring2="Petrov Ring",
  230. back="Bleating Mantle", waist="Windbuffet Belt +1", legs="Taeon Tights", feet=gear.tp_HercFeet}
  231.  
  232. sets.engaged.DD = {ammo="Ginsen",
  233. head="Dampening Tam", neck="Asperity Necklace", ear1="Trux Earring", ear2="Brutal Earring",
  234. body="Rawhide Vest", hands=gear.tp_HercHands, ring1="Epona's Ring", ring2="Petrov Ring",
  235. back="Bleating Mantle", waist="Windbuffet Belt +1", legs="Ta'lab Trousers", feet=gear.tp_HercFeet}
  236.  
  237. sets.engaged.Acc = {ammo="Honed Tathlum",
  238. head=gear.tp_HercHead, neck="Combatant's Torque", ear1="Cessance Earring", ear2="Zennaroi Earring",
  239. body=gear.tp_HercBody, hands=gear.tp_HercHands, ring1="Ramuh Ring +1", ring2="Ramuh Ring +1",
  240. back="Grounded Mantle +1", waist="Kentarch Belt +1", legs=gear.tp_HercLegs, feet=gear.tp_HercFeet}
  241.  
  242. sets.engaged.PDT = {ammo="Amar Cluster",
  243. head="Lithelimb Cap", neck="Combatant's Torque", ear1="Genmei Earring", ear2="Black Earring",
  244. body="Erilaz Surcoat +1", hands="Erilaz Gauntlets +1", ring1="Defending Ring", ring2="Dark Ring",
  245. back="Evasionist's Cape", waist="Flume Belt", legs="Eri. Leg Guards +1", feet="Erilaz Greaves +1"}
  246.  
  247. sets.engaged.MDT = {ammo="Vanir Battery",
  248. head="Dampening Tam", neck="Twilight Torque", ear1="Sanare Earring", ear2="Etiolation Earring",
  249. body="Runeist Coat +1", hands="Futhark Mitons +1", ring1="Defending Ring", ring2="Shadow Ring",
  250. back="Engulfer Cape +1", waist="Flume Belt", legs="Eri. Leg Guards +1", feet="Erilaz Greaves +1"}
  251.  
  252. sets.engaged.BDT = {ammo="Vanir Battery",
  253. head="Erilaz Galea +1", neck="Twilight Torque", ear1="Genmei Earring", ear2="Sanare Earring",
  254. body="Futhark Coat +1", hands="Kurys Gloves", ring1="Defending Ring", ring2="Dark Ring",
  255. back="Mollusca Mantle", waist="Lieutenant's Sash", legs="Mes'yohi Slacks", feet="Erilaz Greaves +1",}
  256.  
  257. sets.engaged.repulse = {}
  258.  
  259. sets.engaged.Aettir = {main="Aettir"}
  260. sets.engaged.Humility = {main="Humility"}
  261. sets.engaged.Reikiko = {main="Reikiko"}
  262. sets.engaged.Fettering = {main="Fettering Blade"}
  263.  
  264. end
  265.  
  266. ------------------------------------------------------------------
  267. -- Action events
  268. ------------------------------------------------------------------
  269.  
  270. -- Run after the default midcast() is done.
  271. -- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
  272. function job_post_midcast(spell, action, spellMap, eventArgs)
  273. if spell.english == 'Lunge' or spell.english == 'Swipe' then
  274. local obi = get_obi(get_rune_obi_element())
  275. if obi then
  276. equip({waist=obi})
  277. end
  278. end
  279. end
  280.  
  281.  
  282. function job_aftercast(spell)
  283. if not spell.interrupted then
  284. if spell.type == 'Rune' then
  285. update_timers(spell)
  286. elseif spell.name == "Lunge" or spell.name == "Gambit" or spell.name == 'Rayke' then
  287. reset_timers()
  288. elseif spell.name == "Swipe" then
  289. send_command(trim(1))
  290. end
  291. end
  292. end
  293.  
  294.  
  295. -------------------------------------------------------------------------------------------------------------------
  296. -- Customization hooks for idle and melee sets, after they've been automatically constructed.
  297. -------------------------------------------------------------------------------------------------------------------
  298.  
  299. -------------------------------------------------------------------------------------------------------------------
  300. -- General hooks for other events.
  301. -------------------------------------------------------------------------------------------------------------------
  302. function job_precast(spell)
  303. if info.RuneEnchantment:contains(spell.english) then
  304. equip(sets.enmity)
  305. end
  306. end
  307. -------------------------------------------------------------------------------------------------------------------
  308. -- User code that supplements self-commands.
  309. -------------------------------------------------------------------------------------------------------------------
  310.  
  311. -------------------------------------------------------------------------------------------------------------------
  312. -- Utility functions specific to this job.
  313. -------------------------------------------------------------------------------------------------------------------
  314.  
  315. -- Select default macro book on initial load or subjob change.
  316. function select_default_macro_book()
  317. -- Default macro set/book
  318. if player.sub_job == 'WAR' then
  319. set_macro_page(1, 17)
  320. elseif player.sub_job == 'NIN' then
  321. set_macro_page(1, 17)
  322. elseif player.sub_job == 'SAM' then
  323. set_macro_page(1, 17)
  324. else
  325. set_macro_page(1, 17)
  326. end
  327. end
  328.  
  329. function get_rune_obi_element()
  330. weather_rune = buffactive[elements.rune_of[world.weather_element] or '']
  331. day_rune = buffactive[elements.rune_of[world.day_element] or '']
  332.  
  333. local found_rune_element
  334.  
  335. if weather_rune and day_rune then
  336. if weather_rune > day_rune then
  337. found_rune_element = world.weather_element
  338. else
  339. found_rune_element = world.day_element
  340. end
  341. elseif weather_rune then
  342. found_rune_element = world.weather_element
  343. elseif day_rune then
  344. found_rune_element = world.day_element
  345. end
  346.  
  347. return found_rune_element
  348. end
  349.  
  350. function get_obi(element)
  351. if element and elements.obi_of[element] then
  352. return (player.inventory[elements.obi_of[element]] or player.wardrobe[elements.obi_of[element]]) and elements.obi_of[element]
  353. end
  354. end
  355.  
  356.  
  357. ------------------------------------------------------------------
  358. -- Timer manipulation
  359. ------------------------------------------------------------------
  360.  
  361. -- Add a new run to the custom timers, and update index values for existing timers.
  362. function update_timers(spell)
  363. local expires_time = os.time() + 300
  364. local entry_index = rune_count(spell.name) + 1
  365.  
  366. local entry = {rune=spell.name, index=entry_index, expires=expires_time}
  367.  
  368. rune_timers:append(entry)
  369. local cmd_queue = create_timer(entry).. ';wait 0.05;'
  370.  
  371. cmd_queue = cmd_queue .. trim()
  372.  
  373. -- add_to_chat(123,'cmd_queue='..cmd_queue)
  374.  
  375. send_command(cmd_queue)
  376. end
  377.  
  378. -- Get the command string to create a custom timer for the provided entry.
  379. function create_timer(entry)
  380. local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
  381. local duration = entry.expires - os.time()
  382. return 'timers c ' .. timer_name .. ' ' .. tostring(duration) .. ' down'
  383. end
  384.  
  385. -- Get the command string to delete a custom timer for the provided entry.
  386. function delete_timer(entry)
  387. local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
  388. return 'timers d ' .. timer_name .. ''
  389. end
  390.  
  391. -- Reset all timers
  392. function reset_timers()
  393. local cmd_queue = ''
  394. for index,entry in pairs(rune_timers) do
  395. cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
  396. end
  397. rune_timers:clear()
  398. send_command(cmd_queue)
  399. end
  400.  
  401. -- Get a count of the number of runes of a given type
  402. function rune_count(rune)
  403. local count = 0
  404. local current_time = os.time()
  405. for _,entry in pairs(rune_timers) do
  406. if entry.rune == rune and entry.expires > current_time then
  407. count = count + 1
  408. end
  409. end
  410. return count
  411. end
  412.  
  413. -- Remove the oldest rune(s) from the table, until we're below the max_runes limit.
  414. -- If given a value n, remove n runes from the table.
  415. function trim(n)
  416. local cmd_queue = ''
  417.  
  418. local to_remove = n or (rune_timers:length() - max_runes)
  419.  
  420. while to_remove > 0 and rune_timers:length() > 0 do
  421. local oldest
  422. for index,entry in pairs(rune_timers) do
  423. if oldest == nil or entry.expires < rune_timers[oldest].expires then
  424. oldest = index
  425. end
  426. end
  427.  
  428. cmd_queue = cmd_queue .. prune(rune_timers[oldest].rune)
  429. to_remove = to_remove - 1
  430. end
  431.  
  432. return cmd_queue
  433. end
  434.  
  435. -- Drop the index of all runes of a given type.
  436. -- If the index drops to 0, it is removed from the table.
  437. function prune(rune)
  438. local cmd_queue = ''
  439.  
  440. for index,entry in pairs(rune_timers) do
  441. if entry.rune == rune then
  442. cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
  443. entry.index = entry.index - 1
  444. end
  445. end
  446.  
  447. for index,entry in pairs(rune_timers) do
  448. if entry.rune == rune then
  449. if entry.index == 0 then
  450. rune_timers[index] = nil
  451. else
  452. cmd_queue = cmd_queue .. create_timer(entry) .. ';wait 0.05;'
  453. end
  454. end
  455. end
  456.  
  457. return cmd_queue
  458. end
  459.  
  460.  
  461. ------------------------------------------------------------------
  462. -- Reset events
  463. ------------------------------------------------------------------
  464.  
  465. windower.raw_register_event('zone change',reset_timers)
  466. windower.raw_register_event('logout',reset_timers)
  467. windower.raw_register_event('status change',function(new, old)
  468. if gearswap.res.statuses[new].english == 'Dead' then
  469. reset_timers()
  470. end
  471. end)
Advertisement
Add Comment
Please, Sign In to add comment