Advertisement
Guest User

Untitled

a guest
May 14th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 22.23 KB | None | 0 0
  1. -------------------------------------------------------------------------------------------------------------------
  2. -- Setup functions for this job.  Generally should not be modified.
  3. -------------------------------------------------------------------------------------------------------------------
  4.  
  5. -- Initialization function for this job file.
  6. function get_sets()
  7.         mote_include_version = 2
  8.  
  9.         -- Load and initialize the include file.
  10.         include('Mote-Include.lua')
  11. end
  12.  
  13. -- Setup vars that are user-independent.  state.Buff vars initialized here will automatically be tracked.
  14. function job_setup()
  15.         indi_timer = ''
  16.         indi_duration = 280
  17. end
  18.  
  19. -------------------------------------------------------------------------------------------------------------------
  20. -- Job-specific hooks for standard casting events.
  21. -------------------------------------------------------------------------------------------------------------------
  22. function precast(spell,action)
  23. -- Auto-Echo drop :D --
  24.     if spell.action_type == 'Magic' and buffactive['Silence'] then
  25.       cancel_spell()
  26.       send_command('input /item "Echo Drops" <me>')
  27. -- Auto Blaze of Glory for lazies :p --    
  28.     elseif string.find(spell.english, 'Geo-') then
  29.         if not buffactive['Bolster'] and not buffactive['Amnesia'] and not pet.isvalid and windower.ffxi.get_ability_recasts()[247] < 1 then
  30.             cancel_spell()
  31.             send_command('input /ja "Blaze of Glory" <me>;wait 2;input /ma "'..spell.english..'" '..spell.target.name)
  32.         end
  33. -- Auto Entrust if you are targeting someone else than you --  
  34.     elseif string.find(spell.english, 'Indi-') then
  35.         if spell.target.type == 'PLAYER' and windower.ffxi.get_ability_recasts()[93] < 1 and not buffactive['Entrust'] and not buffactive['Amnesia']  then
  36.             cancel_spell()
  37.             send_command('input /ja "entrust" <me>;wait 1.5;input /ma "'..spell.name..'" '..spell.target.name..';')    
  38.         end
  39.     end
  40. end
  41.  
  42. function job_precast(spell, action, spellMap, eventArgs)
  43.         refine_nukes(spell, action, spellMap, eventArgs)
  44.         refine_various_spells(spell, action, spellMap, eventArgs)
  45. end
  46.  
  47. function refine_various_spells(spell, action, spellMap, eventArgs)
  48.         aspirs = S{'Aspir','Aspir II','Aspir III'}
  49.         sleeps = S{'Sleep','Sleep II'}
  50.         sleepgas = S{'Sleepga','Sleepga II'}
  51.  
  52.         if not sleepgas:contains(spell.english) and not sleeps:contains(spell.english) and not aspirs:contains(spell.english) then
  53.                 return
  54.         end
  55.  
  56.         local newSpell = spell.english
  57.         local spell_recasts = windower.ffxi.get_spell_recasts()
  58.         local cancelling = 'All '..spell.english..' spells are on cooldown. Cancelling spell casting.'
  59.  
  60.         if spell_recasts[spell.recast_id] > 0 then
  61.                 if aspirs:contains(spell.english) then
  62.                         if spell.english == 'Aspir' then
  63.                                 add_to_chat(122,cancelling)
  64.                                 eventArgs.cancel = true
  65.                                 return
  66.                         elseif spell.english == 'Aspir II' then newSpell = 'Aspir'
  67.                         elseif spell.english == 'Aspir III' then newSpell = 'Aspir II'
  68.                         end                    
  69.                 elseif sleeps:contains(spell.english) then
  70.                         if spell.english == 'Sleep' then
  71.                                 add_to_chat(122,cancelling)
  72.                                 eventArgs.cancel = true
  73.                                 return
  74.                         elseif spell.english == 'Sleep II' then newSpell = 'Sleep'
  75.                         end
  76.                 elseif sleepgas:contains(spell.english) then
  77.                         if spell.english == 'Sleepga' then
  78.                                 add_to_chat(122,cancelling)
  79.                                 eventArgs.cancel = true
  80.                                 return
  81.                         elseif spell.english == 'Sleepga II' then newSpell = 'Sleepga'
  82.                         end
  83.                 end
  84.         end
  85.  
  86.         if newSpell ~= spell.english then
  87.                 send_command('@input /ma "'..newSpell..'" '..tostring(spell.target.raw))
  88.                 eventArgs.cancel = true
  89.                 return
  90.         end
  91. end
  92.  
  93. function midcast(spell)
  94.     if spell.action_type == 'Magic' then
  95.         if spell.skill == 'Geomancy' then
  96.             if string.find(spell.english, 'Geo-') then
  97.                 equip(sets.midcast.Geomancy)
  98.             elseif string.find(spell.english, 'Indi-') then
  99.                 equip(sets.midcast.Geomancy.Indi)          
  100.                 if buffactive['Entrust'] then
  101.                     sets.midcast.Geomancy.Indi = set_combine(sets.midcast.Geomancy.Indi, {main="Solstice"})        
  102.                 end
  103.             end
  104.         end
  105.     end
  106. end
  107.    
  108. function job_aftercast(spell, action, spellMap, eventArgs)
  109.         if not spell.interrupted then
  110.                 if spell.english:startswith('Indi') then
  111.                         if not classes.CustomIdleGroups:contains('Indi') then
  112.                                 classes.CustomIdleGroups:append('Indi')
  113.                         end
  114.                         send_command('@timers d "'..indi_timer..'"')
  115.                         indi_timer = spell.english
  116.                         send_command('@timers c "'..indi_timer..'" '..indi_duration..' down spells/00136.png')
  117.                 elseif spell.english == 'Sleep' or spell.english == 'Sleepga' then
  118.                         send_command('@timers c "'..spell.english..' ['..spell.target.name..']" 60 down spells/00220.png')
  119.                 elseif spell.english == 'Sleep II' or spell.english == 'Sleepga II' then
  120.                         send_command('@timers c "'..spell.english..' ['..spell.target.name..']" 90 down spells/00220.png')
  121.                 end
  122.         elseif not player.indi then
  123.                 classes.CustomIdleGroups:clear()
  124.         end
  125. end
  126.  
  127. -------------------------------------------------------------------------------------------------------------------
  128. -- Job-specific hooks for non-casting events.
  129. -------------------------------------------------------------------------------------------------------------------
  130.  
  131. -- Called when a player gains or loses a buff.
  132. -- buff == buff gained or lost
  133. -- gain == true if the buff was gained, false if it was lost.
  134. function job_buff_change(buff, gain)
  135.         if player.indi and not classes.CustomIdleGroups:contains('Indi')then
  136.                 classes.CustomIdleGroups:append('Indi')
  137.                 handle_equipping_gear(player.status)
  138.         elseif classes.CustomIdleGroups:contains('Indi') and not player.indi then
  139.                 classes.CustomIdleGroups:clear()
  140.                 handle_equipping_gear(player.status)
  141.         end
  142. end
  143.  
  144.  
  145. -------------------------------------------------------------------------------------------------------------------
  146. -- User code that supplements standard library decisions.
  147. -------------------------------------------------------------------------------------------------------------------
  148.  
  149. function job_get_spell_map(spell, default_spell_map)
  150.         if spell.action_type == 'Magic' then
  151.                 if spell.skill == 'Enfeebling Magic' then
  152.                         if spell.type == 'WhiteMagic' then
  153.                                 return 'MndEnfeebles'
  154.                         else
  155.                                 return 'IntEnfeebles'
  156.                         end
  157.                 elseif spell.skill == 'Geomancy' then
  158.                         if spell.english:startswith('Indi') then
  159.                                 return 'Indi'
  160.                         end
  161.                 end
  162.         end
  163. end
  164.  
  165. function customize_idle_set(idleSet)
  166.         if player.mpp < 51 then
  167.                 idleSet = set_combine(idleSet, sets.latent_refresh)
  168.         end
  169.         return idleSet
  170. end
  171.  
  172. -- Called by the 'update' self-command.
  173. function job_update(cmdParams, eventArgs)
  174.         classes.CustomIdleGroups:clear()
  175.         if player.indi then
  176.                 classes.CustomIdleGroups:append('Indi')
  177.         end
  178. end
  179.  
  180. -- Function to display the current relevant user state when doing an update.
  181. function display_current_job_state(eventArgs)
  182.         display_current_caster_state()
  183.         eventArgs.handled = true
  184. end
  185.  
  186. -------------------------------------------------------------------------------------------------------------------
  187. -- Utility functions specific to this job.
  188. -------------------------------------------------------------------------------------------------------------------
  189.  
  190. -- Select default macro book on initial load or subjob change.
  191. function select_default_macro_book()
  192.         set_macro_page(1, 3)
  193. end
  194.  
  195. function refine_nukes(spell, action, spellMap, eventArgs)
  196.         local nuke_mp_cost = {  ['Stone'] = 4, ['Stone II'] = 16, ['Stone III'] = 46, ['Stone IV'] = 88,                          ['Stone V'] = 135,                      ['Stone VI'] = 237,
  197.                                                         ['Water'] = 5, ['Water II'] = 19, ['Water III'] = 46, ['Water IV'] = 99,                          ['Water V'] = 175,                      ['Water VI'] = 266,
  198.                                                         ['Aero'] = 6, ['Aero II'] = 22, ['Aero III'] = 54, ['Aero IV'] = 115,                     ['Aero V'] = 198,                        ['Aero VI'] = 299,
  199.                                                         ['Fire'] = 7, ['Fire II'] = 26, ['Fire III'] = 63, ['Fire IV'] = 135,                     ['Fire V'] = 228,                        ['Fire VI'] = 339,
  200.                                                         ['Blizzard'] = 8, ['Blizzard II'] = 31, ['Blizzard III'] = 75, ['Blizzard IV'] = 162,  ['Blizzard V'] = 267,   ['Blizzard VI'] = 386,
  201.                                                         ['Thunder'] = 9, ['Thunder II'] = 37, ['Thunder III'] = 91, ['Thunder IV'] = 195,   ['Thunder V'] = 306,        ['Thunder VI'] = 437,
  202.                                                         ['Stonera'] = 54, ['Stonera II'] = 143, ['Stonera III'] = 276,
  203.                                                         ['Watera'] = 66, ['Watera II'] = 163, ['Watera III'] = 312,
  204.                                                         ['Aera'] = 79, ['Aera II'] = 184, ['Aera III'] = 350,
  205.                                                         ['Fira'] = 93, ['Fira II'] = 206, ['Fira III'] = 390,
  206.                                                         ['Blizzara'] = 108, ['Blizzara II'] = 229, ['Blizzara III'] = 432,
  207.                                                         ['Thundara'] = 123, ['Thundara II'] = 253, ['Thundara III'] = 476,}
  208.  
  209.         if spell.skill ~= 'Elemental Magic' or no_down:contains(spell.english) then
  210.                 return
  211.         end
  212.  
  213.         local elementType
  214.  
  215.         if spell.element == 'Earth' then elementType = 'Stone'
  216.         elseif spell.element == 'Water' then elementType = 'Water'
  217.         elseif spell.element == 'Wind' then elementType = 'Aero'
  218.         elseif spell.element == 'Fire' then elementType = 'Fire'
  219.         elseif spell.element == 'Ice' then elementType = 'Blizzard'
  220.         elseif spell.element == 'Lightning' then elementType = 'Thunder'
  221.         end
  222.  
  223.         local newAra
  224.  
  225.         if aras:contains(spell.english)then
  226.                 if elementType == 'Stone' then newAra = 'Stonera'
  227.                 elseif elementType == 'Water' then newAra = 'Watera'
  228.                 elseif elementType == 'Aero' then newAra = 'Aera'
  229.                 elseif elementType == 'Fire' then newAra = 'Fira'
  230.                 elseif elementType == 'Blizzard' then newAra = 'Blizzara'
  231.                 elseif elementType == 'Thunder' then newAra = 'Thundara'
  232.                 end
  233.         end
  234.  
  235.         local newNuke = spell.english
  236.  
  237.         local nukeMpCost = nuke_mp_cost[newNuke]
  238.  
  239.         if buffactive['Dark Arts'] or buffactive['Addendum: Black'] then
  240.                 nukeMpCost = math.floor(nukeMpCost * 0.9)
  241.         elseif buffactive['Light Arts'] or buffactive['Addendum: White'] then
  242.                 nukeMpCost = math.ceil(nukeMpCost * 1.2)
  243.         end
  244.  
  245.         local downgrade
  246.  
  247.         -- Downgrade the spell to what we can actually afford
  248.         if player.mp < nukeMpCost and not buffactive['Mana Well'] then
  249.                 if spell.element == 'Earth' then
  250.                         if aras:contains(spell.english) then
  251.                                 if player.mp < 54 then
  252.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  253.                                         eventArgs.cancel = true
  254.                                         return
  255.                                 elseif player.mp < 143 then newNuke = ''..newAra..''
  256.                                 elseif player.mp < 276 then newNuke = ''..newAra..' II'
  257.                                 end
  258.                         elseif not aras:contains(spell.english) then
  259.                                 if player.mp < 4 then
  260.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  261.                                         eventArgs.cancel = true
  262.                                         return
  263.                                 elseif player.mp < 16 then newNuke = 'Stone'
  264.                                 elseif player.mp < 40 then newNuke = 'Stone II'
  265.                                 elseif player.mp < 88 then newNuke = 'Stone III'
  266.                                 elseif player.mp < 156 then newNuke = 'Stone IV'
  267.                                 elseif player.mp < 237 then newNuke = 'Stone V'
  268.                                 end
  269.                         end
  270.                 elseif spell.element == 'Water' then
  271.                         if aras:contains(spell.english) then
  272.                                 if player.mp < 66 then
  273.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  274.                                         eventArgs.cancel = true
  275.                                         return
  276.                                 elseif player.mp < 163 then newNuke = ''..newAra..''
  277.                                 elseif player.mp < 312 then newNuke = ''..newAra..' II'
  278.                                 end
  279.                         elseif not aras:contains(spell.english) then
  280.                                 if player.mp < 5 then
  281.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  282.                                         eventArgs.cancel = true
  283.                                         return
  284.                                 elseif player.mp < 19 then newNuke = 'Water'
  285.                                 elseif player.mp < 46 then newNuke = 'Water II'
  286.                                 elseif player.mp < 99 then newNuke = 'Water III'
  287.                                 elseif player.mp < 175 then newNuke = 'Water IV'
  288.                                 elseif player.mp < 266 then newNuke = 'Water V'
  289.                                 end
  290.                         end
  291.                 elseif spell.element == 'Wind' then
  292.                         if aras:contains(spell.english) then
  293.                                 if player.mp < 79 then
  294.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  295.                                         eventArgs.cancel = true
  296.                                         return
  297.                                 elseif player.mp < 184 then newNuke = ''..newAra..''
  298.                                 elseif player.mp < 350 then newNuke = ''..newAra..' II'
  299.                                 end
  300.                         elseif not aras:contains(spell.english) then
  301.                                 if player.mp < 6 then
  302.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  303.                                         eventArgs.cancel = true
  304.                                         return
  305.                                 elseif player.mp < 22 then newNuke = 'Aero'
  306.                                 elseif player.mp < 54 then newNuke = 'Aero II'
  307.                                 elseif player.mp < 115 then newNuke = 'Aero III'
  308.                                 elseif player.mp < 198 then newNuke = 'Aero IV'
  309.                                 elseif player.mp < 299 then newNuke = 'Aero V'
  310.                                 end
  311.                         end
  312.                 elseif spell.element == 'Fire' then
  313.                         if aras:contains(spell.english) then
  314.                                 if player.mp < 93 then
  315.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  316.                                         eventArgs.cancel = true
  317.                                         return
  318.                                 elseif player.mp < 206 then newNuke = ''..newAra..''
  319.                                 elseif player.mp < 390 then newNuke = ''..newAra..' II'
  320.                                 end
  321.                         elseif not aras:contains(spell.english) then
  322.                                 if player.mp < 7 then
  323.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  324.                                         eventArgs.cancel = true
  325.                                         return
  326.                                 elseif player.mp < 26 then newNuke = 'Fire'
  327.                                 elseif player.mp < 63 then newNuke = 'Fire II'
  328.                                 elseif player.mp < 135 then newNuke = 'Fire III'
  329.                                 elseif player.mp < 228 then newNuke = 'Fire IV'
  330.                                 elseif player.mp < 339 then newNuke = 'Fire V'
  331.                                 end
  332.                         end
  333.                 elseif spell.element == 'Ice' then
  334.                         if aras:contains(spell.english) then
  335.                                 if player.mp < 108 then
  336.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  337.                                         eventArgs.cancel = true
  338.                                         return
  339.                                 elseif player.mp < 229 then newNuke = ''..newAra..''
  340.                                 elseif player.mp < 432 then newNuke = ''..newAra..' II'
  341.                                 end
  342.                         elseif not aras:contains(spell.english) then
  343.                                 if player.mp < 8 then
  344.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  345.                                         eventArgs.cancel = true
  346.                                         return
  347.                                 elseif player.mp < 31 then newNuke = 'Blizzard'
  348.                                 elseif player.mp < 75 then newNuke = 'Blizzard II'
  349.                                 elseif player.mp < 162 then newNuke = 'Blizzard III'
  350.                                 elseif player.mp < 267 then newNuke = 'Blizzard IV'
  351.                                 elseif player.mp < 386 then newNuke = 'Blizzard V'
  352.                                 end
  353.                         end
  354.                 elseif spell.element == 'Lightning' then
  355.                         if aras:contains(spell.english) then
  356.                                 if player.mp < 123 then
  357.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  358.                                         eventArgs.cancel = true
  359.                                         return
  360.                                 elseif player.mp < 253 then newNuke = ''..newAra..''
  361.                                 elseif player.mp < 476 then newNuke = ''..newAra..' II'
  362.                                 end
  363.                         elseif not aras:contains(spell.english) then
  364.                                 if player.mp < 9 then
  365.                                         add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
  366.                                         eventArgs.cancel = true
  367.                                         return
  368.                                 elseif player.mp < 37 then newNuke = 'Thunder'
  369.                                 elseif player.mp < 91 then newNuke = 'Thunder II'
  370.                                 elseif player.mp < 195 then newNuke = 'Thunder III'
  371.                                 elseif player.mp < 306 then newNuke = 'Thunder IV'
  372.                                 elseif player.mp < 437 then newNuke = 'Thunder V'
  373.                                 end
  374.                         end
  375.                 end
  376.  
  377.                 downgrade = 'Insufficient MP ['..tostring(player.mp)..'] to cast '..spell.english..'. Changing spell to '..newNuke..'.'
  378.         end
  379.  
  380.         -- Downgrade the spell to what we can actually cast
  381.         local spell_recasts = windower.ffxi.get_spell_recasts()
  382.         if spell_recasts[spell.recast_id] > 0 then
  383.                 if t1:contains(spell.english) then
  384.                         add_to_chat(122, ''..spell.english..' is on cooldown. Cancelling.')
  385.                         eventArgs.cancel = true
  386.                         return
  387.                 elseif t2:contains(spell.english) then newNuke = ''..elementType..''
  388.                 elseif t3:contains(spell.english) then newNuke = ''..elementType..' II'
  389.                 elseif t4:contains(spell.english) then newNuke = ''..elementType..' III'
  390.                 elseif t5:contains(spell.english) then newNuke = ''..elementType..' IV'
  391.                 elseif t6:contains(spell.english) then newNuke = ''..elementType..' V'
  392.                 elseif ra2:contains(spell.english) then newNuke = ''..newAra..''
  393.                 elseif ra3:contains(spell.english) then newNuke = ''..newAra..' II'
  394.                 end
  395.  
  396.                 downgrade = '***'..spell.english..'*** is on cooldown. Downgrading spell to ***'..newNuke..'***.'
  397.         end
  398.  
  399.         if newNuke ~= spell.english then
  400.                 send_command('@input /ma "'..newNuke..'" '..tostring(spell.target.raw))
  401.                 if downgrade then
  402.                         add_to_chat(122, downgrade)
  403.                 end
  404.                 eventArgs.cancel = true
  405.                 return
  406.         end
  407. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement