function job_post_precast(spell, spellMap, eventArgs)
if spell.type == 'WeaponSkill' then
local WSset = standardize_set(get_precast_set(spell, spellMap))
local wsacc = check_ws_acc()
if (WSset.ear1 == "Moonshade Earring" or WSset.ear2 == "Moonshade Earring") then
-- Replace Moonshade Earring if we're at cap TP
if get_effective_player_tp(spell, WSset) > 3200 then
if data.weaponskills.elemental:contains(spell.english) then
if wsacc:contains('Acc') and sets.MagicalAccMaxTP then
equip(sets.MagicalAccMaxTP[spell.english] or sets.MagicalAccMaxTP)
elseif sets.MagicalMaxTP then
equip(sets.MagicalMaxTP[spell.english] or sets.MagicalMaxTP)
else
end
elseif spell.skill == 26 then
if wsacc:contains('Acc') and sets.RangedAccMaxTP then
equip(sets.RangedAccMaxTP[spell.english] or sets.RangedAccMaxTP)
elseif sets.RangedMaxTP then
equip(sets.RangedMaxTP[spell.english] or sets.RangedMaxTP)
else
end
else
if wsacc:contains('Acc') and not buffactive['Sneak Attack'] and sets.AccMaxTP then
equip(sets.AccMaxTP[spell.english] or sets.AccMaxTP)
elseif sets.MaxTP then
equip(sets.MaxTP[spell.english] or sets.MaxTP)
else
end
end
end
end
elseif spell.type == 'CorsairShot' and not (spell.english == 'Light Shot' or spell.english == 'Dark Shot') then
if (state.WeaponskillMode.value == "Proc" or state.CastingMode.value == "Proc") and sets.precast.CorsairShot.Proc then
equip(sets.precast.CorsairShot.Proc)
elseif state.CastingMode.value == 'Fodder' and sets.precast.CorsairShot.Damage then
equip(sets.precast.CorsairShot.Damage)
end
elseif spell.english == 'Light Shot' or spell.english == 'Dark Shot' then
if state.CastingMode.value == 'Fodder' then
equip(set_combine(sets.precast.CorsairShot.Damage, sets.precast.CorsairShot[spell.english]))
else
equip(set_combine(sets.precast.CorsairShot, sets.precast.CorsairShot[spell.english]))
end
elseif spell.action_type == 'Ranged Attack' then
if buffactive.Flurry then
if sets.precast.RA.Flurry and lastflurry == 1 then
equip(sets.precast.RA.Flurry)
elseif sets.precast.RA.Flurry2 and lastflurry == 2 then
equip(sets.precast.RA.Flurry2)
end
end
elseif spell.type == 'CorsairRoll' or spell.english == "Double-Up" then
if state.LuzafRing.value and item_available("Luzaf's Ring") then
equip(sets.precast.LuzafRing)
end
if spell.type == 'CorsairRoll' and state.CompensatorMode.value ~= 'Never' and (state.CompensatorMode.value == 'Always' or tonumber(state.CompensatorMode.value) > player.tp) then
if item_available("Compensator") then
enable('range')
equip({range="Compensator"})
end
if sets.precast.CorsairRoll.main and sets.precast.CorsairRoll.main ~= player.equipment.main then
enable('main')
equip({main=sets.precast.CorsairRoll.main})
end
end
elseif spell.english == 'Fold' and buffactive['Bust'] == 2 and sets.precast.FoldDoubleBust then
equip(sets.precast.FoldDoubleBust)
end
end