Also why does the order matter if it's multiplicative?
|
Because the order in which you multiply, when dealing with percents, affects the out-come? Increasing an amount by 60%, then 40% yields a different answer than increasing an amount by 40%, then 60%.
I suppose you are correct about the two table approach, but the metatable could be universal for two seperate tables, yielding only 3 tables, instead of four? (Bare in mind I know nothing about metatables, I just saw it used as a solution to a problem
similar to mine).
If your code is not performance critical...
|
I guess you could say that code
is performance critical.
My approach was, and this is pretty theoretical, to sort a table of healing increases (and decreases in a separate table) by hand, and as a for-loop iterates over it (assuming it is in descending order), if a player has a buff in the table, that percentage will be applied to an amount, and the process continues. In the example posted above, if a player had BOTH Guardian Spirit and Vampiric Blood, a potential heal would be increased by 60%, then 25(or 40)%.
My approach could be horrid, but it seemed like the most simple approach, until I ran into the issue with my table being impossible to index, and impossible to iterate over with ipairs().
Thanks for the replies!
Edit:
Here was the script I was using (granted, it doesn't
work in that it reads the table in any order, but it still
works)
Lua Code:
for k, v in pairs(generalHealingIncrease) do
if UnitAura("player", k) then
totalDamageAmount = addPercent(totalDamageAmount, v)
end
end