Advertisement
Loire

Loire Sam

Oct 6th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 19.40 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 = 2
  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', 'Mid', 'Acc', 'PDT', 'MDT')
  43.     state.WeaponskillMode:options('Normal', 'Acc')
  44.     state.PhysicalDefenseMode:options('PDT')
  45.     state.IdleMode:options('Regen')
  46.  
  47.     select_default_macro_book()
  48.  
  49.     info.RuneEnchantment = S{"Tellus", "Unda", "Flabra", "Ignis", "Gelus", "Sulpor", "Lux", "Tenebrae"}
  50.    
  51. end
  52.  
  53.  
  54. function init_gear_sets()
  55.     sets.enmity = {
  56.             head="Loess Barbuta +1", neck="Warder's Charm", ear1="Trux Earring", ear2="Cryptic Earring",
  57.             body="Emet Harness +1", hands="Kurys Gloves", ring1="Pernicious ring", ring2="Supershear Ring",
  58.             back="Mubvum. Mantle", waist="Goading Belt", legs="Zoar Subligar +1", feet="Usk. Sune-Ate +1"}
  59.  
  60.     --------------------------------------
  61.     -- Precast sets
  62.     --------------------------------------
  63.  
  64.     -- Precast sets to enhance JAs
  65.     sets.precast.JA = sets.enmity
  66.     sets.precast.JA['Meikyo Shisui'] = set_combine(sets.enmity, {feet="Sak. Sune-Ate +1"}) 
  67.     sets.precast.JA['Blade Bash'] = set_combine(sets.enmity, {hands="Sakonji Kote +1",})
  68.     sets.precast.JA['Sekkanoki'] = set_combine(sets.enmity, {hands="Kasuga kote +1",})
  69.     sets.precast.JA['Meditate'] = set_combine(sets.enmity, {head="Wakido Kabuto +1", hands="Sakonji Kote +1", back="Takaha Mantle",})
  70.     sets.precast.JA['Warding Circle'] = set_combine(sets.enmity, {head="Wakido Kabuto +1"})
  71.     sets.precast.JA['Seigan'] = set_combine(sets.enmity, {head="Kasuga Kabuto +1"})
  72.     sets.precast.JA['Third Eye'] = set_combine(sets.enmity, {legs="Sao. Haidate +2"})
  73.     sets.precast.JA['Konzen-ittai'] = set_combine(sets.enmity, {})
  74.     sets.precast.JA['Hagakure'] = set_combine(sets.enmity, {})
  75.     sets.precast.JA['Sengikori'] = set_combine(sets.enmity, {feet="Kasuga sune-ate +1",})
  76.  
  77.     -- Fast cast sets for spells
  78.     sets.precast.FC = {
  79.             head="Otronif Mask +1", neck="Orunmila's Torque", ear1="Loquacious Earring", ear2="Etiolation Earring",
  80.             body="Emet Harness +1", hands="Buremte Gloves", ring1="Weather. Ring", ring2="Prolix Ring",
  81.             back="Mollusca Mantle", waist="Flume Belt", legs="Xaddi Cuisses", feet="Amm Greaves"}
  82.            
  83.     sets.precast.FC['Utsusemi: Ichi'] = set_combine(sets.precast.FC, {})
  84.     sets.precast.FC['Utsusemi: Ni'] = set_combine(sets.precast.FC['Utsusemi: Ichi'], {})
  85.  
  86.  
  87.     -- Weaponskill sets
  88.     sets.precast.WS = {
  89.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Moonshade Earring",
  90.             body="Phorcys Korazin", hands="Despair Fin. Gaunt.", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  91.             back="Buquwik Cape", waist="Fotia Belt", legs="Zoar Subligar +1", feet="Loyalist Sabatons"}
  92.    
  93.     sets.precast.WS['Tachi: Fudo'] = {
  94.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Moonshade Earring",
  95.             body="Phorcys Korazin", hands="Despair Fin. Gaunt.", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  96.             back="Buquwik Cape", waist="Metalsinger Belt", legs="Zoar Subligar +1", feet="Loyalist Sabatons"}
  97.            
  98.     sets.precast.WS['Tachi: Fudo'].Acc = set_combine(sets.precast.WS['Tachi: Fudo'].Normal,
  99.             {body="Acro Surcoat", ring1="Rufescent Ring",
  100.             back="Takaha Mantle", waist="Prosilio Belt +1", legs="Acro Breeches", feet="Acro Leggings"})
  101.  
  102.     sets.precast.WS['Tachi: Kasha'] = {
  103.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Moonshade Earring",
  104.             body="Phorcys Korazin", hands="Despair Fin. Gaunt.", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  105.             back="Buquwik Cape", waist="Metalsinger Belt", legs="Zoar Subligar +1", feet="Loyalist Sabatons"}
  106.            
  107.     sets.precast.WS['Tachi: Kasha'].Acc = set_combine(sets.precast.WS['Tachi: Kasha'].Normal,
  108.             {body="Acro Surcoat", ring1="Rufescent Ring",
  109.             back="Takaha Mantle", waist="Prosilio Belt +1", legs="Acro Breeches", feet="Acro Leggings"})           
  110.  
  111.     sets.precast.WS['Tachi: Gekko'] = {
  112.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Moonshade Earring",
  113.             body="Phorcys Korazin", hands="Despair Fin. Gaunt.", ring1="Ifrit Ring +1", ring2="Ifrit Ring +1",
  114.             back="Buquwik Cape", waist="Metalsinger Belt", legs="Zoar Subligar +1", feet="Loyalist Sabatons"}
  115.            
  116.     sets.precast.WS['Tachi: Gekko'].Acc = set_combine(sets.precast.WS['Tachi: Gekko'].Normal,
  117.             {body="Acro Surcoat", ring1="Rufescent Ring",
  118.             back="Takaha Mantle", waist="Prosilio Belt +1", legs="Acro Breeches", feet="Acro Leggings"})
  119.  
  120.     sets.precast.WS['Tachi: Rana'] = {
  121.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Cessance Earring",
  122.             body="Acro Surcoat", hands="Despair Fin. Gaunt.", ring1="Rufescent Ring", ring2="Ifrit Ring +1",
  123.             back="Annealed Mantle", waist="Fotia Belt", legs="Acro Breeches", feet="Acro Leggings"}
  124.            
  125.     sets.precast.WS['Tachi: Rana'].Acc = set_combine(sets.precast.WS['Tachi: Rana'].Normal,
  126.             {ear2="Zennaroi Earring",
  127.             ring2="Ramuh Ring +1",
  128.             back="Takaha Mantle", waist="Fotia Belt"})
  129.  
  130.     sets.precast.WS['Stardiver'] = {
  131.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Cessance Earring",
  132.             body="Acro Surcoat", hands="Despair Fin. Gaunt.", ring1="Rufescent Ring", ring2="Ifrit Ring +1",
  133.             back="Annealed Mantle", waist="Fotia Belt", legs="Acro Breeches", feet="Acro Leggings"}
  134.            
  135.     sets.precast.WS['Stardiver'].Acc = set_combine(sets.precast.WS['Stardiver'].Normal,
  136.             {ear2="Zennaroi Earring",
  137.             ring2="Ramuh Ring +1",
  138.             back="Takaha Mantle", waist="Fotia Belt"})
  139.  
  140.     sets.precast.WS['Apex Arrow'] = {
  141.             head="Sakonji Kabuto +1", neck="Fotia Gorget", ear1="Clearview Earring", ear2="Moonshade Earring",
  142.             body="Kyujutsugi", hands="Unkai Kote +2", ring1="Hajduk Ring", ring2="Longshot Ring",
  143.             back="Buquwik Cape", waist="Fotia Belt", legs="Aeto. Trousers +1", feet="Wakido Sune-Ate +1"}
  144.            
  145.     sets.precast.WS['Apex Arrow'].Acc = set_combine(sets.precast.WS['Apex Arrow'].Normal, {})          
  146.  
  147.     sets.precast.WS['Tachi: Hobaku'] = {
  148.             head="Gavialis Helm", neck="Fotia Gorget", ear1="Zwazo Earring +1", ear2="Zennaroi Earring",
  149.             body="Acro Surcoat", hands="Despair Fin. Gaunt.", ring1="Rufescent Ring", ring2="Ramuh Ring +1",
  150.             back="Takaha Mantle", waist="Fotia Belt", legs="Acro Breeches", feet="Acro Leggings"}
  151.            
  152.     sets.precast.WS['Tachi: Hobaku'].Acc = set_combine(sets.precast.WS['Tachi: Hobaku'].Normal, {})    
  153.  
  154.  
  155.     --------------------------------------
  156.     -- Midcast sets
  157.     --------------------------------------
  158.    
  159.     sets.midcast.FastRecast = {
  160.             head="Otronif Mask +1", neck="Orunmila's Torque", ear1="Loquacious Earring", ear2="Etiolation Earring",
  161.             body="Emet Harness +1", hands="Buremte Gloves", ring1="Weather. Ring", ring2="Prolix Ring",
  162.             back="Mollusca Mantle", waist="Flume Belt", legs="Xaddi Cuisses", feet="Amm Greaves"}
  163.            
  164.     sets.midcast.FastRecast['Utsusemi: Ichi'] = sets.midcast.FastRecast
  165.     sets.midcast.FastRecast['Utsusemi: Ni'] = sets.midcast.FastRecast
  166.     --------------------------------------
  167.     -- Idle/resting/defense/etc sets
  168.     --------------------------------------
  169.  
  170.     sets.idle = {range="Cibitshavore", ammo="Eminent Arrow",
  171.             head="Twilight Helm", neck="Wiglen Gorget", ear1="Genmei earring", ear2="Etiolation earring",
  172.             body="Kumarbi's Akar", hands="Sakonji Kote +1", ring1="Sheltered Ring", ring2="Paguroidea ring",
  173.             back="Mubvum. Mantle", waist="Flume Belt", legs="Otronif Brais +1", feet="Danzo Sune-Ate"}
  174.            
  175.     sets.defense.PDT = {range="Cibitshavore", ammo="Eminent Arrow",
  176.             head="Loess Barbuta +1", neck="Twilight Torque", ear1="Black Earring", ear2="Genmei Earring",
  177.             body="Emet Harness +1", hands="Sakonji Kote +1", ring1="Defending Ring", ring2="Dark Ring",
  178.             back="Mollusca Mantle", waist="Flume Belt", legs="Xaddi Cuisses", feet="Amm Greaves",}
  179.  
  180.     sets.defense.MDT = {range="Cibitshavore", ammo="Eminent Arrow",
  181.             head="Gavialis Helm", neck="Warder's Charm", ear1="Sanare Earring", ear2="Etiolation Earring",
  182.             body="Kyujutsugi", hands="Kurys Gloves", ring1="Defending Ring", ring2="Shadow Ring",
  183.             back="Mubvum. Mantle", waist="Lieutenant's Sash", legs="Osmium Cuisses", feet="Daihanshi Habaki",}
  184.            
  185.     sets.defense.BDT = {range="Cibitshavore", ammo="Eminent Arrow",
  186.             head="Loess Barbuta +1", neck="Twilight Torque", ear1="Zwazo Earring +1", ear2="Cryptic Earring",
  187.             body="Kyujutsugi", hands="Kurys Gloves", ring1="Defending Ring", ring2="K'ayres Ring",
  188.             back="Mollusca Mantle", waist="Lieutenant's Sash", legs="Scuff. Cosciales", feet="Amm Greaves",}           
  189.  
  190.  
  191.     sets.Kiting = {feet="Danzo Sune-Ate"}
  192.  
  193.  
  194.     --------------------------------------
  195.     -- Engaged sets
  196.     --------------------------------------
  197.  
  198.     sets.engaged = {sub="Bloodrain Strap", range="Cibitshavore", ammo="Eminent Arrow",
  199.             head="Acro Helm", neck="Ganesha's Mala", ear1="Trux Earring", ear2="Cessance Earring",
  200.             body="Kasuga Domaru +1", hands="Acro Gauntlets", ring1="Petrov Ring", ring2="Rajas Ring",
  201.             back="Takaha Mantle", waist="Windbuffet Belt +1", legs="Kasuga Haidate +1", feet="Acro Leggings"}
  202.            
  203.     sets.engaged.Mid = {sub="Bloodrain Strap", range="Cibitshavore", ammo="Eminent Arrow",
  204.             head="Acro Helm", neck="Da. Nodowa +1", ear1="Zwazo Earring +1", ear2="Cessance Earring",
  205.             body="Kasuga Domaru +1", hands="Acro Gauntlets", ring1="Petrov Ring", ring2="Rajas Ring",
  206.             back="Takaha Mantle", waist="Kentarch Belt +1", legs="Kasuga Haidate +1", feet="Acro Leggings"}
  207.            
  208.     sets.engaged.Acc = {sub="Bloodrain Strap", range="Cibitshavore", ammo="Eminent Arrow",
  209.             head="Acro Helm", neck="Subtlety Spectacles", ear1="Zwazo Earring +1", ear2="Zennaroi Earring",
  210.             body="Kasuga Domaru +1", hands="Acro Gauntlets", ring1="Ramuh Ring +1", ring2="Ramuh Ring +1",
  211.             back="Takaha Mantle", waist="Olseni Belt", legs="Kasuga Haidate +1", feet="Acro Leggings"}
  212.            
  213.     sets.engaged.PDT = {sub="Bloodrain Strap", range="Cibitshavore", ammo="Eminent Arrow",
  214.             head="Loess Barbuta +1", neck="Agitator's Collar", ear1="Black Earring", ear2="Genmei Earring",
  215.             body="Emet Harness +1", hands="Sakonji Kote +1", ring1="Defending Ring", ring2="Patricius Ring",
  216.             back="Mollusca Mantle", waist="Dynamic Belt +1", legs="Xaddi Cuisses", feet="Amm Greaves",}
  217.            
  218.     sets.engaged.MDT = {sub="Bloodrain Strap", range="Cibitshavore", ammo="Eminent Arrow",
  219.             head="Gavialis Helm", neck="Twilight Torque", ear1="Sanare Earring", ear2="Etiolation Earring",
  220.             body="Kyujutsugi", hands="Kurys Gloves", ring1="Defending Ring", ring2="Shadow Ring",
  221.             back="Engulfer Cape +1", waist="Dynamic Belt +1", legs="Osmium Cuisses", feet="Daihanshi Habaki",}
  222.            
  223.     sets.engaged.repulse = {}
  224.    
  225.     sets.engaged.Kogarasumaru = {main="Kogarasumaru"}
  226.     sets.engaged.Murasamemaru = {main="Murasamemaru"}
  227.     sets.engaged.Soboro = {main="Soboro Sukehiro"}
  228.     sets.engaged.Polearm = {main="Nativus Halberd"}
  229.     sets.engaged.Quint = {main="Quint spear"}
  230.     sets.engaged.Bow = {range="Hangaku-no-Yumi"}
  231. end
  232.  
  233. ------------------------------------------------------------------
  234. -- Action events
  235. ------------------------------------------------------------------
  236.  
  237. -- Run after the default midcast() is done.
  238. -- eventArgs is the same one used in job_midcast, in case information needs to be persisted.
  239. function job_post_midcast(spell, action, spellMap, eventArgs)
  240.     if spell.english == 'Lunge' or spell.english == 'Swipe' then
  241.         local obi = get_obi(get_rune_obi_element())
  242.         if obi then
  243.             equip({waist=obi})
  244.         end
  245.     end
  246. end
  247.  
  248.  
  249. function job_aftercast(spell)
  250.     if not spell.interrupted then
  251.         if spell.type == 'Rune' then
  252.             update_timers(spell)
  253.         elseif spell.name == "Lunge" or spell.name == "Gambit" or spell.name == 'Rayke' then
  254.             reset_timers()
  255.         elseif spell.name == "Swipe" then
  256.             send_command(trim(1))
  257.         end
  258.     end
  259. end
  260.  
  261.  
  262. -------------------------------------------------------------------------------------------------------------------
  263. -- Customization hooks for idle and melee sets, after they've been automatically constructed.
  264. -------------------------------------------------------------------------------------------------------------------
  265.  
  266. -------------------------------------------------------------------------------------------------------------------
  267. -- General hooks for other events.
  268. -------------------------------------------------------------------------------------------------------------------
  269. function job_precast(spell)
  270.     if info.RuneEnchantment:contains(spell.english) then
  271.         equip(sets.enmity)
  272.     end
  273. end
  274. -------------------------------------------------------------------------------------------------------------------
  275. -- User code that supplements self-commands.
  276. -------------------------------------------------------------------------------------------------------------------
  277.  
  278. -------------------------------------------------------------------------------------------------------------------
  279. -- Utility functions specific to this job.
  280. -------------------------------------------------------------------------------------------------------------------
  281.  
  282. -- Select default macro book on initial load or subjob change.
  283. function select_default_macro_book()
  284.     -- Default macro set/book
  285.     if player.sub_job == 'WAR' then
  286.         set_macro_page(1, 3)
  287.     elseif player.sub_job == 'NIN' then
  288.         set_macro_page(2, 3)
  289.     elseif player.sub_job == 'RUN' then
  290.         set_macro_page(3, 3)
  291.     else
  292.         set_macro_page(1, 3)
  293.     end
  294. end
  295.  
  296. function get_rune_obi_element()
  297.     weather_rune = buffactive[elements.rune_of[world.weather_element] or '']
  298.     day_rune = buffactive[elements.rune_of[world.day_element] or '']
  299.    
  300.     local found_rune_element
  301.    
  302.     if weather_rune and day_rune then
  303.         if weather_rune > day_rune then
  304.             found_rune_element = world.weather_element
  305.         else
  306.             found_rune_element = world.day_element
  307.         end
  308.     elseif weather_rune then
  309.         found_rune_element = world.weather_element
  310.     elseif day_rune then
  311.         found_rune_element = world.day_element
  312.     end
  313.    
  314.     return found_rune_element
  315. end
  316.  
  317. function get_obi(element)
  318.     if element and elements.obi_of[element] then
  319.         return (player.inventory[elements.obi_of[element]] or player.wardrobe[elements.obi_of[element]]) and elements.obi_of[element]
  320.     end
  321. end
  322.  
  323.  
  324. ------------------------------------------------------------------
  325. -- Timer manipulation
  326. ------------------------------------------------------------------
  327.  
  328. -- Add a new run to the custom timers, and update index values for existing timers.
  329. function update_timers(spell)
  330.     local expires_time = os.time() + 300
  331.     local entry_index = rune_count(spell.name) + 1
  332.  
  333.     local entry = {rune=spell.name, index=entry_index, expires=expires_time}
  334.  
  335.     rune_timers:append(entry)
  336.     local cmd_queue = create_timer(entry).. ';wait 0.05;'
  337.    
  338.     cmd_queue = cmd_queue .. trim()
  339.  
  340.     -- add_to_chat(123,'cmd_queue='..cmd_queue)
  341.  
  342.     send_command(cmd_queue)
  343. end
  344.  
  345. -- Get the command string to create a custom timer for the provided entry.
  346. function create_timer(entry)
  347.     local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
  348.     local duration = entry.expires - os.time()
  349.     return 'timers c ' .. timer_name .. ' ' .. tostring(duration) .. ' down'
  350. end
  351.  
  352. -- Get the command string to delete a custom timer for the provided entry.
  353. function delete_timer(entry)
  354.     local timer_name = '"Rune: ' .. entry.rune .. '-' .. tostring(entry.index) .. '"'
  355.     return 'timers d ' .. timer_name .. ''
  356. end
  357.  
  358. -- Reset all timers
  359. function reset_timers()
  360.     local cmd_queue = ''
  361.     for index,entry in pairs(rune_timers) do
  362.         cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
  363.     end
  364.     rune_timers:clear()
  365.     send_command(cmd_queue)
  366. end
  367.  
  368. -- Get a count of the number of runes of a given type
  369. function rune_count(rune)
  370.     local count = 0
  371.     local current_time = os.time()
  372.     for _,entry in pairs(rune_timers) do
  373.         if entry.rune == rune and entry.expires > current_time then
  374.             count = count + 1
  375.         end
  376.     end
  377.     return count
  378. end
  379.  
  380. -- Remove the oldest rune(s) from the table, until we're below the max_runes limit.
  381. -- If given a value n, remove n runes from the table.
  382. function trim(n)
  383.     local cmd_queue = ''
  384.  
  385.     local to_remove = n or (rune_timers:length() - max_runes)
  386.  
  387.     while to_remove > 0 and rune_timers:length() > 0 do
  388.         local oldest
  389.         for index,entry in pairs(rune_timers) do
  390.             if oldest == nil or entry.expires < rune_timers[oldest].expires then
  391.                 oldest = index
  392.             end
  393.         end
  394.        
  395.         cmd_queue = cmd_queue .. prune(rune_timers[oldest].rune)
  396.         to_remove = to_remove - 1
  397.     end
  398.    
  399.     return cmd_queue
  400. end
  401.  
  402. -- Drop the index of all runes of a given type.
  403. -- If the index drops to 0, it is removed from the table.
  404. function prune(rune)
  405.     local cmd_queue = ''
  406.    
  407.     for index,entry in pairs(rune_timers) do
  408.         if entry.rune == rune then
  409.             cmd_queue = cmd_queue .. delete_timer(entry) .. ';wait 0.05;'
  410.             entry.index = entry.index - 1
  411.         end
  412.     end
  413.  
  414.     for index,entry in pairs(rune_timers) do
  415.         if entry.rune == rune then
  416.             if entry.index == 0 then
  417.                 rune_timers[index] = nil
  418.             else
  419.                 cmd_queue = cmd_queue .. create_timer(entry) .. ';wait 0.05;'
  420.             end
  421.         end
  422.     end
  423.    
  424.     return cmd_queue
  425. end
  426.  
  427.  
  428. ------------------------------------------------------------------
  429. -- Reset events
  430. ------------------------------------------------------------------
  431.  
  432. windower.raw_register_event('zone change',reset_timers)
  433. windower.raw_register_event('logout',reset_timers)
  434. windower.raw_register_event('status change',function(new, old)
  435.     if gearswap.res.statuses[new].english == 'Dead' then
  436.         reset_timers()
  437.     end
  438. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement