Guest User

brd.lua

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