FG Spreadshirt Swag
  1. #1291
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,674
    Blog Entries
    1
    Quote Originally Posted by DMReckless View Post
    Anyone have an idea how to code a dice string that takes 2d12 plus one other die (d6.d8.d10.d12, or d20) and keeps only the best 2 dice?
    What game system?
    How do you decide when to use the additional dice and what size to use?
    The OpenLegend game system uses something similar but it uses d20s and multiple extra dice and they explode...

  2. #1292
    It's an unpublished game system called Factor12. Ideally, each skill would have an option for straight 2d12 and then the more complicated roll, and rolling 24 on the 2d12 would also trigger rolling the extra die once and adding it to the 24 total. Being able to "slot" the Competency (extra) die into the skill on the player side would be good, but as long as the formula at least did the 2d12+1d#+#, take best 2, the other stuff could be figured out in game.

    Has openlegend been coded for morecore? I could look at that maybe. I was working a bit with altering rolled last night, but haven't been able to test it out.

    Edit: and rolling 2 on the 2d12 would also trigger the Competency die, with another 1 indicating a "deuce"(fumble).
    Last edited by DMReckless; December 4th, 2018 at 11:52.

  3. #1293
    Working with rolld, I've been able to get it to roll the extra type die and keep the top two. Gotta figure out how to add in a modifier now.

  4. #1294
    damned's Avatar
    Join Date
    Mar 2011
    Location
    Australia
    Posts
    26,674
    Blog Entries
    1
    Quote Originally Posted by DMReckless View Post
    Working with rolld, I've been able to get it to roll the extra type die and keep the top two. Gotta figure out how to add in a modifier now.
    Very good.
    Have a search in the \scripts folder for nMod and see how to call it, save it and clear it.

  5. #1295
    Darned frustrating, trying to find nMod strings among all that other stuff, hours later, going to bed with no luck.

    ---
    --- Initialization
    ---
    local sCmd = "factwelve";

    -- MoreCore v0.60
    function onInit()
    CustomDiceManager.add_roll_type(sCmd, performAction, onLanded, true, "all");
    end


    function onInit()
    Comm.registerSlashHandler("factwelve", processRoll);
    GameSystem.actions["factwelve"] = { bUseModStack = true };
    ActionsManager.registerModHandler("factwelve", onMod)
    ActionsManager.registerResultHandler("factwelve", onRoll);

    -- send launch message
    local msg = {sender = "", font = "emotefont"};
    msg.text = "Factor12 Dice loaded. Type \"/factwelve ?\" for usage.";
    ChatManager.registerLaunchMessage(msg);
    end

    ---
    --- This is the function that is called when the factwelve slash command is called.
    --- The default value for sParams is equal to "2d12+1d4+0 1"
    ---
    function processRoll(sCommand, sParams)
    if not sParams or sParams == "" then
    sParams = "2d12+1d4+0 1";
    end

    if sParams == "?" or string.lower(sParams) == "help" then
    createHelpMessage();
    else
    local rRoll = createRoll(sParams);
    ActionsManager.roll(nil, nil, rRoll);
    end
    end

    ---
    --- This function creates the roll object based on the parameters sent in
    ---
    function createRoll(sParams)
    local rRoll = {};
    rRoll.sType = "factwelve";
    rRoll.nMod = 0;
    rRoll.sUser = User.getUsername();
    rRoll.aDice = {};
    rRoll.aDropped = {};

    -- If no number to drop is specified, we will assume it is 1
    if(not sParams:match("(%d+)d([%dF]*)+(%d+)d([%dF]*)+(%d+)%s(%d+)") and sParams:match("(%d+)d([%dF]+(%d+)d([%dF]*)+(%d+)+)")) then
    sParams = sParams .. " 1"
    end

    -- Now we check that we have a properly formatted parameter, or we set the sDesc for the roll with a message.
    if not sParams:match("(%d+)d([%dF]*)+(%d+)d([%dF]*)+(%d+)%s(%d+)") then
    rRoll.sDesc = "Parameters not in correct format. Should be in the format of \"2d12+#d#+# #\"";
    return rRoll;
    end

    local sNum, sSize, tNum, tSize, aMod, sDrop = sParams:match("(%d+)d([%dF]+)+(%d+)d([%dF]*)+(%d+)%s(%d+)");
    local count = tonumber(sNum);
    local comp = tonumber(tNum);
    local drop = tonumber(sDrop);

    if (drop > count + comp) then
    rRoll.sDesc = "You cannot drop more results than the number of dice being rolled.";
    return rRoll;
    end

    while count > 0 do
    table.insert(rRoll.aDice, "d" .. sSize);

    -- For d100 rolls, we also need to add a d10 dice for the ones place
    if sSize == "100" then
    table.insert(rRoll.aDice, "d10");
    end
    count = count - 1;
    end

    while comp > 0 do
    table.insert(rRoll.aDice, "d" .. tSize);

    -- For d100 rolls, we also need to add a d10 dice for the ones place
    if sSize == "100" then
    table.insert(rRoll.aDice, "d10");
    end
    comp = comp - 1;
    end

    rRoll.nDrop = drop;

    return rRoll;
    end

    ---
    --- This function first sorts the dice rolls in ascending order, then it splits
    --- the dice results into kept and dropped dice, and stores them as rRoll.aDice
    --- and rRoll.aDropped.
    ---
    function dropDiceResults(rRoll)
    if #(rRoll.aDice) < 2 then return rRoll end
    local len = #(rRoll.aDice) or 0;
    local drop = tonumber(rRoll.nDrop) or 0;
    local dropped = {};
    local kept = {};

    table.sort(rRoll.aDice, function(a,b) return a.result < b.result end);
    local count = 1;
    while count <= len do
    if count <= drop then
    table.insert(dropped, rRoll.aDice[count]);
    else
    table.insert(kept, rRoll.aDice[count]);
    end

    count = count + 1;
    end
    rRoll.aDice = kept;
    rRoll.aDropped = dropped;
    return rRoll;
    end

    ---
    --- This function creates a chat message that displays the results.
    ---
    function createChatMessage(rSource, rRoll)
    local rMessage = ActionsManager.createActionMessage(rSource, rRoll);
    if #(rRoll.aDice) > 0 then
    rMessage.text = rMessage.text .. "[KEPT]";
    for _,v in ipairs(rRoll.aDice) do
    rMessage.text = rMessage.text .. " " .. v.result;
    end
    end
    if #(rRoll.aDice) > 0 and #(rRoll.aDropped) > 0 then
    rMessage.text = rMessage.text .. "\n";
    end
    if #(rRoll.aDropped) > 0 then
    rMessage.text = rMessage.text .. "[DROPPED]";
    for _,v in ipairs(rRoll.aDropped) do
    rMessage.text = rMessage.text .. " " .. v.result;
    end
    end

    return rMessage;
    end

    ---
    --- This function creates the help text message for output.
    ---
    function createHelpMessage()
    local rMessage = ChatManager.createBaseMessage(nil, nil);
    rMessage.text = rMessage.text .. "The \"/factwelve\" command is used to roll a set of dice, removing a number of the lowest results.\n";
    rMessage.text = rMessage.text .. "You can specify the number of dice to roll, the type of dice, and the number of results to be dropped ";
    rMessage.text = rMessage.text .. "by supplying the \"/factwelve\" command with parameters in the format of \"#d#+#d#+# #\".";
    rMessage.text = rMessage.text .. "If no parameters are supplied, the default parameters of \"2d12+1d4+0 1\" are used.";
    Comm.deliverChatMessage(rMessage);
    end

    ---
    --- This is the callback that gets triggered after the roll is completed.
    ---
    function onRoll(rSource, rTarget, rRoll)
    rRoll = dropDiceResults(rRoll);
    rMessage = createChatMessage(rSource, rRoll);
    rMessage.type = "dice";
    Comm.deliverChatMessage(rMessage);
    end

  6. #1296

  7. #1297
    /factwelve 2d12+1d4+1 1
    /factwelve 2d12+1d8+4 1
    Really, anything in that setup works (except for the mod) like
    /factwelve 3d6+2d8+1 2
    will drop the lowest 2 dice but won't add in the 1 mod.

    I'm also having a problem getting it to work as a macro inside the MoreCore character sheet, but that's probably a function of having to set up "factwelve" withe the sheet scripts?
    Last edited by DMReckless; December 5th, 2018 at 14:41.

  8. #1298

  9. #1299
    thanks. followed that, but getting script error:

    Script Error: [string "common/scripts/morecore_rolls/lua"]:80: attempt to concatenate 'sParams' (a nil value}

  10. #1300
    Hi !
    First thanks for this great "rule pak";
    We use it to play hackmaster and it work ok.

    However since last update as a GM i have encounter a little problem: I can't open the Old character selection screen ?
    Now, instead i've got a scrolling list who looks exactly like the NPC list. (no portrait of the character only their name).
    I can open Character sheet from this list but I cannot "own" them, export or import them. Only the create and erase option are available when right clicking in this list.
    For Player who join a game the "old" character selction screen open once at the beginning and if they close it we didn't find a way to open it again.
    I guess there is a new function that i'm not aware of.

    Thanks for the pak anyway it's great !

Thread Information

Users Browsing this Thread

There are currently 3 users browsing this thread. (0 members and 3 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
STAR TREK 2d20

Log in

Log in