Advertisement
TC24k

common-functions

Jan 4th, 2021
882
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.94 KB | None | 0 0
  1. include('includes/config')
  2.  
  3. --initialise variables to inherit from master config
  4. local showFCInfo = config.showFastCastInfo
  5. local showSpellInfo = config.showSpellInfo
  6. local showCancelInfo = config.showCancelInfo
  7.  
  8.  
  9. function weathercheck(spell_element,set)
  10.     if not set then return end
  11.     if spell_element == world.weather_element or spell_element == world.day_element then
  12.         send_command('@input /echo >> Weather or Day element matches spell element <<')
  13.         equip(set,sets.Obis[spell_element]) --Equip standard obi, force fallback below
  14.         equip(set,sets.Obis.AIO) --Force fallback onto Hachirin-no-Obi, just in case individual obis no longer exist
  15.     else
  16.         equip(set)
  17.     end
  18.     if set[spell_element] then equip(set[spell_element]) end
  19. end
  20.  
  21.  
  22. function equipGearByState()
  23.     if player.status == 'Idle' then
  24.         equip(sets.aftercast.Idle)
  25.     elseif sets.aftercast[player.status][TPStyle[TPStyleIndex]] then
  26.         equip(sets.aftercast[player.status][TPStyle[TPStyleIndex]],sets.aftercast)
  27.     else
  28.         equip(sets.aftercast.Idle,sets.aftercast)
  29.     end
  30. end
  31.  
  32. function cancelBuff(spell, casttime, FC, buff) --Requires cancel plugin
  33.  
  34.     --Setup list of buffs to be autocancelled
  35.     local autoCancelList = S{"Enstone", "Enwater", "Enaero", "Enfire", "Enblizzard", "Enthunder", "Stoneskin", "Blaze Spikes","Ice Spikes"}
  36.    
  37.     --Setup amount of Fast Cast available
  38.     local FastCastAmount = FC
  39.    
  40.     -- Multiply out Fast Cast - 80% Fast Cast will result in a 0.2 multiplier (20%)
  41.     -- Setting FastCastAmount properly lets FastCastMultiplier to determine how quickly we need to cancel buffs
  42.     local FastCastMultiplier = ((100 - FastCastAmount)/100)
  43.    
  44.     --Last responsible moment to cancel is 75% of your total FastCastMultiplier - 80% Fast Cast means 20% total cast time (10s => 2s). Take 75% of this final amount to cancel out, stopping any rogue late cancels
  45.     FastCastMultiplier = FastCastMultiplier*0.75
  46.    
  47.     if (autoCancelList:contains(spell)) then
  48.         add_to_chat(8, spell.." found in auto-cancel list.")
  49.  
  50.         if (showFCInfo) then
  51.             add_to_chat(8, "Base casting time: " ..casttime)
  52.             add_to_chat(8, "Fast Cast Amount: " ..FastCastAmount.."%. Fast Cast Multiplier is: " ..FastCastMultiplier..". Cancelling spells at "..(FastCastMultiplier*100).."%.")
  53.         end
  54.         delay = (casttime * FastCastMultiplier)
  55.         if (showCancelInfo) then
  56.             add_to_chat(8, "Delay to cancel buff: " ..delay)
  57.         end
  58.        
  59.         if buff == nil then
  60.             send_command('@wait '..delay..'; cancel '..spell)
  61.             if (showCancelInfo) then
  62.                 add_to_chat(10, "Cancelling "..spell.." in "..delay.."s...")
  63.             end
  64.         else
  65.             send_command('@wait '..delay..'; cancel '..buff)
  66.             if (showCancelInfo) then
  67.                 add_to_chat(10, "Cancelling "..buff.." in "..delay.."s...")
  68.             end
  69.         end
  70.     end
  71. end
  72.  
  73. -- Just a neater macro change option
  74. function switchMacroSet(book, page)
  75.     add_to_chat(8, "Switching Macros.. Book: "..book.."/Page: "..page)
  76.     send_command('input /macro book '..book..';wait .1;input /macro set '..page)
  77. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement