JSHidaka

BRD Lua 1.0

Jan 4th, 2014
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.27 KB | None | 0 0
  1. -- Simple BRD LUA for Daurdabla and Gjallarhorn
  2. -- Auto Pianissimo
  3. -- Gearswaps Precast(w/ occ. quick cast gear), Midcast (Empy set / +Duration Set)
  4. -- Pending: PDT/MDT set, Healing Set
  5. -- For Daurdabla use a macro /console gs c Daurdabla, it will equip Daurdabla, and lock the instrument for the next song,
  6.  
  7.  
  8. function get_sets()
  9.     timer_reg = {}
  10.     debuff = S{"Carnage Elegy", "Battlefield Elegy", "Foe Requiem IV", "Foe Requiem V", "Foe Requiem VI", "Foe Requiem VII", "Horde Lullaby", "Horde Lullaby II",
  11.     "Magic Finale", "Foe Lullaby II", "Foe Lullaby", "Dark Threnody", "Light Threnody", "Water Threnody", "Ltng. Threnody",
  12.     "Earth Threnody", "Wind Threnody", "Fire Threnody", "Ice Threnody", "Pining Nocture", "Magic Finale", "Maiden's Virelai"}
  13.     dummy = S{"Army's Paeon", "Army's Paeon II", "Army's Paeon III", "Army's Paeon V", "Army's Paeon VI", "Army's Paeon IV"}
  14.    
  15.     autopianext = 0
  16.    
  17.     sets.DBuff = {range="Daurdabla"}
  18.     sets.precast = {}
  19.     sets.precast.JA = {}
  20.     sets.precast.JA.Nightingale = {feet="Bihu Slippers"}
  21.     sets.precast.JA.Troubadour = {body="Bard's Justaucorps +2"}
  22.     sets.precast.JA['Soul Voice'] = {legs="Bihu Cannions"} 
  23.    
  24.     -- Precast Sets
  25.     sets.precast.FC = {}
  26.    
  27.     sets.precast.FC.Song = {
  28.         head="Aoidos' Calot +2",
  29.         body="Marduk's Jubbah +1",
  30.         hands="Gendewitha Gages",
  31.         legs="Gendewitha Spats",
  32.         feet="Bihu Slippers",
  33.         neck="Aoidos' Matinee",
  34.         waist="Witful Belt",
  35.         left_ear="Aoidos' Earring",
  36.         right_ear="Loquac. Earring",
  37.         left_ring="Prolix Ring",
  38.         right_ring="Veneficium Ring",
  39.         back="Ogapepo Cape",
  40.         range=empty,
  41.         ammo="Impatiens",
  42.         main="Felibre's Dague",
  43.         sub=empty,
  44. }
  45.     sets.Dummy = {
  46.         head="Aoidos' Calot +2",
  47.         body="Marduk's Jubbah +1",
  48.         hands="Gendewitha Gages",
  49.         legs="Gendewitha Spats",
  50.         feet="Bihu Slippers",
  51.         neck="Twilight Torque",
  52.         waist="Witful Belt",
  53.         left_ear="Aoidos' Earring",
  54.         right_ear="Loquac. Earring",
  55.         left_ring="Prolix Ring",
  56.         right_ring="Veneficium Ring",
  57.         back="Ogapepo Cape",
  58.         range=empty,
  59.         ammo="Impatiens",
  60.         main="Felibre's Dague",
  61.         sub=empty,
  62. }
  63.  
  64.                
  65.     sets.precast.FC.Thunder = {main='Apamajas I'}
  66.     sets.precast.FC.Fire = {main='Atar I'} 
  67.    
  68.     -- Midcast Sets
  69.     sets.midcast = {}
  70.        
  71.     sets.midcast.BuffSet = {
  72.         ammo=empty,
  73.         head="Aoidos' Calot +2",
  74.         body="Aoidos' Hngrln. +2",
  75.         hands="Ad. Mnchtte. +2",
  76.         legs="Aoidos' Rhing. +2",
  77.         feet="Aoidos' Cothrn. +2",
  78.         neck="Aoidos' Matinee",
  79.         waist="Witful Belt",
  80.         range="Gjallarhorn",
  81.         left_ear="Aoidos' Earring",
  82.         right_ear="Loquac. Earring",
  83.         left_ring="Prolix Ring",
  84.         right_ring="Balrahn's Ring",
  85.         back="Swith Cape",
  86.         main="Legato Dagger",
  87.         sub="Genbu's Shield",
  88. }
  89.     sets.midcast.Sentinel = {
  90.         feet="Aoidos' Cothrn. +2",
  91. }
  92.     sets.midcast.Ballad = {
  93.         legs="Aoidos' Rhing. +2",
  94. }
  95. sets.midcast.BuffDuration = {
  96.     ammo=empty,
  97.     range="Gjallarhorn",
  98.     main="Legato Dagger",
  99.     sub="Genbu's Shield",
  100.     head="Aoidos' Calot +2",
  101.     body="Aoidos' Hngrln. +2",
  102.     hands="Ad. Mnchtte. +2",
  103.     legs="Mdk. Shalwar +1",
  104.     feet="Brioso Slippers +1",
  105.     neck="Aoidos' Matinee",
  106.     waist="Witful Belt",
  107.     left_ear="Aoidos' Earring",
  108.     right_ear="Loquac. Earring",
  109.     left_ring="Prolix Ring",
  110.     right_ring="Balrahn's Ring",
  111.     back="Swith Cape",
  112. }
  113.     sets.midcast.Debuff = {
  114.         ammo=empty,
  115.         main="Lehbrailg +2",
  116.         range="Gjallarhorn",
  117.         head="Brioso Roundlet +1",
  118.         body="Brioso Just. +1",
  119.         hands="Ad. Mnchtte. +2",
  120.         legs="Brioso Cann. +1",
  121.         feet="Brioso Slippers +1",
  122.         neck="Aoidos' Matinee",
  123.         waist="Witful Belt",
  124.         left_ear="Psystorm Earring",
  125.         right_ear="Lifestorm Earring",
  126.         left_ring="Prolix Ring",
  127.         right_ring="Balrahn's Ring",
  128.         back="Rhapsode's Cape",
  129. }
  130.     sets.midcast.cure = {
  131.     main="Arka IV",
  132.     sub=empty,
  133.     ammo="Impatiens",
  134.     head="Aoidos' Calot +2",
  135.     body="Heka's Kalasiris",
  136.     hands="Serpentes Cuffs",
  137.     legs="Nares Trews",
  138.     feet="Serpentes Sabots",
  139.     neck="Twilight Torque",
  140.     waist="Witful Belt",
  141.     left_ear="Aoidos' Earring",
  142.     right_ear="Loquac. Earring",
  143.     left_ring="Veneficium Ring",
  144.     right_ring="Prolix Ring",
  145.     back="Ogapepo Cape",
  146. }
  147.  
  148. sets.midcast.Buff = sets.midcast.BuffSet
  149.     --Aftercast Sets
  150. sets.aftercast={
  151.     main="Legato Dagger",
  152.     sub="Genbu's Shield",
  153.     range="Daurdabla",
  154.     head="Nefer Khat",
  155.     body="Heka's Kalasiris",
  156.     hands="Serpentes Cuffs",
  157.     legs="Nares Trews",
  158.     feet="Serpentes Sabots",
  159.     neck="Twilight Torque",
  160.     waist="Witful Belt",
  161.     left_ear="Aoidos' Earring",
  162.     right_ear="Loquac. Earring",
  163.     left_ring="Dark Ring",
  164.     right_ring="Defending Ring",
  165.     back="Umbra Cape",
  166. }
  167.  
  168. sets.ac={
  169.     range="Daurdabla",
  170.     neck="Twilight Torque",
  171.     left_ring="Dark Ring",
  172.     right_ring="Defending Ring",
  173.     back="Umbra Cape",
  174.     feet="Aoidos' Cothrn. +2",
  175.     head="Aoidos' Calot +2",
  176.     body="Aoidos' Hngrln. +2",
  177.     hands="Ad. Mnchtte. +2",
  178.     legs="Aoidos' Rhing. +2",
  179. }
  180.  
  181. end
  182.  
  183. function pretarget(spell)
  184.         if spell.type == 'BardSong' and not debuff:contains(spell.name) then
  185.             if player.target.type == "MONSTER" then
  186.                 change_target('<me>')
  187.                 return
  188.             end
  189.            
  190.             if player.target.type == "NPC" then
  191.                 change_target('<me>')
  192.                 return
  193.             end
  194.         end
  195.     if spell.type == 'BardSong' and spell.target.type and spell.target.type == 'PLAYER' and autopianext == 0 and not spell.target.charmed then
  196.         cancel_spell()
  197.                 autopianext = 1
  198.                 aptarget = spell.target.name
  199.                 apspell = spell.name
  200.         send_command('input /ja "Pianissimo" <me>;')
  201.         return
  202.     end
  203. end
  204.  
  205. function precast(spell,action)
  206.     if spell.type == 'BardSong' then
  207.             equip(sets.precast.FC.Song)
  208.     elseif sets.precast.JA[spell.english] then
  209.             equip(sets.precast.JA[spell.english])
  210.     else
  211.             equip(sets.midcast.cure)
  212.     end
  213.            
  214.  
  215.     if sets.precast.FC[tostring(spell.element)] then
  216.         equip(sets.precast.FC[tostring(spell.element)])
  217.     end
  218.    
  219.    
  220.    
  221.    
  222. end
  223.  
  224. function midcast(spell,action)
  225.     if spell.type == 'BardSong' then
  226.         if debuff:contains(spell.name) then
  227.             equip(sets.midcast.Debuff)
  228.         else
  229.             equip(sets.midcast.Buff)
  230.         end
  231.     end
  232.    
  233.     if job_post_midcast then
  234.         job_post_midcast(spell, action)
  235.     end
  236.        
  237. end
  238.  
  239. function job_post_midcast(spell,action)
  240.     if string.find(spell.english,'Ballad')then
  241.         equip(sets.midcast.Ballad)
  242.     elseif spell.name == "Sentinel's Scherzo" then
  243.         equip(sets.midcast.Sentinel)
  244.     end
  245.    
  246.     if dummy:contains(spell.name) and player.equipment.range == 'Daurdabla' then
  247.         equip(sets.Dummy)
  248.         add_to_chat(100, 'Dummy Song')
  249.     end
  250.  
  251. end
  252.  
  253. function aftercast(spell,action)
  254.     if player.mpp < 70 then
  255.             enable('range', 'ammo')
  256.             equip(sets.aftercast)
  257.     else
  258.             enable('range', 'ammo')
  259.             equip(sets.ac)
  260.     end
  261.    
  262.     if spell.interrupted then
  263.         if spell.type == 'BardSong' then
  264.             return
  265.         else
  266.             autopianext = 0
  267.         end
  268.     end
  269.  
  270.     if autopianext == 1 and spell.type == 'BardSong' then
  271.         add_to_chat(100, spell.type)
  272.                 local t = os.time()
  273.                 local dur = calculate_duration(apspell)-30
  274.                 send_command('timers delete "'..aptarget..'"')
  275.                 send_command('timers create "'..aptarget..'" '..dur..' down')      
  276.     end
  277.    
  278.  if spell.type and spell.type == 'BardSong' and spell.target and spell.target.type:upper() == 'SELF' then
  279.         local t = os.time()
  280.         local tempreg = {}
  281.         for i,v in pairs(timer_reg) do
  282.             if v < t then tempreg[i] = true end
  283.         end
  284.         for i,v in pairs(tempreg) do
  285.             timer_reg[i] = nil
  286.         end
  287.        
  288.         local dur = calculate_duration(spell.name)
  289.         if timer_reg[spell.name] then
  290.                 send_command('timers delete "'..spell.name..'"')
  291.                 timer_reg[spell.name] = t + dur
  292.                 send_command('timers create "'..spell.name..'" '..dur..' down')
  293.         else
  294.             local maxsongs = 2
  295.             if player.equipment.range == 'Daurdabla' then
  296.                 maxsongs = maxsongs+1 -- 1 if Daurdabla 90/95 2 if Daurdabla 99
  297.             end
  298.             if buffactive['Clarion Call'] then
  299.                 maxsongs = maxsongs+1
  300.             end
  301.             if maxsongs < table.length(timer_reg) then
  302.                 maxsongs = table.length(timer_reg)
  303.             end
  304.            
  305.             if table.length(timer_reg) < maxsongs then
  306.                 timer_reg[spell.name] = t+dur
  307.                 send_command('timers create "'..spell.name..'" '..dur..' down')
  308.             else
  309.                 local rep,repsong
  310.                 for i,v in pairs(timer_reg) do
  311.                     if t+dur > v then
  312.                         if not rep or rep > v then
  313.                             rep = v
  314.                             repsong = i
  315.                         end
  316.                     end
  317.                 end
  318.                 if repsong then
  319.                     timer_reg[repsong] = nil
  320.                     send_command('timers delete "'..repsong..'"')
  321.                     timer_reg[spell.name] = t+dur
  322.                     send_command('timers create "'..spell.name..'" '..dur..' down')
  323.                 end
  324.             end
  325.         end
  326.     end
  327. end
  328.  
  329. function buff_change(status,gain_or_loss)
  330.     if status == "Pianissimo" and autopianext == 1 then
  331.         if gain_or_loss then
  332.             send_command('input /ma "'..apspell..'" '..aptarget..';')
  333.         else
  334.             autopianext = 0
  335.         end
  336.     end
  337. end
  338.  
  339. function self_command(cmd)
  340.     if cmd == 'unlock' then
  341.         enable('main','sub')
  342.     end
  343.     if cmd == 'Daurdabla' then
  344.         equip(sets.DBuff)
  345.         send_command('@wait .5;gs disable range; gs disable ammo')
  346.         add_to_chat(100, 'Daurdabla Next Song!!!!')
  347.     end
  348.     if cmd == 'midcast' then
  349.         if sets.midcast.Buff == sets.midcast.BuffSet then
  350.             sets.midcast.Buff = sets.midcast.BuffDuration
  351.             add_to_chat(100, 'Midcast set to Duration!!!!')
  352.         else
  353.             sets.midcast.Buff = sets.midcast.BuffSet
  354.             add_to_chat(100, 'Midcast set to Empy Set!!!!')
  355.         end
  356.     end
  357.    
  358. end
  359.  
  360. function calculate_duration(name)
  361.     local mult = 1
  362.     if player.equipment.range == 'Daurdabla' then mult = mult + 0.3 end
  363.     if player.equipment.range == "Gjallarhorn" then mult = mult + 0.4 end
  364.    
  365.     if player.equipment.neck == "Aoidos' Matinee" then mult = mult + 0.1 end
  366.     if player.equipment.feet == "Brioso Slippers +1" then mult = mult + 0.11 end
  367.     if player.equipment.body == "Aoidos' Hngrln. +2" then mult = mult + 0.1 end
  368.     if player.equipment.legs == "Mdk. Shalwar +1" then mult = mult + 0.1 end
  369.     if player.equipment.main == "Carnwenhan" then mult = mult + 0.5 end
  370.     if player.equipment.main == "Legato Dagger" then mult = mult + 0.05 end
  371.    
  372.     if string.find(name,'March') and player.equipment.hands == 'Ad. Mnchtte. +2' then mult = mult + 0.1 end
  373.     if string.find(name,'Minuet') and player.equipment.body == "Aoidos' Hngrln. +2" then mult = mult + 0.1 end
  374.     if string.find(name,'Madrigal') and player.equipment.head == "Aoidos' Calot +2" then mult = mult + 0.1 end
  375.     if string.find(name,'Ballad') and player.equipment.legs == "Aoidos' Rhing. +2" then mult = mult + 0.1 end
  376.     if string.find(name,'Scherzo') and player.equipment.feet == "Aoidos' Cothrn. +2" then mult = mult + 0.1 end
  377.    
  378.     if buffactive.Troubadour then
  379.         mult = mult*2
  380.     end
  381.     if string.find(name,'Scherzo') and buffactive['Soul Voice'] then
  382.         mult = mult*2
  383.     elseif string.find(name,'Scherzo') and buffactive.marcato then
  384.         mult = mult*1.5
  385.     end
  386.    
  387.     return mult*120
  388. end
Advertisement
Add Comment
Please, Sign In to add comment