Skip to content

Instantly share code, notes, and snippets.

@mattwells
Last active February 2, 2019 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattwells/300af25fb07a7939ffd8d0f97886706e to your computer and use it in GitHub Desktop.
Save mattwells/300af25fb07a7939ffd8d0f97886706e to your computer and use it in GitHub Desktop.
GearSwap Waltz Refinements
function get_target_missing_hp(target)
if target.type == "SELF" then
return player.max_hp - player.hp
end
if not target.isallymember then
return
end
local target = find_player_in_alliance(target.name)
return math.floor((target.hp / (target.hpp / 100)) - target.hp)
end
function get_dnc_level()
if player.sub_job == "DNC" then
return player.sub_job_level
end
return player.main_job_level
end
function refine_waltz(spell)
if player.tp < 200 then
add_to_chat(122, "No TP!")
cancel_spell()
return
end
local dncLevel = get_dnc_level()
local spellRecasts = windower.ffxi.get_spell_recasts()
local missingHP = get_target_missing_hp(spell.target)
if not missingHP then
return true
end
if spell.target.type == "SELF" and missingHP < 40 then
add_to_chat(122, "Full HP!")
cancel_spell()
return
end
local waltzes =
table.filter(
{
{id = 190, name = "Curing Waltz", level = 15, tp = 200, hp = 300},
{id = 191, name = "Curing Waltz II", level = 30, tp = 350, hp = 600},
{id = 192, name = "Curing Waltz III", level = 45, tp = 500, hp = 1000},
{id = 193, name = "Curing Waltz IV", level = 70, tp = 650, hp = 1500},
{id = 194, name = "Curing Waltz V", level = 87, tp = 800, hp = 2000}
},
function(waltz)
return waltz.level <= dncLevel and waltz.tp <= player.tp and spellRecasts[waltz.id] < 1
end
)
local newWaltz = "Curing Waltz"
for _, waltz in ipairs(waltzes) do
if waltz.hp > missingHP then
break
end
newWaltz = waltz.name
end
if newWaltz ~= spell.english then
send_command('@input /ja "' .. newWaltz .. '" ' .. tostring(spell.target.raw))
cancel_spell()
return
end
return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment