Advertisement
Bokura

Bokura_COR

Jan 19th, 2014
1,797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.95 KB | None | 0 0
  1. -- *** Credit goes to Flippant for helping me with Gearswap *** --
  2. -- ** I Use Some of Motenten's Functions ** --
  3.  
  4. function get_sets()
  5.     AccIndex = 1
  6.     AccArray = {"LowACC","MidACC","HighACC"} -- 3 Levels Of Accuracy Sets For Shooting/QD/TP/WS. 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 --
  7.     IdleIndex = 1
  8.     IdleArray = {'Movement', 'Regen'} -- Default Idle Set Is Movement --
  9.     Armor = 'None'
  10.     define_roll_values()
  11.     warning = false
  12.     Lock_Main = 'OFF' -- Set Default Lock Main Weapon ON or OFF Here --
  13.     AutoGunWS = "Last Stand" -- Set Auto Gun WS Here --
  14.     AutoMode = 'OFF' -- Set Default Auto RA/WS ON or OFF Here --
  15.     Obi = 'ON' -- Turn Default Obi ON or OFF Here --
  16.     ammo_warning_limit = 10 -- Set Ammo Limit Check Here --
  17.     target_distance = 5 -- Set Default Distance Here --
  18.     select_default_macro_book() -- Change Default Macro Book At The End --
  19.  
  20.     ACC_Shots = S{"Light Shot","Dark Shot"}
  21.  
  22.     Cure_Spells = {"Cure","Cure II","Cure III","Cure IV"} -- Cure Degradation --
  23.     Curaga_Spells = {"Curaga","Curaga II"} -- Curaga Degradation --
  24.     sc_map = {SC1="CoursersRoll", SC2="DiaII", SC3="LightShot"} -- 3 Additional Binds. Can Change Whatever JA/WS/Spells You Like Here. Remember Not To Use Spaces. --
  25.  
  26.     -- Idle/Town Sets --
  27.     sets.Idle = {}
  28.     sets.Idle.Regen = {}
  29.     sets.Idle.Movement = set_combine(sets.Idle.Regen,{})
  30.  
  31.     -- QD Sets --
  32.     sets.QD = {}
  33.     sets.QD.MidACC = set_combine(sets.QD,{})
  34.     sets.QD.HighACC = set_combine(sets.QD.MidACC,{})
  35.  
  36.     -- PDT/MDT Sets --
  37.     sets.PDT = {}
  38.  
  39.     sets.MDT = set_combine(sets.PDT,{})
  40.  
  41.     -- Roll Set --
  42.     sets.Rolls = set_combine(sets.PDT,{
  43.             head="Lanun Tricorne +1",
  44.             hands="Chasseur's Gants +1",
  45.             ring1="Luzaf's Ring",
  46.             ring2="Barataria Ring"})
  47.  
  48.     -- Preshot --
  49.     sets.Preshot = {}
  50.  
  51.     -- Shooting Base Set --
  52.     sets.Midshot = {}
  53.  
  54.     -- Death Penalty Sets --
  55.     sets.Midshot['Death Penalty'] = {}
  56.     sets.Midshot['Death Penalty'].MidACC = set_combine(sets.Midshot['Death Penalty'],{})
  57.     sets.Midshot['Death Penalty'].HighACC = set_combine(sets.Midshot['Death Penalty'].MidACC,{})
  58.  
  59.     -- Armageddon Sets --
  60.     sets.Midshot.Armageddon = {}
  61.     sets.Midshot.Armageddon.MidACC = set_combine(sets.Midshot.Armageddon,{})
  62.     sets.Midshot.Armageddon.HighACC = set_combine(sets.Midshot.Armageddon.MidACC,{})
  63.  
  64.     -- Vanir Gun Sets --
  65.     sets.Midshot['Vanir Gun'] = {}
  66.     sets.Midshot['Vanir Gun'].MidACC = set_combine(sets.Midshot['Vanir Gun'],{})
  67.     sets.Midshot['Vanir Gun'].HighACC = set_combine(sets.Midshot['Vanir Gun'].MidACC,{})
  68.  
  69.     -- Melee Sets --
  70.     sets.Melee = {}
  71.     sets.Melee.MidACC = set_combine(sets.Melee,{})
  72.     sets.Melee.HighACC = set_combine(sets.Melee.MidACC,{})
  73.  
  74.     -- WS Base Set --
  75.     sets.WS = {}
  76.  
  77.     -- Last Stand Sets --
  78.     sets.WS["Last Stand"] = {}
  79.     sets.WS["Last Stand"].MidACC = set_combine(sets.WS["Last Stand"],{})
  80.     sets.WS["Last Stand"].HighACC = set_combine(sets.WS["Last Stand"].MidACC,{})
  81.  
  82.     -- Wildfire Sets --
  83.     sets.WS.Wildfire = {}
  84.     sets.WS.Wildfire.MidACC = set_combine(sets.WS.Wildfire,{})
  85.     sets.WS.Wildfire.HighACC = set_combine(sets.WS.Wildfire.MidACC,{})
  86.  
  87.     -- Leaden Salute Sets --
  88.     sets.WS['Leaden Salute'] = {}
  89.     sets.WS['Leaden Salute'].MidACC = set_combine(sets.WS['Leaden Salute'],{})
  90.     sets.WS['Leaden Salute'].HighACC = set_combine(sets.WS['Leaden Salute'].MidACC,{})
  91.  
  92.     -- Elemental Obi --
  93.     sets.Obi = {}
  94.     sets.Obi.Lightning = {waist='Hachirin-no-Obi'}
  95.     sets.Obi.Water = {waist='Hachirin-no-Obi'}
  96.     sets.Obi.Fire = {waist='Hachirin-no-Obi'}
  97.     sets.Obi.Ice = {waist='Hachirin-no-Obi'}
  98.     sets.Obi.Wind = {waist='Hachirin-no-Obi'}
  99.     sets.Obi.Earth = {waist='Hachirin-no-Obi'}
  100.     sets.Obi.Light = {waist='Hachirin-no-Obi'}
  101.     sets.Obi.Dark = {waist='Hachirin-no-Obi'}
  102.  
  103.     -- JA Sets --
  104.     sets.JA = {}
  105.     sets.JA["Random Deal"] = {body="Lanun Frac +1"}
  106.     sets.JA.Fold = {hands="Lanun Gauntlets +1"}
  107.     sets.JA["Snake Eye"] = {legs="Lanun Culottes +1"}
  108.     sets.JA["Wild Card"] = {feet="Lanun Boots +1"}
  109.  
  110.     -- Waltz Set --
  111.     sets.Waltz = {}
  112.  
  113.     sets.Precast = {}
  114.     --Fastcast Set --
  115.     sets.Precast.FastCast = {}
  116.  
  117.     sets.Midcast = {}
  118.     -- Magic Haste Set --
  119.     sets.Midcast.Haste = set_combine(sets.PDT,{})
  120.  
  121.     -- Cure Set --
  122.     sets.Midcast.Cure = {}
  123. end
  124.  
  125. function pretarget(spell,action)
  126.     if spell.action_type == 'Magic' and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
  127.         cancel_spell()
  128.         send_command('input /item "Echo Drops" <me>')
  129.     elseif spell.type == "CorsairRoll" and buffactive[spell.english] then -- Change Any Rolls To Double-Up When You Have A Roll Up --
  130.         cancel_spell()
  131.         send_command('doubleup')
  132.     elseif spell.english == "Seigan" and buffactive.Seigan then -- Change Seigan To Third Eye If Seigan Is On --
  133.         cancel_spell()
  134.         send_command('ThirdEye')
  135.     elseif spell.english == "Meditate" and player.tp > 2900 then -- Cancel Meditate If TP Is Above 2900 --
  136.         cancel_spell()
  137.         add_to_chat(123, spell.name .. ' Canceled: ' .. player.tp)
  138.     elseif spell.action_type == 'Ranged Attack' then
  139.         if spell.target.distance > 24.9 then -- Cancel Ranged Attack If You Are Out Of Range --
  140.             cancel_spell()
  141.             add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  142.             return
  143.         else
  144.             if AutoMode == 'ON' and not buffactive.amnesia then -- Auto WS/Triple Shot --
  145.                 if player.tp >= 1000 then
  146.                     cancel_spell()
  147.                     autoWS()
  148.                 elseif windower.ffxi.get_ability_recasts()[84] < 1 then
  149.                     cancel_spell()
  150.                     send_command('TripleShot')
  151.                 end
  152.             end
  153.         end
  154.     elseif spell.type == 'WeaponSkill' and player.status == 'Engaged' then
  155.         if spell.skill == 'Marksmanship' then
  156.             if spell.target.distance > 16+target_distance then
  157.                 cancel_spell()
  158.                 add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  159.                 return
  160.             end
  161.         else
  162.             if spell.target.distance > target_distance then
  163.                 cancel_spell()
  164.                 add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  165.                 return
  166.             end
  167.         end
  168.     end
  169. end
  170.  
  171. function precast(spell,action)
  172.     if spell.action_type == 'Ranged Attack' or spell.type == "WeaponSkill" then
  173.         if player.equipment.ammo == "Animikii Bullet" then -- Cancel Ranged Attack or WS If You Have Animikii Bullet Equipped --
  174.             cancel_spell()
  175.             add_to_chat(123, spell.name .. ' Canceled: [Animikii Bullet Equipped!]')
  176.             return
  177.         else
  178.             local check_ammo
  179.             local check_ammo_count = 1
  180.             if spell.action_type == 'Ranged Attack' then
  181.                 check_ammo = player.equipment.ammo
  182.                 if player.equipment.ammo == 'empty' or player.inventory[check_ammo].count <= check_ammo_count then
  183.                     add_to_chat(123, spell.name..' Canceled: [Out of Ammo]')
  184.                     cancel_spell()
  185.                     return
  186.                 else
  187.                     equip(sets.Preshot,(buffactive["Triple Shot"] and {body="Chasseur's Frac +1"} or {}))
  188.                     if player.inventory[check_ammo].count <= ammo_warning_limit and player.inventory[check_ammo].count > 1 and not warning then
  189.                         add_to_chat(8, '***** [Low Ammo Warning!] *****')
  190.                         warning = true
  191.                     elseif player.inventory[check_ammo].count > ammo_warning_limit and warning then
  192.                         warning = false
  193.                     end
  194.                 end
  195.             elseif spell.type == "WeaponSkill" then
  196.                 if player.status ~= 'Engaged' then -- Cancel WS If You Are Not Engaged. Can Delete It If You Don't Need It --
  197.                     cancel_spell()
  198.                     add_to_chat(123,'Unable To Use WeaponSkill: [Disengaged]')
  199.                     return
  200.                 else
  201.                     equipSet = sets.WS
  202.                     if equipSet[spell.english] then
  203.                         equipSet = equipSet[spell.english]
  204.                     end
  205.                     if equipSet[AccArray[AccIndex]] then
  206.                         equipSet = equipSet[AccArray[AccIndex]]
  207.                     end
  208.                     if buffactive['Reive Mark'] then -- Equip Ygnas's Resolve +1 During Reive --
  209.                         equipSet = set_combine(equipSet,{neck="Ygnas's Resolve +1"})
  210.                     end
  211.                     if spell.english == "Last Stand" and (player.tp > 2990 or buffactive.Sekkanoki) then -- Equip Altdorf's Earring and Wilhelm's Earring When You Have 3000 TP or Sekkanoki For Last Stand --
  212.                         equipSet = set_combine(equipSet,{ear1="Altdorf's Earring",ear2="Wilhelm's Earring"})
  213.                     end
  214.                     equip(equipSet)
  215.                 end
  216.             end
  217.         end
  218.     elseif spell.type == "JobAbility" then
  219.         if sets.JA[spell.english] then
  220.             equip(sets.JA[spell.english])
  221.             if spell.english == "Snake Eye" then -- Auto Double-Up After You Use Snake Eye --
  222.                 send_command('@wait 1;input /ja Double-Up <me>')
  223.             end
  224.         end
  225.     elseif spell.type == "CorsairRoll" or spell.english == "Double-Up" then
  226.         equip(sets.Rolls)
  227.         if spell.english == "Tactician's Roll" then -- Change Tactician's Roll Equipment Here --
  228.             equip({body="Chasseur's Frac +1"})
  229.         elseif spell.english == "Caster's Roll" then -- Change Caster's Roll Equipment Here --
  230.             equip({legs="Chas. Culottes +1"})
  231.         elseif spell.english == "Courser's Roll" then -- Change Courser's Roll Equipment Here --
  232.             equip({feet="Chass. Bottes +1"})
  233.         elseif spell.english == "Blitzer's Roll" then -- Change Blitzer's Roll Equipment Here --
  234.             equip({head="Chass. Tricorne +1"})
  235.         elseif spell.english == "Allies' Roll" then -- Change Allies' Roll Equipment Here --
  236.             equip({hands="Chasseur's Gants +1"})
  237.         end
  238.     elseif spell.type == "CorsairShot" then
  239.         equipSet = sets.QD
  240.         if ACC_Shots:contains(spell.english) then
  241.             equipSet = sets.QD.HighACC
  242.         else
  243.             if equipSet[AccArray[AccIndex]] then
  244.                 equipSet = equipSet[AccArray[AccIndex]]
  245.             end
  246.             if not ACC_Shots:contains(spell.english) and (world.day_element == spell.element or world.weather_element == spell.element) and sets.Obi[spell.element] and Obi == 'ON' then -- Use Obi Toggle To Unlock Elemental Obi --
  247.                 equipSet = set_combine(equipSet,sets.Obi[spell.element])
  248.             end
  249.         end
  250.         equip(equipSet)
  251.     elseif spell.action_type == 'Magic' then
  252.         if spell.english == 'Utsusemi: Ni' then
  253.             if buffactive['Copy Image (3)'] then
  254.                 cancel_spell()
  255.                 add_to_chat(123, spell.name .. ' Canceled: [3 Images]')
  256.                 return
  257.             else
  258.                 equip(sets.Precast.FastCast)
  259.             end
  260.         else
  261.             equip(sets.Precast.FastCast)
  262.         end
  263.     elseif spell.type == "Waltz" then
  264.         refine_waltz(spell,action)
  265.         equip(sets.Waltz)
  266.     elseif spell.english == 'Spectral Jig' and buffactive.Sneak then
  267.         cast_delay(0.2)
  268.         send_command('cancel Sneak')
  269.     end
  270. end
  271.  
  272. function midcast(spell,action)
  273.     if spell.action_type == 'Ranged Attack' then
  274.         equipSet = sets.Midshot
  275.         if equipSet[player.equipment.range] then
  276.             equipSet = equipSet[player.equipment.range]
  277.         end
  278.         if equipSet[AccArray[AccIndex]] then
  279.             equipSet = equipSet[AccArray[AccIndex]]
  280.         end
  281.         if bufactive["Triple Shot"] then
  282.             equipSet = set_combine(equipSet,{body="Chasseur's Frac +1"})
  283.         end
  284.         equip(equipSet)
  285.     elseif spell.action_type == 'Magic' then
  286.         if spell.english:startswith('Cur') and spell.english ~= "Cursna" then
  287.             equip(sets.Midcast.Cure)
  288.         elseif spell.english == "Stoneskin" then
  289.             if buffactive.Stoneskin then
  290.                 send_command('@wait 2.8;cancel stoneskin')
  291.             end
  292.             equip(sets.Midcast.Stoneskin)
  293.         elseif spell.english == "Sneak" then
  294.             if spell.target.name == player.name and buffactive['Sneak'] then
  295.                 send_command('cancel sneak')
  296.             end
  297.             equip(sets.Midcast.Haste)
  298.         elseif spell.english:startswith('Utsusemi') then
  299.             if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)'] or buffactive['Copy Image (3)']) then
  300.                 send_command('@wait 1.7;cancel Copy Image*')
  301.             end
  302.             equip(sets.Midcast.Haste)
  303.         elseif spell.english == 'Monomi: Ichi' then
  304.             if buffactive['Sneak'] then
  305.                 send_command('@wait 1.7;cancel sneak')
  306.             end
  307.             equip(sets.Midcast.Haste)
  308.         else
  309.             equip(sets.Midcast.Haste)
  310.         end
  311.     end
  312. end
  313.  
  314. function aftercast(spell,action)
  315.     if spell.action_type == 'Ranged Attack' and AutoMode == 'ON' then
  316.         autoRA()
  317.     else
  318.         status_change(player.status)
  319.     end
  320.     if not spell.interrupted then
  321.         if spell.type == "WeaponSkill" then
  322.             send_command('wait 0.2;gs c TP')
  323.         elseif spell.type == 'CorsairRoll' then
  324.             display_roll_info(spell)
  325.         elseif spell.english == 'Light Shot' then -- Sleep Countdown --
  326.             send_command('wait 50;input /echo '..spell.name..' Effect: [WEARING OFF IN 10 SEC.];wait 10;input /echo '..spell.name..' Effect: [OFF]')
  327.         end
  328.     end
  329. end
  330.  
  331. function status_change(new,old)
  332.     check_equip_lock()
  333.     if Armor == 'PDT' then
  334.         equip(sets.PDT)
  335.     elseif Armor == 'MDT' then
  336.         equip(sets.MDT)
  337.     elseif new == 'Engaged' then
  338.         equipSet = sets.Melee
  339.         if equipSet[AccArray[AccIndex]] then
  340.             equipSet = equipSet[AccArray[AccIndex]]
  341.         end
  342.         if buffactive['Reive Mark'] then -- Equip Ygnas's Resolve +1 During Reive --
  343.             equipSet = set_combine(equipSet,{neck="Ygnas's Resolve +1"})
  344.         end
  345.         if world.area:endswith('Adoulin') then
  346.             equipSet = set_combine(equipSet,{body="Councilor's Garb"})
  347.         end
  348.         equip(equipSet)
  349.     elseif new == 'Idle' then
  350.         equip(sets.Idle[IdleArray[IdleIndex]])
  351.     elseif new == 'Resting' then
  352.         equip(sets.Resting)
  353.     end
  354. end
  355.  
  356. function buff_change(buff,gain)
  357.     buff = string.lower(buff)
  358.     if buff == "aftermath: lv.3" then -- AM3 Timer/Countdown --
  359.         if gain then
  360.             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.]')
  361.         else
  362.             send_command('timers delete "Aftermath: Lv.3"')
  363.             add_to_chat(123,'AM3: [OFF]')
  364.         end
  365.     elseif buff == 'weakness' then -- Weakness Timer --
  366.         if gain then
  367.             send_command('timers create "Weakness" 300 up')
  368.         else
  369.             send_command('timers delete "Weakness"')
  370.         end
  371.     end
  372.     if not midaction() then
  373.         status_change(player.status)
  374.     end
  375. end
  376.  
  377. -- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
  378. function self_command(command)
  379.     if command == 'C1' then -- Accuracy Level Toggle --
  380.         AccIndex = (AccIndex % #AccArray) + 1
  381.         status_change(player.status)
  382.         add_to_chat(158,'Accuracy Level: ' .. AccArray[AccIndex])
  383.     elseif command == 'C5' then -- Auto Update Gear Toggle --
  384.         status_change(player.status)
  385.         add_to_chat(158,'Auto Update Gear')
  386.     elseif command == 'C3' then -- Obi Toggle --
  387.         if Obi == 'ON' then
  388.             Obi = 'OFF'
  389.             add_to_chat(123,'Obi: [OFF]')
  390.         else
  391.             Obi = 'ON'
  392.             add_to_chat(158,'Obi: [ON]')
  393.         end
  394.         status_change(player.status)
  395.     elseif command == 'C7' then -- PDT Toggle --
  396.         if Armor == 'PDT' then
  397.             Armor = 'None'
  398.             add_to_chat(123,'PDT Set: [Unlocked]')
  399.         else
  400.             Armor = 'PDT'
  401.             add_to_chat(158,'PDT Set: [Locked]')
  402.         end
  403.         status_change(player.status)
  404.     elseif command == 'C15' then -- MDT Toggle --
  405.         if Armor == 'MDT' then
  406.             Armor = 'None'
  407.             add_to_chat(123,'MDT Set: [Unlocked]')
  408.         else
  409.             Armor = 'MDT'
  410.             add_to_chat(158,'MDT Set: [Locked]')
  411.         end
  412.         status_change(player.status)
  413.     elseif command == 'C17' then -- Lock Main Weapon Toggle --
  414.         if Lock_Main == 'ON' then
  415.             Lock_Main = 'OFF'
  416.             add_to_chat(123,'Main Weapon: [Unlocked]')
  417.         else
  418.             Lock_Main = 'ON'
  419.             add_to_chat(158,'Main Weapon: [Locked]')
  420.         end
  421.         status_change(player.status)
  422.     elseif command == 'C8' then -- Distance Toggle --
  423.         if player.target.distance then
  424.             target_distance = math.floor(player.target.distance*10)/10
  425.             add_to_chat(158,'Distance: '..target_distance)
  426.         else
  427.             add_to_chat(123,'No Target Selected')
  428.         end
  429.     elseif command == 'C6' then -- Idle Toggle --
  430.         IdleIndex = (IdleIndex % #IdleArray) + 1
  431.         status_change(player.status)
  432.         add_to_chat(158,'Idle Set: ' .. IdleArray[IdleIndex])
  433.     elseif command == 'C2' then -- Auto RA/WS Toggle. *Don't Rely On This. It Isn't As Fast As Shooting Manually. It Is Mainly For AFK or When You Dualbox* --
  434.         if AutoMode == 'ON' then
  435.             AutoMode = 'OFF'
  436.             add_to_chat(123,'Auto Mode: [OFF]')
  437.         else
  438.             AutoMode = 'ON'
  439.             add_to_chat(158,'Auto Mode: [ON]')
  440.         end
  441.     elseif command == 'TP' then
  442.         add_to_chat(158,'TP Return: ['..tostring(player.tp)..']')
  443.     elseif command:match('^SC%d$') then
  444.         send_command('//' .. sc_map[command])
  445.     end
  446. end
  447.  
  448. function check_equip_lock() -- Lock Equipment Here --
  449.     if player.equipment.left_ring == "Warp Ring" or player.equipment.left_ring == "Capacity Ring" or player.equipment.right_ring == "Warp Ring" or player.equipment.right_ring == "Capacity Ring" then
  450.         disable('ring1','ring2')
  451.     elseif player.equipment.back == "Mecisto. Mantle" or player.equipment.back == "Aptitude Mantle +1" or player.equipment.back == "Aptitude Mantle" then
  452.         disable('back')
  453.     elseif Lock_Main == 'ON' then
  454.         disable('main','sub')
  455.     else
  456.         enable('main','sub','ring1','ring2','back')
  457.     end
  458. end
  459.  
  460. function autoRA() -- Make Auto RA Delay Adjustment Here --
  461.     local delay = '2.2'
  462.     if spell.type == "WeaponSkill" then
  463.         delay = '2.25'
  464.     else
  465.         if buffactive["Courser's Roll"] then
  466.             delay = '0.7'
  467.         elseif buffactive[581] then -- Flurry II --
  468.             delay = '0.5'
  469.         else
  470.             delay = '1.05'
  471.         end
  472.     end
  473.     send_command('@wait '..delay..'; input /ra <t>')
  474. end
  475.  
  476. function autoWS()
  477.     send_command('input /ws "'..AutoGunWS..'" <t>')
  478. end
  479.  
  480. function define_roll_values()
  481.     rolls = {
  482.         CorsairsRoll    = {lucky=5, unlucky=9, bonus="Experience Points"},
  483.         NinjaRoll       = {lucky=4, unlucky=8, bonus="Evasion"},
  484.         HuntersRoll     = {lucky=4, unlucky=8, bonus="Accuracy"},
  485.         ChaosRoll       = {lucky=4, unlucky=8, bonus="Attack"},
  486.         MagussRoll      = {lucky=2, unlucky=6, bonus="Magic Defense"},
  487.         HealersRoll     = {lucky=3, unlucky=7, bonus="Cure Potency Received"},
  488.         PuppetRoll      = {lucky=4, unlucky=8, bonus="Pet Magic Accuracy/Attack"},
  489.         ChoralRoll      = {lucky=2, unlucky=6, bonus="Spell Interruption Rate"},
  490.         MonksRoll       = {lucky=3, unlucky=7, bonus="Subtle Blow"},
  491.         BeastRoll       = {lucky=4, unlucky=8, bonus="Pet Attack"},
  492.         SamuraiRoll     = {lucky=2, unlucky=6, bonus="Store TP"},
  493.         EvokersRoll     = {lucky=5, unlucky=9, bonus="Refresh"},
  494.         RoguesRoll      = {lucky=5, unlucky=9, bonus="Critical Hit Rate"},
  495.         WarlocksRoll    = {lucky=4, unlucky=8, bonus="Magic Accuracy"},
  496.         FightersRoll    = {lucky=5, unlucky=9, bonus="Double Attack Rate"},
  497.         DrachenRoll     = {lucky=3, unlucky=7, bonus="Pet Accuracy"},
  498.         GallantsRoll    = {lucky=3, unlucky=7, bonus="Defense"},
  499.         WizardsRoll     = {lucky=5, unlucky=9, bonus="Magic Attack"},
  500.         DancersRoll     = {lucky=3, unlucky=7, bonus="Regen"},
  501.         ScholarsRoll    = {lucky=2, unlucky=6, bonus="Conserve MP"},
  502.         BoltersRoll     = {lucky=3, unlucky=9, bonus="Movement Speed"},
  503.         CastersRoll     = {lucky=2, unlucky=7, bonus="Fast Cast"},
  504.         CoursersRoll    = {lucky=3, unlucky=9, bonus="Snapshot"},
  505.         BlitzersRoll    = {lucky=4, unlucky=9, bonus="Attack Delay"},
  506.         TacticiansRoll  = {lucky=5, unlucky=8, bonus="Regain"},
  507.         AlliessRoll     = {lucky=3, unlucky=10, bonus="Skillchain Damage"},
  508.         MisersRoll      = {lucky=5, unlucky=7, bonus="Save TP"},
  509.         CompanionsRoll  = {lucky=2, unlucky=10, bonus="Pet Regain and Regen"},
  510.         AvengersRoll    = {lucky=4, unlucky=8, bonus="Counter Rate"}
  511.         }
  512. end
  513.  
  514. function display_roll_info(spell)
  515.     rollinfo = rolls[(string.gsub((string.gsub(spell.english, "%'+", "")), "%s+", ""))]
  516.     if rollinfo then
  517.         add_to_chat(158, spell.english..' = '..rollinfo.bonus..'. Lucky Roll is '..
  518.         tostring(rollinfo.lucky)..', Unlucky Roll is '..tostring(rollinfo.unlucky)..'.')
  519.     end
  520. end
  521.  
  522. function refine_waltz(spell,action)
  523.     if spell.type ~= 'Waltz' then
  524.         return
  525.     end
  526.  
  527.     if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" or spell.name == "Divine Waltz II" then
  528.         return
  529.     end
  530.  
  531.     local newWaltz = spell.english
  532.            
  533.     local missingHP = 0
  534.     local targ
  535.  
  536.     if spell.target.type == "SELF" then
  537.         targ = alliance[1][1]
  538.         missingHP = player.max_hp - player.hp
  539.     elseif spell.target.isallymember then
  540.         targ = find_player_in_alliance(spell.target.name)
  541.         local est_max_hp = targ.hp / (targ.hpp/100)
  542.         missingHP = math.floor(est_max_hp - targ.hp)
  543.     end
  544.  
  545.     if targ then
  546.         if player.sub_job == 'DNC' then
  547.             if missingHP < 40 then
  548.                 add_to_chat(123,'Full HP!')
  549.                 cancel_spell()
  550.                 return
  551.             elseif missingHP < 150 then
  552.                 newWaltz = 'Curing Waltz'
  553.             elseif missingHP < 300 then
  554.                 newWaltz = 'Curing Waltz II'
  555.             else
  556.                 newWaltz = 'Curing Waltz III'
  557.             end
  558.         else
  559.             return
  560.         end
  561.     end
  562.  
  563.     local waltzTPCost = {['Curing Waltz'] = 20,['Curing Waltz II'] = 35,['Curing Waltz III'] = 50,['Curing Waltz IV'] = 65,['Curing Waltz V'] = 80}
  564.     local tpCost = waltzTPCost[newWaltz]
  565.     local downgrade
  566.  
  567.     if player.tp < tpCost and not buffactive.trance then       
  568.         if player.tp < 20 then
  569.             add_to_chat(123, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
  570.             cancel_spell()
  571.             return
  572.         elseif player.tp < 35 then
  573.             newWaltz = 'Curing Waltz'
  574.         elseif player.tp < 50 then
  575.             newWaltz = 'Curing Waltz II'
  576.         elseif player.tp < 65 then
  577.             newWaltz = 'Curing Waltz III'
  578.         elseif player.tp < 80 then
  579.             newWaltz = 'Curing Waltz IV'
  580.         end
  581.         downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
  582.     end
  583.  
  584.     if newWaltz ~= spell.english then
  585.         send_command('wait 0.03;input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
  586.         if downgrade then
  587.             add_to_chat(8, downgrade)
  588.         end
  589.         cancel_spell()
  590.         return
  591.     end
  592.  
  593.     if missingHP > 0 then
  594.         add_to_chat(8,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
  595.     end
  596. end
  597.  
  598. function find_player_in_alliance(name)
  599.     for i,v in ipairs(alliance) do
  600.         for k,p in ipairs(v) do
  601.             if p.name == name then
  602.                 return p
  603.             end
  604.         end
  605.     end
  606. end
  607.  
  608. function actualCost(originalCost)
  609.     if buffactive["Penury"] then
  610.         return originalCost*.5
  611.     elseif buffactive["Light Arts"] then
  612.         return originalCost*.9
  613.     else
  614.         return originalCost
  615.     end
  616. end
  617.  
  618. function degrade_spell(spell,degrade_array)
  619.     spell_index = table.find(degrade_array,spell.name)
  620.     if spell_index>1 then
  621.         new_spell = degrade_array[spell_index - 1]
  622.         change_spell(new_spell,spell.target.raw)
  623.         add_to_chat(8,spell.name..' Canceled: ['..player.mp..'/'..player.max_mp..'MP::'..player.mpp..'%] Casting '..new_spell..' instead.')
  624.     end
  625. end
  626.  
  627. function change_spell(spell_name,target)
  628.     cancel_spell()
  629.     send_command('//'..spell_name..' '..target)
  630. end
  631.  
  632. function sub_job_change(newSubjob, oldSubjob)
  633.     select_default_macro_book()
  634. end
  635.  
  636. function set_macro_page(set,book)
  637.     if not tonumber(set) then
  638.         add_to_chat(123,'Error setting macro page: Set is not a valid number ('..tostring(set)..').')
  639.         return
  640.     end
  641.     if set < 1 or set > 10 then
  642.         add_to_chat(123,'Error setting macro page: Macro set ('..tostring(set)..') must be between 1 and 10.')
  643.         return
  644.     end
  645.  
  646.     if book then
  647.         if not tonumber(book) then
  648.             add_to_chat(123,'Error setting macro page: book is not a valid number ('..tostring(book)..').')
  649.             return
  650.         end
  651.         if book < 1 or book > 20 then
  652.             add_to_chat(123,'Error setting macro page: Macro book ('..tostring(book)..') must be between 1 and 20.')
  653.             return
  654.         end
  655.         send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(set))
  656.     else
  657.         send_command('@input /macro set '..tostring(set))
  658.     end
  659. end
  660.  
  661. function select_default_macro_book()
  662.     -- Default macro set/book
  663.     if player.sub_job == 'SAM' then
  664.         set_macro_page(1, 5)
  665.     elseif player.sub_job == 'WHM' then
  666.         set_macro_page(2, 5)
  667.     elseif player.sub_job == 'DNC' then
  668.         set_macro_page(3, 5)
  669.     elseif player.sub_job == 'NIN' then
  670.         set_macro_page(5, 5)
  671.     elseif player.sub_job == 'RDM' then
  672.         set_macro_page(8, 5)
  673.     elseif player.sub_job == 'WAR' then
  674.         set_macro_page(9, 5)
  675.     elseif player.sub_job == 'DRG' then
  676.         set_macro_page(10, 5)
  677.     else
  678.         set_macro_page(1, 5)
  679.     end
  680. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement