celestian
March 11th, 2020, 16:58
I am not sure if this is intended but I ran across this working on something last night. The function getReductionType() returns a list of damage types with the associated modifier. So if it's "RESIST: 12 fire" it will note "fire" with a modifier of 12. If there are 2 entries with fire it'll pick whichever one is "last" in the node list. So if you have RESIST: 12 fire and another entry of RESIST: 20 cold,fire it could pick 12 or 20 depending on whichever node is last in the for loop.
This might not be an issue for 5E but I thought I would mention it. I would "think" the intent would be to use the highest modifier or maybe stack them? For my case I needed the highest (best) one.
Here is the code snippet with the highlighted section.
function getReductionType(rSource, rTarget, sEffectType)
local aEffects = EffectManager5E.getEffectsByType(rTarget, sEffectType, {}, rSource);
local aFinal = {};
for _,v in pairs(aEffects) do
local rReduction = {};
rReduction.mod = v.mod;
rReduction.aNegatives = {};
for _,vType in pairs(v.remainder) do
if #vType > 1 and ((vType:sub(1,1) == "!") or (vType:sub(1,1) == "~")) then
if StringManager.contains(DataCommon.dmgtypes, vType:sub(2)) then
table.insert(rReduction.aNegatives, vType:sub(2));
end
end
end
for _,vType in pairs(v.remainder) do
if vType ~= "untyped" and vType ~= "" and vType:sub(1,1) ~= "!" and vType:sub(1,1) ~= "~" then
if StringManager.contains(DataCommon.dmgtypes, vType) or vType == "all" then
aFinal[vType] = rReduction;
end
end
end
end
return aFinal;
end
This might not be an issue for 5E but I thought I would mention it. I would "think" the intent would be to use the highest modifier or maybe stack them? For my case I needed the highest (best) one.
Here is the code snippet with the highlighted section.
function getReductionType(rSource, rTarget, sEffectType)
local aEffects = EffectManager5E.getEffectsByType(rTarget, sEffectType, {}, rSource);
local aFinal = {};
for _,v in pairs(aEffects) do
local rReduction = {};
rReduction.mod = v.mod;
rReduction.aNegatives = {};
for _,vType in pairs(v.remainder) do
if #vType > 1 and ((vType:sub(1,1) == "!") or (vType:sub(1,1) == "~")) then
if StringManager.contains(DataCommon.dmgtypes, vType:sub(2)) then
table.insert(rReduction.aNegatives, vType:sub(2));
end
end
end
for _,vType in pairs(v.remainder) do
if vType ~= "untyped" and vType ~= "" and vType:sub(1,1) ~= "!" and vType:sub(1,1) ~= "~" then
if StringManager.contains(DataCommon.dmgtypes, vType) or vType == "all" then
aFinal[vType] = rReduction;
end
end
end
end
return aFinal;
end