PDA

View Full Version : Applying Modifier to Target Number Rather Than Dice Roll



Netzilla
April 16th, 2021, 15:48
I’m working on a ruleset for Champions / the Hero System, which uses a 3d6 roll under mechanic. Modifiers are typically applied to the target number rather than the die roll, which keeps beneficial modifiers positive and harmful modifiers negative. So, my sample character here has the Deduction skill at a base of 14-.
45791

Let’s say he’s working on a difficult issue and has a -2 modifier, making the target number 12-. So, I apply that modifier to the modifier stack manually.
45792

Now, when I make the die roll, my ruleset does the calculation properly, but the dice display still shows the -2 applying to the die roll, which is confusing to the players and just doesn’t look nice.
45793

Here is the code I’m using for applying the modifier to the target number.


function onSuccessRoll(rSource, rTarget, rRoll)
local rMessage = ActionsManager.createActionMessage(rSource, rRoll);

if (rRoll.nTarget) then
local nTargetValue = tonumber(rRoll.nTarget) or 0;
if (rRoll.nMod) then
nTargetValue = nTargetValue + tonumber(rRoll.nMod);
rRoll.nMod = 0;
end
local nTotal = ActionsManager.total(rRoll);

local nDiff = nTargetValue - nTotal;

rMessage.text = rMessage.text .. " (" .. nTargetValue .. "-) Rolled " .. nTotal;
if (nTotal <= nTargetValue) then
rMessage.text = rMessage.text .. "\n[SUCCESS]";
else
rMessage.text = rMessage.text .. "\n[FAILURE]";
end
rMessage.text = rMessage.text .. " by " .. math.abs(nDiff);
end

rMessage.secret = CombatManagerChamps.isCTHidden(rSource);
Comm.deliverChatMessage(rMessage);
end

How do I adjust the dice display to reflect what the code is actually doing?

damned
April 16th, 2021, 15:59
You can experiment with


rMessage.dicedisplay = 0;

which wont show the sum of the dice and you can do that all in the chat message.

there is also the onDiceTotal() function which allows you to set the value to something else.

[code]
function onDiceTotal( messagedata )
local sMyTotal = string.match(messagedata.text, "]%s(%d+)");
return true, tonumber(sMyTotal);
end
[code]

And I think FGU gives us another way but I cant think of an example to post...

Moon Wizard
April 16th, 2021, 16:17
I find it better to pass the target total as a separate value in the roll structure; or inject into the roll string and read it back out.

In that way, it never shows up in the roll expression or roll total.

Regards,
JPG

Netzilla
April 16th, 2021, 16:45
You can experiment with


rMessage.dicedisplay = 0;

which wont show the sum of the dice and you can do that all in the chat message.

And I think FGU gives us another way but I cant think of an example to post...

I couldn't get rMessage.dicedisplay to work, but that did lead me to rMessage.diemodifier and setting that to zero took care of it. Thanks.

Netzilla
April 16th, 2021, 16:51
FYI, upon further testing, it seems that rMessage.dicedisplay only suppresses the total and not the formula or icons. So, the "3d8-2" above the dice was still showing.