Guest User

SCH

a guest
Sep 16th, 2014
589
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.20 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Setup functions for this job.  Generally should not be modified.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. --[[
  6.         Custom commands:
  7.  
  8.         Shorthand versions for each strategem type that uses the version appropriate for
  9.         the current Arts.
  10.  
  11.                                         Light Arts              Dark Arts
  12.  
  13.         gs c scholar light              Light Arts/Addendum
  14.         gs c scholar dark                                       Dark Arts/Addendum
  15.         gs c scholar cost               Penury                  Parsimony
  16.         gs c scholar speed              Celerity                Alacrity
  17.         gs c scholar aoe                Accession               Manifestation
  18.         gs c scholar power              Rapture                 Ebullience
  19.         gs c scholar duration           Perpetuance
  20.         gs c scholar accuracy           Altruism                Focalization
  21.         gs c scholar enmity             Tranquility             Equanimity
  22.         gs c scholar skillchain                                 Immanence
  23.         gs c scholar addendum           Addendum: White         Addendum: Black
  24. --]]
  25.  
  26.  
  27.  
  28. -- Initialization function for this job file.
  29. function get_sets()
  30.     mote_include_version = 2
  31.  
  32.     -- Load and initialize the include file.
  33.     include('Mote-Include.lua')
  34. end
  35.  
  36. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  37. function job_setup()
  38.     info.addendumNukes = S{"Stone IV", "Water IV", "Aero IV", "Fire IV", "Blizzard IV", "Thunder IV",
  39.         "Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}
  40.  
  41.     state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
  42.     update_active_strategems()
  43. end
  44.  
  45. -------------------------------------------------------------------------------------------------------------------
  46. -- User setup functions for this job.  Recommend that these be overridden in a sidecar file.
  47. -------------------------------------------------------------------------------------------------------------------
  48.  
  49. -- Setup vars that are user-dependent.  Can override this function in a sidecar file.
  50. function user_setup()
  51.     state.OffenseMode:options('None', 'Normal')
  52.     state.CastingMode:options('Normal', 'Resistant')
  53.     state.IdleMode:options('Normal', 'PDT')
  54.  
  55.  
  56.     info.low_nukes = S{"Stone", "Water", "Aero", "Fire", "Blizzard", "Thunder"}
  57.     info.mid_nukes = S{"Stone II", "Water II", "Aero II", "Fire II", "Blizzard II", "Thunder II",
  58.                        "Stone III", "Water III", "Aero III", "Fire III", "Blizzard III", "Thunder III",
  59.                        "Stone IV", "Water IV", "Aero IV", "Fire IV", "Blizzard IV", "Thunder IV",}
  60.     info.high_nukes = S{"Stone V", "Water V", "Aero V", "Fire V", "Blizzard V", "Thunder V"}
  61.  
  62.     gear.macc_hagondes = {}
  63.  
  64.     send_command('bind ` input /ma Stun <t>')
  65.     send_command('bind ^- gs c scholar light')
  66.     send_command('bind ^= gs c scholar dark')
  67.     send_command('bind delete gs c scholar speed')
  68.     send_command('bind Home gs c scholar duration')
  69.     send_command('bind End gs c scholar aoe')
  70.  
  71.     select_default_macro_book()
  72. end
  73.  
  74. function user_unload()
  75.     send_command('unbind `')
  76.     send_command('unbind ^-')
  77.     send_command('unbind ^=')
  78.     send_command('unbind delete')
  79.     send_command('unbind end')
  80.     send_command('unbind home')
  81. end
  82.  
  83. -------------------------------------------------------------------------------------------------------------------
  84. -- Job-specific hooks for standard casting events.
  85. -------------------------------------------------------------------------------------------------------------------
  86. function pretarget(spell,action)
  87.     if (spell.type:endswith('Magic') or spell.type == "Ninjutsu") and buffactive.silence then -- Auto Use Echo Drops If You Are Silenced --
  88.         cancel_spell()
  89.         send_command('input /item "Echo Drops" <me>')
  90.     end
  91. end
  92.  
  93. -- Run after the general midcast() is done.
  94. function job_post_midcast(spell, action, spellMap, eventArgs)
  95.     if spell.action_type == 'Magic' then
  96.         apply_grimoire_bonuses(spell, action, spellMap, eventArgs)
  97.     end
  98. end
  99.  
  100. -------------------------------------------------------------------------------------------------------------------
  101. -- Job-specific hooks for non-casting events.
  102. -------------------------------------------------------------------------------------------------------------------
  103.  
  104. -- Called when a player gains or loses a buff.
  105. -- buff == buff gained or lost
  106. -- gain == true if the buff was gained, false if it was lost.
  107. function job_buff_change(buff, gain)
  108.     if buff == "Sublimation: Activated" then
  109.         handle_equipping_gear(player.status)
  110.     end
  111. end
  112.  
  113. -- Handle notifications of general user state change.
  114. function job_state_change(stateField, newValue, oldValue)
  115.     if stateField == 'Offense Mode' then
  116.         if newValue == 'Normal' then
  117.             disable('main','sub','range')
  118.         else
  119.             enable('main','sub','range')
  120.         end
  121.     end
  122. end
  123.  
  124. -------------------------------------------------------------------------------------------------------------------
  125. -- User code that supplements standard library decisions.
  126. -------------------------------------------------------------------------------------------------------------------
  127.  
  128. -- Custom spell mapping.
  129. function job_get_spell_map(spell, default_spell_map)
  130.     if spell.action_type == 'Magic' then
  131.         if default_spell_map == 'Cure' or default_spell_map == 'Curaga' then
  132.             if world.weather_element == 'Light' then
  133.                 return 'CureWithLightWeather'
  134.             end
  135.         elseif spell.skill == 'Enfeebling Magic' then
  136.             if spell.type == 'WhiteMagic' then
  137.                 return 'MndEnfeebles'
  138.             else
  139.                 return 'IntEnfeebles'
  140.             end
  141.         elseif spell.skill == 'Elemental Magic' then
  142.             if info.low_nukes:contains(spell.english) then
  143.                 return 'LowTierNuke'
  144.             elseif info.mid_nukes:contains(spell.english) then
  145.                 return 'MidTierNuke'
  146.             elseif info.high_nukes:contains(spell.english) then
  147.                 return 'HighTierNuke'
  148.             end
  149.         end
  150.     end
  151. end
  152.  
  153. function customize_idle_set(idleSet)
  154.     if state.Buff['Sublimation: Activated'] then
  155.         if state.IdleMode.value == 'Normal' then
  156.             idleSet = set_combine(idleSet, sets.buff.FullSublimation)
  157.         elseif state.IdleMode.value == 'PDT' then
  158.             idleSet = set_combine(idleSet, sets.buff.PDTSublimation)
  159.         end
  160.     end
  161.  
  162.     if player.mpp < 51 then
  163.         idleSet = set_combine(idleSet, sets.latent_refresh)
  164.     end
  165.  
  166.     return idleSet
  167. end
  168.  
  169. -- Called by the 'update' self-command.
  170. function job_update(cmdParams, eventArgs)
  171.     if cmdParams[1] == 'user' and not (buffactive['light arts']      or buffactive['dark arts'] or
  172.                        buffactive['addendum: white'] or buffactive['addendum: black']) then
  173.         if state.IdleMode.value == 'Stun' then
  174.             send_command('@input /ja "Dark Arts" <me>')
  175.         else
  176.             send_command('@input /ja "Light Arts" <me>')
  177.         end
  178.     end
  179.  
  180.     update_active_strategems()
  181.     update_sublimation()
  182. end
  183.  
  184. -- Function to display the current relevant user state when doing an update.
  185. -- Return true if display was handled, and you don't want the default info shown.
  186. function display_current_job_state(eventArgs)
  187.     display_current_caster_state()
  188.     eventArgs.handled = true
  189. end
  190.  
  191. -------------------------------------------------------------------------------------------------------------------
  192. -- User code that supplements self-commands.
  193. -------------------------------------------------------------------------------------------------------------------
  194.  
  195. -- Called for direct player commands.
  196. function job_self_command(cmdParams, eventArgs)
  197.     if cmdParams[1]:lower() == 'scholar' then
  198.         handle_strategems(cmdParams)
  199.         eventArgs.handled = true
  200.     end
  201. end
  202.  
  203. -------------------------------------------------------------------------------------------------------------------
  204. -- Utility functions specific to this job.
  205. -------------------------------------------------------------------------------------------------------------------
  206.  
  207. -- Reset the state vars tracking strategems.
  208. function update_active_strategems()
  209.     state.Buff['Ebullience'] = buffactive['Ebullience'] or false
  210.     state.Buff['Rapture'] = buffactive['Rapture'] or false
  211.     state.Buff['Perpetuance'] = buffactive['Perpetuance'] or false
  212.     state.Buff['Immanence'] = buffactive['Immanence'] or false
  213.     state.Buff['Penury'] = buffactive['Penury'] or false
  214.     state.Buff['Parsimony'] = buffactive['Parsimony'] or false
  215.     state.Buff['Celerity'] = buffactive['Celerity'] or false
  216.     state.Buff['Alacrity'] = buffactive['Alacrity'] or false
  217.  
  218.     state.Buff['Klimaform'] = buffactive['Klimaform'] or false
  219. end
  220.  
  221. function update_sublimation()
  222.     state.Buff['Sublimation: Activated'] = buffactive['Sublimation: Activated'] or false
  223. end
  224.  
  225. -- Equip sets appropriate to the active buffs, relative to the spell being cast.
  226. function apply_grimoire_bonuses(spell, action, spellMap)
  227.     if state.Buff.Perpetuance and spell.type =='WhiteMagic' and spell.skill == 'Enhancing Magic' then
  228.         equip(sets.buff['Perpetuance'])
  229.     end
  230.     if state.Buff.Rapture and (spellMap == 'Cure' or spellMap == 'Curaga') then
  231.         equip(sets.buff['Rapture'])
  232.     end
  233.     if spell.skill == 'Elemental Magic' and spellMap ~= 'ElementalEnfeeble' then
  234.         if state.Buff.Ebullience and spell.english ~= 'Impact' then
  235.             equip(sets.buff['Ebullience'])
  236.         end
  237.         if state.Buff.Immanence then
  238.             equip(sets.buff['Immanence'])
  239.         end
  240.         if state.Buff.Klimaform and spell.element == world.weather_element then
  241.             equip(sets.buff['Klimaform'])
  242.         end
  243.     end
  244.  
  245.     if state.Buff.Penury then equip(sets.buff['Penury']) end
  246.     if state.Buff.Parsimony then equip(sets.buff['Parsimony']) end
  247.     if state.Buff.Celerity then equip(sets.buff['Celerity']) end
  248.     if state.Buff.Alacrity then equip(sets.buff['Alacrity']) end
  249. end
  250.  
  251.  
  252. -- General handling of strategems in an Arts-agnostic way.
  253. -- Format: gs c scholar <strategem>
  254. function handle_strategems(cmdParams)
  255.     -- cmdParams[1] == 'scholar'
  256.     -- cmdParams[2] == strategem to use
  257.  
  258.     if not cmdParams[2] then
  259.         add_to_chat(123,'Error: No strategem command given.')
  260.         return
  261.     end
  262.     local strategem = cmdParams[2]:lower()
  263.  
  264.     if strategem == 'light' then
  265.         if buffactive['light arts'] then
  266.             send_command('input /ja "Addendum: White" <me>')
  267.         elseif buffactive['addendum: white'] then
  268.             add_to_chat(122,'Error: Addendum: White is already active.')
  269.         else
  270.             send_command('input /ja "Light Arts" <me>')
  271.         end
  272.     elseif strategem == 'dark' then
  273.         if buffactive['dark arts'] then
  274.             send_command('input /ja "Addendum: Black" <me>')
  275.         elseif buffactive['addendum: black'] then
  276.             add_to_chat(122,'Error: Addendum: Black is already active.')
  277.         else
  278.             send_command('input /ja "Dark Arts" <me>')
  279.         end
  280.     elseif buffactive['light arts'] or buffactive['addendum: white'] then
  281.         if strategem == 'cost' then
  282.             send_command('input /ja Penury <me>')
  283.         elseif strategem == 'speed' then
  284.             send_command('input /ja Celerity <me>')
  285.         elseif strategem == 'aoe' then
  286.             send_command('input /ja Accession <me>')
  287.         elseif strategem == 'power' then
  288.             send_command('input /ja Rapture <me>')
  289.         elseif strategem == 'duration' then
  290.             send_command('input /ja Perpetuance <me>')
  291.         elseif strategem == 'accuracy' then
  292.             send_command('input /ja Altruism <me>')
  293.         elseif strategem == 'enmity' then
  294.             send_command('input /ja Tranquility <me>')
  295.         elseif strategem == 'skillchain' then
  296.             add_to_chat(122,'Error: Light Arts does not have a skillchain strategem.')
  297.         elseif strategem == 'addendum' then
  298.             send_command('input /ja "Addendum: White" <me>')
  299.         else
  300.             add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
  301.         end
  302.     elseif buffactive['dark arts']  or buffactive['addendum: black'] then
  303.         if strategem == 'cost' then
  304.             send_command('input /ja Parsimony <me>')
  305.         elseif strategem == 'speed' then
  306.             send_command('input /ja Alacrity <me>')
  307.         elseif strategem == 'aoe' then
  308.             send_command('input /ja Manifestation <me>')
  309.         elseif strategem == 'power' then
  310.             send_command('input /ja Ebullience <me>')
  311.         elseif strategem == 'duration' then
  312.             add_to_chat(122,'Error: Dark Arts does not have a duration strategem.')
  313.         elseif strategem == 'accuracy' then
  314.             send_command('input /ja Focalization <me>')
  315.         elseif strategem == 'enmity' then
  316.             send_command('input /ja Equanimity <me>')
  317.         elseif strategem == 'skillchain' then
  318.             send_command('input /ja Immanence <me>')
  319.         elseif strategem == 'addendum' then
  320.             send_command('input /ja "Addendum: Black" <me>')
  321.         else
  322.             add_to_chat(123,'Error: Unknown strategem ['..strategem..']')
  323.         end
  324.     else
  325.         add_to_chat(123,'No arts has been activated yet.')
  326.     end
  327. end
  328.  
  329.  
  330. -- Gets the current number of available strategems based on the recast remaining
  331. -- and the level of the sch.
  332. function get_current_strategem_count()
  333.     -- returns recast in seconds.
  334.     local allRecasts = windower.ffxi.get_ability_recasts()
  335.     local stratsRecast = allRecasts[231]
  336.  
  337.     local maxStrategems = (player.main_job_level + 10) / 20
  338.  
  339.     local fullRechargeTime = 4*60
  340.  
  341.     local currentCharges = math.floor(maxStrategems - maxStrategems * stratsRecast / fullRechargeTime)
  342.  
  343.     return currentCharges
  344. end
  345.  
  346.  
  347. -- Select default macro book on initial load or subjob change.
  348. function select_default_macro_book()
  349.     set_macro_page(1, 8)
  350. end
Advertisement
Add Comment
Please, Sign In to add comment