Advertisement
Arnan

BRD (mule) Lua October 2017

Oct 4th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 21.39 KB | None | 0 0
  1. -- *** Credit goes to Flippant for helping me with Gearswap *** --
  2. -- ** I Use Byrth & Motenten's Functions ** --
  3.  
  4. function get_sets()
  5.     AccIndex = 1
  6.     AccArray = {"LowACC","MidACC","HighACC"} -- 3 Levels Of Accuracy Sets For TP/WS. First Set Is LowACC. Add More ACC Sets If Needed Then Create Your New ACC Below --
  7.     IdleIndex = 1
  8.     IdleArray = {"Movement","Refresh"} -- Default Idle Set Is Movement --
  9.     Armor = 'None'
  10.     timer_reg = {}
  11.     pianissimo_cycle = false
  12.     Terpander = 'OFF' -- Set Default Lock Terpander ON or OFF Here --
  13.     Elemental_Staff = 'OFF' -- Set Default Precast Elemental Staves ON or OFF Here --
  14.     Lock_Main = 'OFF' -- Set Default Lock Main Weapon ON or OFF Here --
  15.     target_distance = 6 -- Set Default Distance Here --
  16.     select_default_macro_book() -- Change Default Macro Book At The End --
  17.  
  18.     -- Terpander Trigger Songs: Use The Following Songs or Terpander Toggle To Equip Terpander, Add or Remove Terpander Songs --
  19.     DaurdSongs = S{}
  20.  
  21.     Cure_Spells = {"Cure","Cure II","Cure III","Cure IV"} -- Cure Degradation --
  22.     Curaga_Spells = {"Curaga","Curaga II"} -- Curaga Degradation --
  23.     sc_map = {SC1 = "ChocoboMazurka", SC2 = "HerbPastoral", SC3 = "GoblinGavotte"} -- 3 Additional Binds. Can Change Whatever JA/WS/Spells You Like Here. Remember Not To Use Spaces. --
  24.  
  25.     sets.Idle = {}
  26.     -- Idle Sets --
  27.     sets.Idle.Refresh = {
  28.             head="Inyanga Tiara +1",
  29.             body="Witching Robe",
  30.             hands="Inyan. Dastanas +2",
  31.             legs="Assid. Pants +1",
  32.             feet="Fili Cothurnes +1",
  33.             neck="Twilight Torque",
  34.             waist="Flume Belt",
  35.             left_ear="Ethereal Earring",
  36.             right_ear="Hearty Earring",
  37.             left_ring="Defending Ring",
  38.             right_ring="Inyanga Ring",
  39.             back="Moonbeam Cape"}
  40.     sets.Idle.Movement = set_combine(sets.Idle.Refresh,{})
  41.     sets.Resting = set_combine(sets.Idle.Movement,{})
  42.  
  43.     -- PDT Set --
  44.     sets.PDT = {}
  45.  
  46.     sets.Precast ={
  47.             head="Inyanga Tiara +1",
  48.             body="Inyanga Jubbah +1",
  49.             hands="Inyan. Dastanas +2",
  50.             legs="Lengo Pants",
  51.             feet="Inyan. Crackows +1",
  52.             waist="Witful Belt",
  53.             left_ear="Loquac. Earring",
  54.             left_ring="Defending Ring",
  55.             right_ring="Prolix Ring",
  56.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}}
  57.            
  58.     -- Song Precast Set (empty = To Fix Club/Staff Issue) --
  59.     sets.Precast.SongCast = {
  60.             head="Fili Calot +1",
  61.             body="Inyanga Jubbah +1",
  62.             hands="Inyan. Dastanas +1",
  63.             legs="Lengo Pants",
  64.             feet="Coalrake Sabots",
  65.             neck="Aoidos' Matinee",
  66.             waist="Witful Belt",
  67.             left_ear="Loquac. Earring",
  68.             left_ring="Defending Ring",
  69.             right_ring="Prolix Ring",
  70.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}}
  71.  
  72.     -- Elemental Staves --
  73.     sets.Precast.Lightning = {}
  74.     sets.Precast.Water = {}
  75.     sets.Precast.Fire = {}
  76.     sets.Precast.Ice = {}
  77.     sets.Precast.Wind = {}
  78.     sets.Precast.Earth = {}
  79.     sets.Precast.Light = {}
  80.     sets.Precast.Dark = {}
  81.  
  82.     -- Precast Terpander Set --
  83.     sets.Precast.Terpander = {
  84.             range="Terpander",
  85.             ammo=empty}
  86.  
  87.     -- Fastcast Set --
  88.     sets.Precast.FastCast = {
  89.             head="Inyanga Tiara +1",
  90.             body="Inyanga Jubbah +1",
  91.             hands="Inyan. Dastanas +1",
  92.             legs="Artsieq Hose",
  93.             feet="Inyan. Crackows +1",
  94.             neck="Aoidos' Matinee",
  95.             waist="Witful Belt",
  96.             left_ear="Loquac. Earring",
  97.             left_ring="Defending Ring",
  98.             right_ring="Prolix Ring",
  99.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}}
  100.  
  101.     -- Cure Precast Set --
  102.     sets.Precast.Cure = {}
  103.  
  104.     -- Midcast Base Set --
  105.     sets.Midcast = {}
  106.  
  107.     -- Song Debuff Set --
  108.     sets.Midcast.Wind = {
  109.             range="Eminent Flute",
  110.             head="Fili Calot +1",
  111.             neck="Moonbow Whistle",
  112.             ear1="Loquac. Earring",
  113.             ear2="Musical Earring",
  114.             body="Fili Hongreline +1",
  115.             hands="Inyan. Dastanas +2",
  116.             waist="Harfner's Sash",
  117.             legs="Inyanga Shalwar +2",
  118.             feet="Brioso Slippers +1",
  119.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}}
  120.  
  121.     -- Song Buff Set --
  122.     sets.Midcast.WindBuff = {
  123.             range="Eminent Flute",
  124.             head="Fili Calot +1",
  125.             neck="Moonbow Whistle",
  126.             ear1="Loquac. Earring",
  127.             ear2="Musical Earring",
  128.             body="Fili Hongreline +1",
  129.             hands="Inyan. Dastanas +2",
  130.             waist="Harfner's Sash",
  131.             legs="Inyanga Shalwar +2",
  132.             feet="Brioso Slippers +1",
  133.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}}
  134.  
  135.     sets.Midcast.March = {hands="Fili Manchettes +1"}
  136.     sets.Midcast.Minuet = {body="Fili Hongreline +1"}
  137.     sets.Midcast.Madrigal = {head="Fili Calot +1","Intarabus's Cape"}
  138.     sets.Midcast.Ballad = {} -- legs="Fili Rhingrave" --
  139.     sets.Midcast.Scherzo = {feet="Fili Cothurnes +1"}
  140.     sets.Midcast.Mazurka = {}
  141.     sets.Midcast.Paeon = {} -- head="Brioso Roundlet" --
  142.     sets.Midcast.Finale = {}
  143.     sets.Midcast.Lullaby = {}
  144.  
  145.     -- Cure Set --
  146.     sets.Midcast.Cure = {}
  147.  
  148.     -- Curaga Set --
  149.     sets.Midcast.Curaga = {}
  150.  
  151.     -- Haste Set --
  152.     sets.Midcast.Haste = set_combine(sets.Precast.FastCast,{
  153.             head="Inyanga Tiara +1",
  154.             body="Inyanga Jubbah +1",
  155.             hands="Inyan. Dastanas +1",
  156.             legs="Artsieq Hose",
  157.             feet="Inyan. Crackows +1",
  158.             neck="Aoidos' Matinee",
  159.             waist="Witful Belt",
  160.             left_ear="Loquac. Earring",
  161.             left_ring="Defending Ring",
  162.             right_ring="Prolix Ring",
  163.             back={ name="Intarabus's Cape", augments={'"Fast Cast"+10',}}})
  164.  
  165.     -- Cursna Set --
  166.     sets.Midcast.Cursna = set_combine(sets.Midcast.Haste,{})
  167.  
  168.     -- Stoneskin Set --
  169.     sets.Midcast.Stoneskin = set_combine(sets.Midcast.Haste)
  170.  
  171.     -- JA Sets --
  172.     sets.JA = {}
  173.     sets.JA.Nightingale = {feet="Bihu Slippers"}
  174.     sets.JA.Troubadour = {body="Bihu Justaucorps"}
  175.     sets.JA["Soul Voice"] = {legs="Bihu Cannions"}
  176.  
  177.     -- Waltz --
  178.     sets.Waltz = {}
  179.  
  180.     -- Melee Sets --
  181.     sets.Melee ={
  182.         head="Inyanga Tiara +1",
  183.         body="Inyanga Jubbah +1",
  184.         hands="Chironic Gloves",
  185.         legs="Artsieq Hose",
  186.         feet="Battlecast Gaiters",
  187.         neck="Lissome Necklace",
  188.         waist="Windbuffet Belt",
  189.         left_ear="Cessance Earring",
  190.         right_ear="Brutal Earring",
  191.         left_ring="Petrov Ring",
  192.         right_ring="Pernicious Ring",
  193.         back="Enuma Mantle"}
  194.     sets.Melee.MidACC = set_combine(sets.Melee,{})
  195.     sets.Melee.HighACC = set_combine(sets.Melee.MidACC,{})
  196.  
  197.     -- WS Base Set --
  198.     sets.WS = {}
  199.  
  200.     sets.WS.Exenterator = {}
  201.     sets.WS.Exenterator.MidACC = set_combine(sets.WS.Exenterator,{})
  202.     sets.WS.Exenterator.HighACC = set_combine(sets.WS.Exenterator.MidACC,{})
  203.  
  204.     sets.WS.Evisceration = {}
  205.     sets.WS.Evisceration.MidACC = set_combine(sets.WS.Evisceration,{})
  206.     sets.WS.Evisceration.HighACC = set_combine(sets.WS.Evisceration.MidACC,{})
  207.  
  208.     sets.WS["Mercy Stroke"] = {}
  209.     sets.WS["Mercy Stroke"].MidACC = set_combine(sets.WS["Mercy Stroke"],{})
  210.     sets.WS["Mercy Stroke"].HighACC = set_combine(sets.WS["Mercy Stroke"].MidACC,{})
  211.  
  212.     sets.WS["Rudra's Storm"] = {}
  213.     sets.WS["Rudra's Storm"].MidACC = set_combine(sets.WS["Rudra's Storm"],{})
  214.     sets.WS["Rudra's Storm"].HighACC = set_combine(sets.WS["Rudra's Storm"].MidACC,{})
  215.  
  216.     sets.WS["Mordant Rime"] = {}
  217. end
  218.  
  219. function pretarget(spell,action)
  220.     if spell.action_type == 'Magic' and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
  221.         cancel_spell()
  222.         send_command('input /item "Echo Drops" <me>')
  223.     elseif spell.type == "WeaponSkill" and spell.target.distance > target_distance and player.status == 'Engaged' then -- Cancel WS If You Are Out Of Range --
  224.         cancel_spell()
  225.         add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  226.         return
  227.     elseif spell.type == "BardSong" and spell.target.name == player.name and buffactive.Pianissimo then -- Change Target From <me> To <t> When Pianissimo Is Active --
  228.         change_target('<t>')
  229.     elseif spell.type == 'BardSong' and spell.target.type and spell.target.type == 'PLAYER' and not buffactive.Pianissimo and not spell.target.charmed and not pianissimo_cycle then -- Auto Pianoissimo When You Cast A Song On A Player --
  230.         cancel_spell()
  231.         pianissimo_cycle = true
  232.         send_command('input /ja "Pianissimo" <me>;wait 1.5;input /ma "'..spell.name..'" '..spell.target.name..';')
  233.         return
  234.     elseif spell.english:ifind("Cure") and player.mp<actualCost(spell.mp_cost) then
  235.         degrade_spell(spell,Cure_Spells)
  236.     elseif spell.english:ifind("Curaga") and player.mp<actualCost(spell.mp_cost) then
  237.         degrade_spell(spell,Curaga_Spells)
  238.     end
  239.     if spell.name ~= 'Pianissimo' then
  240.         pianissimo_cycle = false
  241.     end
  242. end
  243.  
  244. function precast(spell,action)
  245.     if spell.action_type == 'Magic' then
  246.         if buffactive.silence or spell.target.distance > 16+target_distance then -- Cancel Magic or Ninjutsu or BardSong If You Are Silenced or Out of Range --
  247.             cancel_spell()
  248.             add_to_chat(123, spell.name..' Canceled: [Silenced or Out of Casting Range]')
  249.             return
  250.         else
  251.             if spell.type == 'BardSong' then
  252.                 if Terpander == 'ON' then
  253.                     equip(sets.Precast.Terpander)
  254.                 else
  255.                     if buffactive.Nightingale then
  256.                         equip_song_gear(spell)
  257.                         return
  258.                     else
  259.                         equip_song_gear(spell)
  260.                         equip(sets.Precast.SongCast)
  261.                     end
  262.                 end
  263.             elseif spell.english:startswith('Cur') and spell.english ~= "Cursna" then
  264.                 equip(sets.Precast.Cure)
  265.             elseif spell.english == 'Utsusemi: Ni' then
  266.                 if buffactive['Copy Image (3)'] then
  267.                     cancel_spell()
  268.                     add_to_chat(123, spell.name .. ' Canceled: [3 Images]')
  269.                     return
  270.                 else
  271.                     equip(sets.Precast.FastCast)
  272.                 end
  273.             else
  274.                 equip(sets.Precast.FastCast)
  275.             end
  276.         end
  277.     elseif spell.type == "WeaponSkill" then
  278.         if player.status ~= 'Engaged' then -- Cancel WS If You Are Not Engaged. Can Delete It If You Don't Need It --
  279.             cancel_spell()
  280.             add_to_chat(123,'Unable To Use WeaponSkill: [Disengaged]')
  281.             return
  282.         else
  283.             equipSet = sets.WS
  284.             if equipSet[spell.english] then
  285.                 equipSet = equipSet[spell.english]
  286.             end
  287.             if equipSet[AccArray[AccIndex]] then
  288.                 equipSet = equipSet[AccArray[AccIndex]]
  289.             end
  290.             if spell.english == "Evisceration" and player.tp > 2990 then
  291.                 equipSet = set_combine(equipSet,{ear1="Jupiter's Pearl"})
  292.             end
  293.             equip(equipSet)
  294.         end
  295.     elseif spell.type == "JobAbility" then
  296.         if sets.JA[spell.english] then
  297.             equip(sets.JA[spell.english])
  298.         end
  299.     elseif spell.type == "Waltz" then
  300.         refine_waltz(spell,action)
  301.         equip(sets.Waltz)
  302.     elseif spell.english == 'Spectral Jig' and buffactive.Sneak then
  303.         cast_delay(0.2)
  304.         send_command('cancel Sneak')
  305.     end
  306.     if sets.Precast[spell.element] and not buffactive.Nightingale and Elemental_Staff == 'ON' then
  307.         equip(sets.Precast[spell.element])
  308.     end
  309. end
  310.  
  311. function midcast(spell,action)
  312.     equipSet = {}
  313.     if spell.action_type == 'Magic' then
  314.         equipSet = sets.Midcast
  315.         if equipSet[spell.english] then
  316.             equipSet = equipSet[spell.english]
  317.         elseif spell.english:startswith('Cur') and spell.english ~= "Cursna" then
  318.             if spell.english:startswith('Cure') then
  319.                 equipSet = equipSet.Cure
  320.             elseif spell.english:startswith('Cura') then
  321.                 equipSet = equipSet.Curaga
  322.             end
  323.             if world.day_element == spell.element or world.weather_element == spell.element then
  324.                 equipSet = set_combine(equipSet,{})
  325.             end
  326.         elseif spell.english == "Stoneskin" then
  327.             if buffactive.Stoneskin then
  328.                 send_command('@wait 2.8;cancel stoneskin')
  329.             end
  330.             equipSet = equipSet.Stoneskin
  331.         elseif spell.english == "Sneak" then
  332.             if spell.target.name == player.name and buffactive['Sneak'] then
  333.                 send_command('cancel sneak')
  334.             end
  335.             equipSet = equipSet.Haste
  336.         elseif spell.english:startswith('Utsusemi') then
  337.             if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)'] or buffactive['Copy Image (3)']) then
  338.                 send_command('@wait 1.7;cancel Copy Image*')
  339.             end
  340.             equipSet = equipSet.Haste
  341.         elseif spell.english == 'Monomi: Ichi' then
  342.             if buffactive['Sneak'] then
  343.                 send_command('@wait 1.7;cancel sneak')
  344.             end
  345.             equipSet = equipSet.Haste
  346.         elseif spell.type == 'BardSong' then
  347.             if Terpander == 'ON' then
  348.                 equip(sets.Precast.Terpander)
  349.             else
  350.                 equip_song_gear(spell)
  351.             end
  352.         end
  353.     end
  354.     equip(equipSet)
  355. end
  356.  
  357. function aftercast(spell,action)
  358.     if midaction() then
  359.         return
  360.     else
  361.         status_change(player.status)
  362.     end
  363. end
  364.  
  365. function status_change(new,old)
  366.     check_equip_lock()
  367.     if Armor == 'PDT' then
  368.         equip(sets.PDT)
  369.     elseif new == 'Engaged' then
  370.         equipSet = sets.Melee
  371.         if equipSet[AccArray[AccIndex]] then
  372.             equipSet = equipSet[AccArray[AccIndex]]
  373.         end
  374.         equip(equipSet)
  375.     elseif new == 'Idle' then
  376.         equipSet = sets.Idle
  377.         if equipSet[IdleArray[IdleIndex]] then
  378.             equipSet = equipSet[IdleArray[IdleIndex]]
  379.         end
  380.         if buffactive['Reive Mark'] then -- Equip Arciela's Grace +1 During Reive --
  381.             equipSet = set_combine(equipSet,{})
  382.         end
  383.         if world.area:endswith('Adoulin') then
  384.             equipSet = set_combine(equipSet,{body="Councilor's Garb"})
  385.         end
  386.         equip(equipSet)
  387.     elseif new == 'Resting' then
  388.         equip(sets.Resting)
  389.     end
  390. end
  391.  
  392. function buff_change(buff,gain)
  393.     buff = string.lower(buff)
  394.     if buff == "aftermath: lv.3" then -- AM3 Timer/Countdown --
  395.         if gain then
  396.             send_command('timers create "Aftermath: Lv.3" 180 down;wait 150;input /echo Aftermath: Lv.3 [WEARING OFF IN 30 SEC.];wait 15;input /echo Aftermath: Lv.3 [WEARING OFF IN 15 SEC.];wait 5;input /echo Aftermath: Lv.3 [WEARING OFF IN 10 SEC.]')
  397.         else
  398.             send_command('timers delete "Aftermath: Lv.3"')
  399.             add_to_chat(123,'AM3: [OFF]')
  400.         end
  401.     elseif buff == 'weakness' then -- Weakness Timer --
  402.         if gain then
  403.             send_command('timers create "Weakness" 300 up')
  404.         else
  405.             send_command('timers delete "Weakness"')
  406.         end
  407.     end
  408.     if not midaction() then
  409.         status_change(player.status)
  410.     end
  411. end
  412.  
  413. -- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
  414. function self_command(command)
  415.     if command == 'C1' then
  416.         send_command('input /ma "Victory March" <me>')
  417.         add_to_chat(158,'Melee Speed II: [Victory March]')
  418.     elseif command == 'C2' then
  419.         send_command('input /ma "Advancing March" <me>')
  420.         add_to_chat(158,'Melee Speed: [Advancing March]')
  421.     elseif command == 'C3' then
  422.         send_command('input /ma "Valor Minuet V" <me>')
  423.         add_to_chat(158,'Melee Attack: [Valor Minuet V]')
  424.     elseif command == 'C5' then
  425.         send_command('input /ma "Valor Minuet IV" <me>')
  426.         add_to_chat(158,'Melee Attack: [Valor Minuet IV]')
  427.     elseif command == 'C9' then
  428.         send_command('input /ma "Blade Madrigal" <me>')
  429.         add_to_chat(158,'Melee Accuracy II: [Blade Madrigal]')
  430.     elseif command == 'C10' then
  431.         send_command('input /ma "Sword Madrigal" <me>')
  432.         add_to_chat(158,'Melee Accuracy: [Sword Madrigal]')
  433.     elseif command == 'C15' then -- PDT Toggle --
  434.         if Armor == 'PDT' then
  435.             Armor = 'None'
  436.             add_to_chat(123,'PDT Set: [Unlocked]')
  437.         else
  438.             Armor = 'PDT'
  439.             add_to_chat(158,'PDT Set: [Locked]')
  440.         end
  441.         status_change(player.status)
  442.     elseif command == 'C17' then -- Lock Main Weapon Toggle --
  443.         if Lock_Main == 'ON' then
  444.             Lock_Main = 'OFF'
  445.             add_to_chat(123,'Main Weapon: [Unlocked]')
  446.         else
  447.             Lock_Main = 'ON'
  448.             add_to_chat(158,'Main Weapon: [Locked]')
  449.         end
  450.         status_change(player.status)
  451.     elseif command == 'C7' then -- Terpander Toggle --
  452.         if Terpander == 'ON' then
  453.             Terpander = 'OFF'
  454.             add_to_chat(123,'Terpander: [OFF]')
  455.         else
  456.             Terpander = 'ON'
  457.             add_to_chat(158,'Terpander: [ON]')
  458.         end
  459.         status_change(player.status)
  460.     elseif command == 'C16' then -- Accuracy Level Toggle --
  461.         AccIndex = (AccIndex % #AccArray) + 1
  462.         status_change(player.status)
  463.         add_to_chat(158,'Accuracy Level: ' .. AccArray[AccIndex])
  464.     elseif command == 'C12' then -- Auto Update Gear Toggle --
  465.         status_change(player.status)
  466.         add_to_chat(158,'Auto Update Gear')
  467.     elseif command == 'C8' then -- Distance Toggle --
  468.         if player.target.distance then
  469.             target_distance = math.floor(player.target.distance*10)/10
  470.             add_to_chat(158,'Distance: '..target_distance)
  471.         else
  472.             add_to_chat(123,'No Target Selected')
  473.         end
  474.     elseif command == 'C6' then -- Idle Toggle --
  475.         IdleIndex = (IdleIndex % #IdleArray) + 1
  476.         add_to_chat(158,'Idle Set: '..IdleArray[IdleIndex])
  477.         status_change(player.status)
  478.     elseif command:match('^SC%d$') then
  479.         send_command('//' .. sc_map[command])
  480.     end
  481. end
  482.  
  483. function check_equip_lock() -- Lock Equipment Here --
  484.     if player.equipment.left_ring == "Warpish Ring" or player.equipment.left_ring == "Capacity Ring" or player.equipment.right_ring == "Warpish Ring" or player.equipment.right_ring == "Capacity Ring" then
  485.         disable('ring1','ring2')
  486.     elseif player.equipment.back == "Mecisto. Mantle" or player.equipment.back == "Aptitude Mantle +1" or player.equipment.back == "Aptitude Mantle" then
  487.         disable('back')
  488.     elseif Lock_Main == 'ON' then
  489.         disable('main','sub')
  490.     else
  491.         enable('main','sub','ring1','ring2','back')
  492.     end
  493. end
  494.  
  495. function equip_song_gear(spell)
  496.     if DaurdSongs:contains(spell.english) then
  497.         equip(sets.Precast.Terpander)
  498.         add_to_chat(158,'Terpander: [ON]')
  499.     else
  500.         if spell.target.type == 'MONSTER' then
  501.             equip(sets.Midcast.Wind)
  502.             if string.find(spell.english,'Finale') then equip(sets.Midcast.Finale) end
  503.             if string.find(spell.english,'Lullaby') then equip(sets.Midcast.Lullaby) end
  504.         else
  505.             equip(sets.Midcast.WindBuff)
  506.             if string.find(spell.english,'March') then equip(sets.Midcast.March) end
  507.             if string.find(spell.english,'Minuet') then equip(sets.Midcast.Minuet) end
  508.             if string.find(spell.english,'Madrigal') then equip(sets.Midcast.Madrigal) end
  509.             if string.find(spell.english,'Ballad') then equip(sets.Midcast.Ballad) end
  510.             if string.find(spell.english,'Scherzo') then equip(sets.Midcast.Scherzo) end
  511.             if string.find(spell.english,'Mazurka') then equip(sets.Midcast.Mazurka) end
  512.             if string.find(spell.english,'Paeon') then equip(sets.Midcast.Paeon) end
  513.         end
  514.     end
  515. end
  516.  
  517. function actualCost(originalCost)
  518.     if buffactive["Penury"] then
  519.         return originalCost*.5
  520.     elseif buffactive["Light Arts"] or buffactive["Addendum: White"] then
  521.         return originalCost*.9
  522.     elseif buffactive["Dark Arts"] or buffactive["Addendum: Black"] then
  523.         return originalCost*1.1
  524.     else
  525.         return originalCost
  526.     end
  527. end
  528.  
  529. function degrade_spell(spell,degrade_array)
  530.     spell_index = table.find(degrade_array,spell.name)
  531.     if spell_index > 1 then
  532.         new_spell = degrade_array[spell_index - 1]
  533.         change_spell(new_spell,spell.target.raw)
  534.         add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..new_spell..' instead.')
  535.     end
  536. end
  537.  
  538. function change_spell(spell_name,target)
  539.     cancel_spell()
  540.     send_command('//'..spell_name..' '..target)
  541. end
  542.  
  543. function refine_waltz(spell,action)
  544.     if spell.type ~= 'Waltz' then
  545.         return
  546.     end
  547.  
  548.     if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" then
  549.         return
  550.     end
  551.  
  552.     local newWaltz = spell.english
  553.     local waltzID
  554.  
  555.     local missingHP
  556.  
  557.     if spell.target.type == "SELF" then
  558.         missingHP = player.max_hp - player.hp
  559.     elseif spell.target.isallymember then
  560.         local target = find_player_in_alliance(spell.target.name)
  561.         local est_max_hp = target.hp / (target.hpp/100)
  562.         missingHP = math.floor(est_max_hp - target.hp)
  563.     end
  564.  
  565.     if missingHP ~= nil then
  566.         if player.sub_job == 'DNC' then
  567.             if missingHP < 40 and spell.target.name == player.name then
  568.                 add_to_chat(123,'Full HP!')
  569.                 cancel_spell()
  570.                 return
  571.             elseif missingHP < 150 then
  572.                 newWaltz = 'Curing Waltz'
  573.                 waltzID = 190
  574.             elseif missingHP < 300 then
  575.                 newWaltz = 'Curing Waltz II'
  576.                 waltzID = 191
  577.             else
  578.                 newWaltz = 'Curing Waltz III'
  579.                 waltzID = 192
  580.             end
  581.         else
  582.             return
  583.         end
  584.     end
  585.  
  586.     local waltzTPCost = {['Curing Waltz'] = 20, ['Curing Waltz II'] = 35, ['Curing Waltz III'] = 50}
  587.     local tpCost = waltzTPCost[newWaltz]
  588.  
  589.     local downgrade
  590.  
  591.     if player.tp < tpCost then
  592.  
  593.         if player.tp < 20 then
  594.             add_to_chat(123, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
  595.             cancel_spell()
  596.             return
  597.         elseif player.tp < 35 then
  598.             newWaltz = 'Curing Waltz'
  599.         elseif player.tp < 50 then
  600.             newWaltz = 'Curing Waltz II'
  601.         end
  602.  
  603.         downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
  604.     end
  605.  
  606.     if newWaltz ~= spell.english then
  607.         send_command('@input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
  608.         if downgrade then
  609.             add_to_chat(8, downgrade)
  610.         end
  611.         cancel_spell()
  612.         return
  613.     end
  614.  
  615.     if missingHP > 0 then
  616.         add_to_chat(8,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
  617.     end
  618. end
  619.  
  620. function find_player_in_alliance(name)
  621.     for i,v in ipairs(alliance) do
  622.         for k,p in ipairs(v) do
  623.             if p.name == name then
  624.                 return p
  625.             end
  626.         end
  627.     end
  628. end
  629.  
  630. function sub_job_change(newSubjob, oldSubjob)
  631.     select_default_macro_book()
  632. end
  633.  
  634. function set_macro_page(set,book)
  635.     if not tonumber(set) then
  636.         add_to_chat(123,'Error setting macro page: Set is not a valid number ('..tostring(set)..').')
  637.         return
  638.     end
  639.     if set < 1 or set > 10 then
  640.         add_to_chat(123,'Error setting macro page: Macro set ('..tostring(set)..') must be between 1 and 10.')
  641.         return
  642.     end
  643.  
  644.     if book then
  645.         if not tonumber(book) then
  646.             add_to_chat(123,'Error setting macro page: book is not a valid number ('..tostring(book)..').')
  647.             return
  648.         end
  649.         if book < 1 or book > 20 then
  650.             add_to_chat(123,'Error setting macro page: Macro book ('..tostring(book)..') must be between 1 and 20.')
  651.             return
  652.         end
  653.         send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(set))
  654.     else
  655.         send_command('@input /macro set '..tostring(set))
  656.     end
  657. end
  658.  
  659. function select_default_macro_book()
  660.     -- Default macro set/book
  661.     if player.sub_job == 'WHM' then
  662.         set_macro_page(1, 2)
  663.     elseif player.sub_job == 'BLM' then
  664.         set_macro_page(1, 2)
  665.     elseif player.sub_job == 'DNC' then
  666.         set_macro_page(1, 2)
  667.     elseif player.sub_job == 'NIN' then
  668.         set_macro_page(1, 2)
  669.     elseif player.sub_job == 'WAR' then
  670.         set_macro_page(1, 2)
  671.     else
  672.         set_macro_page(1, 2)
  673.     end
  674. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement