Advertisement
shadowmeld

sch-function.lua

Jan 17th, 2014
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.98 KB | None | 0 0
  1. local schfunc = {}
  2.  
  3. function schfunc.file_unload()
  4.  
  5.     unalias_strategems()
  6.  
  7. end
  8.  
  9. function schfunc.job_precast(spell, action, spellMap, eventArgs)
  10.  
  11.     local cast_addendum = false
  12.     local arts_needed = nil
  13.     local addendum = nil
  14.    
  15.     if spell.type == 'WhiteMagic' then
  16.         arts_needed = 'Light Arts'
  17.         addendum = 'Addendum: White'
  18.     elseif spell.type == 'BlackMagic' then
  19.         arts_needed = 'Dark Arts'
  20.         addendum = 'Addendum: Black'
  21.     end
  22.    
  23.     if spell.type == 'WhiteMagic' or spell.type == 'BlackMagic' then
  24.         if addendum_spells[arts_needed][spell.name] and not (buffactive[addendum] or buffactive['Enlightenment']) then
  25.             if not (addendum_spells[player.sub_job] and addendum_spells[player.sub_job][spell.english]) then
  26.                 windower.add_to_chat(123, 'This spell requires the appropriate Addendum or Enlightenment to cast.')
  27.                 cast_addendum = true
  28.             end
  29.         end
  30.        
  31.         if cast_addendum then
  32.             eventArgs.cancel = true
  33.    
  34.             if (not buffactive[arts_needed] or addendum_spells.tried_addend) and not addendum_spells.tried_enlighten then
  35.                 windower.add_to_chat(123, 'Opposite or no arts active, trying Enlightenment')
  36.                 windower.send_command('input /ja "Enlightenment" <me>; wait 2; input /ma "' .. spell.english .. '" ' .. spell.target.raw)
  37.                 addendum_spells.tried_enlighten = true
  38.                 return
  39.             elseif buffactive[arts_needed] and not addendum_spells.tried_addend then
  40.                 windower.add_to_chat(123, 'Trying Addendum')
  41.                 windower.send_command('input /ja "' .. addendum .. '" <me>; wait 2; input /ma "' .. spell.english .. '" ' .. spell.target.raw)
  42.                 addendum_spells.tried_addend = true
  43.                 return
  44.             else
  45.                 windower.add_to_chat(123, 'Unable to cast spell, unable to use Addendum or Enlightenment.')
  46.             end
  47.         end
  48.        
  49.         addendum_spells.tried_addend = false
  50.         addendum_spells.tried_enlighten = false
  51.     end
  52.  
  53. end
  54.  
  55. function schfunc.build_post_precast_set(spell, action, spellMap)
  56.  
  57.     if not (buffactive['Celerity'] or buffactive['Alacrity']) then
  58.         if buffactive['Light Arts'] or buffactive['Dark Arts'] or buffactive['Addendum: White'] or buffactive['Addendum: Black'] then
  59.             sets.Casting.Precast = set_combine(sets.Casting.Precast, sets.Grimoire.CastTime)
  60.         end
  61.     end
  62.  
  63. end
  64.  
  65. function schfunc.build_post_midcast_set(spell, action, spellMap)
  66.  
  67.     if spell.skill == 'EnhancingMagic' and (buffactive['Light Arts'] or buffactive['Addendum: White']) and spellMap ~= 'Regen' then
  68.         if (sets.EnhancingMagic[spell.name] or sets.EnhancingMagic[spellMap]) then
  69.             sets.Casting.Midcast = set_combine(sets.Casting.Midcast, sets.Grimoire['Light Arts'])
  70.         end
  71.     end
  72.    
  73.     if (spell.skill == 'DarkMagic') and (buffactive['Dark Arts'] or buffactive['Addendum: Black']) then
  74.         if spell.english ~= 'Stun' then
  75.             sets.Casting.Midcast = set_combine(sets.Casting.Midcast, sets.Grimoire['Dark Arts'])
  76.         end
  77.     end
  78.    
  79.     if (spell.skill == 'EnfeeblingMagic') and (buffactive['Dark Arts'] or buffactive['Addendum: Black']) then
  80.         sets.Casting.Midcast = set_combine(sets.Casting.Midcast, sets.Grimoire['Dark Arts'])
  81.     end
  82.    
  83.     if spell.skill == 'ElementalMagic' and spellMap ~= 'Debuff' and buffactive.Klimaform then
  84.         sets.Casting.Midcast = set_combine(sets.Casting.Midcast, sets.Grimoire.Klimaform)
  85.     end
  86.  
  87.     for i = 1, #strategems.affected[spell.skill] do
  88.         if buffactive[strategems.affected[spell.skill][i]] and sets.Grimoire[strategems.affected[spell.skill][i]] then
  89.             sets.Casting.Midcast = set_combine(sets.Casting.Midcast, sets.Grimoire[strategems.affected[spell.skill][i]])
  90.         end
  91.     end
  92.  
  93. end
  94.  
  95. function schfunc.job_buff_change(buff, gain)
  96.  
  97.     if buff == 'Sublimation: Activated' then
  98.         if gain then
  99.             sets.Idle = set_combine(sets.Idle, sets.Sublimation)
  100.             sets.Engaged = sets.Idle
  101.         else
  102.             sets.Idle = sets.Idle.Default
  103.             sets.Engaged = sets.Idle
  104.         end
  105.        
  106.         if world.weather_element == 'Earth' or buffactive.Sandstorm then
  107.             sets.Idle = set_combine(sets.Idle, sets.Kite)
  108.         end
  109.        
  110.         equip(sets[player.status])
  111.     end
  112.    
  113. end
  114.  
  115. function schfunc.job_self_command(cmdParams, eventArgs)
  116.  
  117.     if cmdParams[1] and strategems.alias_list:contains(cmdParams[1]) then
  118.         use_strategem(cmdParams[1])
  119.         eventArgs.handled = true
  120.     elseif cmdParams[1] and cmdParams[1] == 'help' and cmdParams[2] == 'strat' then
  121.         windower.add_to_chat(80, '********** SCH.lua strat aliases **********')
  122.         windower.add_to_chat(80, 'the following aliases have been defined for SCH.lua')
  123.         windower.add_to_chat(80, 'to aid the use of strategems in their respective arts')
  124.         windower.add_to_chat(80, 'addend, cost, speed, aoe, power, duration,')
  125.         windower.add_to_chat(80, 'skillchain, accuracy, and enmity')
  126.         windower.add_to_chat(80, 'Additionally, if you attempt to cast a spell that')
  127.         windower.add_to_chat(80, 'requires an addendum, SCH.lua will attempt to either')
  128.         windower.add_to_chat(80, 'use the appropriate addendum or use enlightenment')
  129.     end
  130.  
  131. end
  132.  
  133. function schfunc.use_strategem(strat)
  134.  
  135.     if buffactive['Light Arts'] or buffactive['Addendum: White'] then
  136.         if strategems['Light Arts'][strat] then
  137.             windower.send_command('input /ja "' .. strategems['Light Arts'][strat] .. '" <me>')
  138.         else
  139.             windower.add_to_chat(123, 'Light Arts does not have a strategem for ' .. strat .. '.')
  140.         end
  141.     elseif buffactive['Dark Arts'] or buffactive['Addendum: Black'] then
  142.         if strategems['Dark Arts'][strat] then
  143.             windower.send_command('input /ja "' .. strategems['Dark Arts'][strat] .. '" <me>')
  144.         else
  145.             windower.add_to_chat(123, 'Dark Arts does not have a strategem for ' .. strat .. '.')
  146.         end
  147.     end
  148.  
  149. end
  150.  
  151. function schfunc.alias_strategems()
  152.  
  153.     print('Adding SCH Stratagem Aliases....')
  154.     for i = 1, #strategems.alias_list do
  155.         windower.send_command('alias ' .. strategems.alias_list[i] .. ' gs c ' .. strategems.alias_list[i])
  156.     end
  157.     print('Finished Adding SCH Strategem Aliases.')
  158.  
  159. end
  160.  
  161. function schfunc.unalias_strategems()
  162.  
  163.     print('Removing SCH Stratagem Aliases.....')
  164.     for i = 1, #strategems.alias_list do
  165.         windower.send_command('unalias ' .. strategems.alias_list[i])
  166.     end
  167.     print('Finished Removing SCH Stratagem Aliases.')
  168.  
  169. end
  170.  
  171. return schfunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement