|
Help for Gearswap Cure
Carbuncle.Doryll
Serveur: Carbuncle
Game: FFXI
By Carbuncle.Doryll 2015-04-29 09:24:04
Hello,
I saw in Mote-utility.lua a rules for Curing Waltz automatically adapt the good tiers of Cure depends of TP resting.
Is-it possible to adapt it for Curing spells like CureI-VI ?
This is the rules in Mote-utility.lua :
Quote: function refine_waltz(spell, action, spellMap, eventArgs)
if spell.type ~= 'Waltz' then
return
end
-- Don't modify anything for Healing Waltz or Divine Waltzes
if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" or spell.name == "Divine Waltz II" then
return
end
local newWaltz = spell.english
local waltzID
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
-- If we can estimate missing HP, we can adjust the preferred tier used.
if missingHP ~= nil then
if player.main_job == 'DNC' then
if missingHP < 40 and spell.target.name == player.name then
-- not worth curing yourself for so little; allow for other targets to wake them up
add_to_chat(122,'Full HP!')
eventArgs.cancel = true
return
elseif missingHP < 200 then
newWaltz = 'Curing Waltz'
waltzID = 190
elseif missingHP < 600 then
newWaltz = 'Curing Waltz II'
waltzID = 191
elseif missingHP < 1100 then
newWaltz = 'Curing Waltz III'
waltzID = 192
elseif missingHP < 1500 then
newWaltz = 'Curing Waltz IV'
waltzID = 193
else
newWaltz = 'Curing Waltz V'
waltzID = 311
end
elseif player.sub_job == 'DNC' then
if missingHP < 40 and spell.target.name == player.name then
-- not worth curing yourself for so little; allow for other targets to wake them up
add_to_chat(122,'Full HP!')
eventArgs.cancel = true
return
elseif missingHP < 150 then
newWaltz = 'Curing Waltz'
waltzID = 190
elseif missingHP < 300 then
newWaltz = 'Curing Waltz II'
waltzID = 191
else
newWaltz = 'Curing Waltz III'
waltzID = 192
end
else
-- Not dnc main or sub; bail out
return
end
end
local waltzTPCost = {['Curing Waltz'] = 20, ['Curing Waltz II'] = 35, ['Curing Waltz III'] = 50, ['Curing Waltz IV'] = 65, ['Curing Waltz V'] = 80}
local tpCost = waltzTPCost[newWaltz]
--local tpCost
--if waltzID ~= nil then
-- local abil = res.abilities[waltzID]
-- tpCost = abil.tp_cost
--else
-- tpCost = spell.tpcost
--end
local downgrade
-- Downgrade the spell to what we can afford
if player.tp < tpCost and not buffactive.trance then
--[[ Costs:
Curing Waltz: 20 TP
Curing Waltz II: 35 TP
Curing Waltz III: 50 TP
Curing Waltz IV: 65 TP
Curing Waltz V: 80 TP
Divine Waltz: 40 TP
Divine Waltz II: 80 TP
--]]
if player.tp < 20 then
add_to_chat(122, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
eventArgs.cancel = true
return
elseif player.tp < 35 then
newWaltz = 'Curing Waltz'
elseif player.tp < 50 then
newWaltz = 'Curing Waltz II'
elseif player.tp < 65 then
newWaltz = 'Curing Waltz III'
elseif player.tp < 80 then
newWaltz = 'Curing Waltz IV'
end
downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
end
if newWaltz ~= spell.english then
send_command('@input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
if downgrade then
add_to_chat(122, downgrade)
end
eventArgs.cancel = true
return
end
if missingHP > 0 then
add_to_chat(122,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
end
end
Thank you
By Lunareticc 2015-04-29 10:22:06
You can try that (test required): Code 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
Quetzalcoatl.Orestes
Serveur: Quetzalcoatl
Game: FFXI
Posts: 430
By Quetzalcoatl.Orestes 2015-04-29 10:23:10
Yeah, it should be possible.
Assuming you use Mote's includes, you would create a file in your data folder called User-Globals.lua. Write the function refine_cure() and define user_precast() inside. For more info on how User-Globals.lua works, see here, under Optional Files.
In this case, you are providing a user_precast() function, which is going to be seen by all your job files.
Code
function refine_cure(spell, action, spellMap, eventArgs)
-- bunch of code
end
-- Global intercept on precast.
function user_precast(spell, action, spellMap, eventArgs)
refine_cure(spell, action, spellMap, eventArgs)
end
edit: If you follow what I posted, and decide to use Lunareticc's example, make sure you copy his code from line 8 down. You don't want to put this inside precast(), or you'll have to copy the entire function into every job.lua that uses it.
Carbuncle.Doryll
Serveur: Carbuncle
Game: FFXI
By Carbuncle.Doryll 2015-04-29 16:14:58
Thanks Orestes and Lunaretic
Can you explain more please,
I do a User-Globals.lua and i write Lunaretic's code without 7 first lines ?
Right ?
And nothing in jobs.lua files ?
Thank you
Quetzalcoatl.Orestes
Serveur: Quetzalcoatl
Game: FFXI
Posts: 430
By Quetzalcoatl.Orestes 2015-04-29 16:54:02
Thanks Orestes and Lunaretic
Can you explain more please,
I do a User-Globals.lua and i write Lunaretic's code without 7 first lines ?
Right ?
And nothing in jobs.lua files ?
Thank you
Create the file User-Globals.lua, and place this inside. It contains Lunaretic's code, and a call to user_precast()
Code
-- 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 cure_mp_cost = {['Cure'] = 8, ['Cure II'] = 24, ['Cure III'] = 46, ['Cure IV'] = 88, ['Cure V'] = 135, ['Cure VI'] = 230}
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
-- Global intercept on precast.
function user_precast(spell, action, spellMap, eventArgs)
refine_cure(spell, action, spellMap, eventArgs)
end
I haven't tested it myself. In theory it will work for all your jobs / subjobs that can cast cure without having to touch your job.lua files.
Carbuncle.Doryll
Serveur: Carbuncle
Game: FFXI
By Carbuncle.Doryll 2015-04-29 16:59:46
Thank you very much !!
Tested, it's ok
Hello,
I saw in Mote-utility.lua a rules for Curing Waltz automatically adapt the good tiers of Cure depends of TP resting.
Is-it possible to adapt it for Curing spells like CureI-VI ?
This is the rules in Mote-utility.lua :
Quote: function refine_waltz(spell, action, spellMap, eventArgs)
if spell.type ~= 'Waltz' then
return
end
-- Don't modify anything for Healing Waltz or Divine Waltzes
if spell.name == "Healing Waltz" or spell.name == "Divine Waltz" or spell.name == "Divine Waltz II" then
return
end
local newWaltz = spell.english
local waltzID
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
-- If we can estimate missing HP, we can adjust the preferred tier used.
if missingHP ~= nil then
if player.main_job == 'DNC' then
if missingHP < 40 and spell.target.name == player.name then
-- not worth curing yourself for so little; allow for other targets to wake them up
add_to_chat(122,'Full HP!')
eventArgs.cancel = true
return
elseif missingHP < 200 then
newWaltz = 'Curing Waltz'
waltzID = 190
elseif missingHP < 600 then
newWaltz = 'Curing Waltz II'
waltzID = 191
elseif missingHP < 1100 then
newWaltz = 'Curing Waltz III'
waltzID = 192
elseif missingHP < 1500 then
newWaltz = 'Curing Waltz IV'
waltzID = 193
else
newWaltz = 'Curing Waltz V'
waltzID = 311
end
elseif player.sub_job == 'DNC' then
if missingHP < 40 and spell.target.name == player.name then
-- not worth curing yourself for so little; allow for other targets to wake them up
add_to_chat(122,'Full HP!')
eventArgs.cancel = true
return
elseif missingHP < 150 then
newWaltz = 'Curing Waltz'
waltzID = 190
elseif missingHP < 300 then
newWaltz = 'Curing Waltz II'
waltzID = 191
else
newWaltz = 'Curing Waltz III'
waltzID = 192
end
else
-- Not dnc main or sub; bail out
return
end
end
local waltzTPCost = {['Curing Waltz'] = 20, ['Curing Waltz II'] = 35, ['Curing Waltz III'] = 50, ['Curing Waltz IV'] = 65, ['Curing Waltz V'] = 80}
local tpCost = waltzTPCost[newWaltz]
--local tpCost
--if waltzID ~= nil then
-- local abil = res.abilities[waltzID]
-- tpCost = abil.tp_cost
--else
-- tpCost = spell.tpcost
--end
local downgrade
-- Downgrade the spell to what we can afford
if player.tp < tpCost and not buffactive.trance then
--[[ Costs:
Curing Waltz: 20 TP
Curing Waltz II: 35 TP
Curing Waltz III: 50 TP
Curing Waltz IV: 65 TP
Curing Waltz V: 80 TP
Divine Waltz: 40 TP
Divine Waltz II: 80 TP
--]]
if player.tp < 20 then
add_to_chat(122, 'Insufficient TP ['..tostring(player.tp)..']. Cancelling.')
eventArgs.cancel = true
return
elseif player.tp < 35 then
newWaltz = 'Curing Waltz'
elseif player.tp < 50 then
newWaltz = 'Curing Waltz II'
elseif player.tp < 65 then
newWaltz = 'Curing Waltz III'
elseif player.tp < 80 then
newWaltz = 'Curing Waltz IV'
end
downgrade = 'Insufficient TP ['..tostring(player.tp)..']. Downgrading to '..newWaltz..'.'
end
if newWaltz ~= spell.english then
send_command('@input /ja "'..newWaltz..'" '..tostring(spell.target.raw))
if downgrade then
add_to_chat(122, downgrade)
end
eventArgs.cancel = true
return
end
if missingHP > 0 then
add_to_chat(122,'Trying to cure '..tostring(missingHP)..' HP using '..newWaltz..'.')
end
end
Thank you
|
|