Code:
function get_sets()
include('Mote-Include.lua')
end
function init_gear_sets()
sets.precast.JA['Benediction'] = {body="Piety Briault"}
sets.precast.JA['Devotion'] = {head="Piety Cap"}
sets.precast.JA['Martyr'] = {hands="Piety Mitts"}
sets.precast.JA['Divine Caress'] = {hands="Orison Mitts +2",back="Mending Cape"}
sets.precast.FC = {ammo="Incantor Stone",head="Haruspex Hat",neck="Orison Locket",ear2="Loquacious Earring",
hands="Gendewitha Gages",ring2="Prolix Ring",back="Swith Cape",legs="Orvail Pants +1"}
sets.precast.Cure = set_combine(sets.precast.FC, {head="Piety Cap",back="Pahtli Cape",
legs="Orison Pantaloons +2",feet="Cure Clogs"})
sets.precast.FC['Enhancing Magic'] = set_combine(sets.precast.FC, {back="Ogapepo Cape",waist="Siegel Sash"})
sets.midcast.Cure = {
ammo="Mana Ampulla",
head="Gendewitha Caubeen",
neck="Nesanice Torque",
ear1="Roundel Earring",
ear2="Beatific Earring",
body="Orison Bliaud +2",
hands="Theophany Mitts",
ring1="Ephedra Ring",
ring2="Sirona's Ring",
back="Tempered Cape",
waist="CCleric's Belt",
legs="Orison Pantaloons +2",
feet="Piety Duckbills"
}
sets.midcast['Enhancing Magic'] = {
ear1="Gifted Earring",
back="Vita Cape",
waist="Austerity Belt",
feet="Umbani Boots"
}
sets.midcast.Holy = {
main="Baqil Staff",
sub="Mephitis Grip",
ammo="Witchstone",
head="Buremte Hat",
neck="Eddy Necklace",
ear1="Friomisi Earring",
ear2="Hecate's Earring",
body="Haruspex Coat",
hands="Otomi Gloves",
ring1="Acumen Ring",
ring2="Sangoma Ring",
back="Toro Cape",
waist="Aswang Sash",
legs="Gendewitha Spats",
feet="Umbani Boots"
}
sets.midcast.Protectra = {ring1="Sheltered Ring",feet="Piety Duckbills"}
sets.midcast.Shellra = {ring1="Sheltered Ring",legs="Piety Pantaloons"}
sets.idle = {
main="Owleyes",
sub="Sors Shield",
ammo="Incantor Stone",
head="Gendewitha Caubeen",
neck="Orison Locket",
ear1="Gifted Earring",
ear2="Moonshade Earring",
body="Piety Briault",
hands="Serpentes Cuffs",
ring1="Sangoma Ring",
ring2="Mediator's Ring",
back="Pahtli Cape",
waist="Cleric's Belt",
legs="Piety Pantaloons",
feet="Serpentes Sabots"
}
end
function precast(spell)
if spell.english:startswith('Cure') then
refine_cure(spell, action, spellMap, eventArgs)
end
end
local cureMPCost = {['Cure'] = 8, ['Cure II'] = 24, ['Cure III'] = 46, ['Cure IV'] = 88, ['Cure V'] = 135, ['Cure VI'] = 230}
-- Utility function for automatically adjusting the cure spell being used to match HP needs and MP limits.
-- Handle spell changes before attempting any precast stuff.
function refine_cure(spell, action, spellMap, eventArgs)
-- Only handles single-target cures.
if not spell.english:startswith('Cure') then
return
end
-- Get the estimated amount of HP the target of the spell is below max.
-- Returns nil for targets outside of alliance (no info available).
local missingHP = get_targets_missing_hp(spell)
local preferredCure = spell.english
-- If we have an estimated missing HP value, we can adjust the preferred spell used.
if missingHP then
-- Whm has high skill and up to Cure VI
if player.main_job == 'WHM' then
if missingHP < 150 then
preferredCure = 'Cure'
elseif missingHP < 350 then
preferredCure = 'Cure II'
elseif missingHP < 650 then
preferredCure = 'Cure III'
elseif missingHP < 1000 then
preferredCure = 'Cure IV'
elseif missingHP < 1600 then
preferredCure = 'Cure V'
else
preferredCure = 'Cure VI'
end
-- Rdm, Sch and Pld have high skill and up to Cure IV
elseif player.main_job == 'RDM' or player.main_job == 'SCH' or player.main_job == 'PLD' then
if missingHP < 150 then
preferredCure = 'Cure'
elseif missingHP < 350 then
preferredCure = 'Cure II'
elseif missingHP < 650 then
preferredCure = 'Cure III'
else
preferredCure = 'Cure IV'
end
-- Subbing /whm or /rdm gets you up to Cure IV
elseif player.sub_job == 'WHM' or player.sub_job == 'RDM' then
if missingHP < 150 then
preferredCure = 'Cure'
elseif missingHP < 300 then
preferredCure = 'Cure II'
elseif missingHP < 550 then
preferredCure = 'Cure III'
else
preferredCure = 'Cure IV'
end
-- Subbing /sch or /pld gets you up to Cure III
else
if missingHP < 150 then
preferredCure = 'Cure'
elseif missingHP < 300 then
preferredCure = 'Cure II'
else
preferredCure = 'Cure III'
end
end
end
local mpCost = cure_mp_cost[preferredCure]
if buffactive['Light Arts'] or buffactive['Addendum: White'] then
mpCost = math.floor(mpCost * 0.9)
elseif buffactive['Dark Arts'] or buffactive['Addendum: Black'] then
mpCost = math.floor(mpCost * 1.1)
end
local downgrade_msg
-- Downgrade the spell to what we can actually afford
if player.mp < mpCost and not (buffactive['Manafont'] or buffactive['Mana Well']) then
if player.mp < 8 then
add_to_chat(122, 'Insufficient MP ['..tostring(player.mp)..']. Cancelling.')
eventArgs.cancel = true
return
elseif player.mp < 24 then
preferredCure = 'Cure'
elseif player.mp < 46 then
preferredCure = 'Cure II'
elseif player.mp < 88 then
preferredCure = 'Cure III'
elseif player.mp < 135 then
preferredCure = 'Cure IV'
elseif player.mp < 227 then
preferredCure = 'Cure V'
end
downgrade_msg = 'Insufficient MP ['..tostring(player.mp)..']. Downgrading to '..preferredCure..'.'
end
if preferredCure ~= spell.english then
eventArgs.cancel = true
send_command('@input /ma "'..preferredCure..'" '..tostring(spell.target.raw))
if downgrade then
add_to_chat(122, downgrade_msg)
end
return
end
if missingHP and missingHP > 0 then
add_to_chat(122,'Trying to cure '..tostring(missingHP)..' HP using '..preferredCure..'.')
end
end
function get_targets_missing_hp(spell)
local missingHP
-- If curing ourself, get our exact missing HP
if spell.target.type == "SELF" then
missingHP = player.max_hp - player.hp
-- If curing someone in our alliance, we can estimate their missing HP
elseif spell.target.isallymember then
local target = find_player_in_alliance(spell.target.name)
local est_max_hp = target.hp / (target.hpp/100)
missingHP = math.floor(est_max_hp - target.hp)
end
return missingHP
end
I copied everything right from Motenten's earlier posts but it still doesn't seem to be working. I'm not sure if I called the function properly or not as I'm still very, very green with GearSwap. Any help would be greatly appreciated. Thanks!