-
March 18th, 2022, 02:06 #91
By all means go in your own direction.
Already by the time I decided to stop there are things I would have done differently - particularly with skills
Also bear in mind - I have never played the game so your perspective will be different to mine.
All of those changes sound legitimate so keep on going.
-
March 18th, 2022, 02:09 #92
- Join Date
- Jun 2020
- Posts
- 536
Will do, thanks! I haven’t played either actually - just reading the core Rulebook cover to cover now, and working on the ruleset as I go. But- I really want to run this game (in Fantasy Grounds of course!)
Anyway, I haven’t got to skills yet. Looking forward to tackling that next, probably, if not items/equipment first.
-
March 19th, 2022, 19:31 #93
- Join Date
- Jun 2020
- Posts
- 536
So I actually did get some code working that handles Exploding dice on 10 (adding result) and on 1 (subtracting result) using a custom result handler for skill checks. It colors the additional d10 red or green, and only explodes once.
I am going to implement it for all skills and allow for just rolling on an ability as well, and implement it there too. (As well as auto adding penalties due to armor on relevant skills/abilities.). I can provide a code snippet for any trying to do this too, if interested.
Edit: Here's a screenshot of my WIP (still need to do weapons and all here too, but think I am going to implement skills and item templates first to do that properly.)
Screen Shot 2022-03-19 at 2.33.12 PM.png. (Ignore the bugged "Crit failure" for rolls that were normal... fixed that already lol).Last edited by seansps; March 19th, 2022 at 19:35.
-
March 20th, 2022, 00:24 #94
Well done! Looking good. I would love to see your code.
-
March 20th, 2022, 01:09 #95
- Join Date
- Jun 2020
- Posts
- 536
Thanks! Certainly!
In campaign/scripts/manager_cpred.lua: (You can ignore the `customPerformAction` for now, I am going to use that later to calculate hits based on the range of the target to the actor, and each item will have it's own DV table in the template, is the plan.) The code for `resolveAbility` was heavily borrowed from an old thread, so I am not sure if I need the second result check here. But just in case... for now, it's there.
Code:function onInit() GameSystem.actions= { ["dice"] = { bUseModStack = "true" }, ["table"] = { }, ["effect"] = {sIcon = "action_effect", sTargeting = "all" }, ["deathsave"] = {sIcon = "action_effect", sTargeting = "none" }, ["initiative"] = {sIcon = "action_effect", sTargeting = "none" }, ["ability"] = {sIcon = "action_effect", sTargeting = "none" }, }; ActionsManager.registerResultHandler("deathsave", resolveDeathSave); ActionsManager.registerResultHandler("initiative", resolveInitiative); ActionsManager.registerResultHandler("ability", resolveAbility); performAction = ActionsManager.performAction; ActionsManager.performAction = customPerformAction; end function resolveAbility(rSource, rTarget, rRoll) local nDiceRoll = 0; Debug.console(rRoll); Debug.console(rRoll.aDice[0]); local firstResult = 0; local secondResult = 0; local isCrit = false; local isCritFail = false; local dicetable = rRoll.aDice; local reroll = false; local total = {}; -- TODO Cleanup, remove second result? if dicetable then for n = 1, table.maxn(dicetable) do if dicetable[n].type == "d10" then if firstResult > 0 and dicetable[n].result > secondResult then secondResult = dicetable[n].result; total[2] = dicetable[n]; elseif dicetable[n].result > firstResult then firstResult = dicetable[n].result; total[1] = dicetable[n]; end end end end if firstResult == 10 or secondResult == 10 then isCrit = true; local dieRoll = math.random(1,10); local explode = {}; explode.type = "g10"; explode.result = dieRoll; table.insert(total, explode); -- Show the roll a d10 local dice = {}; table.insert(dice, "d10"); Comm.throwDice("explode", dice, 0, "explode"); -- Insert into actual result table.insert(rRoll.aDice, explode); elseif firstResult == 1 then isCritFail = true; local dieRoll = math.random(1,10); local explode = {}; explode.type = "r10"; explode.result = dieRoll; table.insert(total, explode); -- Show the roll a d10 local dice = {}; table.insert(dice, "d10"); Comm.throwDice("explode", dice, 0, "explode"); -- Insert into actual result explode.result = dieRoll * -1; table.insert(rRoll.aDice, explode); end -- TODO deduct penalties if needed? local rMessage = ActionsManager.createActionMessage(rSource, rRoll); local playerName = ActorManager.getDisplayName(rSource); rMessage.text = "[".. rRoll.sDesc .. "]"; if isCrit then rMessage.text = "[".. rRoll.sDesc .. "][CRIT SUCCESS]"; elseif isCritFail then rMessage.text = "[".. rRoll.sDesc .. "][CRIT FAILURE]"; end Comm.deliverChatMessage(rMessage); end
Code:function onInit() local w = addBitmapWidget("field_rollable"); w.setPosition("bottomleft", 4, -6); setHoverCursor("hand"); end function action(draginfo) local nodeWin = window.getDatabaseNode(); local rActor = ActorManager.resolveActor(nodeWin); local nStat = nodeWin.getChild("int_current").getValue(); rRoll = { sType = "ability", sDesc = "INT", aDice = {expr = "1d10" }, nMod = nStat, nTarget = nil }; ActionsManager.performAction(draginfo, rActor, rRoll); end function onDragStart(button, x, y, draginfo) action(draginfo); return true; end function onDoubleClick(x, y) action(); return true; end
-
March 20th, 2022, 01:24 #96
-
March 20th, 2022, 01:25 #97
- Join Date
- Jun 2020
- Posts
- 536
-
March 30th, 2022, 08:17 #98
- Join Date
- Dec 2018
- Location
- England, UK
- Posts
- 198
Hi Seansps, your code for adding the exploding die has helped me tremendously with my issue of only exploding if both dice are max value. Thanks.
I have noticed that most of the time the rolled extra die on the screen does not match the number shown in the chat window. See attached file. Have you found a way to get around this?
I have checked the standard RSW exploding die (with 2d6e) and this appears to be okay.
Any advice would be greatly appreciated.
-
March 30th, 2022, 10:35 #99
- Join Date
- Jun 2020
- Posts
- 536
Hi! Glad to be of help. As for the visual not matching... yes... I have noticed that as well. Unfortunately, right now I am just using the `throwDice` command as a visual to go with the "exploding" dice and have not been able to figure out how to replace the result with what I randomly generated that before. I can keep poking around there and see if there is a way. I could just be using this function wrong or might need to do call `ActionsManager.buildThrow` first with the right values.
Until then, short of having it do another `performAction` and then a separate handler for that, I haven't figured that part out! But, you might be able to use the "1d10e#1" notation, which rolls a d10 and explodes only once on 10. This was fixed with a recent release of FG. And I believe "1d10l#1" does the negative-explode low. This didn't work for me here because I have to be able to do both (and that notation didn't seem to allow for both!)
-
March 30th, 2022, 19:00 #100
- Join Date
- Dec 2018
- Location
- England, UK
- Posts
- 198
Thanks for your thoughts on what to look at. I will see if I can work out how to use the ActionsManager.buildThrow function.
The exploding dice function built in doesn't work for me as I need the roll to explode only if both dice roll a 6.
I am hoping someone will be able to suggest how I can read the value of the rolled dice and add it rather than generate a random number and hope the dice throw shows the same result.
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks