Advertisement
Bokura

Bokura_RUN

Mar 11th, 2014
1,417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.35 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 TP/WS/Hybrid. Default ACC Set 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.     target_distance = 5 -- Set Default Distance Here --
  11.     select_default_macro_book() -- Change Default Macro Book At The End --
  12.  
  13.     sc_map = {SC1="Resolution", SC2="Berserk", SC3="Aggressor"} -- 3 Additional Binds. Can Change Whatever JA/WS/Spells You Like Here. Remember Not To Use Spaces. --
  14.  
  15.     sets.Idle = {}
  16.     -- Idle/Town Sets --
  17.     sets.Idle.Regen = {}
  18.     sets.Idle.Movement = set_combine(sets.Idle.Regen,{})
  19.  
  20.     -- TP Sets --
  21.     sets.TP = {}
  22.     sets.TP.MidACC = set_combine(sets.TP,{})
  23.     sets.TP.HighACC = set_combine(sets.TP.MidACC,{})
  24.  
  25.     -- TP Swordplay Set
  26.     sets.TP.Swordplay = {hands="Futhark Mitons +1"}
  27.  
  28.     -- PDT/MDT Sets --
  29.     sets.PDT = {}
  30.  
  31.     sets.MDT = set_combine(sets.PDT,{})
  32.  
  33.     -- Hybrid Sets --
  34.     sets.TP.Hybrid = set_combine(sets.PDT,{})
  35.     sets.TP.Hybrid.MidACC = set_combine(sets.TP.Hybrid,{})
  36.     sets.TP.Hybrid.HighACC = set_combine(sets.TP.Hybrid.MidACC,{})
  37.  
  38.     -- WS Base Set --
  39.     sets.WS = {}
  40.  
  41.     -- WS Sets --
  42.     sets.WS.Resolution = {}
  43.     sets.WS.Resolution.MidACC = set_combine(sets.WS.Resolution,{})
  44.     sets.WS.Resolution.HighACC = set_combine(sets.WS.Resolution.MidACC,{})
  45.  
  46.     sets.WS.Upheaval = {}
  47.     sets.WS.Upheaval.MidACC = set_combine(sets.WS.Upheaval,{})
  48.     sets.WS.Upheaval.HighACC = set_combine(sets.WS.Upheaval.MidACC,{})
  49.  
  50.     -- Enmity Set --
  51.     sets.Enmity = {}
  52.  
  53.     sets.JA = {}
  54.     -- JA Sets --
  55.     sets.JA.Lunge = {}
  56.     sets.JA.Swipe = set_combine(sets.Lunge,{})
  57.     sets.JA.Vallation = set_combine(sets.Enmity,{body="Runeist Coat +1"})
  58.     sets.JA.Swordplay = set_combine(sets.Enmity,{hands="Futhark Mitons +1"})
  59.     sets.JA.Pflug = set_combine(sets.Enmity,{feet="Runeist Bottes +1"})
  60.     sets.JA.Valiance = set_combine(sets.Enmity,{body="Runeist Coat +1"})
  61.     sets.JA.Embolden = set_combine(sets.Enmity,{legs="Futhark Trousers +1"})
  62.     sets.JA.Gambit = set_combine(sets.Enmity,{hands="Runeist Mitons +1"})
  63.     sets.JA.Liement = set_combine(sets.Enmity,{body="Futhark Coat +1"})
  64.     sets.JA["One For All"] = set_combine(sets.Enmity)
  65.     sets.JA.Battuta = set_combine(sets.Enmity,{head="Fu. Bandeau +1"})
  66.     sets.JA.Rayke = set_combine(sets.Enmity,{feet="Futhark Boots +1"})
  67.     sets.JA['Elemental Sforzo'] = set_combine(sets.Enmity,{body="Futhark Coat +1"})
  68.     sets.JA['Vivacious Pulse'] = set_combine(sets.Enmity,{head="Erilaz Galea +1"})
  69.     sets.JA.Provoke = set_combine(sets.Enmity)
  70.     sets.JA.Warcry = set_combine(sets.Enmity)
  71.  
  72.     -- Waltz Set --
  73.     sets.Waltz = {}
  74.  
  75.     -- Flourish --
  76.     sets.Flourish = {}
  77.  
  78.     sets.Precast = {}
  79.     -- Fastcast Set --
  80.     sets.Precast.FastCast = {
  81.             head="Rune. Bandeau +1"}
  82.  
  83.     -- Utsusemi Precast Set --
  84.     sets.Precast.Utsusemi = set_combine(sets.Precast.FastCast,{neck="Magoraga Beads"})
  85.  
  86.     -- Precast Enhancing Magic --
  87.     sets.Precast['Enhancing Magic'] = set_combine(sets.Precast.FastCast,{
  88.             waist="Siegel Sash",
  89.             legs="Futhark Trousers +1"})
  90.  
  91.     -- Midcast Base Set --
  92.     sets.Midcast = {}
  93.  
  94.     -- Magic Haste Set --
  95.     sets.Midcast.Haste = set_combine(sets.PDT,{})
  96.  
  97.     -- Flash Set --
  98.     sets.Midcast.Flash = {}
  99.  
  100.     -- Enhancing Magic --
  101.     sets.Midcast['Enhancing Magic'] = {
  102.             head="Erilaz Galea +1",
  103.             hands="Runeist Mitons +1",
  104.             legs="Futhark Trousers +1"}
  105.  
  106.     -- Stoneskin --
  107.     sets.Midcast.Stoneskin = set_combine(sets.Midcast['Enhancing Magic'],{})
  108.  
  109.     -- Phalanx --
  110.     sets.Midcast.Phalanx = set_combine(sets.Midcast['Enhancing Magic'],{head="Futhark Mitons +1"})
  111.  
  112.     -- Regen --
  113.     sets.Midcast.Regen = {head="Rune. Bandeau +1"}
  114.  
  115.     -- Divine Magic --
  116.     sets.Midcast['Divine Magic'] = {}
  117. end
  118.  
  119. function pretarget(spell,action)
  120.     if spell.action_type == 'Magic' and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
  121.         cancel_spell()
  122.         send_command('input /item "Echo Drops" <me>')
  123.     elseif spell.english == "Berserk" and buffactive.Berserk then -- Change Berserk To Aggressor If Berserk Is On --
  124.         cancel_spell()
  125.         send_command('Aggressor')
  126.     elseif spell.type == "WeaponSkill" and spell.target.distance > target_distance and player.status == 'Engaged' then -- Cancel WS If You Are Out Of Range --
  127.         cancel_spell()
  128.         add_to_chat(123, spell.name..' Canceled: [Out of Range]')
  129.         return
  130.     end
  131. end
  132.  
  133. function precast(spell,action)
  134.     if spell.type == "WeaponSkill" then
  135.         if player.status ~= 'Engaged' then -- Cancel WS If You Are Not Engaged. Can Delete It If You Don't Need It --
  136.             cancel_spell()
  137.             add_to_chat(123,'Unable To Use WeaponSkill: [Disengaged]')
  138.             return
  139.         else
  140.             equipSet = sets.WS
  141.             if equipSet[spell.english] then
  142.                 equipSet = equipSet[spell.english]
  143.             end
  144.             if equipSet[AccArray[AccIndex]] then
  145.                 equipSet = equipSet[AccArray[AccIndex]]
  146.             end
  147.             if buffactive['Reive Mark'] then -- Equip Ygnas's Resolve +1 During Reive --
  148.                 equipSet = set_combine(equipSet,{neck="Ygnas's Resolve +1"})
  149.             end
  150.             equip(equipSet)
  151.         end
  152.     elseif spell.type == "JobAbility" or spell.type == "Ward" or spell.type == "Effusion" then
  153.         if sets.JA[spell.english] then
  154.             equip(sets.JA[spell.english])
  155.         end
  156.     elseif spell.type == "Rune" then
  157.         equip(sets.Enmity)
  158.     elseif spell.action_type == 'Magic' then
  159.         if buffactive.silence or spell.target.distance > 16+target_distance then -- Cancel Magic or Ninjutsu If You Are Silenced or Out of Range --
  160.             cancel_spell()
  161.             add_to_chat(123, spell.name..' Canceled: [Silenced or Out of Casting Range]')
  162.             return
  163.         else
  164.             if spell.english:startswith('Utsusemi') then
  165.                 if spell.english == 'Utsusemi: Ni' then
  166.                     if buffactive['Copy Image (3)'] then
  167.                         cancel_spell()
  168.                         add_to_chat(123, spell.name .. ' Canceled: [3 Images]')
  169.                         return
  170.                     else
  171.                         equip(sets.Precast.Utsusemi)
  172.                     end
  173.                 else
  174.                     equip(sets.Precast.Utsusemi)
  175.                 end
  176.             elseif sets.Precast[spell.skill] then
  177.                 equip(sets.Precast[spell.skill])
  178.             else
  179.                 equip(sets.Precast.FastCast)
  180.             end
  181.         end
  182.     elseif spell.type:endswith('Flourish') then
  183.         if spell.english == "Animated Flourish" then
  184.             equip(sets.Enmity)
  185.         else
  186.             equip(sets.Flourish)
  187.         end
  188.     elseif spell.type == "Waltz" then
  189.         refine_waltz(spell,action)
  190.         equip(sets.Waltz)
  191.     elseif spell.english == 'Spectral Jig' and buffactive.Sneak then
  192.         cast_delay(0.2)
  193.         send_command('cancel Sneak')
  194.     end
  195. end
  196.  
  197. function midcast(spell,action)
  198.     equipSet = {}
  199.     if spell.action_type == 'Magic' then
  200.         equipSet = sets.Midcast
  201.         if equipSet[spell.english] then
  202.             equipSet = equipSet[spell.english]
  203.         elseif spell.english:startswith('Protect') or spell.english:startswith('Shell') then
  204.             equipSet = equipSet.Haste
  205.             if spell.target.name == player.name then
  206.                 equipSet = set_combine(equipSet,{ring2="Sheltered Ring"})
  207.             end
  208.         elseif spell.english == "Stoneskin" then
  209.             if buffactive.Stoneskin then
  210.                 send_command('@wait 2.8;cancel stoneskin')
  211.             end
  212.             equipSet = equipSet.Stoneskin
  213.         elseif spell.english == "Sneak" then
  214.             if spell.target.name == player.name and buffactive['Sneak'] then
  215.                 send_command('cancel sneak')
  216.             end
  217.             equipSet = equipSet.Haste
  218.         elseif spell.english:endswith('Spikes') then
  219.             equipSet = equipSet.Haste
  220.         elseif spell.english:startswith('Utsusemi') then
  221.             if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)'] or buffactive['Copy Image (3)']) then
  222.                 send_command('@wait 1.7;cancel Copy Image*')
  223.             end
  224.             equipSet = equipSet.Haste
  225.         elseif spell.english == 'Monomi: Ichi' then
  226.             if buffactive['Sneak'] then
  227.                 send_command('@wait 1.7;cancel sneak')
  228.             end
  229.             equipSet = equipSet.Haste
  230.         elseif equipSet[spell.skill] then
  231.             equipSet = equipSet[spell.skill]
  232.         end
  233.     elseif equipSet[spell.english] then
  234.         equipSet = equipSet[spell.english]
  235.     end
  236.     equip(equipSet)
  237. end
  238.  
  239. function aftercast(spell,action)
  240.     if spell.type == "WeaponSkill" and not spell.interrupted then
  241.         send_command('wait 0.2;gs c TP')
  242.     end
  243.     status_change(player.status)
  244. end
  245.  
  246. function status_change(new,old)
  247.     check_equip_lock()
  248.     if Armor == 'PDT' then
  249.         equip(sets.PDT)
  250.     elseif Armor == 'MDT' then
  251.         equip(sets.MDT)
  252.     elseif new == 'Engaged' then
  253.         equipSet = sets.TP
  254.         if Armor == 'Hybrid' and equipSet["Hybrid"] then
  255.             equipSet = equipSet["Hybrid"]
  256.         end
  257.         if equipSet[AccArray[AccIndex]] then
  258.             equipSet = equipSet[AccArray[AccIndex]]
  259.         end
  260.         if buffactive.Swordplay then
  261.             equipSet = set_combine(equipSet,sets.TP.Swordplay)
  262.         end
  263.         equip(equipSet)
  264.     else
  265.         equipSet = sets.Idle
  266.         if equipSet[IdleArray[IdleIndex]] then
  267.             equipSet = equipSet[IdleArray[IdleIndex]]
  268.         end
  269.         if buffactive['Reive Mark'] then -- Equip Ygnas's Resolve +1 During Reive --
  270.             equipSet = set_combine(equipSet,{neck="Ygnas's Resolve +1"})
  271.         end
  272.         if world.area:endswith('Adoulin') then
  273.             equipSet = set_combine(equipSet,{body="Councilor's Garb"})
  274.         end
  275.         equip(equipSet)
  276.     end
  277. end
  278.  
  279. function buff_change(buff,gain)
  280.     buff = string.lower(buff)
  281.     if buff == "aftermath: lv.3" then -- AM3 Timer/Countdown --
  282.         if gain then
  283.             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.]')
  284.         else
  285.             send_command('timers delete "Aftermath: Lv.3"')
  286.             add_to_chat(123,'AM3: [OFF]')
  287.         end
  288.     elseif buff == 'weakness' then -- Weakness Timer --
  289.         if gain then
  290.             send_command('timers create "Weakness" 300 up')
  291.         else
  292.             send_command('timers delete "Weakness"')
  293.         end
  294.     end
  295.     if not midaction() then
  296.         status_change(player.status)
  297.     end
  298. end
  299.  
  300. -- In Game: //gs c (command), Macro: /console gs c (command), Bind: gs c (command) --
  301. function self_command(command)
  302.     if command == 'C1' then -- Accuracy Level Toggle --
  303.         AccIndex = (AccIndex % #AccArray) + 1
  304.         add_to_chat(158,'Accuracy Level: ' .. AccArray[AccIndex])
  305.         status_change(player.status)
  306.     elseif command == 'C5' then -- Auto Update Gear Toggle --
  307.         status_change(player.status)
  308.         add_to_chat(158,'Auto Update Gear')
  309.     elseif command == 'C2' then -- Hybrid Toggle --
  310.         if Armor == 'Hybrid' then
  311.             Armor = 'None'
  312.             add_to_chat(123,'Hybrid Set: [Unlocked]')
  313.         else
  314.             Armor = 'Hybrid'
  315.             add_to_chat(158,'Hybrid Set: '..AccArray[AccIndex])
  316.         end
  317.         status_change(player.status)
  318.     elseif command == 'C7' then -- PDT Toggle --
  319.         if Armor == 'PDT' then
  320.             Armor = 'None'
  321.             add_to_chat(123,'PDT Set: [Unlocked]')
  322.         else
  323.             Armor = 'PDT'
  324.             add_to_chat(158,'PDT Set: [Locked]')
  325.         end
  326.         status_change(player.status)
  327.     elseif command == 'C15' then -- MDT Toggle --
  328.         if Armor == 'MDT' then
  329.             Armor = 'None'
  330.             add_to_chat(123,'MDT Set: [Unlocked]')
  331.         else
  332.             Armor = 'MDT'
  333.             add_to_chat(158,'MDT Set: [Locked]')
  334.         end
  335.         status_change(player.status)
  336.     elseif command == 'C8' then -- Distance Toggle --
  337.         if player.target.distance then
  338.             target_distance = math.floor(player.target.distance*10)/10
  339.             add_to_chat(158,'Distance: '..target_distance)
  340.         else
  341.             add_to_chat(123,'No Target Selected')
  342.         end
  343.     elseif command == 'C6' then -- Idle Toggle --
  344.         IdleIndex = (IdleIndex % #IdleArray) + 1
  345.         add_to_chat(158,'Idle Set: ' .. IdleArray[IdleIndex])
  346.         status_change(player.status)
  347.     elseif command == 'TP' then
  348.         add_to_chat(158,'TP Return: ['..tostring(player.tp)..']')
  349.     elseif command:match('^SC%d$') then
  350.         send_command('//' .. sc_map[command])
  351.     end
  352. end
  353.  
  354. function check_equip_lock() -- Lock Equipment Here --
  355.     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
  356.         disable('ring1','ring2')
  357.     elseif player.equipment.back == "Mecisto. Mantle" or player.equipment.back == "Aptitude Mantle +1" or player.equipment.back == "Aptitude Mantle" then
  358.         disable('back')
  359.     else
  360.         enable('ring1','ring2','back')
  361.     end
  362. end
  363.  
  364. function refine_waltz(spell,action)
  365.     if spell.type ~= 'Waltz' then
  366.         return
  367.     end
  368.  
  369.     if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" or spell.name == "Divine Waltz II" then
  370.         return
  371.     end
  372.  
  373.     local newWaltz = spell.english
  374.     local waltzID
  375.  
  376.     local missingHP
  377.  
  378.     if spell.target.type == "SELF" then
  379.         missingHP = player.max_hp - player.hp
  380.     elseif spell.target.isallymember then
  381.         local target = find_player_in_alliance(spell.target.name)
  382.         local est_max_hp = target.hp / (target.hpp/100)
  383.         missingHP = math.floor(est_max_hp - target.hp)
  384.     end
  385.  
  386.     if missingHP ~= nil then
  387.         if player.sub_job == 'DNC' then
  388.             if missingHP < 40 and spell.target.name == player.name then
  389.                 add_to_chat(123,'Full HP!')
  390.                 cancel_spell()
  391.                 return
  392.             elseif missingHP < 150 then
  393.                 newWaltz = 'Curing Waltz'
  394.                 waltzID = 190
  395.             elseif missingHP < 300 then
  396.                 newWaltz = 'Curing Waltz II'
  397.                 waltzID = 191
  398.             else
  399.                 newWaltz = 'Curing Waltz III'
  400.                 waltzID = 192
  401.             end
  402.         else
  403.             return
  404.         end
  405.     end
  406.  
  407.     local waltzTPCost = {['Curing Waltz'] = 20, ['Curing Waltz II'] = 35, ['Curing Waltz III'] = 50, ['Curing Waltz IV'] = 65, ['Curing Waltz V'] = 80}
  408.     local tpCost = waltzTPCost[newWaltz]
  409.  
  410.     local downgrade
  411.  
  412.     if player.tp < tpCost and not buffactive.trance then
  413.  
  414.         if player.tp < 20 then
  415.             add_to_chat(123, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
  416.             cancel_spell()
  417.             return
  418.         elseif player.tp < 35 then
  419.             newWaltz = 'Curing Waltz'
  420.         elseif player.tp < 50 then
  421.             newWaltz = 'Curing Waltz II'
  422.         elseif player.tp < 65 then
  423.             newWaltz = 'Curing Waltz III'
  424.         elseif player.tp < 80 then
  425.             newWaltz = 'Curing Waltz IV'
  426.         end
  427.  
  428.         downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
  429.     end
  430.  
  431.     if newWaltz ~= spell.english then
  432.         send_command('@input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
  433.         if downgrade then
  434.             add_to_chat(158, downgrade)
  435.         end
  436.         cancel_spell()
  437.         return
  438.     end
  439.  
  440.     if missingHP > 0 then
  441.         add_to_chat(158,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
  442.     end
  443. end
  444.  
  445. function find_player_in_alliance(name)
  446.     for i,v in ipairs(alliance) do
  447.         for k,p in ipairs(v) do
  448.             if p.name == name then
  449.                 return p
  450.             end
  451.         end
  452.     end
  453. end
  454.  
  455. function sub_job_change(newSubjob, oldSubjob)
  456.     select_default_macro_book()
  457. end
  458.  
  459. function set_macro_page(set,book)
  460.     if not tonumber(set) then
  461.         add_to_chat(123,'Error setting macro page: Set is not a valid number ('..tostring(set)..').')
  462.         return
  463.     end
  464.     if set < 1 or set > 10 then
  465.         add_to_chat(123,'Error setting macro page: Macro set ('..tostring(set)..') must be between 1 and 10.')
  466.         return
  467.     end
  468.  
  469.     if book then
  470.         if not tonumber(book) then
  471.             add_to_chat(123,'Error setting macro page: book is not a valid number ('..tostring(book)..').')
  472.             return
  473.         end
  474.         if book < 1 or book > 20 then
  475.             add_to_chat(123,'Error setting macro page: Macro book ('..tostring(book)..') must be between 1 and 20.')
  476.             return
  477.         end
  478.         send_command('@input /macro book '..tostring(book)..';wait .1;input /macro set '..tostring(set))
  479.     else
  480.         send_command('@input /macro set '..tostring(set))
  481.     end
  482. end
  483.  
  484. function select_default_macro_book()
  485.     -- Default macro set/book
  486.     if player.sub_job == 'WAR' then
  487.         set_macro_page(1, 3)
  488.     elseif player.sub_job == 'DNC' then
  489.         set_macro_page(3, 3)
  490.     elseif player.sub_job == 'NIN' then
  491.         set_macro_page(2, 3)
  492.     else
  493.         set_macro_page(1, 3)
  494.     end
  495. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement