Pentazer
November 12th, 2019, 15:52
So my home brew setting has an ability called willpower whose modifier is the combined sum of both intelligence and wisdom modifiers, so if you had a +3 INT and +1 WIS your WIL is +4. I've got everything set, it shows up in the character sheet, the ability scores appropriately and is intractable. however I've got one problem left I don't know how to resolve. The sheet is expecting base 10 when WIL is base 0. Meaning a will score of 0 is giving a -5 modifier and a +4 is giving a -3 when it should be 0 for 0 and +4 for +4.
Side note: it would be great if WIL was automatically filled by reading the characters INT and WIS modifiers and summing them together, but I have no clue how to do that.
Here's the area that is impacted:
function getAbilityScore(rActor, sAbility)
if not sAbility then
return -1;
end
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
if not nodeActor then
return -1;
end
local nStatScore = -1;
local sShort = string.sub(string.lower(sAbility), 1, 3);
if sShort == "lev" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "level", 0);
else
local sHD = StringManager.trim(DB.getValue(nodeActor, "hd", ""));
nStatScore = 0;
for sLevelSub in sHD:gmatch("(%d+)[dD](%d+)") do
nStatScore = nStatScore + (tonumber(sLevelSub) or 0);
end
end
elseif sShort == "prf" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "profbonus", 0);
else
local nCR = tonumber(DB.getValue(nodeActor, "cr", ""):match("^%d+$")) or 0;
nStatScore = math.max(2, math.floor((nCR - 1) / 4) + 2);
end
elseif sShort == "str" then
nStatScore = DB.getValue(nodeActor, "abilities.strength.score", 0);
elseif sShort == "dex" then
nStatScore = DB.getValue(nodeActor, "abilities.dexterity.score", 0);
elseif sShort == "con" then
nStatScore = DB.getValue(nodeActor, "abilities.constitution.score", 0);
elseif sShort == "int" then
nStatScore = DB.getValue(nodeActor, "abilities.intelligence.score", 0);
elseif sShort == "wis" then
nStatScore = DB.getValue(nodeActor, "abilities.wisdom.score", 0);
elseif sShort == "cha" then
nStatScore = DB.getValue(nodeActor, "abilities.charisma.score", 0);
elseif sShort == "wil" then
nStatScore = DB.getValue(nodeActor, "abilities.willpower.score", 0);
elseif StringManager.contains(DataCommon.classes, sAbility) then
nStatScore = getClassLevel(nodeActor, sAbility);
end
return nStatScore;
end
I figure that because the willpower score is listed among the rest of the scores, that's why this is happening. But I don't know if I can... maybe write a secondary block of the following:
if sShort == "lev" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "level", 0);
else
local sHD = StringManager.trim(DB.getValue(nodeActor, "hd", ""));
nStatScore = 0;
for sLevelSub in sHD:gmatch("(%d+)[dD](%d+)") do
nStatScore = nStatScore + (tonumber(sLevelSub) or 0);
end
end
elseif sShort == "prf" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "profbonus", 0);
else
local nCR = tonumber(DB.getValue(nodeActor, "cr", ""):match("^%d+$")) or 0;
nStatScore = math.max(2, math.floor((nCR - 1) / 4) + 2);
end
That could have the right math in it? I don't know if that would break FG or... how to go about getting a separate math rule established. I mean, right now I can just simply remove that whole calculation and just manually do the roll using the modifier control on the bottom left, in game, but I'm trying to make it automatic!
Thanks in advance for your help!
Side note: it would be great if WIL was automatically filled by reading the characters INT and WIS modifiers and summing them together, but I have no clue how to do that.
Here's the area that is impacted:
function getAbilityScore(rActor, sAbility)
if not sAbility then
return -1;
end
local sActorType, nodeActor = ActorManager.getTypeAndNode(rActor);
if not nodeActor then
return -1;
end
local nStatScore = -1;
local sShort = string.sub(string.lower(sAbility), 1, 3);
if sShort == "lev" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "level", 0);
else
local sHD = StringManager.trim(DB.getValue(nodeActor, "hd", ""));
nStatScore = 0;
for sLevelSub in sHD:gmatch("(%d+)[dD](%d+)") do
nStatScore = nStatScore + (tonumber(sLevelSub) or 0);
end
end
elseif sShort == "prf" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "profbonus", 0);
else
local nCR = tonumber(DB.getValue(nodeActor, "cr", ""):match("^%d+$")) or 0;
nStatScore = math.max(2, math.floor((nCR - 1) / 4) + 2);
end
elseif sShort == "str" then
nStatScore = DB.getValue(nodeActor, "abilities.strength.score", 0);
elseif sShort == "dex" then
nStatScore = DB.getValue(nodeActor, "abilities.dexterity.score", 0);
elseif sShort == "con" then
nStatScore = DB.getValue(nodeActor, "abilities.constitution.score", 0);
elseif sShort == "int" then
nStatScore = DB.getValue(nodeActor, "abilities.intelligence.score", 0);
elseif sShort == "wis" then
nStatScore = DB.getValue(nodeActor, "abilities.wisdom.score", 0);
elseif sShort == "cha" then
nStatScore = DB.getValue(nodeActor, "abilities.charisma.score", 0);
elseif sShort == "wil" then
nStatScore = DB.getValue(nodeActor, "abilities.willpower.score", 0);
elseif StringManager.contains(DataCommon.classes, sAbility) then
nStatScore = getClassLevel(nodeActor, sAbility);
end
return nStatScore;
end
I figure that because the willpower score is listed among the rest of the scores, that's why this is happening. But I don't know if I can... maybe write a secondary block of the following:
if sShort == "lev" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "level", 0);
else
local sHD = StringManager.trim(DB.getValue(nodeActor, "hd", ""));
nStatScore = 0;
for sLevelSub in sHD:gmatch("(%d+)[dD](%d+)") do
nStatScore = nStatScore + (tonumber(sLevelSub) or 0);
end
end
elseif sShort == "prf" then
if sActorType == "pc" then
nStatScore = DB.getValue(nodeActor, "profbonus", 0);
else
local nCR = tonumber(DB.getValue(nodeActor, "cr", ""):match("^%d+$")) or 0;
nStatScore = math.max(2, math.floor((nCR - 1) / 4) + 2);
end
That could have the right math in it? I don't know if that would break FG or... how to go about getting a separate math rule established. I mean, right now I can just simply remove that whole calculation and just manually do the roll using the modifier control on the bottom left, in game, but I'm trying to make it automatic!
Thanks in advance for your help!