EmptyOwl
June 24th, 2020, 13:55
Hiyas,
I am seeing some weird behavior if I try to replace d20 with 3d6 in the Pathfinder 2 die rolling functions. In the following function fragment what is nDiceRoll? I thought it was the result of the dice rolled (i.e., the result of the 3d6) vs nTotal which would be the total of the roll + mods. This seems to be true except that nDiceRoll only stores the result of the first d6 rolled. I find this confusing and how would I store the total of the 3d6 to compare the dice roll result and total result to determine critical fails, fails, success, and crit success?
Fragment of the base getd20CheckResult:
function getd20CheckResult(nDiceRoll, nTotal, nTargetDC)
Line 476: if (nTotal >= (nTargetDC + 10) or nDiceRoll == 20) and nDiceRoll ~= 1 then
Line 476: if (nTotal >= (nTargetDC + 10) or nDiceRoll == 20) and nDiceRoll ~= 1 then
Line 478: elseif nDiceRoll == 1 and nTotal < (nTargetDC + 10) then
Line 484: if (nTotal <= (nTargetDC - 10) or nDiceRoll == 1) and nDiceRoll ~= 20 then
Line 484: if (nTotal <= (nTargetDC - 10) or nDiceRoll == 1) and nDiceRoll ~= 20 then
Line 486: elseif nDiceRoll == 20 and nTotal > (nTargetDC - 10) then
Line 491: GlobalDebug.consoleObjects("GameSystem.getd20CheckResult - sResult, nDiceRoll, nTotal, nTargetDC = ", sResult, nDiceRoll, nTotal, nTargetDC);
Line 491: GlobalDebug.consoleObjects("GameSystem.getd20CheckResult - sResult, nDiceRoll, nTotal, nTargetDC = ", sResult, nDiceRoll, nTotal, nTargetDC);
My experimental 3d6 tester function:
function getd20CheckResult(nDiceRoll, nTotal, nTargetDC)
-- Return the level of success/failure based off the target DC
-- This function should only be called if there is a target DC - success/failure cannot be determined without.
if nTargetDC == nil then
return "";
end
local sResult = "";
-- Roll meets or exceeds target DC - success unless there is a critical success/failure.
if nTotal >= nTargetDC then
sResult = "SUCCESS";
if (nTotal >= (nTargetDC + 6) or nDiceRoll == 18 or nDiceRoll == 17 or nDiceRoll == 16) and (nDiceRoll ~= 3 and nDiceRoll ~= 4 and nDiceRoll ~= 5) then
sResult = "CRITICAL SUCCESS";
elseif (nDiceRoll == 3 or nDiceRoll == 4 or nDiceRoll == 5) and nTotal < (nTargetDC + 6) then
sResult = "FAILURE";
end
-- Roll doesn't meet target DC - failure unless there is a critical success/failure.
elseif nTotal < nTargetDC then
sResult = "FAILURE";
if (nTotal <= (nTargetDC - 6) or (nDiceRoll == 3 or nDiceRoll == 4 or nDiceRoll == 5)) and (nDiceRoll ~= 18 and nDiceRoll ~= 17 and nDiceRoll ~= 16) then
sResult = "CRITICAL FAILURE";
elseif (nDiceRoll == 18 or nDiceRoll == 17 or nDiceRoll == 16) and nTotal > (nTargetDC - 6) then
sResult = "SUCCESS";
end
end
Mine seems to work except it seems to only base comparisons of the dice roll based on the first d6 in the roll. If my logic is off, it may be becasue I fiddled with the function before I realized the strange 1 die result behavior. Any help on this would be appreciated!
Thanks!
I am seeing some weird behavior if I try to replace d20 with 3d6 in the Pathfinder 2 die rolling functions. In the following function fragment what is nDiceRoll? I thought it was the result of the dice rolled (i.e., the result of the 3d6) vs nTotal which would be the total of the roll + mods. This seems to be true except that nDiceRoll only stores the result of the first d6 rolled. I find this confusing and how would I store the total of the 3d6 to compare the dice roll result and total result to determine critical fails, fails, success, and crit success?
Fragment of the base getd20CheckResult:
function getd20CheckResult(nDiceRoll, nTotal, nTargetDC)
Line 476: if (nTotal >= (nTargetDC + 10) or nDiceRoll == 20) and nDiceRoll ~= 1 then
Line 476: if (nTotal >= (nTargetDC + 10) or nDiceRoll == 20) and nDiceRoll ~= 1 then
Line 478: elseif nDiceRoll == 1 and nTotal < (nTargetDC + 10) then
Line 484: if (nTotal <= (nTargetDC - 10) or nDiceRoll == 1) and nDiceRoll ~= 20 then
Line 484: if (nTotal <= (nTargetDC - 10) or nDiceRoll == 1) and nDiceRoll ~= 20 then
Line 486: elseif nDiceRoll == 20 and nTotal > (nTargetDC - 10) then
Line 491: GlobalDebug.consoleObjects("GameSystem.getd20CheckResult - sResult, nDiceRoll, nTotal, nTargetDC = ", sResult, nDiceRoll, nTotal, nTargetDC);
Line 491: GlobalDebug.consoleObjects("GameSystem.getd20CheckResult - sResult, nDiceRoll, nTotal, nTargetDC = ", sResult, nDiceRoll, nTotal, nTargetDC);
My experimental 3d6 tester function:
function getd20CheckResult(nDiceRoll, nTotal, nTargetDC)
-- Return the level of success/failure based off the target DC
-- This function should only be called if there is a target DC - success/failure cannot be determined without.
if nTargetDC == nil then
return "";
end
local sResult = "";
-- Roll meets or exceeds target DC - success unless there is a critical success/failure.
if nTotal >= nTargetDC then
sResult = "SUCCESS";
if (nTotal >= (nTargetDC + 6) or nDiceRoll == 18 or nDiceRoll == 17 or nDiceRoll == 16) and (nDiceRoll ~= 3 and nDiceRoll ~= 4 and nDiceRoll ~= 5) then
sResult = "CRITICAL SUCCESS";
elseif (nDiceRoll == 3 or nDiceRoll == 4 or nDiceRoll == 5) and nTotal < (nTargetDC + 6) then
sResult = "FAILURE";
end
-- Roll doesn't meet target DC - failure unless there is a critical success/failure.
elseif nTotal < nTargetDC then
sResult = "FAILURE";
if (nTotal <= (nTargetDC - 6) or (nDiceRoll == 3 or nDiceRoll == 4 or nDiceRoll == 5)) and (nDiceRoll ~= 18 and nDiceRoll ~= 17 and nDiceRoll ~= 16) then
sResult = "CRITICAL FAILURE";
elseif (nDiceRoll == 18 or nDiceRoll == 17 or nDiceRoll == 16) and nTotal > (nTargetDC - 6) then
sResult = "SUCCESS";
end
end
Mine seems to work except it seems to only base comparisons of the dice roll based on the first d6 in the roll. If my logic is off, it may be becasue I fiddled with the function before I realized the strange 1 die result behavior. Any help on this would be appreciated!
Thanks!