Advertisement
Amadis

THF lua

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