Kushitap

THF

Jul 6th, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.01 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Setup functions for this job.  Generally should not be modified.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. --[[
  6.     Custom commands:
  7.  
  8.     gs c cycle treasuremode (set on ctrl-= by default): Cycles through the available treasure hunter modes.
  9.    
  10.     Treasure hunter modes:
  11.         None - Will never equip TH gear
  12.         Tag - Will equip TH gear sufficient for initial contact with a mob (either melee, ranged hit, or Aeolian Edge AOE)
  13.         SATA - Will equip TH gear sufficient for initial contact with a mob, and when using SATA
  14.         Fulltime - Will keep TH gear equipped fulltime
  15.  
  16. --]]
  17.  
  18. -- Initialization function for this job file.
  19. function get_sets()
  20.     mote_include_version = 2
  21.    
  22.     -- Load and initialize the include file.
  23.     include('Mote-Include.lua')
  24. end
  25.  
  26. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  27. function job_setup()
  28.     state.Buff['Sneak Attack'] = buffactive['sneak attack'] or false
  29.     state.Buff['Trick Attack'] = buffactive['trick attack'] or false
  30.     state.Buff['Feint'] = buffactive['feint'] or false
  31.    
  32.     include('Mote-TreasureHunter')
  33.  
  34.     -- For th_action_check():
  35.     -- JA IDs for actions that always have TH: Provoke, Animated Flourish
  36.     info.default_ja_ids = S{35, 204}
  37.     -- Unblinkable JA IDs for actions that always have TH: Quick/Box/Stutter Step, Desperate/Violent Flourish
  38.     info.default_u_ja_ids = S{201, 202, 203, 205, 207}
  39. end
  40.  
  41. -------------------------------------------------------------------------------------------------------------------
  42. -- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
  43. -------------------------------------------------------------------------------------------------------------------
  44.  
  45. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  46. function user_setup()
  47.     state.OffenseMode:options('Normal', 'Party', 'Acc', 'Evasion')
  48.     --state.HybridMode:options('Normal', 'Evasion', 'PDT')
  49.     --state.RangedMode:options('Normal', 'Acc')
  50.     state.WeaponskillMode:options('Normal', 'Party', 'Acc')
  51.     state.PhysicalDefenseMode:options('PDT', 'Evasion')
  52.     state.MagicalDefenseMode:options('MDT')
  53.  
  54.  
  55.     -- Additional local binds
  56.     send_command('bind ^` input /ja "Flee" <me>')
  57.     send_command('bind ^= gs c cycle treasuremode')
  58.     send_command('bind !- gs c cycle targetmode')
  59.     send_command('bind !q input /ja "Animated flourish" <t>;input /ja "Provoke" <t>;input /ma "Utsusemi: Ichi" <me>')
  60.     send_command('bind !w input /ja "Violent flourish" <t>;input /ja "Defender" <me>;input /ma "Utsusemi: Ni" <me>')
  61.     send_command('bind !e input /ja "Quickstep" <t>')
  62.     send_command('bind !r input /ja "Reverse Flourish" <me>')
  63.     send_command('bind !a input /ja "Spectral Jig" <me>;input /ja "Berserk" <me>;input /ma "Monomi: Ichi" <me>')
  64.     send_command('bind !s input /ja "Haste samba" <me>;input /ja "Warcry" <me>;input /ma "Tonko: Ni" <me>')
  65.     send_command('bind !d input /ja "Box step" <t>;input /ja "Aggressor" <me>')
  66.     send_command('bind !z input /ja "Curing waltz III" <stpc>')
  67.     send_command('bind !x input /ja "Healing waltz" <stpc>')
  68.  
  69.     select_default_macro_book()
  70. end
  71.  
  72. -- Called when this job file is unloaded (eg: job change)
  73. function user_unload()
  74.     send_command('unbind ^`')
  75.     send_command('unbind !-')
  76. end
  77.  
  78. -- Define sets and vars used by this job file.
  79. function init_gear_sets()
  80.     include('THF_gear.lua')
  81. end
  82.  
  83. -------------------------------------------------------------------------------------------------------------------
  84. -- Job-specific hooks for standard casting events.
  85. -------------------------------------------------------------------------------------------------------------------
  86.  
  87. -- Run after the general precast() is done.
  88. function job_post_precast(spell, action, spellMap, eventArgs)
  89.     if spell.english == 'Aeolian Edge' and state.TreasureMode.value ~= 'None' then
  90.         equip(sets.TreasureHunter)
  91.     elseif spell.english=='Sneak Attack' or spell.english=='Trick Attack' or spell.type == 'WeaponSkill' then
  92.         if state.TreasureMode.value == 'SATA' or state.TreasureMode.value == 'Fulltime' then
  93.             equip(sets.TreasureHunter)
  94.         end
  95.     end
  96.     if spell.english == 'Utsusemi: Ichi' and (buffactive['Copy Image'] or buffactive['Copy Image (2)']) then
  97.         send_command('@wait 3; cancel 66; cancel 444')
  98.     end
  99.     if spell.english == 'Spectral Jig' then
  100.         send_command('cancel 71;')
  101.     end
  102. end
  103.  
  104. -- Run after the general midcast() set is constructed.
  105. function job_post_midcast(spell, action, spellMap, eventArgs)
  106.     if state.TreasureMode.value ~= 'None' and spell.action_type == 'Ranged Attack' then
  107.         equip(sets.TreasureHunter)
  108.     end
  109. end
  110.  
  111. -- Set eventArgs.handled to true if we don't want any automatic gear equipping to be done.
  112. function job_aftercast(spell, action, spellMap, eventArgs)
  113.     -- Weaponskills wipe SATA/Feint.  Turn those state vars off before default gearing is attempted.
  114.     if spell.type == 'WeaponSkill' and not spell.interrupted then
  115.         state.Buff['Sneak Attack'] = false
  116.         state.Buff['Trick Attack'] = false
  117.         state.Buff['Feint'] = false
  118.     end
  119. end
  120.  
  121. -- Called after the default aftercast handling is complete.
  122. function job_post_aftercast(spell, action, spellMap, eventArgs)
  123.     -- If Feint is active, put that gear set on on top of regular gear.
  124.     -- This includes overlaying SATA gear.
  125.     check_buff('Feint', eventArgs)
  126. end
  127.  
  128. -------------------------------------------------------------------------------------------------------------------
  129. -- Job-specific hooks for non-casting events.
  130. -------------------------------------------------------------------------------------------------------------------
  131.  
  132. -- Called when a player gains or loses a buff.
  133. -- buff == buff gained or lost
  134. -- gain == true if the buff was gained, false if it was lost.
  135. function job_buff_change(buff, gain)
  136.     if state.Buff[buff] ~= nil then
  137.         if not midaction() then
  138.             handle_equipping_gear(player.status)
  139.         end
  140.     end
  141. end
  142.  
  143.  
  144. -------------------------------------------------------------------------------------------------------------------
  145. -- User code that supplements standard library decisions.
  146. -------------------------------------------------------------------------------------------------------------------
  147.  
  148. function get_custom_wsmode(spell, spellMap, defaut_wsmode)
  149.     local wsmode
  150.  
  151.     if state.Buff['Sneak Attack'] then
  152.         wsmode = 'SA'
  153.     end
  154.     if state.Buff['Trick Attack'] then
  155.         wsmode = (wsmode or '') .. 'TA'
  156.     end
  157.  
  158.     return wsmode
  159. end
  160.  
  161.  
  162. -- Called any time we attempt to handle automatic gear equips (ie: engaged or idle gear).
  163. function job_handle_equipping_gear(playerStatus, eventArgs)
  164.     -- Check that ranged slot is locked, if necessary
  165.     check_range_lock()
  166.  
  167.     -- Check for SATA when equipping gear.  If either is active, equip
  168.     -- that gear specifically, and block equipping default gear.
  169.     check_buff('Sneak Attack', eventArgs)
  170.     check_buff('Trick Attack', eventArgs)
  171. end
  172.  
  173.  
  174. function customize_idle_set(idleSet)
  175.     if player.hpp < 80 then
  176.         idleSet = set_combine(idleSet, sets.ExtraRegen)
  177.     end
  178.  
  179.     return idleSet
  180. end
  181.  
  182.  
  183. function customize_melee_set(meleeSet)
  184.     if state.TreasureMode.value == 'Fulltime' then
  185.         meleeSet = set_combine(meleeSet, sets.TreasureHunter)
  186.     end
  187.    
  188.     if state.DefenseMode.value ~= "None" and buffactive['Reive Mark'] then
  189.         meleeSet = set_combine(meleeSet, {neck="Adoulin's Refuge +1"})
  190.     end
  191.  
  192.     return meleeSet
  193. end
  194.  
  195.  
  196. -- Called by the 'update' self-command.
  197. function job_update(cmdParams, eventArgs)
  198.     th_update(cmdParams, eventArgs)
  199. end
  200.  
  201. -- Function to display the current relevant user state when doing an update.
  202. -- Return true if display was handled, and you don't want the default info shown.
  203. function display_current_job_state(eventArgs)
  204.     local msg = 'Melee'
  205.    
  206.     if state.CombatForm.has_value then
  207.         msg = msg .. ' (' .. state.CombatForm.value .. ')'
  208.     end
  209.    
  210.     msg = msg .. ': '
  211.    
  212.     msg = msg .. state.OffenseMode.value
  213.     if state.HybridMode.value ~= 'Normal' then
  214.         msg = msg .. '/' .. state.HybridMode.value
  215.     end
  216.     msg = msg .. ', WS: ' .. state.WeaponskillMode.value
  217.    
  218.     if state.DefenseMode.value ~= 'None' then
  219.         msg = msg .. ', ' .. 'Defense: ' .. state.DefenseMode.value .. ' (' .. state[state.DefenseMode.value .. 'DefenseMode'].value .. ')'
  220.     end
  221.    
  222.     if state.Kiting.value == true then
  223.         msg = msg .. ', Kiting'
  224.     end
  225.  
  226.     if state.PCTargetMode.value ~= 'default' then
  227.         msg = msg .. ', Target PC: '..state.PCTargetMode.value
  228.     end
  229.  
  230.     if state.SelectNPCTargets.value == true then
  231.         msg = msg .. ', Target NPCs'
  232.     end
  233.    
  234.     msg = msg .. ', TH: ' .. state.TreasureMode.value
  235.  
  236.     add_to_chat(122, msg)
  237.  
  238.     eventArgs.handled = true
  239. end
  240.  
  241. -------------------------------------------------------------------------------------------------------------------
  242. -- Utility functions specific to this job.
  243. -------------------------------------------------------------------------------------------------------------------
  244.  
  245. -- State buff checks that will equip buff gear and mark the event as handled.
  246. function check_buff(buff_name, eventArgs)
  247.     if state.Buff[buff_name] then
  248.         equip(sets.buff[buff_name] or {})
  249.         if state.TreasureMode.value == 'SATA' or state.TreasureMode.value == 'Fulltime' then
  250.             equip(sets.TreasureHunter)
  251.         end
  252.         eventArgs.handled = true
  253.     end
  254. end
  255.  
  256.  
  257. -- Check for various actions that we've specified in user code as being used with TH gear.
  258. -- This will only ever be called if TreasureMode is not 'None'.
  259. -- Category and Param are as specified in the action event packet.
  260. function th_action_check(category, param)
  261.     if category == 2 or -- any ranged attack
  262.         --category == 4 or -- any magic action
  263.         (category == 3 and param == 30) or -- Aeolian Edge
  264.         (category == 6 and info.default_ja_ids:contains(param)) or -- Provoke, Animated Flourish
  265.         (category == 14 and info.default_u_ja_ids:contains(param)) -- Quick/Box/Stutter Step, Desperate/Violent Flourish
  266.         then return true
  267.     end
  268. end
  269.  
  270.  
  271. -- Function to lock the ranged slot if we have a ranged weapon equipped.
  272. function check_range_lock()
  273.     if player.equipment.range ~= 'empty' then
  274.         disable('range', 'ammo')
  275.     else
  276.         enable('range', 'ammo')
  277.     end
  278. end
  279.  
  280.  
  281. -- Select default macro book on initial load or subjob change.
  282. function select_default_macro_book()
  283.     -- Default macro set/book
  284.     if player.sub_job == 'DNC' then
  285.         set_macro_page(1, 1)
  286.     elseif player.sub_job == 'WAR' then
  287.         set_macro_page(1, 1)
  288.     elseif player.sub_job == 'NIN' then
  289.         set_macro_page(1, 1)
  290.     else
  291.         set_macro_page(1, 1)
  292.     end
  293. end
Add Comment
Please, Sign In to add comment