KLoOoSH

My THF gearswap

Dec 24th, 2014
826
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 20.06 KB | None | 0 0
  1. -- *** Credit goes to Flippant for helping me with Gearswap *** --
  2. -- ** I Use Some of Motenten's Functions ** --
  3. -- Last Updated: 05/02/14 10:00 PM *Added Feint Set* --
  4.  
  5. function get_sets()
  6.     AccIndex = 1
  7.     AccArray = {"LowACC","MidACC","HighACC"} -- 3 Levels Of Accuracy Sets For TP/WS/Hybrid. Default ACC Set Is LowACC. The First TP Set Of Your Main Weapon Is LowACC. Add More ACC Sets If Needed Then Create Your New ACC Below --
  8.     WeaponIndex = 1
  9.     WeaponArray = {"Izhiikoh","Sandung"} -- Default Sub Weapon Is Izhiikoh. Can Delete Any Weapons/Sets That You Don't Need Or Replace/Add The New Weapons That You Want To Use. --
  10.     IdleIndex = 1
  11.     IdleArray = {"Regen","Movement"} -- Default Idle Set Is Regen --
  12.     SA = false
  13.     TA = false
  14.     TH = 'OFF' -- Set Default Full TH ON or OFF Here --
  15.     Mecisto = 'OFF' -- Mecisto. Mantle (Capacity Points Back) Toggle Default
  16.     target_distance = 5 -- Set Default Distance Here --
  17.     select_default_macro_book() -- Change Default Macro Book At The End --
  18.  
  19.     sc_map = {SC1="Exenterator", SC2="HasteSamba", SC3="Ranged"} -- 3 Additional Binds. Can Change Whatever JA/WS/Spells You Like Here. Remember Not To Use Spaces. --
  20.  
  21.     -- Idle/Town Sets --
  22.     sets.Idle = {}
  23.     sets.Idle.Movement = {
  24.             ear1="Reraise Earring",
  25.             ring1="Capacity Ring",
  26.             ring2="Warp Ring"}
  27.  
  28.     sets.Idle.Regen = set_combine(sets.Idle.Regen,{
  29.             ammo="Honed Tathlum",
  30.             head="Oce. Headpiece +1",
  31.             neck="Wiglen Gorget",
  32.             ear1="Dudgeon Earring",
  33.             ear2="Dawn Earring",
  34.             body="Kheper jacket",
  35.             hands="Qaaxo mitaines",
  36.             ring1="Paguroidea Ring",
  37.             ring2="Karieyh Ring",
  38.             back="Scuta Cape",
  39.             waist="Lycopodium Sash",
  40.             legs="Pill. Culottes +1",
  41.             feet="Pill. Poulaines +1"})
  42.  
  43.     -- Normal TP Sets --
  44.     sets.TP = {
  45.             ammo="Honed Tathlum",
  46.             head="Iuitl headgear +1",
  47.             neck="Asperity Necklace",
  48.             ear1="Dudgeon Earring",
  49.             ear2="Heartseeker Earring",
  50.             body="Skadi's cuirie +1",
  51.             hands="Pill. Armlets +1",
  52.             ring1="Epona's Ring",
  53.             ring2="Oneiros Ring",
  54.             back="Canny Cape",
  55.             waist="Windbuffet belt +1",
  56.             legs="Pill. Culottes +1",
  57.             feet="Plun. Poulaines +1"}
  58.     sets.TP.MidACC = set_combine(sets.TP,{
  59.             neck="Iqabi necklace",
  60.             body="Skadi's cuirie +1",
  61.             hands="Qaaxo Mitaines",
  62.             back="Canny Cape",
  63.             feet="Qaaxo Leggings"})
  64.     sets.TP.HighACC = set_combine(sets.TP.MidACC,{
  65.             head="Whirlpool Mask",
  66.             body="Manibozho Jerkin",
  67.             ring1="Patricius Ring",
  68.             ring2="Beeline Ring",
  69.             waist="Anguinus Belt"})
  70.  
  71.     -- March x2 + Haste --
  72.     sets.TP.MidHaste = set_combine(sets.TP,{
  73.             body="Thaumas Coat"})
  74.     sets.TP.MidACC.MidHaste = set_combine(sets.TP.MidHaste,{
  75.             neck="Iqabi necklace",
  76.             body="Pillager's vest +1",
  77.             hands="Qaaxo Mitaines",
  78.             back="Canny Cape",
  79.             feet="Qaaxo Leggings"})
  80.     sets.TP.HighACC.MidHaste = set_combine(sets.TP.MidACC.MidHaste,{
  81.             head="Whirlpool Mask",
  82.             body="Manibozho Jerkin",
  83.             ring1="Patricius Ring",
  84.             waist="Anguinus Belt"})
  85.  
  86.     -- March x2 + Haste + Samba --
  87.     sets.TP.HighHaste = set_combine(sets.TP.MidHaste,{
  88.             ear1="Trux Earring",
  89.             ear2="Brutal Earring",
  90.             waist="Windbuffet Belt +1"})
  91.     sets.TP.MidACC.HighHaste = set_combine(sets.TP.HighHaste,{
  92.             neck="Iqabi necklace",
  93.             ear1="Steelflash Earring",
  94.             ear2="Bladeborn Earring",
  95.             body="Pillager's vest +1",
  96.             hands="Qaaxo Mitaines",
  97.             back="Canny Cape",
  98.             feet="Qaaxo Leggings"})
  99.     sets.TP.HighACC.MidHaste = set_combine(sets.TP.MidACC.MidHaste,{
  100.             head="Whirlpool Mask",
  101.             body="Manibozho Jerkin",
  102.             ring1="Patricius Ring"})
  103.  
  104.     -- Full TH TP Set --
  105.     sets.TP.TH = {
  106.             hands="Plun. Armlets +1",
  107.             waist="Chaac Belt",
  108.             feet="Raid. Poulaines +2"}
  109.  
  110.     -- Capacity Points Mantle --
  111.     sets.Mecisto = {back="Mecisto. Mantle"}
  112.  
  113.     -- TP Feint Set --
  114.     sets.TP.Feint = {legs="Plun. Culottes +1"}
  115.  
  116.     -- PDT/MDT Sets --
  117.     sets.PDT = {
  118.             head="Iuitl Headgear +1",
  119.             neck="Twilight Torque",
  120.             ear1="Black Earring",
  121.             ear2="Darkness Earring",
  122.             body="Emet harness",
  123.             hands="Qaaxo mitaines",
  124.             ring1="Patricius Ring",
  125.             ring2="Defending Ring",
  126.             back="Mollusca Mantle",
  127.             waist="Flume Belt +1",
  128.             legs="Quiahuiz trousers",
  129.             feet="Qaaxo Leggings"}
  130.  
  131.     sets.MDT = set_combine(sets.PDT,{
  132.             ear1="Merman's Earring",
  133.             ear2="Sanare Earring",
  134.             ring1="Shadow Ring",
  135.             back="Engulfer Cape",
  136.             waist="Resolute Belt"})
  137.  
  138.     -- Hybrid/Evasion Sets --
  139.     sets.TP.Hybrid = set_combine(sets.PDT,{})
  140.     sets.TP.Hybrid.MidACC = set_combine(sets.TP.Hybrid,{})
  141.     sets.TP.Hybrid.HighACC = set_combine(sets.TP.Hybrid.MidACC,{})
  142.  
  143.     sets.Evasion = set_combine(sets.PDT,{})
  144.  
  145.     -- WS Base Set --
  146.     sets.WS = {}
  147.  
  148.     -- WS Sets --
  149.     sets.WS["Mercy Stroke"] = {
  150.             head="Uk'uxkaj cap",
  151.             neck="Asperity necklace",
  152.             ear1="Steelflash Earring",
  153.             ear2="Bladeborn Earring",
  154.             body="Plunderer's vest +1",
  155.             hands="Pill. Armlets +1",
  156.             ring1="Ifrit Ring",
  157.             ring2="Karieyh Ring",
  158.             back="Buquwik Cape",
  159.             waist="Metalsinger Belt",
  160.             legs="Quiahuiz Trousers",
  161.             feet="Plun. Poulaines +1"}
  162.     sets.WS["Mercy Stroke"].SA = {}
  163.     sets.WS["Mercy Stroke"].TA = {}
  164.  
  165.     sets.WS.Exenterator = {
  166.             head="Pill. Bonnet +1",
  167.             neck="Asperity necklace",
  168.             ear1="Steelflash Earring",
  169.             ear2="Bladeborn Earring",
  170.             body="Plunderer's vest +1",
  171.             hands="Pill. Armlets +1",
  172.             ring1="Epona's Ring",
  173.             ring2="Karieyh Ring",
  174.             back="Canny Cape",
  175.             waist="Chaac Belt",
  176.             legs="Plun. Culottes +1",
  177.             feet="Plun. Poulaines +1"}
  178.     sets.WS.Exenterator.SA = set_combine(sets.WS.Exenterator,{head="Pill. Bonnet +1",legs="Pill. Culottes +1"})
  179.     sets.WS.Exenterator.TA = set_combine(sets.WS.Exenterator,{head="Pill. Bonnet +1",legs="Pill. Culottes +1"})
  180.  
  181.     sets.WS.Evisceration = {
  182.             head="Pill. Bonnet +1",
  183.             neck="Iqabi Necklace",
  184.             ear1="Trux Earring",
  185.             ear2="Brutal Earring",
  186.             body="Pillager's Vest +1",
  187.             hands="Pill. Armlets +1",
  188.             ring1="Epona's Ring",
  189.             ring2="Karieyh Ring",
  190.             back="Cavaros Mantle",
  191.             waist="Anguinus Belt",
  192.             legs="Pill. Culottes +1",
  193.             feet="Plun. Poulaines +1"}
  194.     sets.WS.Evisceration.SA = set_combine(sets.WS.Evisceration,{hands="Raider's Armlets +2"})
  195.     sets.WS.Evisceration.TA = set_combine(sets.WS.Evisceration,{})
  196.  
  197.     sets.WS["Rudra's Storm"] = {
  198.             ammo="Yetshila",
  199.             head="Pill. Bonnet +1",
  200.             neck="Shifting Neck. +1",
  201.             ear1="Pixie Earring",
  202.             ear2="Dawn Earring",
  203.             body="Pillager's Vest +1",
  204.             hands="Pill. Armlets +1",
  205.             ring1="Ramuh Ring",
  206.             ring2="Karieyh Ring",
  207.             back="Meanagh cape +1",
  208.             waist="Artful Belt",
  209.             legs="Pill. Culottes +1",
  210.             feet="Plun. Poulaines +1"}
  211.     sets.WS["Rudra's Storm"].SA = set_combine(sets.WS["Rudra's Storm"],{head="Pill. Bonnet +1",legs="Pill. Culottes +1"})
  212.     sets.WS["Rudra's Storm"].TA = set_combine(sets.WS["Rudra's Storm"],{head="Pill. Bonnet +1",legs="Pill. Culottes +1"})
  213.  
  214.     sets.WS["Aeolian Edge"] = {
  215.             head="Pill. Bonnet +1",
  216.             neck="Iqabi Necklace",
  217.             ear1="Trux Earring",
  218.             ear2="Brutal Earring",
  219.             body="Pillager's Vest +1",
  220.             hands="Pill. Armlets +1",
  221.             ring1="Epona's Ring",
  222.             ring2="Karieyh Ring",
  223.             back="Cavaros Mantle",
  224.             waist="Anguinus Belt",
  225.             legs="Pill. Culottes +1",
  226.             feet="Plun. Poulaines +1"}
  227.  
  228.     sets.WS["Mandalic Stab"] = {}
  229.  
  230.     -- JA Sets --
  231.     sets.JA = {}
  232.     TH_Gear = {hands="Plun. Armlets +1",waist="Chaac Belt",feet="Raid. Poulaines +2"}
  233.     sets.JA.Conspirator = {body="Raider's Vest +2"}
  234.     sets.JA.Accomplice = {head="Raid. Bonnet +2"}
  235.     sets.JA.Collaborator = {head="Raid. Bonnet +2"}
  236.     sets.JA["Perfect Dodge"] = {hands="Plun. Armlets +1"}
  237.     sets.JA.Steal = {hands="Pill. Armlets +1",legs="Pill. Culottes +1",feet="Pill. Poulaines +1"}
  238.     sets.JA.Flee = {feet="Pill. Poulaines +1"}
  239.     sets.JA.Despoil = {legs="Raid. Culottes +2",feet="Raid. Poulaines +2"}
  240.     sets.JA.Mug = {head="Plun. Bonnet +1"}
  241.     sets.JA.Hide = {body="Pillager's Vest +1"}
  242.     sets.JA.Provoke = TH_Gear
  243.     sets.JA["Sneak Attack"] = {
  244.             head="Pill. Bonnet +1",
  245.             body="Pillager's Vest +1",
  246.             hands="Raider's Armlets +2",
  247.             legs="Pill. Culottes +1",
  248.             feet="Plun. Poulaines +1"}
  249.     sets.JA["Trick Attack"] = set_combine(sets.JA["Sneak Attack"],{hands="Pill. Armlets +1"})
  250.  
  251.     -- Step Set --
  252.     sets.Step = set_combine({},TH_Gear)
  253.  
  254.     -- Flourish Set --
  255.     sets.Flourish = set_combine({},TH_Gear)
  256.  
  257.     -- Waltz Set --
  258.     sets.Waltz = {}
  259.  
  260.     sets.Precast = {}
  261.     -- Fastcast Set --
  262.     sets.Precast.FastCast = {
  263.             head="Haruspex Hat +1",
  264.             neck="Orunmila's Torque",
  265.             ear1="Loquac. Earring",
  266.             hands="Thaumas Gloves",
  267.             ring1="Prolix Ring",
  268.             ring2="Veneficium Ring",
  269.             legs="Enif Cosciales"}
  270.     -- Utsusemi Precast Set --
  271.     sets.Precast.Utsusemi = set_combine(sets.Precast.FastCast,{neck="Magoraga Beads"})
  272.  
  273.     sets.Midcast = {}
  274.     -- Magic Haste Set --
  275.     sets.Midcast.Haste = set_combine(sets.PDT,{})
  276. end
  277.  
  278. function pretarget(spell,action)
  279.     if (spell.type:endswith('Magic') or spell.type == "Ninjutsu") and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
  280.         cancel_spell()
  281.         send_command('input /item "Echo Drops" <me>')
  282.     elseif spell.english == "Berserk" and buffactive.Berserk then -- Change Berserk To Aggressor If Berserk Is On --
  283.         cancel_spell()
  284.         send_command('Aggressor')
  285.     elseif (spell.english == 'Ranged' and spell.target.distance > 24.9) or (spell.type == "WeaponSkill" and spell.target.distance > target_distance and player.status == 'Engaged') then -- Cancel Ranged Attack or WS If You Are Out Of Range --
  286.         cancel_spell()
  287.         add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  288.         return
  289.     end
  290. end
  291.  
  292. function precast(spell,action)
  293.     if spell.type == "WeaponSkill" then
  294.         if player.status ~= 'Engaged' then -- Cancel WS If You Are Not Engaged. Can Delete It If You Don't Need It --
  295.             cancel_spell()
  296.             add_to_chat(123,'Unable To Use WeaponSkill: [Disengaged]')
  297.             return
  298.         else
  299.             equipSet = sets.WS
  300.             if equipSet[spell.english] then
  301.                 equipSet = equipSet[spell.english]
  302.             end
  303.             if SA and equipSet["SA"] then
  304.                 equipSet = equipSet["SA"]
  305.             end
  306.             if TA and equipSet["TA"] then
  307.                 equipSet = equipSet["TA"]
  308.             end
  309.             if spell.english == "Evisceration" and player.tp > 299 then -- Equip Jupiter's Pearl When You Have 300 TP --
  310.                 equipSet = set_combine(equipSet,{ear1="Jupiter's Pearl"})
  311.             end
  312.             equip(equipSet)
  313.         end
  314.     elseif spell.type=="JobAbility" then
  315.         if sets.JA[spell.english] then
  316.             equip(sets.JA[spell.english])
  317.         end
  318.     elseif spell.type:endswith('Magic') or spell.type == "Ninjutsu" then
  319.         if string.find(spell.english,'Utsusemi') then
  320.             if buffactive['Copy Image (3)'] or buffactive['Copy Image (4)'] then
  321.                 cancel_spell()
  322.                 add_to_chat(123, spell.name .. ' Canceled: [3+ Images]')
  323.                 return
  324.             else
  325.                 equip(sets.Precast.Utsusemi)
  326.             end
  327.         else
  328.             equip(sets.Precast.FastCast)
  329.         end
  330.     elseif spell.type == 'Step' then
  331.         equip(sets.Step)
  332.     elseif string.find(spell.type,'Flourish') then
  333.         equip(sets.Flourish)
  334.     elseif spell.type == "Waltz" then
  335.         refine_waltz(spell,action)
  336.         equip(sets.Waltz)
  337.     elseif spell.english == 'Spectral Jig' and buffactive.Sneak then
  338.         cast_delay(0.2)
  339.         send_command('cancel Sneak')
  340.     end
  341.     if Mecisto == 'ON' then
  342.         equip(sets.Mecisto)                
  343.     end
  344. end
  345.  
  346. function midcast(spell,action)
  347.     if spell.english == 'Ranged' then
  348.         equip(TH_Gear)
  349.     elseif spell.type:endswith('Magic') or spell.type == "Ninjutsu" then
  350.         if string.find(spell.english,'Utsusemi') then
  351.             if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)']) then
  352.                 send_command('@wait 1.7;cancel Copy Image*')
  353.             end
  354.             equip(sets.Midcast.Haste)
  355.         elseif spell.english == 'Monomi: Ichi' then
  356.             if buffactive['Sneak'] then
  357.                 send_command('@wait 1.7;cancel sneak')
  358.             end
  359.             equip(sets.Midcast.Haste)
  360.         else
  361.             equip(sets.Midcast.Haste)
  362.         end
  363.     end
  364. end
  365.  
  366. function aftercast(spell,action)
  367.     if spell.type == "WeaponSkill" and not spell.interrupted then
  368.         send_command('wait 0.2;gs c TP')
  369.     end
  370.     status_change(player.status)
  371. end
  372.  
  373. function status_change(new,old)
  374.     if player.equipment.range ~= 'empty' then
  375.         disable('range','ammo')
  376.     else
  377.         enable('range','ammo')
  378.     end
  379.     if Armor == 'PDT' then
  380.         equip(sets.PDT)
  381.     elseif Armor == 'MDT' then
  382.         equip(sets.MDT)
  383.     elseif Armor == 'EVA' then
  384.         equip(sets.Evasion)
  385.     elseif new == 'Engaged' then
  386.         equipSet = sets.TP
  387.         if Armor == 'Hybrid' and equipSet["Hybrid"] then
  388.             equipSet = equipSet["Hybrid"]
  389.         end
  390.         if equipSet[AccArray[AccIndex]] then
  391.             equipSet = equipSet[AccArray[AccIndex]]
  392.         end
  393.         if (buffactive.Embrava and (buffactive.Haste or buffactive.March) and buffactive['Haste Samba']) or (buffactive.March == 2 and buffactive.Haste and buffactive['Haste Samba']) and equipSet["HighHaste"] then
  394.             equipSet = equipSet["HighHaste"]
  395.         end
  396.         if (buffactive.Embrava and (buffactive.Haste or buffactive.March or buffactive['Haste Samba'])) or (buffactive.March == 1 and buffactive.Haste and buffactive['Haste Samba'] and equipSet["MidHaste"]) or (buffactive.March == 2 and (buffactive.Haste or buffactive['Haste Samba'])) and equipSet["MidHaste"] then
  397.             equipSet = equipSet["MidHaste"]
  398.         end
  399.         if SA then
  400.             equipSet = set_combine(equipSet,sets.JA["Sneak Attack"])
  401.         end
  402.         if TA then
  403.             equipSet = set_combine(equipSet,sets.JA["Trick Attack"])
  404.         end
  405.         if buffactive.Feint then
  406.             equipSet = set_combine(equipSet,sets.TP.Feint)
  407.         end
  408.         if Mecisto == 'ON' then
  409.             equipSet = set_combine(sets.Mecisto)
  410.         end
  411.         if TH == 'ON' then -- Use TH Toggle To Lock Full TH Set --
  412.             equipSet = set_combine(equipSet,sets.TP.TH)
  413.         end
  414.         equip(equipSet)
  415.     else
  416.         equipSet = sets.Idle
  417.         if equipSet[IdleArray[IdleIndex]] then
  418.             equipSet = equipSet[IdleArray[IdleIndex]]
  419.         end
  420.         if equipSet[WeaponArray[WeaponIndex]] then
  421.             equipSet = equipSet[WeaponArray[WeaponIndex]]
  422.         end
  423.         equip(equipSet)
  424.         if Mecisto == 'ON' then
  425.             equip(sets.Mecisto)        
  426.         end
  427.     end
  428. end
  429.  
  430. function buff_change(buff,gain)
  431.     buff = string.lower(buff)
  432.     if buff == "sneak attack" then
  433.         SA = gain
  434.     elseif buff == "trick attack" then
  435.         TA = gain
  436.     elseif buff == 'weakness' then -- Weakness Timer --
  437.         if gain then
  438.             send_command('timers create "Weakness" 300 up')
  439.         else
  440.             send_command('timers delete "Weakness"')
  441.         end
  442.     end
  443.     if not midaction() then
  444.         status_change(player.status)
  445.     end
  446. end
  447.  
  448. -- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
  449. function self_command(command)
  450.     if command == 'c2' then -- Accuracy Level Toggle --
  451.         AccIndex = (AccIndex % #AccArray) + 1
  452.         status_change(player.status)
  453.         add_to_chat(158,'Accuracy Level: ' .. AccArray[AccIndex])
  454.     elseif command == 'main' then -- Main Weapon Toggle --
  455.         WeaponIndex = (WeaponIndex % #WeaponArray) + 1
  456.         add_to_chat(158,'Main Weapon: '..WeaponArray[WeaponIndex])
  457.         status_change(player.status)
  458.     elseif command == 'C5555' then -- Auto Update Gear Toggle --
  459.         status_change(player.status)
  460.         add_to_chat(158,'Auto Update Gear')
  461.     elseif command == 'c33' then -- Hybrid Toggle --
  462.         if Armor == 'Hybrid' then
  463.             Armor = 'None'
  464.             add_to_chat(123,'Hybrid Set: [Unlocked]')
  465.         else
  466.             Armor = 'Hybrid'
  467.             add_to_chat(158,'Hybrid Set: '..AccArray[AccIndex])
  468.         end
  469.         status_change(player.status)
  470.     elseif command == 'c4' then -- Full TH Set Toggle --
  471.         if TH == 'ON' then
  472.             TH = 'OFF'
  473.             add_to_chat(123,'Full TH Set: [Unlocked]')
  474.         else
  475.             TH = 'ON'
  476.             add_to_chat(158,'Full TH Set: [Locked]')
  477.         end
  478.         status_change(player.status)
  479.     elseif command == 'c5' then -- PDT Toggle --
  480.         if Armor == 'PDT' then
  481.             Armor = 'None'
  482.             add_to_chat(123,'PDT Set: [Unlocked]')
  483.         else
  484.             Armor = 'PDT'
  485.             add_to_chat(158,'PDT Set: [Locked]')
  486.         end
  487.         status_change(player.status)
  488.     elseif command == 'C15' then -- MDT Toggle --
  489.         if Armor == 'MDT' then
  490.             Armor = 'None'
  491.             add_to_chat(123,'MDT Set: [Unlocked]')
  492.         else
  493.             Armor = 'MDT'
  494.             add_to_chat(158,'MDT Set: [Locked]')
  495.         end
  496.         status_change(player.status)
  497.     elseif command == 'c6' then -- Evasion Toggle --
  498.         if Armor == 'EVA' then
  499.             Armor = 'None'
  500.             add_to_chat(123,'Evasion Set: [Unlocked]')
  501.         else
  502.             Armor = 'EVA'
  503.             add_to_chat(158,'Evasion Set: [Locked]')
  504.         end
  505.         status_change(player.status)
  506.     elseif command == 'c3' then -- Mecisto. Mantle Toggle --
  507.         if Mecisto == 'ON' then
  508.             Mecisto = 'OFF'            
  509.             add_to_chat(123,'Mecisto. Mantle: [Unlocked]')
  510.         else
  511.             Mecisto = 'ON'             
  512.             add_to_chat(158,'Mecisto. Mantle: [Locked]')
  513.         end
  514.         status_change(player.status)   
  515.     elseif command == 'C8' then -- Distance Toggle --
  516.         if player.target.distance then
  517.             target_distance = math.floor(player.target.distance*10)/10
  518.             add_to_chat(158,'Distance: '..target_distance)
  519.         else
  520.             add_to_chat(123,'No Target Selected')
  521.         end
  522.     elseif command == 'c1' then -- Idle Toggle --
  523.         IdleIndex = (IdleIndex % #IdleArray) + 1
  524.         status_change(player.status)
  525.         add_to_chat(158,'Idle Set: ' .. IdleArray[IdleIndex])
  526.     elseif command == 'TP' then
  527.         add_to_chat(158,'TP Return: ['..tostring(player.tp)..']')
  528.     elseif command:match('^SC%d$') then
  529.         send_command('//' .. sc_map[command])
  530.     end
  531. end
  532.  
  533. function refine_waltz(spell,action)
  534.     if spell.type ~= 'Waltz' then
  535.         return
  536.     end
  537.  
  538.     if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" or spell.name == "Divine Waltz II" then
  539.         return
  540.     end
  541.  
  542.     local newWaltz = spell.english
  543.     local waltzID
  544.  
  545.     local missingHP
  546.  
  547.     if spell.target.type == "SELF" then
  548.         missingHP = player.max_hp - player.hp
  549.     elseif spell.target.isallymember then
  550.         local target = find_player_in_alliance(spell.target.name)
  551.         local est_max_hp = target.hp / (target.hpp/100)
  552.         missingHP = math.floor(est_max_hp - target.hp)
  553.     end
  554.  
  555.     if missingHP ~= nil then
  556.         if player.sub_job == 'DNC' then
  557.             if missingHP < 40 and spell.target.name == player.name then
  558.                 add_to_chat(123,'Full HP!')
  559.                 cancel_spell()
  560.                 return
  561.             elseif missingHP < 150 then
  562.                 newWaltz = 'Curing Waltz'
  563.                 waltzID = 190
  564.             elseif missingHP < 300 then
  565.                 newWaltz = 'Curing Waltz II'
  566.                 waltzID = 191
  567.             else
  568.                 newWaltz = 'Curing Waltz III'
  569.                 waltzID = 192
  570.             end
  571.         else
  572.             return
  573.         end
  574.     end
  575.  
  576.     local waltzTPCost = {['Curing Waltz'] = 20, ['Curing Waltz II'] = 35, ['Curing Waltz III'] = 50}
  577.     local tpCost = waltzTPCost[newWaltz]
  578.  
  579.     local downgrade
  580.  
  581.     if player.tp < tpCost and not buffactive.trance then
  582.  
  583.         if player.tp < 20 then
  584.             add_to_chat(123, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
  585.             cancel_spell()
  586.             return
  587.         elseif player.tp < 35 then
  588.             newWaltz = 'Curing Waltz'
  589.         elseif player.tp < 50 then
  590.             newWaltz = 'Curing Waltz II'
  591.         end
  592.  
  593.         downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
  594.     end
  595.  
  596.     if newWaltz ~= spell.english then
  597.         send_command('@input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
  598.         if downgrade then
  599.             add_to_chat(158, downgrade)
  600.         end
  601.         cancel_spell()
  602.         return
  603.     end
  604.  
  605.     if missingHP > 0 then
  606.         add_to_chat(158,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
  607.     end
  608. end
  609.  
  610. function find_player_in_alliance(name)
  611.     for i,v in ipairs(alliance) do
  612.         for k,p in ipairs(v) do
  613.             if p.name == name then
  614.                 return p
  615.             end
  616.         end
  617.     end
  618. end
  619.  
  620. function sub_job_change(newSubjob, oldSubjob)
  621.     select_default_macro_book()
  622. end
  623.  
  624. function set_macro_page(set,book)
  625.     if not tonumber(set) then
  626.         add_to_chat(123,'Error setting macro page: Set is not a valid number ('..tostring(set)..').')
  627.         return
  628.     end
  629.     if set < 1 or set > 10 then
  630.         add_to_chat(123,'Error setting macro page: Macro set ('..tostring(set)..') must be between 1 and 10.')
  631.         return
  632.     end
  633.  
  634.     if book then
  635.         if not tonumber(book) then
  636.             add_to_chat(123,'Error setting macro page: book is not a valid number ('..tostring(book)..').')
  637.             return
  638.         end
  639.         if book < 1 or book > 20 then
  640.             add_to_chat(123,'Error setting macro page: Macro book ('..tostring(book)..') must be between 1 and 20.')
  641.             return
  642.         end
  643.         send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(set))
  644.     else
  645.         send_command('@input /macro set '..tostring(set))
  646.     end
  647. end
  648.  
  649. function select_default_macro_book()
  650.     -- Default macro set/book
  651.     if player.sub_job == 'WAR' then
  652.         set_macro_page(1, 2)
  653.     elseif player.sub_job == 'DNC' then
  654.         set_macro_page(1, 2)
  655.     elseif player.sub_job == 'NIN' then
  656.         set_macro_page(1, 2)
  657.     else
  658.         set_macro_page(1, 2)
  659.     end
  660. end
Advertisement
Add Comment
Please, Sign In to add comment