
Originally Posted by
worldslost
How would I write a command for blu Mage so that it checks to see if party members are low hp and if I'm going to self cure have it cast AOE instead if the proper spells are set?
Getting the missing HP of a player is annoying, or at least it used to be. A ripped Mote function from a while back, which I used for automatic upgrade/downgrade on WHM cures:
Code:
function find_player_in_alliance(name)
for i,v in ipairs(alliance) do
for k,p in ipairs(v) do
if p.name == name then
return p
end
end
end
end
Maybe some of this is more exposed now, but that'll find it for a given player.
What you'd have to do is reappropriate this array walk to totalize and/or average missing HP from all members within, while ignoring anyone who's close enough to max HP.
Something like:
Code:
function average_alliance_missing_hp()
local tot = 0
local ct = 0
for i,v in ipairs(alliance) do
for k,p in ipairs(v) do
local maxhp = p.hp / (p.hpp/100)
local missinghp = math.floor(maxhp - p.hp)
if missinghp > 100 then
tot += missinghp
ct++
end
end
end
return math.floor(tot/ct)
end
You can tune on the threshold (the >100) so you don't get insignificant amounts mixed in as well as the returned average. Could possibly return the count of players past the missing hp threshold instead, or a list/array/whatever with both. I think having the average value is handy if you want to upgrade a tier, but I'm working in WHM space again.