Advertisement
Guest User

Untitled

a guest
Apr 13th, 2014
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 23.89 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Initialization function that defines sets and variables to be used.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. -- IMPORTANT: Make sure to also get the Mote-Include.lua file (and its supplementary files) to go with this.
  6.  
  7. --[[
  8.     Custom commands:
  9.    
  10.     Daurdabla has a set of modes: None, Dummy, Daurdabla
  11.    
  12.     You can set these via the standard 'set' and 'cycle' self-commands.  EG:
  13.     gs c cycle daurdabla
  14.     gs c set daurdabla Dummy
  15.    
  16.     The Dummy state will equip the Daurdabla and ensure non-duration gear is equipped.
  17.     The Daurdabla state will simply equip the Daurdabla on top of standard gear.
  18.    
  19.     Use the Dummy version to put up dummy songs that can be overwritten by full-potency songs.
  20.    
  21.     Use the Daurdabla version to simply put up additional songs without worrying about dummy songs.
  22.    
  23.     /console gs c set daurdabla Daurdabla
  24.    
  25.     Simple macro to cast a dummy Daurdabla song:
  26.     /console gs c set daurdabla Dummy
  27.     /ma "Shining Fantasia" <me>
  28.    
  29.    
  30.     There is also an auto-handling of Daurdabla songs, via the state.AutoDaurdabla flag:
  31.    
  32.     If state.DaurdablaMode is None, and if currently tracked songs (via timers) is less
  33.     than the max we could sing while using the Daurdabla, and if the song is cast on
  34.     self (rather than Pianissimo on another player), then it will equip the Daurdabla on
  35.     top of standard duration gear.
  36.  
  37. --]]
  38.  
  39. -- Initialization function for this job file.
  40. function get_sets()
  41.     -- Load and initialize the include file.
  42.     include('Mote-Include.lua')
  43. end
  44.  
  45.  
  46. -- Setup vars that are user-independent.
  47. function job_setup()
  48.     state.Buff['Pianissimo'] = buffactive['pianissimo'] or false
  49.  
  50.     options.DaurdablaModes = {'None','Dummy','Daurdabla'}
  51.     state.DaurdablaMode = 'None'
  52.  
  53.     -- For tracking current recast timers via the Timers plugin.
  54.     timer_reg = {}
  55. end
  56.  
  57.  
  58. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  59. function user_setup()
  60.     -- Options: Override default values
  61.     options.CastingModes = {'Normal', 'Resistant'}
  62.     options.OffenseModes = {'None', 'Normal'}
  63.     options.DefenseModes = {'Normal'}
  64.     options.WeaponskillModes = {'Normal'}
  65.     options.IdleModes = {'Normal', 'PDT'}
  66.     options.RestingModes = {'Normal'}
  67.     options.PhysicalDefenseModes = {'PDT'}
  68.     options.MagicalDefenseModes = {'MDT'}
  69.  
  70.     state.Defense.PhysicalMode = 'PDT'
  71.     state.OffenseMode = 'None'
  72.  
  73.     brd_daggers = S{'Izhiikoh', 'Vanir Knife', 'Atoyac', 'Aphotic Kukri'}
  74.     pick_tp_weapon()
  75.    
  76.     -- How many extra songs we can keep from Daurdabla
  77.     info.DaurdablaSongs = 2
  78.     -- Whether to try to automatically use Daurdabla when an appropriate gap in current vs potential
  79.     -- songs appears, and you haven't specifically changed state.DaurdablaMode.
  80.     state.AutoDaurdabla = false
  81.    
  82.     -- Additional local binds
  83.     send_command('bind ^` input /ma "Chocobo Mazurka" <me>')
  84. end
  85.  
  86.  
  87. -- Called when this job file is unloaded (eg: job change)
  88. function file_unload()
  89.     if binds_on_unload then
  90.         binds_on_unload()
  91.     end
  92.  
  93.     send_command('unbind ^`')
  94. end
  95.  
  96.  
  97. -- Define sets and vars used by this job file.
  98. function init_gear_sets()
  99.     --------------------------------------
  100.     -- Start defining the sets
  101.     --------------------------------------
  102.     add_to_chat(123,"Heretic's testtting Gearswap sidecar loaded") 
  103.     -- Precast Sets
  104.  
  105.     -- Fast cast sets for spells
  106.     sets.precast.FC = {head="Nahtirah Hat",ear2="Loquac. Earring",
  107.         hands="Gendewitha Gages",ring1="Prolix Ring",
  108.         back="Swith Cape",waist="Witful Belt",legs="Orvail Pants +1",feet="Chelona Boots +1"}
  109.  
  110.     sets.precast.FC.Cure = set_combine(sets.precast.FC, {body="Heka's Kalasiris"})
  111.  
  112.     sets.precast.FC.EnhancingMagic = set_combine(sets.precast.FC, {waist="Siegel Sash"})
  113.  
  114.     sets.precast.FC.BardSong = {main="Felibre's Dague",ammo="Eluder's Sachet",
  115.         head="Aoidos' Calot +2",neck="Aoidos' Matinee",ear1="Aoidos' Earring",ear2="Loquac. Earring",
  116.         body="Sha'ir Manteel",hands="Gendewitha Gages",ring1="Prolix Ring",
  117.         back="Swith Cape",waist="Witful Belt",legs="Gendewitha Spats",feet="Bokwus Boots"}
  118.  
  119.     sets.precast.FC.Daurdabla = set_combine(sets.precast.FC.BardSong, {range="Daurdabla"})
  120.        
  121.    
  122.     -- Precast sets to enhance JAs
  123.    
  124.     sets.precast.JA.Nightingale = {feet="Bard's Slippers +2"}
  125.     sets.precast.JA.Troubadour = {body="Bard's Justaucorps +2"}
  126.     sets.precast.JA['Soul Voice'] = {legs="Bard's Cannions +2"}
  127.  
  128.     -- Waltz set (chr and vit)
  129.     sets.precast.Waltz = {range="Gjallarhorn",
  130.         head="Nahtirah Hat",
  131.         body="Gendewitha Bliaut",hands="Buremte Gloves",
  132.         back="Refraction Cape",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  133.    
  134.        
  135.     -- Weaponskill sets
  136.     -- Default set for any weaponskill that isn't any more specifically defined
  137.     sets.precast.WS = {range="Gjallarhorn",
  138.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  139.         body="Bard's Justaucorps +2",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  140.         back="Atheling Mantle",waist="Caudata Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  141.    
  142.     -- Specific weaponskill sets.  Uses the base set if an appropriate WSMod version isn't found.
  143.     sets.precast.WS['Evisceration'] = {
  144.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  145.         body="Bard's Justaucorps +2",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  146.         back="Atheling Mantle",waist="Caudata Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  147.  
  148.     sets.precast.WS['Exenterator'] = {
  149.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  150.         body="Bard's Justaucorps +2",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  151.         back="Atheling Mantle",waist="Caudata Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  152.  
  153.     sets.precast.WS['Mordant Rime'] = {range="Gjallarhorn",
  154.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  155.         body="Bard's Justaucorps +2",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  156.         back="Atheling Mantle",waist="Caudata Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  157.    
  158.    
  159.     -- Midcast Sets
  160.  
  161.     -- General set for recast times.
  162.     sets.midcast.FastRecast = {range="Angel Lyre",
  163.         head="Nahtirah Hat",ear2="Loquacious Earring",
  164.         body="Vanir Cotehardie",hands="Gendewitha Gages",ring1="Prolix Ring",
  165.         back="Swith Cape",waist="Goading Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  166.        
  167.     -- Gear to enhance certain classes of songs.  No instruments added here since Gjallarhorn is being used.
  168.     sets.midcast.Ballad = {legs="Aoidos' Rhing. +2"}
  169.     sets.midcast.Lullaby = {hands="Brioso Cuffs"}
  170.     sets.midcast.Madrigal = {head="Aoidos' Calot +2"}
  171.     sets.midcast.March = {hands="Aoidos' Manchettes +2"}
  172.     sets.midcast.Minuet = {body="Aoidos' Hongreline +2"}
  173.     sets.midcast.Minne = {}
  174.     sets.midcast.Carol = {head="Aoidos' Calot +2",
  175.         body="Aoidos' Hongreline +2",hands="Aoidos' Manchettes +2",
  176.         legs="Aoidos' Rhing. +2",feet="Aoidos' Cothrn. +2"}
  177.     sets.midcast["Sentinel's Scherzo"] = {feet="Aoidos' Cothrn. +2"}
  178.     sets.midcast['Magic Finale'] = {neck="Wind Torque",waist="Corvax Sash",legs="Aoidos' Rhing. +2"}
  179.  
  180.     sets.midcast.Mazurka = {range="Daurdabla"}
  181.    
  182.  
  183.     -- For song buffs (duration and AF3 set bonus)
  184.     sets.midcast.SongEffect = {main="Legato Dagger",range="Gjallarhorn",
  185.         head="Aoidos' Calot +2",neck="Aoidos' Matinee",ear2="Loquacious Earring",
  186.         body="Aoidos' Hongreline +2",hands="Aoidos' Manchettes +2",ring1="Prolix Ring",
  187.         back="Harmony Cape",waist="Corvax Sash",legs="Marduk's Shalwar +1",feet="Brioso Slippers"}
  188.  
  189.     -- For song defbuffs (duration primary, accuracy secondary)
  190.     sets.midcast.SongDebuff = {main="Legato Dagger",range="Gjallarhorn",
  191.         head="Nahtirah Hat",neck="Aoidos' Matinee",ear1="Psystorm Earring",ear2="Lifestorm Earring",
  192.         body="Aoidos' Hongreline +2",hands="Aoidos' Manchettes +2",ring1="Prolix Ring",ring2="Sangoma Ring",
  193.         back="Refraction Cape",waist="Goading Belt",legs="Marduk's Shalwar +1",feet="Brioso Slippers"}
  194.  
  195.     -- For song defbuffs (accuracy primary, duration secondary)
  196.     sets.midcast.ResistantSongDebuff = {main="Izhiikoh",range="Gjallarhorn",
  197.         head="Nahtirah Hat",neck="Wind Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
  198.         body="Brioso Justaucorps",hands="Aoidos' Manchettes +2",ring1="Prolix Ring",ring2="Sangoma Ring",
  199.         back="Refraction Cape",waist="Goading Belt",legs="Aoidos' Rhing. +2",feet="Bokwus Boots"}
  200.  
  201.     -- Song-specific recast reduction
  202.     sets.midcast.SongRecast = {ear2="Loquacious Earring",
  203.         ring1="Prolix Ring",
  204.         back="Harmony Cape",waist="Corvax Sash",legs="Aoidos' Rhing. +2"}
  205.  
  206.     --sets.midcast.Daurdabla = set_combine(sets.midcast.FastRecast, sets.midcast.SongRecast, {range="Daurdabla"})
  207.  
  208.     -- Cast spell with normal gear, except using Daurdabla instead
  209.     sets.midcast.Daurdabla = {range="Daurdabla"}
  210.  
  211.     -- Dummy song with Daurdabla; minimize duration to make it easy to overwrite.
  212.     sets.midcast.DaurdablaDummy = {main="Izhiikoh",range="Daurdabla",
  213.         head="Nahtirah Hat",neck="Wind Torque",ear1="Psystorm Earring",ear2="Lifestorm Earring",
  214.         body="Brioso Justaucorps",hands="Aoidos' Manchettes +2",ring1="Prolix Ring",ring2="Sangoma Ring",
  215.         back="Swith Cape",waist="Goading Belt",legs="Gendewitha Spats",feet="Bokwus Boots"}
  216.  
  217.     -- Other general spells and classes.
  218.     sets.midcast.Cure = {main="Arka IV",sub='Achaq Grip',
  219.         head="Gendewitha Caubeen",
  220.         body="Gendewitha Bliaut",hands="Bokwus Gloves",ring1="Ephedra Ring",ring2="Sirona's Ring",
  221.         legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  222.        
  223.     sets.midcast.Stoneskin = {
  224.         head="Nahtirah Hat",
  225.         body="Gendewitha Bliaut",hands="Gendewitha Gages",
  226.         legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  227.        
  228.     sets.midcast.Cursna = {
  229.         neck="Malison Medallion",
  230.         hands="Hieros Mittens",ring1="Ephedra Ring"}
  231.  
  232.    
  233.     -- Sets to return to when not performing an action.
  234.    
  235.     -- Resting sets
  236.     sets.resting = {main=gear.Staff.HMP,
  237.         body="Gendewitha Bliaut",
  238.         legs="Nares Trews",feet="Chelona Boots +1"}
  239.    
  240.    
  241.     -- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)
  242.     sets.idle = {main=gear.Staff.PDT, sub="Quire Grip",range="Oneiros Harp",
  243.         head="Gendewitha Caubeen",neck="Wiglen Gorget",ear1="Bloodgem Earring",ear2="Loquacious Earring",
  244.         body="Gendewitha Bliaut",hands="Gendewitha Gages",ring1="Paguroidea Ring",ring2="Sangoma Ring",
  245.         back="Umbra Cape",waist="Flume Belt",legs="Nares Trews",feet="Aoidos' Cothurnes +2"}
  246.  
  247.     sets.idle.Town = {main=gear.Staff.PDT, sub="Quire Grip",range="Oneiros Harp",
  248.         head="Gendewitha Caubeen",neck="Wiglen Gorget",ear1="Bloodgem Earring",ear2="Loquacious Earring",
  249.         body="Gendewitha Bliaut",hands="Gendewitha Gages",ring1="Paguroidea Ring",ring2="Sangoma Ring",
  250.         back="Umbra Cape",waist="Flume Belt",legs="Nares Trews",feet="Aoidos' Cothurnes +2"}
  251.    
  252.     sets.idle.Weak = {main=gear.Staff.PDT,sub="Quire Grip",range="Oneiros Harp",
  253.         head="Gendewitha Caubeen",neck="Twilight Torque",ear1="Bloodgem Earring",
  254.         body="Gendewitha Bliaut",hands="Gendewitha Gages",ring1="Dark Ring",ring2="Sangoma Ring",
  255.         back="Umbra Cape",waist="Flume Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  256.    
  257.    
  258.     -- Defense sets
  259.  
  260.     sets.defense.PDT = {main=gear.Staff.PDT,sub="Quire Grip",
  261.         head="Gendewitha Caubeen",neck="Twilight Torque",
  262.         body="Gendewitha Bliaut",hands="Gendewitha Gages",ring1='Dark Ring',
  263.         back="Umbra Cape",waist="Flume Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  264.  
  265.     sets.defense.MDT = {main=gear.Staff.PDT,sub="Quire Grip",
  266.         head="Nahtirah Hat",neck="Twilight Torque",
  267.         body="Gendewitha Bliaut",hands="Gendewitha Gages",ring1='Dark Ring',ring2="Shadow Ring",
  268.         back="Engulfer Cape",waist="Flume Belt",legs="Bokwus Slops",feet="Gendewitha Galoshes"}
  269.  
  270.     sets.Kiting = {feet="Aoidos' Cothurnes +2"}
  271.  
  272.     -- Engaged sets
  273.  
  274.     -- Variations for TP weapon and (optional) offense/defense modes.  Code will fall back on previous
  275.     -- sets if more refined versions aren't defined.
  276.     -- If you create a set with both offense and defense modes, the offense mode should be first.
  277.     -- EG: sets.engaged.Dagger.Accuracy.Evasion
  278.    
  279.     -- Basic set for if no TP weapon is defined.
  280.     sets.engaged = {range="Angel Lyre",
  281.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  282.         body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  283.         back="Atheling Mantle",waist="Goading Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  284.  
  285.     -- Sets with weapons defined.
  286.     sets.engaged.Dagger = {range="Angel Lyre",
  287.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Bladeborn Earring",ear2="Steelflash Earring",
  288.         body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  289.         back="Atheling Mantle",waist="Goading Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  290.  
  291.     -- Set if dual-wielding
  292.     sets.engaged.DualWield = {range="Angel Lyre",
  293.         head="Nahtirah Hat",neck="Asperity Necklace",ear1="Dudgeon Earring",ear2="Heartseeker Earring",
  294.         body="Vanir Cotehardie",hands="Buremte Gloves",ring1="Rajas Ring",ring2="K'ayres Ring",
  295.         back="Atheling Mantle",waist="Goading Belt",legs="Gendewitha Spats",feet="Gendewitha Galoshes"}
  296. end
  297.  
  298.  
  299. -------------------------------------------------------------------------------------------------------------------
  300. -- Job- versions of event handlers, allowing overriding default handling.
  301. -------------------------------------------------------------------------------------------------------------------
  302.  
  303. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  304. -- Set eventArgs.useMidcastGear to true if we want midcast gear equipped on precast.
  305. function job_precast(spell, action, spellMap, eventArgs)
  306.     if spell.type == 'BardSong' then
  307.         -- Auto-Pianissimo
  308.         if spell.target.type == 'PLAYER' and not spell.target.charmed and not state.Buff['Pianissimo'] then
  309.             cancel_spell()
  310.             send_command('@input /ja "Pianissimo" <me>; wait 1.25; input /ma "'..spell.name..'" '..spell.target.name)
  311.             eventArgs.cancel = true
  312.             return
  313.         end
  314.     end
  315. end
  316.  
  317.  
  318. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  319. function job_midcast(spell, action, spellMap, eventArgs)
  320.     if spell.action_type == 'Magic' then
  321.         -- Default base equipment layer of fast recast.
  322.         equip(sets.midcast.FastRecast)
  323.  
  324.         if spell.type == 'BardSong' then
  325.             -- layer general gear on first, then let default handler add song-specific gear.
  326.             local generalClass = get_song_class(spell)
  327.             if generalClass and sets.midcast[generalClass] then
  328.                 equip(sets.midcast[generalClass])
  329.             end
  330.         end
  331.     end
  332. end
  333.  
  334.  
  335. function job_post_midcast(spell, action, spellMap, eventArgs)
  336.     if spell.type == 'BardSong' then
  337.         if state.DaurdablaMode == 'Daurdabla' then
  338.             equip(sets.midcast.Daurdabla)
  339.         elseif state.DaurdablaMode == 'None' and spell.target.type == 'SELF' and state.AutoDaurdabla and daur_song_gap() then
  340.             equip(sets.midcast.Daurdabla)
  341.         end
  342.  
  343.         state.DaurdablaMode = 'None'
  344.     end
  345. end
  346.  
  347.  
  348. -- Set eventArgs.handled to true if we don't want automatic gear equipping to be done.
  349. function job_aftercast(spell, action, spellMap, eventArgs)
  350.     if not spell.interrupted then
  351.         if state.Buff[spell.name] ~= nil then
  352.             state.Buff[spell.name] = true
  353.         end
  354.  
  355.         if spell.type == 'BardSong' then
  356.             if spell.target then
  357.                 if spell.target.type and spell.target.type:upper() == 'SELF' then
  358.                     adjust_Timers(spell, action, spellMap)
  359.                 end
  360.             end
  361.         end
  362.     end
  363. end
  364.  
  365. -------------------------------------------------------------------------------------------------------------------
  366. -- Hooks for other events that aren't handled by the include file.
  367. -------------------------------------------------------------------------------------------------------------------
  368.  
  369. function job_buff_change(buff, gain)
  370.     if state.Buff[buff] ~= nil then
  371.         state.Buff[buff] = gain
  372.     end
  373. end
  374.  
  375. -------------------------------------------------------------------------------------------------------------------
  376. -- Hooks for Daurdabla mode handling.
  377. -------------------------------------------------------------------------------------------------------------------
  378.  
  379. -- Request job-specific mode tables.
  380. -- Return true on the third returned value to indicate an error: that we didn't recognize the requested field.
  381. function job_get_mode_list(field)
  382.     if field == 'Daurdabla' and player.inventory.daurdabla then
  383.         return options.DaurdablaModes, state.DaurdablaMode
  384.     end
  385. end
  386.  
  387. -- Set job-specific mode values.
  388. -- Return true if we recognize and set the requested field.
  389. function job_set_mode(field, val)
  390.     if field == 'Daurdabla' then
  391.         state.DaurdablaMode = val
  392.         return true
  393.     end
  394. end
  395.  
  396. -------------------------------------------------------------------------------------------------------------------
  397. -- User code that supplements self-commands.
  398. -------------------------------------------------------------------------------------------------------------------
  399.  
  400. -- Called by the 'update' self-command.
  401. function job_update(cmdParams, eventArgs)
  402.     pick_tp_weapon()
  403. end
  404.  
  405.  
  406. -- Handle notifications of general user state change.
  407. function job_state_change(stateField, newValue)
  408.     if stateField == 'OffenseMode' then
  409.         if newValue == 'Normal' then
  410.             disable('main','sub')
  411.         else
  412.             enable('main','sub')
  413.         end
  414.     elseif stateField == 'Reset' then
  415.         if state.OffenseMode == 'None' then
  416.             enable('main','sub')
  417.         end
  418.     end
  419. end
  420.  
  421. -- Function to display the current relevant user state when doing an update.
  422. -- Return true if display was handled, and you don't want the default info shown.
  423. function display_current_job_state(eventArgs)
  424.     local defenseString = ''
  425.     if state.Defense.Active then
  426.         local defMode = state.Defense.PhysicalMode
  427.         if state.Defense.Type == 'Magical' then
  428.             defMode = state.Defense.MagicalMode
  429.         end
  430.  
  431.         defenseString = 'Defense: '..state.Defense.Type..' '..defMode..', '
  432.     end
  433.    
  434.     local meleeString = ''
  435.     if state.OffenseMode == 'Normal' then
  436.         if state.CombatForm then
  437.             meleeString = 'Melee: Dual-wield, '
  438.         else
  439.             meleeString = 'Melee: Single-wield, '
  440.         end
  441.     end
  442.  
  443.     add_to_chat(122,'Casting ['..state.CastingMode..'], '..meleeString..'Idle ['..state.IdleMode..'], '..defenseString..
  444.         'Kiting: '..on_off_names[state.Kiting])
  445.  
  446.     eventArgs.handled = true
  447. end
  448.  
  449. -------------------------------------------------------------------------------------------------------------------
  450. -- Utility functions specific to this job.
  451. -------------------------------------------------------------------------------------------------------------------
  452.  
  453. -- Determine the custom class to use for the given song.
  454. function get_song_class(spell)
  455.     if spell.targets:contains('Enemy') then
  456.         if state.CastingMode == 'Resistant' then
  457.             return 'ResistantSongDebuff'
  458.         else
  459.             return 'SongDebuff'
  460.         end
  461.     elseif state.DaurdablaMode == 'Dummy' then
  462.         return 'DaurdablaDummy'
  463.     else
  464.         return 'SongEffect'
  465.     end
  466. end
  467.  
  468.  
  469. -- Function to create custom buff-remaining timers with the Timers plugin,
  470. -- keeping only the actual valid songs rather than spamming the default
  471. -- buff remaining timers.
  472. function adjust_Timers(spell, action, spellMap)
  473.     local t = os.time()
  474.    
  475.     -- Eliminate songs that have already expired from our local list.
  476.     local tempreg = {}
  477.     for i,v in pairs(timer_reg) do
  478.         if v < t then tempreg[i] = true end
  479.     end
  480.     for i,v in pairs(tempreg) do
  481.         timer_reg[i] = nil
  482.     end
  483.    
  484.     local dur = calculate_duration(spell.name, spellMap)
  485.     if timer_reg[spell.name] then
  486.         -- Can delete timers that have less than 120 seconds remaining, since
  487.         -- the new version of the song will overwrite the old one.
  488.         -- Otherwise create a new timer counting down til we can overwrite.
  489.         if (timer_reg[spell.name] - t) <= 120 then
  490.             send_command('timers delete "'..spell.name..'"')
  491.             timer_reg[spell.name] = t + dur
  492.             send_command('timers create "'..spell.name..'" '..dur..' down')
  493.         end
  494.     else
  495.         -- Figure out how many songs we can maintain.
  496.         local maxsongs = 2
  497.         if player.equipment.range == 'Daurdabla' then
  498.             maxsongs = maxsongs + info.DaurdablaSongs
  499.         end
  500.         if buffactive['Clarion Call'] then
  501.             maxsongs = maxsongs+1
  502.         end
  503.         -- If we have more songs active than is currently apparent, we can still overwrite
  504.         -- them while they're active, even if not using appropriate gear bonuses (ie: Daur).
  505.         if maxsongs < table.length(timer_reg) then
  506.             maxsongs = table.length(timer_reg)
  507.         end
  508.        
  509.         -- Create or update new song timers.
  510.         if table.length(timer_reg) < maxsongs then
  511.             timer_reg[spell.name] = t+dur
  512.             send_command('timers create "'..spell.name..'" '..dur..' down')
  513.         else
  514.             local rep,repsong
  515.             for i,v in pairs(timer_reg) do
  516.                 if t+dur > v then
  517.                     if not rep or rep > v then
  518.                         rep = v
  519.                         repsong = i
  520.                     end
  521.                 end
  522.             end
  523.             if repsong then
  524.                 timer_reg[repsong] = nil
  525.                 send_command('timers delete "'..repsong..'"')
  526.                 timer_reg[spell.name] = t+dur
  527.                 send_command('timers create "'..spell.name..'" '..dur..' down')
  528.             end
  529.         end
  530.     end
  531. end
  532.  
  533. -- Function to calculate the duration of a song based on the equipment used to cast it.
  534. -- Called from adjust_Timers(), which is only called on aftercast().
  535. function calculate_duration(spellName, spellMap)
  536.     local mult = 1
  537.     if player.equipment.range == 'Daurdabla' then mult = mult + 0.3 end -- change to 0.25 with 90 Daur
  538.     if player.equipment.range == "Gjallarhorn" then mult = mult + 0.4 end -- change to 0.3 with 95 Gjall
  539.    
  540.     if player.equipment.main == "Carnwenhan" then mult = mult + 0.1 end -- 0.1 for 75, 0.4 for 95, 0.5 for 99/119
  541.     if player.equipment.main == "Legato Dagger" then mult = mult + 0.1 end
  542.     if player.equipment.neck == "Aoidos' Matinee" then mult = mult + 0.1 end
  543.     if player.equipment.body == "Aoidos' Hngrln. +2" then mult = mult + 0.1 end
  544.     if player.equipment.legs == "Mdk. Shalwar +1" then mult = mult + 0.1 end
  545.     if player.equipment.feet == "Brioso Slippers" then mult = mult + 0.1 end
  546.     if player.equipment.feet == "Brioso Slippers +1" then mult = mult + 0.11 end
  547.    
  548.     if spellMap == 'Paeon' and player.equipment.head == "Brioso Roundlet" then mult = mult + 0.1 end
  549.     if spellMap == 'Paeon' and player.equipment.head == "Brioso Roundlet +1" then mult = mult + 0.1 end
  550.     if spellMap == 'Madrigal' and player.equipment.head == "Aoidos' Calot +2" then mult = mult + 0.1 end
  551.     if spellMap == 'Minuet' and player.equipment.body == "Aoidos' Hngrln. +2" then mult = mult + 0.1 end
  552.     if spellMap == 'March' and player.equipment.hands == 'Ad. Mnchtte. +2' then mult = mult + 0.1 end
  553.     if spellMap == 'Ballad' and player.equipment.legs == "Aoidos' Rhing. +2" then mult = mult + 0.1 end
  554.     if spellName == "Sentinel's Scherzo" and player.equipment.feet == "Aoidos' Cothrn. +2" then mult = mult + 0.1 end
  555.    
  556.     if buffactive.Troubadour then
  557.         mult = mult*2
  558.     end
  559.     if spellName == "Sentinel's Scherzo" then
  560.         if buffactive['Soul Voice'] then
  561.             mult = mult*2
  562.         elseif buffactive['Marcato'] then
  563.             mult = mult*1.5
  564.         end
  565.     end
  566.    
  567.     -- Tweak for inaccuracies in cast vs aftercast timing
  568.     mult = mult - 0.05
  569.    
  570.     local totalDuration = mult*120
  571.  
  572.     return totalDuration
  573. end
  574.  
  575.  
  576. function daur_song_gap()
  577.     if player.inventory.daurdabla then
  578.         -- Figure out how many songs we can maintain.
  579.         local maxsongs = 2 + info.DaurdablaSongs
  580.        
  581.         local activesongs = table.length(timer_reg)
  582.        
  583.         -- If we already have at least 2 songs on, but not enough to max out
  584.         -- on possible Daur songs, flag us as Daur-ready.
  585.         if activesongs >= 2 and activesongs < maxsongs then
  586.             return true
  587.         end
  588.     end
  589.    
  590.     return false
  591. end
  592.  
  593.  
  594.  
  595. -- Examine equipment to determine what our current TP weapon is.
  596. function pick_tp_weapon()
  597.     if brd_daggers:contains(player.equipment.main) then
  598.         state.CombatWeapon = 'Dagger'
  599.        
  600.         if S{'NIN','DNC'}:contains(player.sub_job) and brd_daggers:contains(player.equipment.sub) then
  601.             state.CombatForm = "DualWield"
  602.         else
  603.             state.CombatForm = nil
  604.         end
  605.     else
  606.         state.CombatWeapon = nil
  607.         state.CombatForm = nil
  608.     end
  609. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement