LauEra

THF.lua

Mar 17th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.10 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Setup functions for this job.  Generally should not be modified.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. --[[
  6.     Custom commands:
  7.     gs c cycle treasuremode (set on ctrl-= by default): Cycles through the available treasure hunter modes.
  8.    
  9.     Treasure hunter modes:
  10.         None - Will never equip TH gear
  11.         Tag - Will equip TH gear sufficient for initial contact with a mob (either melee, ranged hit, or Aeolian Edge AOE)
  12.         SATA - Will equip TH gear sufficient for initial contact with a mob, and when using SATA
  13.         Fulltime - Will keep TH gear equipped fulltime
  14. --]]
  15.  
  16. -- Initialization function for this job file.
  17. function get_sets()
  18.     mote_include_version = 2
  19.    
  20.     -- Load and initialize the include file.
  21.     include('Mote-Include.lua')
  22. end
  23.  
  24. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  25. function job_setup()
  26.     state.Buff['Sneak Attack'] = buffactive['sneak attack'] or false
  27.     state.Buff['Trick Attack'] = buffactive['trick attack'] or false
  28.     state.Buff['Feint'] = buffactive['feint'] or false
  29.    
  30.     include('Mote-TreasureHunter')
  31.  
  32.     -- For th_action_check():
  33.     -- JA IDs for actions that always have TH: Provoke, Animated Flourish
  34.     info.default_ja_ids = S{35, 204}
  35.     -- Unblinkable JA IDs for actions that always have TH: Quick/Box/Stutter Step, Desperate/Violent Flourish
  36.     info.default_u_ja_ids = S{201, 202, 203, 205, 207}
  37. end
  38.  
  39. -------------------------------------------------------------------------------------------------------------------
  40. -- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
  41. -------------------------------------------------------------------------------------------------------------------
  42.  
  43. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  44. function user_setup()
  45.     state.OffenseMode:options('Haste', 'Acc', 'Eva')
  46.     state.IdleMode:options('Normal', 'Eva')
  47.     state.RangedMode:options('Normal', 'Acc')
  48.     state.WeaponskillMode:options('Normal', 'Acc', 'Mod')
  49.     state.PhysicalDefenseMode:options('Evasion', 'PDT')
  50.  
  51.     -- Additional local binds
  52.     send_command('bind ^` input /ja "Flee" <me>')
  53.     send_command('bind ^= gs c cycle treasuremode')
  54.     send_command('bind !- gs c cycle targetmode')
  55.  
  56.     select_default_macro_book()
  57. end
  58.  
  59. -- Called when this job file is unloaded (eg: job change)
  60. function user_unload()
  61.     send_command('unbind ^`')
  62.     send_command('unbind !-')
  63. end
  64.  
  65. -- Define sets and vars used by this job file.
  66. function init_gear_sets()
  67.     --------------------------------------
  68.     -- Special sets (required by rules)
  69.     --------------------------------------
  70.  
  71.     sets.TreasureHunter = {hands="Assassin's Armlets +1"}
  72.  
  73.     sets.ExtraRegen = {}
  74.  
  75.     sets.Kiting = {
  76.         feet="Trotter's Boots"}
  77.  
  78.     sets.buff['Sneak Attack'] = {
  79.         head="Hecatomb Cap +1",
  80.         neck="Love Torque",
  81.         ear1="Pixie Earring",
  82.         ear2="Suppanomimi",
  83.         body="Antares Harness",
  84.         hands="Hecatomb Mittens +1",
  85.         ring1="Rajas Ring",
  86.         ring2="Thunder Ring",
  87.         back="Assassin's Cape",
  88.         waist="Warwolf Belt",
  89.         legs="Hecatomb Subligar +1",
  90.         feet="Hecatomb Leggings +1"}
  91.  
  92.     sets.buff['Trick Attack'] = {
  93.         head="Hecatomb Cap +1",
  94.         neck="Peacock Amulet",
  95.         ear1="Pixie Earring",
  96.         ear2="Suppanomimi",
  97.         body="Antares Harness",
  98.         hands="Hecatomb Mittens +1",
  99.         ring1="Breeze Ring",
  100.         ring2="Breeze Ring",
  101.         back="Assassin's Cape",
  102.         waist="Scouter's Rope",
  103.         legs="War Brais +1",
  104.         feet="Hecatomb Leggings"}
  105.  
  106.     -- Actions we want to use to tag TH.
  107.    
  108.     sets.precast.Step = sets.TreasureHunter
  109.    
  110.     sets.precast.Flourish1 = sets.TreasureHunter
  111.    
  112.     sets.precast.JA.Provoke = sets.TreasureHunter
  113.  
  114.  
  115.     --------------------------------------
  116.     -- Precast sets
  117.     --------------------------------------
  118.    
  119.     sets.precast.RA = {
  120.         head="Optical Hat",
  121.         neck="Peacock Amulet",
  122.         waist="Buccaneer's Belt",
  123.         back="Amemet Mantle +1",
  124.         ring2="Merman's Ring"}
  125.  
  126.     sets.precast.RA.Acc = {
  127.         head="Optical Hat",
  128.         neck="Peacock Amulet",
  129.         waist="Buccaneer's Belt",
  130.         back="Amemet Mantle +1",
  131.         ring2="Merman's Ring"}
  132.  
  133.     -- Precast sets to enhance JAs
  134.    
  135.     sets.precast.JA['Collaborator'] = {}
  136.    
  137.     sets.precast.JA['Accomplice'] =   {}
  138.    
  139.     sets.precast.JA['Flee'] = {
  140.         feet="Rogue's Poulaines"}
  141.    
  142.    
  143.     sets.precast.JA['Hide'] = {
  144.         body="Rogue's Vest"}
  145.    
  146.     sets.precast.JA['Steal'] = {
  147.         legs="Assassin's Culottes",
  148.         head="Rogue's Bonnet",
  149.         feet="Rogue's Poulaines",
  150.         hands="Rogue's Armlets",
  151.         neck="Rabbit Charm"}
  152.  
  153.     sets.precast.JA['Mug'] = {head="Assassin's Bonnet"}
  154.  
  155.     sets.precast.JA['Sneak Attack'] = sets.buff['Sneak Attack']
  156.    
  157.     sets.precast.JA['Trick Attack'] = sets.buff['Trick Attack']
  158.  
  159.  
  160.     -- Waltz set (chr and vit)
  161.    
  162.     sets.precast.Waltz = {}
  163.  
  164.     -- Don't need any special gear for Healing Waltz.
  165.    
  166.     sets.precast.Waltz['Healing Waltz'] = {}
  167.  
  168.  
  169.     -- Fast cast sets for spells
  170.    
  171.     sets.precast.FC = {
  172.         ear1="Loquacious Earring",
  173.         legs="Homam Cosciales"}
  174.  
  175.     sets.precast.FC.Utsusemi = {
  176.         ear1="Loquacious Earring",
  177.         legs="Homam Cosciales"}
  178.  
  179.     -- Weaponskill sets
  180.  
  181.     -- Default set for any weaponskill that isn't any more specifically defined
  182.    
  183.     -- Specific weaponskill sets.  Add WS specific gear in between the {}
  184.  
  185.     sets.precast.WS['Mercy Stroke'] = {
  186.         head="Hecatomb Cap +1",
  187.         neck="Soil Gorget",
  188.         ear1="Barmonius Earring",
  189.         ear2="Brutal Earring",
  190.         body="Hecatomb Harness +1",
  191.         hands="Alkyoneus's Bracelets",
  192.         ring1="Rajas Ring",
  193.         ring2="Toreador's Ring",
  194.         back="Cerberus Mantle +1",
  195.         waist="Warwolf Belt",
  196.         legs="Enkidu's Subligar",
  197.         feet="Hecatomb Leggings +1"}
  198.        
  199.     sets.precast.WS['Shark Bite'] = {
  200.         head="Hecatomb Cap +1",
  201.         neck="Breeze Gorget",
  202.         ear1="Suppanomimi",
  203.         ear2="Brutal Earring",
  204.         body="Antares Harness",
  205.         hands="Hecatomb Mittens +1",
  206.         ring1="Rajas Ring",
  207.         ring2="Toreador's Ring",
  208.         back="Assassin's Cape",
  209.         waist="Warwolf Belt",
  210.         legs="Hecatomb Subligar +1",
  211.         feet="Hecatomb Leggings +1"}
  212.        
  213.     sets.precast.WS['Exenterator'] = {
  214.         head="Hecatomb Cap +1",
  215.         neck="Breeze Gorget",
  216.         ear1="Brutal Earring",
  217.         ear2="Suppanomimi",
  218.         body="Antares Harness",
  219.         hands="Hecatomb Mittens +1",
  220.         ring1="Rajas Ring",
  221.         ring2="Toreador's Ring",
  222.         back="Assassin's Cape",
  223.         waist="Scouter's Rope",
  224.         legs="War Brais +1",
  225.         feet="Enkidu's Leggings"}
  226.     --------------------------------------
  227.     -- Midcast sets
  228.     --------------------------------------
  229.  
  230.     sets.midcast.FastRecast = {
  231.         head="Walahra Turban",
  232.         body="Rapparee Harness",
  233.         feet="Homam Gambieras",
  234.         hands="Dusk Gloves +1",
  235.         waist="Velocious Belt",
  236.         legs="Homam Cosciales"}
  237.  
  238.     -- Specific spells
  239.  
  240.     sets.midcast.Utsusemi = {
  241.         back="Boxer's Mantle",
  242.         hands="Dusk Gloves +1",
  243.         neck="Evasion Torque",
  244.         head="Walahra Turban",
  245.         body="Rapparee Harness",
  246.         feet="Homam Gambieras",
  247.         waist="Velocious Belt",
  248.         legs="Homam Cosciales"}
  249.    
  250.    -- Ranged gear
  251.  
  252.     sets.midcast.RA = {
  253.         head="Optical Hat",
  254.         neck="Peacock Amulet",
  255.         waist="Buccaneer's Belt",
  256.         back="Amemet Mantle +1",
  257.         ring2="Merman's Ring"}
  258.  
  259.     sets.midcast.RA.Acc = {
  260.         head="Optical Hat",
  261.         neck="Peacock Amulet",
  262.         waist="Buccaneer's Belt",
  263.         back="Amemet Mantle +1",
  264.         ring2="Merman's Ring"}
  265.    
  266.     --------------------------------------
  267.     -- Idle/resting/defense sets
  268.     --------------------------------------
  269.  
  270.     -- Resting sets
  271.  
  272.     -- Idle sets (default idle set not needed since the other three are defined, but leaving for testing purposes)
  273.  
  274.    
  275.     sets.idle = {
  276.         head="Walahra Turban",
  277.         neck="Love Torque",
  278.         ear1="Brutal Earring",
  279.         ear2="Suppanomimi",
  280.         body="Homam Corazza",
  281.         hands="Assassin's Armlets +1",
  282.         ring1="Rajas Ring",
  283.         ring2="Toreador's Ring",
  284.         back="Cerberus Mantle +1",
  285.         waist="Velocious Belt",
  286.         legs="Homam Cosciales",
  287.         feet="Trotter Boots"}
  288.        
  289.     sets.idle.Eva = {
  290.         head="Optical Hat",
  291.         body="Scorpion Harness +1",
  292.         hands="War Gloves +1",
  293.         legs="Homam Cosciales",
  294.         feet="Homam Gambieras",
  295.         neck="Evasion Torque",
  296.         waist="Scouter's Rope",
  297.         left_ear="Brutal Earring",
  298.         right_ear="Suppanomimi",
  299.         left_ring="Rajas Ring",
  300.         right_ring="Toreador's Ring",
  301.         back="Boxer's Mantle"}
  302.    
  303.  
  304.     -- Defense sets
  305.  
  306.     --------------------------------------
  307.     -- Melee sets
  308.     --------------------------------------
  309.  
  310.     -- Normal melee group
  311.    
  312.     sets.midcast.RA.Acc = {
  313.         head="Optical Hat",
  314.         neck="Peacock Amulet",
  315.         waist="Buccaneer's Belt",
  316.         back="Amemet Mantle +1",
  317.         ring2="Merman's Ring"}
  318.    
  319.    
  320.     sets.midcast.RA = {
  321.         head="Optical Hat",
  322.         neck="Peacock Amulet",
  323.         waist="Buccaneer's Belt",
  324.         back="Amemet Mantle +1",
  325.         ring2="Merman's Ring"}
  326.    
  327.    
  328.     sets.engaged.Haste = {
  329.         head="Walahra Turban",
  330.         neck="Love Torque",
  331.         ear1="Brutal Earring",
  332.         ear2="Suppanomimi",
  333.         body="Rapparee Harness",
  334.         hands="Dusk Gloves +1",
  335.         ring1="Rajas Ring",
  336.         ring2="Toreador's Ring",
  337.         back="Cerberus Mantle +1",
  338.         waist="Velocious Belt",
  339.         legs="Homam Cosciales",
  340.         feet="Homam Gambieras"}    
  341.                      
  342.     sets.engaged.Acc = {
  343.         head="Optical Hat",
  344.         neck="Love Torque",
  345.         ear1="Brutal Earring",
  346.         ear2="Suppanomimi",
  347.         body="Homam Corazza",
  348.         hands="Homam Manopolas",
  349.         ring1="Rajas Ring",
  350.         ring2="Toreador's Ring",
  351.         back="Cuchulain's Mantle",
  352.         waist="Life Belt",
  353.         legs="Homam Cosciales",
  354.         feet="Homam Gambieras"}
  355.        
  356.     sets.engaged.Eva = {
  357.         head="Optical Hat",
  358.         body="Scorpion Harness +1",
  359.         hands="War Gloves +1",
  360.         legs="Homam Cosciales",
  361.         feet="Homam Gambieras",
  362.         neck="Evasion Torque",
  363.         waist="Scouter's Rope",
  364.         left_ear="Brutal Earring",
  365.         right_ear="Suppanomimi",
  366.         left_ring="Rajas Ring",
  367.         right_ring="Toreador's Ring",
  368.         back="Boxer's Mantle"}
  369. end
  370.  
  371.  
  372. -------------------------------------------------------------------------------------------------------------------
  373. -- Job-specific hooks for standard casting events.
  374. -------------------------------------------------------------------------------------------------------------------
  375.  
  376. -- Run after the general precast() is done.
  377. function job_post_precast(spell, action, spellMap, eventArgs)
  378.     if spell.english == 'Aeolian Edge' and state.TreasureMode.value ~= 'None' then
  379.         equip(sets.TreasureHunter)
  380.     elseif spell.english=='Sneak Attack' or spell.english=='Trick Attack' or spell.type == 'WeaponSkill' then
  381.         if state.TreasureMode.value == 'SATA' or state.TreasureMode.value == 'Fulltime' then
  382.             equip(sets.TreasureHunter)
  383.         end
  384.     end
  385. end
  386.  
  387. -- Run after the general midcast() set is constructed.
  388. function job_post_midcast(spell, action, spellMap, eventArgs)
  389.     if state.TreasureMode.value ~= 'None' and spell.action_type == 'Ranged Attack' then
  390.         equip(sets.TreasureHunter)
  391.     end
  392. end
  393.  
  394. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  395. function job_aftercast(spell, action, spellMap, eventArgs)
  396.     -- Weaponskills wipe SATA/Feint.  Turn those state vars off before default gearing is attempted.
  397.     if spell.type == 'WeaponSkill' and not spell.interrupted then
  398.         state.Buff['Sneak Attack'] = false
  399.         state.Buff['Trick Attack'] = false
  400.         state.Buff['Feint'] = false
  401.     end
  402. end
  403.  
  404. -- Called after the default aftercast handling is complete.
  405. function job_post_aftercast(spell, action, spellMap, eventArgs)
  406.     if spell.english == 'Trick Attack' then
  407.         send_command('@wait 48;input /echo ------- '..spell.english..' is Ready!!!® -------')
  408.     end
  409.     if spell.english == 'Sneak Attack' then
  410.         send_command('@wait 60;input /echo ------- '..spell.english..' is Ready!!! -------')
  411.     end
  412. end
  413.  
  414. -------------------------------------------------------------------------------------------------------------------
  415. -- Job-specific hooks for non-casting events.
  416. -------------------------------------------------------------------------------------------------------------------
  417.  
  418. -- Called when a player gains or loses a buff.
  419. -- buff == buff gained or lost
  420. -- gain == true if the buff was gained, false if it was lost.
  421. function job_buff_change(buff, gain)
  422.     if state.Buff[buff] ~= nil then
  423.         if not midaction() then
  424.             handle_equipping_gear(player.status)
  425.         end
  426.     end
  427. end
  428.  
  429.  
  430. -------------------------------------------------------------------------------------------------------------------
  431. -- User code that supplements standard library decisions.
  432. -------------------------------------------------------------------------------------------------------------------
  433.  
  434. function get_custom_wsmode(spell, spellMap, defaut_wsmode)
  435.     local wsmode
  436.  
  437.     if state.Buff['Sneak Attack'] then
  438.         wsmode = 'SA'
  439.     end
  440.     if state.Buff['Trick Attack'] then
  441.         wsmode = (wsmode or '') .. 'TA'
  442.     end
  443.  
  444.     return wsmode
  445. end
  446.  
  447.  
  448. -- Called any time we attempt to handle automatic gear equips (ie: engaged or idle gear).
  449. function job_handle_equipping_gear(playerStatus, eventArgs)
  450.     -- Check that ranged slot is locked, if necessary
  451.     check_range_lock()
  452.  
  453.     -- Check for SATA when equipping gear.  If either is active, equip
  454.     -- that gear specifically, and block equipping default gear.
  455.     check_buff('Sneak Attack', eventArgs)
  456.     check_buff('Trick Attack', eventArgs)
  457. end
  458.  
  459.  
  460. function customize_idle_set(idleSet)
  461.     if player.hpp < 80 then
  462.         idleSet = set_combine(idleSet, sets.ExtraRegen)
  463.     end
  464.  
  465.     return idleSet
  466. end
  467.  
  468.  
  469. function customize_melee_set(meleeSet)
  470.     if state.TreasureMode.value == 'Fulltime' then
  471.         meleeSet = set_combine(meleeSet, sets.TreasureHunter)
  472.     end
  473.  
  474.     return meleeSet
  475. end
  476.  
  477.  
  478. -- Called by the 'update' self-command.
  479. function job_update(cmdParams, eventArgs)
  480.     th_update(cmdParams, eventArgs)
  481. end
  482.  
  483. -- Function to display the current relevant user state when doing an update.
  484. -- Return true if display was handled, and you don't want the default info shown.
  485. function display_current_job_state(eventArgs)
  486.     local msg = 'Melee'
  487.    
  488.     if state.CombatForm.has_value then
  489.         msg = msg .. ' (' .. state.CombatForm.value .. ')'
  490.     end
  491.    
  492.     msg = msg .. ': '
  493.    
  494.     msg = msg .. state.OffenseMode.value
  495.     if state.HybridMode.value ~= 'Normal' then
  496.         msg = msg .. '/' .. state.HybridMode.value
  497.     end
  498.     msg = msg .. ', WS: ' .. state.WeaponskillMode.value
  499.    
  500.     if state.DefenseMode.value ~= 'None' then
  501.         msg = msg .. ', ' .. 'Defense: ' .. state.DefenseMode.value .. ' (' .. state[state.DefenseMode.value .. 'DefenseMode'].value .. ')'
  502.     end
  503.    
  504.     if state.Kiting.value == true then
  505.         msg = msg .. ', Kiting'
  506.     end
  507.  
  508.     if state.PCTargetMode.value ~= 'default' then
  509.         msg = msg .. ', Target PC: '..state.PCTargetMode.value
  510.     end
  511.  
  512.     if state.SelectNPCTargets.value == true then
  513.         msg = msg .. ', Target NPCs'
  514.     end
  515.    
  516.     msg = msg .. ', TH: ' .. state.TreasureMode.value
  517.  
  518.     add_to_chat(122, msg)
  519.  
  520.     eventArgs.handled = true
  521. end
  522.  
  523. -------------------------------------------------------------------------------------------------------------------
  524. -- Utility functions specific to this job.
  525. -------------------------------------------------------------------------------------------------------------------
  526.  
  527. -- State buff checks that will equip buff gear and mark the event as handled.
  528. function check_buff(buff_name, eventArgs)
  529.     if state.Buff[buff_name] then
  530.         equip(sets.buff[buff_name] or {})
  531.         if state.TreasureMode.value == 'SATA' or state.TreasureMode.value == 'Fulltime' then
  532.             equip(sets.TreasureHunter)
  533.         end
  534.         eventArgs.handled = true
  535.     end
  536. end
  537.  
  538.  
  539. -- Check for various actions that we've specified in user code as being used with TH gear.
  540. -- This will only ever be called if TreasureMode is not 'None'.
  541. -- Category and Param are as specified in the action event packet.
  542. function th_action_check(category, param)
  543.     if category == 2 or -- any ranged attack
  544.         --category == 4 or -- any magic action
  545.         (category == 3 and param == 30) or -- Aeolian Edge
  546.         (category == 6 and info.default_ja_ids:contains(param)) or -- Provoke, Animated Flourish
  547.         (category == 14 and info.default_u_ja_ids:contains(param)) -- Quick/Box/Stutter Step, Desperate/Violent Flourish
  548.         then return true
  549.     end
  550. end
  551.  
  552.  
  553. -- Function to lock the ranged slot if we have a ranged weapon equipped.
  554. function check_range_lock()
  555.     if player.equipment.range ~= 'empty' then
  556.         disable('range', 'ammo')
  557.     else
  558.         enable('range', 'ammo')
  559.     end
  560. end
  561.  
  562.  
  563. -- Select default macro book on initial load or subjob change.
  564. function select_default_macro_book()
  565.     -- Default macro set/book
  566.     if player.sub_job == 'DNC' then
  567.         set_macro_page(3, 1)
  568.     elseif player.sub_job == 'WAR' then
  569.         set_macro_page(3, 1)
  570.     elseif player.sub_job == 'NIN' then
  571.         set_macro_page(3, 1)
  572.     else
  573.         set_macro_page(3, 1)
  574.     end
  575. end
Advertisement
Add Comment
Please, Sign In to add comment