Advertisement
Lygre

Cali's BRD lua

Aug 3rd, 2016
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 24.35 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Setup functions for this job.  Generally should not be modified.
  3. -------------------------------------------------------------------------------------------------------------------
  4. include('organizer-lib.lua')
  5. --[[
  6.     Custom commands:
  7.    
  8.     ExtraSongsMode may take one of three values: None, Dummy, FullLength
  9.    
  10.     You can set these via the standard 'set' and 'cycle' self-commands.  EG:
  11.     gs c cycle ExtraSongsMode
  12.     gs c set ExtraSongsMode Dummy
  13.    
  14.     The Dummy state will equip the bonus song instrument and ensure non-duration gear is equipped.
  15.     The FullLength state will simply equip the bonus song instrument on top of standard gear.
  16.    
  17.    
  18.     Simple macro to cast a dummy Daurdabla song:
  19.     /console gs c set ExtraSongsMode Dummy
  20.     /ma "Shining Fantasia" <me>
  21.    
  22.     To use a Terpander rather than Daurdabla, set the info.ExtraSongInstrument variable to
  23.     'Terpander', and info.ExtraSongs to 1.
  24. --]]
  25.  
  26. -- Initialization function for this job file.
  27. function get_sets()
  28.     mote_include_version = 2
  29.    
  30.     -- Load and initialize the include file.
  31.     include('Mote-Include.lua')
  32. end
  33.  
  34.  
  35. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  36. function job_setup()
  37.     state.ExtraSongsMode = M{['description']='Extra Songs', 'None', 'Dummy', 'FullLength'}
  38.  
  39.     state.Buff['Pianissimo'] = buffactive['pianissimo'] or false
  40.  
  41.     -- For tracking current recast timers via the Timers plugin.
  42.     custom_timers = {}
  43. end
  44.  
  45.  
  46. -------------------------------------------------------------------------------------------------------------------
  47. -- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
  48. -------------------------------------------------------------------------------------------------------------------
  49.  
  50. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  51. function user_setup()
  52.     state.OffenseMode:options('None', 'prep', 'DW', 'Normal')
  53.     state.CastingMode:options('Normal', 'Resistant')
  54.     state.IdleMode:options('Normal', 'PDT')
  55.  
  56.    
  57.     send_command('bind != input /ja "Haste Samba" <me>')
  58.    
  59.     send_command('unbind f10')
  60.     send_command('bind f9 gs c cycle OffenseMode')
  61.     send_command('bind F10 gs c cycle OffenseMode')
  62.     send_command('bind !f9 input /lockstyleset 12')
  63.     send_command('unbind ^f9')
  64.     send_command('unbind ^f10')
  65.     send_command('unbind !f10')
  66.     send_command('unbind ^f11')
  67.     send_command('unbind !f11')
  68.     send_command('bind f11 gs c cycle CastingMode')
  69.     send_command('bind f12 gs c update user')
  70.     send_command('bind !f12 gs c reset defense')
  71.  select_default_macro_book()
  72.  
  73.     gear.CasterHead = {name="Chironic Hat", augments={'Mag. Acc.+23 "Mag.Atk.Bns."+23','"Conserve MP"+4','CHR+2','Mag. Acc.+15','"Mag.Atk.Bns."+10',}}
  74.         gear.RefreshHead = {name="Chironic Hat", augments={'DEX+3','AGI+2','"Refresh"+2','Accuracy+8 Attack+8','Mag. Acc.+1 "Mag.Atk.Bns."+1',}}
  75.  
  76.     gear.CasterHands = {name="Chironic Gloves", augments={'Mag. Acc.+25 "Mag.Atk.Bns."+25','Haste+1','Mag. Acc.+13',}}
  77.    
  78.     -- Adjust this if using the Terpander (new +song instrument)
  79.     info.ExtraSongInstrument = 'Daurdabla'
  80.     -- How many extra songs we can keep from Daurdabla/Terpander
  81.     info.ExtraSongs = 2
  82.    
  83.     -- Set this to false if you don't want to use custom timers.
  84.     state.UseCustomTimers = M(true, 'Use Custom Timers')
  85.    
  86.     -- Additional local binds
  87.     send_command('bind ^` gs c cycle ExtraSongsMode')
  88.     send_command('bind !` input /ma "Chocobo Mazurka" <me>')
  89.  
  90.    
  91. end
  92.  
  93. -- Select default macro book on initial load or subjob change.
  94. function select_default_macro_book()
  95.     -- Default macro set/book
  96.     set_macro_page(1, 5)
  97. end
  98. -- Called when this job file is unloaded (eg: job change)
  99. function user_unload()
  100.     send_command('unbind ^`')
  101.     send_command('unbind !`')
  102. end
  103.  
  104.  
  105. function init_gear_sets()
  106.     --------------------------------------
  107.     -- Start defining the sets
  108.     --------------------------------------
  109.    
  110.     -- Precast Sets
  111.  
  112.     -- Fast cast sets for spells
  113.     sets.precast.FC = {main=gear.RecastStaff,head="Nahtirah Hat",ear2="Loquac. Earring",
  114.         body="Dalmatica +1", hands={ name="Gende. Gages +1", augments={'Phys. dmg. taken -1%','Song spellcasting time -5%',}},
  115.         ring1="Prolix Ring",ring2="",
  116.         back="Perimede Cape",waist="Witful Belt",legs="Gendewitha Spats +1",feet="Medium's Sabots"}
  117.  
  118.     sets.precast.FC.Cure = set_combine(sets.precast.FC, {body="Heka's Kalasiris",back="Pahtli Cape",legs="Doyen Pants",ear1="Mendi. Earring",feet="Iaso Boots"})
  119.  
  120.     sets.precast.FC.Curaga = set_combine(sets.precast.FC,{body="Heka's Kalasiris",back="Pahtli Cape",legs="Doyen Pants",ear1="Mendi. Earring",feet="Iaso Boots"})
  121.  
  122.     sets.midcast.Cure =  {main="Chatoyant Staff",sub="Achaq Grip",
  123.         head="Vanya Hood",neck="Incanter's Torque",ear2="",ear1="Novia Earring",
  124.         body="Kaykaus Bliaut",hands="Kaykaus Cuffs +1",ring1="Janniston Ring",ring2="Sirona's Ring",
  125.         back=gear.ElementalCape,waist=gear.ElementalObi,legs="Kaykaus Tights +1",feet="Vanya Clogs"}
  126.  
  127.     sets.midcast.Curaga = {main="Chatoyant Staff",sub="Achaq Grip",
  128.         head="Vanya Hood",neck="Incanter's Torque",ear2="",ear1="Novia Earring",
  129.         body="Kaykaus Bliaut",hands="Kaykaus Cuffs +1",ring1="Janniston Ring",ring2="Sirona's Ring",
  130.         back=gear.ElementalCape,waist=gear.ElementalObi,legs="Kaykaus Tights +1",feet="Vanya Clogs"}
  131.  
  132.  
  133.     gear.default.obi_waist = "Witful Belt"
  134.     gear.default.obi_back = "Phatli Cape"
  135.  
  136.     sets.precast.FC.EnhancingMagic = set_combine(sets.precast.FC, {})
  137.    
  138.     gear.default.fastcast_staff = "Felibre's Dague"
  139.  
  140.     sets.precast.FC.BardSong = {main=gear.FastcastStaff,
  141.         head="Aoidos' Calot +2",neck="Orunmila's Torque",ear1="Aoidos' Earring",ear2="Loquac. Earring",
  142.         body="Sha'ir Manteel", hands={ name="Gende. Gages +1", augments={'Phys. dmg. taken -1%','Song spellcasting time -5%',}},
  143.         ring1="Prolix Ring",ring2="",
  144.         back="Perimede Cape",waist="Witful Belt",legs="Gendewitha Spats +1",feet="Bihu Slippers"}
  145.  
  146.     sets.precast.HMarch = set_combine(sets.precast.FC.BardSong, {range="Marsyas",hands="Fili Manchettes +1"})
  147.    
  148.        
  149.    
  150.     -- Precast sets to enhance JAs
  151.    
  152.     sets.precast.JA.Nightingale = {feet="Bihu Slippers"}
  153.     sets.precast.JA.Troubadour = {body="Bihu Justaucorps"}
  154.     sets.precast.JA['Soul Voice'] = {legs="Bihu Cannions"}
  155.  
  156.     -- Waltz set (chr and vit)
  157.     sets.precast.Waltz = {}
  158.    
  159.        
  160.    
  161.     sets.fcdagger = {main="Felibre's Dague"}
  162.    
  163.     -- Midcast Sets
  164.  
  165.     -- General set for recast times.
  166.     sets.midcast.FastRecast = {}
  167.        
  168.     sets.midcast.Ballad = {legs="Fili Rhingrave +1"}
  169.     sets.midcast.HordeLullaby = {range="Daurdabla"}
  170.     sets.midcast.FoeLullaby = {main="Carnwenhan",sub="Genbu's Shield",range="Gjallarhorn",sub="Genbu's Shield",
  171.         head=gear.CasterHead,neck="Aoidos' Matinee",ear1="Darkside Earring",ear2="Musical Earring",
  172.         body="Fili Hongreline +1",hands="Brioso Cuffs +1",ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  173.         back="Kumbira Cape",waist="Luminary Sash",legs="Mdk. Shalwar +1",feet="Brioso Slippers +1"}
  174.  
  175.     sets.midcast.Paeon = {range="Daurdabla",
  176.         head="Aoidos' Calot +2",neck="Orunmila's Torque",ear1="Aoidos' Earring",ear2="Loquac. Earring",
  177.         body="Sha'ir Manteel", hands={ name="Gende. Gages +1", augments={'Phys. dmg. taken -1%','Song spellcasting time -5%',}},
  178.         ring1="Prolix Ring",ring2="",
  179.         back="Perimede Cape",waist="Witful Belt",legs="Gendewitha Spats +1",feet="Bihu Slippers"}
  180.  
  181.     sets.midcast.Madrigal = {head="Aoidos' Calot +2"}
  182.     sets.midcast.March = {hands="Fili Manchettes +1"}
  183.     sets.midcast.Scherzo= {feet="Fili Cothurnes +1"}
  184.    
  185.     sets.midcast.HMarch = {range="Marsyas",hands="Fili Manchettes +1"}
  186.     sets.midcast.Minuet = {body="Fili hongreline +1"}
  187.     sets.midcast.Minne = {}
  188.  
  189.     sets.midcast['Magic Finale'] = {main="Carnwenhan",range="Gjallarhorn",sub="Genbu's Shield",
  190.         head=gear.CasterHead,neck="Incanter's Torque",ear1="Darkside Earring",ear2="Musical Earring",
  191.         body="Brioso Just. +1",hands=gear.CasterHands,ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  192.         back="Kumbira Cape",waist="Luminary Sash",legs="Chironic Hose",feet="Medium's Sabots"}
  193.  
  194.     sets.midcast.Mazurka = {range="Daurdabla"}
  195.    
  196.  
  197.     -- For song buffs (duration and AF3 set bonus)
  198.     sets.midcast.SongEffect = {main="Carnwenhan",sub="Genbu's Shield",
  199.         head="Aoidos' Calot +2",neck="Aoidos' Matinee",ear2="Ethereal Earring",ear1="Musical Earring",
  200.         body="Fili hongreline +1",hands="Fili Manchettes +1",ring1="Prolix Ring",ring2="Dark Ring",
  201.         back="Solemnity Cape",waist="Witful Belt",legs="Marduk's Shalwar +1",feet="Brioso Slippers +1"}
  202.  
  203.     -- For song defbuffs (duration primary, accuracy secondary)
  204.     sets.midcast.SongDebuff2 = {main="Carnwenhan",sub="Genbu's Shield",range="Gjallarhorn",sub="Genbu's Shield",
  205.         head=gear.CasterHead,neck="Aoidos' Matinee",ear1="Psystorm Earring",ear2="Lifestorm Earring",
  206.         body="Fili hongreline +1",hands=gear.CasterHands,ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  207.         back="Kumbira Cape",waist="Luminary Sash",legs="Marduk's Shalwar +1",feet="Brioso Slippers +1"}
  208.  
  209.     sets.midcast.Dia = {waist="Chaac Belt"}
  210.  
  211.     -- For song defbuffs (accuracy primary, duration secondary)
  212.     sets.midcast.SongDebuff = {main="Carnwenhan",sub="Genbu's Shield",range="Gjallarhorn",sub="Genbu's Shield",
  213.         head=gear.CasterHead,neck="Incanter's Torque",ear1="Darkside Earring",ear2="Musical Earring",
  214.         body="Brioso Just. +1",hands=gear.CasterHands,ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  215.         back="Kumbira Cape",waist="Luminary Sash",legs="Chironic Hose",feet="Medium's Sabots"}
  216.  
  217.     sets.midcast.Absorb = {main="Carnwenhan",sub="Genbu's Shield",range="Gjallarhorn",sub="Genbu's Shield",
  218.         head=gear.CasterHead,neck="Incanter's Torque",ear1="Darkside Earring",ear2="Musical Earring",
  219.         body="Brioso Just. +1",hands=gear.CasterHands,ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  220.         back="Kumbira Cape",waist="Luminary Sash",legs="Chironic Hose",feet="Medium's Sabots"}
  221.  
  222.  
  223.     sets.midcast.Haste = {main="Grioavolr",range="",ammo="Impatiens",
  224.         head="Telchine Cap",neck="Orunmila's Torque",ear2="Loquacious Earring",
  225.         body="Telchine Chas.",hands="Telchine Gloves",ring1="",ring2="",
  226.         back="Swith Cape +1",waist="Witful Belt",legs="Telchine Braconi",feet="Telchine Pigaches"}
  227.  
  228.     sets.midcast['Enhancing Magic'] = {ear1="Andoaa Earring",
  229.         body="Telchine Chas.",hands="Telchine Gloves",head="Telchine Cap",neck="Incanter's Torque",
  230.         back="",waist="",legs="Telchine Braconi",feet="Telchine Pigaches"}
  231.  
  232.  
  233.     -- Song-specific recast reduction
  234.     sets.midcast.SongRecast = {}
  235.  
  236.    
  237.  
  238.     -- Other general spells and classes.
  239.    
  240.        
  241.     sets.midcast.Stoneskin = {}
  242.    
  243.        
  244.     sets.midcast.Cursna = {
  245.         neck="Malison Medallion",
  246.         hands="Hieros Mittens",ring1="Haoma's Ring",ring2="Ephedra Ring",feet="Gende. Galosh. +1"}
  247.  
  248.    
  249.     -- Sets to return to when not performing an action.
  250.    
  251.     -- Resting sets
  252.     sets.resting = {}
  253.    
  254.    
  255.     -- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)
  256.     sets.idle = {main="Sangoma",sub="Genbu's Shield",
  257.         head=gear.RefreshHead,neck="Loricate Torque +1",ear1="Ethereal Earring",ear2="Moonshade Earring",
  258.         body="Vanya Robe",hands="Shrieker's Cuffs",ring1="Dark Ring",ring2="Dark Ring",
  259.         back="Solemnity Cape",waist="Fucho-no-obi",legs="Assid. Pants +1",feet="Fili Cothurnes +1"}
  260.  
  261.     sets.idle.Town = {main="Carnwenhan",sub="Genbu's Shield",range="Marsyas",
  262.         head="Gala Corsage",neck="Loricate Torque +1",ear1="Ethereal Earring",ear2="Moonshade Earring",
  263.         body="Councilor's Garb", hands="Kaykaus Cuffs +1",
  264.         ring1="Carbuncle Ring +1",ring2="Carbuncle Ring +1",
  265.         back="Solemnity Cape",waist="Fucho-no-obi",legs="Kaykaus Tights +1",feet="Fili Cothurnes +1"}
  266.    
  267.     sets.idle.Weak = {main="Sangoma",sub="Genbu's Shield",
  268.         head=gear.RefreshHead,neck="Loricate Torque +1",ear1="Ethereal Earring",ear2="Moonshade Earring",
  269.         body="Vanya Robe",hands="Shrieker's Cuffs",ring1="Dark Ring",ring2="Dark Ring",
  270.         back="Solemnity Cape",waist="Fucho-no-obi",legs="Assid. Pants +1",feet="Fili Cothurnes +1"}
  271.    
  272.    
  273.     sets.Misc = {main="Atar I"}
  274.    
  275.     sets.Misc2 = {main="Vourukasha I"}
  276.  
  277.     sets.Misc3 = {main="Apamajas I"}
  278.  
  279.     sets.engaged.prep = {main="Carnwenhan", sub="Skinflayer"}
  280.  
  281.     sets.engaged = {main="Carnwenhan", sub="Skinflayer",
  282.         head="Telchine Cap",neck="Clotharius Torque",ear2="Bladeborn Earring",ear1="Steelflash Earring",
  283.         body="Onca Suit",ring1="Rajas Ring",ring2="Hetairoi Ring",
  284.         back="Bleating Mantle",waist="Windbuffet Belt +1"}
  285.  
  286.    
  287.     sets.engaged.DW = {
  288.         head="Telchine Cap",neck="Clotharius Torque",ear2="Dudgeon Earring",ear1="Heartseeker Earring",
  289.         body="Onca Suit",ring1="Rajas Ring",ring2="Hetairoi Ring",
  290.         back="Bleating Mantle",waist="Reiki Yotai"}
  291.  
  292.    
  293.  
  294.     sets.precast.WS = {
  295.         head="Telchine Cap",neck="Iqabi Necklace",ear2="Bladeborn Earring",ear1="Steelflash Earring",
  296.         body="Onca Suit",ring1="Rajas Ring",ring2="Ifrit Ring +1",
  297.         back="Rancorous Mantle",waist="Prosilio Belt +1"}
  298.  
  299.    
  300.    
  301. end
  302.  
  303.  
  304.  
  305. -------------------------------------------------------------------------------------------------------------------
  306. -- Job-specific hooks for standard casting events.
  307. -------------------------------------------------------------------------------------------------------------------
  308.  
  309. function job_pretarget(spell, action, spellMap, eventArgs)
  310.  
  311.     if spell.type == 'BardSong' then
  312.  
  313.                 if buffactive['Nightingale'] or buffactive['Troubadour'] then
  314.  
  315.             state.useMidcastGear:set('true')
  316.  
  317.         end
  318.  
  319.     end
  320.  
  321.     if not buffactive['Nightingale'] and not buffactive['Troubadour'] then
  322.  
  323.         state.useMidcastGear:reset()
  324.  
  325.     end
  326.  
  327. end
  328.  
  329.  
  330. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  331. -- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
  332. function job_precast(spell, action, spellMap, eventArgs)
  333.     if spell.type == 'BardSong' then
  334.         -- Auto-Pianissimo
  335.         if ((spell.target.type == 'PLAYER' and not spell.target.charmed) or (spell.target.type == 'NPC' and spell.target.in_party)) and
  336.             not state.Buff['Pianissimo'] then
  337.            
  338.             local spell_recasts = windower.ffxi.get_spell_recasts()
  339.             if spell_recasts[spell.recast_id] < 2 then
  340.                 send_command('@input /ja "Pianissimo" <me>; wait 1.5; input /ma "'..spell.name..'" '..spell.target.name)
  341.                 eventArgs.cancel = true
  342.                 return
  343.             end
  344.         end
  345.     end
  346. end
  347.  
  348. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  349. function job_midcast(spell, action, spellMap, eventArgs)
  350.     if spell.action_type == 'Magic' then
  351.         if spell.type == 'BardSong' then
  352.             -- layer general gear on first, then let default handler add song-specific gear.
  353.             local generalClass = get_song_class(spell)
  354.             if generalClass and sets.midcast[generalClass] then
  355.                 equip(sets.midcast[generalClass])
  356.             end
  357.         end
  358.     end
  359. end
  360.  
  361. function job_post_midcast(spell, action, spellMap, eventArgs)
  362.     if spell.type == 'BardSong' then
  363.         if state.ExtraSongsMode.value == 'FullLength' then
  364.             equip(sets.midcast.Daurdabla)
  365.         end
  366.  
  367.         state.ExtraSongsMode:reset()
  368.     end
  369. end
  370.  
  371. -- Set eventArgs.handled to true if we don't want automatic gear equipping to be done.
  372. function job_aftercast(spell, action, spellMap, eventArgs)
  373.          if string.find(spell.name,'March') and not spell.interrupted then
  374.        
  375.             adjust_timers(spell, spellMap)
  376.     elseif string.find(spell.name,'Madrigal') and not spell.interrupted then
  377.         adjust_timers(spell, spellMap)
  378.     elseif string.find(spell.name,'Prelude') and not spell.interrupted then
  379.         adjust_timers(spell, spellMap)
  380.     elseif string.find(spell.name,'Ballad') and not spell.interrupted then
  381.         adjust_timers(spell, spellMap)
  382.     elseif string.find(spell.name,'Scherzo') and not spell.interrupted then
  383.         adjust_timers(spell, spellMap)
  384.     elseif string.find(spell.name,'Minuet') and not spell.interrupted then
  385.         adjust_timers(spell, spellMap)
  386.     elseif string.find(spell.name,'Etude') and not spell.interrupted then
  387.         adjust_timers(spell, spellMap)
  388.     elseif string.find(spell.name,'Minne') and not spell.interrupted then
  389.         adjust_timers(spell, spellMap)
  390.         elseif spell.name == 'Haste' and not spell.interrupted then
  391.         adjust_timers(spell, spellMap)
  392.    
  393.     end
  394. end
  395.  
  396. -------------------------------------------------------------------------------------------------------------------
  397. -- Job-specific hooks for non-casting events.
  398. -------------------------------------------------------------------------------------------------------------------
  399. -- Handle notifications of general user state change.
  400. function job_state_change(stateField, newValue, oldValue)
  401.     if stateField == 'Offense Mode' then
  402.         if newValue == 'Normal' then
  403.             disable('main','sub')
  404.      elseif newValue == 'DW' then
  405.             disable('main','sub')
  406.    
  407.         elseif newValue == 'None' then
  408.             enable('main','sub')
  409.         end
  410.     end
  411. end
  412. -------------------------------------------------------------------------------------------------------------------
  413. -- User code that supplements standard library decisions.
  414. -------------------------------------------------------------------------------------------------------------------
  415.  
  416.  
  417.  
  418.  
  419.  
  420. -- Function to display the current relevant user state when doing an update.
  421. function display_current_job_state(eventArgs)
  422.     display_current_caster_state()
  423.     eventArgs.handled = true
  424. end
  425.  
  426. -------------------------------------------------------------------------------------------------------------------
  427. -- Utility functions specific to this job.
  428. -------------------------------------------------------------------------------------------------------------------
  429.  
  430. -- Determine the custom class to use for the given song.
  431. function get_song_class(spell)
  432.     -- Can't use spell.targets:contains() because this is being pulled from resources
  433.     if set.contains(spell.targets, 'Enemy') then
  434.         if state.CastingMode.value == 'Resistant' then
  435.             return 'ResistantSongDebuff'
  436.         else
  437.             return 'SongDebuff'
  438.         end
  439.     elseif state.ExtraSongsMode.value == 'Dummy' then
  440.         return 'DaurdablaDummy'
  441.     else
  442.         return 'SongEffect'
  443.     end
  444. end
  445.  
  446.  
  447. -- Function to create custom buff-remaining timers with the Timers plugin,
  448. -- keeping only the actual valid songs rather than spamming the default
  449. -- buff remaining timers.
  450. function adjust_timers(spell, spellMap)
  451.     if state.UseCustomTimers.value == false then
  452.         return
  453.     end
  454.    
  455.     local current_time = os.time()
  456.    
  457.     -- custom_timers contains a table of song names, with the os time when they
  458.     -- will expire.
  459.    
  460.     -- Eliminate songs that have already expired from our local list.
  461.     local temp_timer_list = {}
  462.     for song_name,expires in pairs(custom_timers) do
  463.         if expires < current_time then
  464.             temp_timer_list[song_name] = true
  465.         end
  466.     end
  467.     for song_name,expires in pairs(temp_timer_list) do
  468.         custom_timers[song_name] = nil
  469.     end
  470.    
  471.     local dur = calculate_duration(spell.name, spellMap)
  472.     if custom_timers[spell.name] then
  473.         -- Songs always overwrite themselves now, unless the new song has
  474.         -- less duration than the old one (ie: old one was NT version, new
  475.         -- one has less duration than what's remaining).
  476.        
  477.         -- If new song will outlast the one in our list, replace it.
  478.         if custom_timers[spell.name] < (current_time + dur) then
  479.             send_command('timers delete "'..spell.name..'"')
  480.             custom_timers[spell.name] = current_time + dur
  481.             send_command('timers create "'..spell.name..' ['..spell.target.name..']" '..dur..' down')
  482.        
  483.        
  484.         end
  485.     else
  486.         -- Figure out how many songs we can maintain.
  487.         local maxsongs = 8
  488.        
  489.         if buffactive['Clarion Call'] then
  490.             maxsongs = maxsongs + 1
  491.         end
  492.         -- If we have more songs active than is currently apparent, we can still overwrite
  493.         -- them while they're active, even if not using appropriate gear bonuses (ie: Daur).
  494.         if maxsongs < table.length(custom_timers) then
  495.             maxsongs = table.length(custom_timers)
  496.         end
  497.        
  498.         -- Create or update new song timers.
  499.         if table.length(custom_timers) < maxsongs then
  500.             custom_timers[spell.name] = current_time + dur
  501.            send_command('timers create "'..spell.name..' ['..spell.target.name..']" '..dur..' down')
  502.         else
  503.             local rep,repsong
  504.             for song_name,expires in pairs(custom_timers) do
  505.                 if current_time + dur > expires then
  506.                     if not rep or rep > expires then
  507.                         rep = expires
  508.                         repsong = song_name
  509.                     end
  510.                 end
  511.             end
  512.             if repsong then
  513.                 custom_timers[repsong] = nil
  514.                 send_command('timers delete "'..repsong..'"')
  515.                 custom_timers[spell.name] = current_time + dur
  516.                send_command('timers create "'..spell.name..' ['..spell.target.name..']" '..dur..' down')
  517.             end
  518.         end
  519.     end
  520. end
  521.  
  522. -- Function to calculate the duration of a song based on the equipment used to cast it.
  523. -- Called from adjust_timers(), which is only called on aftercast().
  524. function calculate_duration(spellName, spellMap)
  525.     local mult = 1
  526.  
  527.     if player.equipment.range == 'Marsyas' then
  528.         mult = mult + 0.5
  529.        
  530.     end
  531.  
  532.  
  533.     if player.equipment.Head == 'Telchine Cap' then mult = mult + 0.1 end
  534.     if player.equipment.Body == 'Telchine Chas.' then mult = mult + 0.1 end
  535.     if player.equipment.Hands == 'Telchine Gloves' then mult = mult + 0.1 end
  536.     if player.equipment.Legs == 'Telchine Braconi' then mult = mult + 0.1 end
  537.     if player.equipment.Feet == 'Telchine Pigaches' then mult = mult + 0.1 end
  538.     if player.equipment.main == "Grioavolr" then mult = mult + 0.9 end --
  539.  
  540.     if player.equipment.range == 'Daurdabla' then mult = mult + 0.3 end -- change to 0.25 with 90 Daur
  541.    
  542.     if player.equipment.range == "Gjallarhorn" then mult = mult + 0.4 end -- change to 0.3 with 95 Gjall
  543.    
  544.     if player.equipment.main == "Carnwenhan" then mult = mult + 0.58 end -- 0.1 for 75, 0.4 for 95, 0.5 for 99/119
  545.     if player.equipment.main == "Legato Dagger" then mult = mult + 0.05 end
  546.     if player.equipment.sub == "Legato Dagger" then mult = mult + 0.05 end
  547.     if player.equipment.neck == "Aoidos' Matinee" then mult = mult + 0.1 end
  548.     if player.equipment.body == "Fili Hongreline +1" then mult = mult + 0.12 end
  549.     if player.equipment.legs == "Mdk. Shalwar +1" then mult = mult + 0.1 end
  550.     if player.equipment.feet == "Brioso Slippers" then mult = mult + 0.1 end
  551.     if player.equipment.feet == "Brioso Slippers +1" then mult = mult + 0.11 end
  552.    
  553.     if spellMap == 'Paeon' and player.equipment.head == "Brioso Roundlet" then mult = mult + 0.1 end
  554.     if spellMap == 'Paeon' and player.equipment.head == "Brioso Roundlet +1" then mult = mult + 0.1 end
  555.     if spellMap == 'Madrigal' and player.equipment.head == "Aoidos' Calot +2" then mult = mult + 0.1 end
  556.     if spellMap == 'Minuet' and player.equipment.body == "Fili Hongreline +1" then mult = mult + 0.1 end
  557.     if spellMap == 'March' and player.equipment.hands == 'Fili Manchettes +1' then mult = mult + 0.1 end
  558.     if spellMap == 'HMarch' and player.equipment.hands == 'Fili Manchettes +1' then mult = mult + 0.1 end
  559.     if spellMap == 'Ballad' and player.equipment.legs == "Fili Rhingrave +1" then mult = mult + 0.1 end
  560.     if spellName == "Sentinel's Scherzo" and player.equipment.feet == "Fili Cothurnes +1" then mult = mult + 0.1 end
  561.  
  562.    
  563.    
  564.     if buffactive.Troubadour then
  565.         mult = mult*2
  566.     end
  567.     if spellName == "Sentinel's Scherzo" then
  568.         if buffactive['Soul Voice'] then
  569.             mult = mult*2
  570.         elseif buffactive['Marcato'] then
  571.             mult = mult*1.5
  572.         end
  573.     end
  574.  
  575.  
  576.  
  577.    
  578.    
  579.  
  580.  
  581.  
  582.     local totalDuration = math.floor(mult*120)
  583.  
  584.     return totalDuration
  585.    
  586.    
  587.    
  588.    
  589. end
  590.  
  591.  
  592.  
  593.  
  594. -- Function to reset timers.
  595. function reset_timers()
  596.     for i,v in pairs(custom_timers) do
  597.         send_command('timers delete "'..i..'"')
  598.     end
  599.     custom_timers = {}
  600. end
  601.  
  602.  
  603.  
  604.  
  605. windower.register_event('zone change',reset_timers)
  606. windower.register_event('logout',reset_timers)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement