PDA

View Full Version : type="dice"



Varsuuk
June 17th, 2018, 18:09
Was looking at this field type to use and I think, if I understand how it is in CoreRPG is that it is meant to hold 1 or more d# values (comma separated if present) - is it possible to use this to display the dice (e.g. d4) but intercept the actual on click to roll action and roll something else (e.g. 1d4+1)?

Granted this just popped in my mind and can look at what Celestian does in AD&DCore and see - but about to step away for lunch and little boy time - not sure if will get to it until very late when folks may not be around if I end up stuck ;) - so if there is an easy answer - please :) if there is an easy ruleset (free or C&C or Savage) please, let me know where to look etc ;)

On slightly related topic, I didn't find on the API page (not saying isn't there...) an explanation of "<rollable>" (I use it, it sets the little graphic widget and lets me roll a "roll under" d20 roll vs the numeric value.) But I didn't find much in code - assumed was in the C++ but I did find in number.lua a "if rollable or (gmrollable..." line. Just didn't find where the rollable value there comes from? Is it magic behind curtain of setting <rollable> on a field?


Happy Father's Day!

Valarian
June 17th, 2018, 19:03
Check out the Yggdrassil ruleset for an example of using dice handlers in CoreRPG. It's in the CoreRPG rulesets folder linked in my signature.

To process a roll separate from normal dice processing, you give the roll a type (e.g. skilldice).


<!-- Rollable Attribute -->
<template name="char_attribute">
<basicnumber>
<script>
function onDragStart(button, x, y, draginfo)
local label = getName():gsub("^%l", string.upper);
local woundState = window.getDatabaseNode().getChild("hpstate");
local penalty = window.getDatabaseNode().getChild("hppenalty");
if woundState.getValue() == "Severely Wounded" then
draginfo.setType("wounddice");
else
draginfo.setType("skilldice");
end
draginfo.setDescription(label);
draginfo.setNumberData(penalty.getValue());
local dice = {};
for i = 1, getValue(), 1 do
table.insert(dice, "d10");
end
draginfo.setDieList(dice);
return true;
end

function onDoubleClick(x,y)
local label = getName():gsub("^%l", string.upper);
local woundState = window.getDatabaseNode().getChild("hpstate");
local penalty = window.getDatabaseNode().getChild("hppenalty");
local type = "dice";
if woundState.getValue() == "Severely Wounded" then
type = "wounddice";
else
type = "skilldice";
end
local dice = {};
for i = 1, getValue(), 1 do
table.insert(dice, "d10");
end
Comm.throwDice(type, dice, penalty.getValue(), label);
return true;
end
</script>
</basicnumber>
</template>


You then set up a dice handler script to intercept the processibg for that type of roll.


function onInit()
ActionsManager.registerResultHandler("skilldice", handleSkillDice);
end

function handleSkillDice(rSource, rTarget, rRoll)
local reroll = false;
local total = {};

local firstResult = 0;
local secondResult = 0;
local dicetable = rRoll.aDice;
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
repeat
local reroll = false;
local dieRoll = math.random(1,10);
local explode = {};
explode.type = "d10";
explode.result = dieRoll;
table.insert(total, explode);
-- Purely for effect - roll a d10
local dice = {};
table.insert(dice, "d10");
Comm.throwDice("explode", dice, 0, "explode");
if dieRoll == 10 then
reroll = true;
end
until not reroll
end

local rMessage = ChatManager.createBaseMessage(rSource, rRoll.sUser);
rMessage.type = rRoll.sType;
rMessage.text = rMessage.text .. rRoll.sDesc;
rMessage.dice = total;
rMessage.diemodifier = rRoll.nMod;

-- Check to see if this roll should be secret (GM or dice tower tag)
if rRoll.bSecret then
rMessage.secret = true;
if rRoll.bTower then
rMessage.icon = "dicetower_icon";
end
elseif User.isHost() and OptionsManager.isOption("REVL", "off") then
rMessage.secret = true;
end

-- Show total if option enabled
if OptionsManager.isOption("TOTL", "on") and total and #(total) > 0 then
rMessage.dicedisplay = 1;
end

Comm.deliverChatMessage(rMessage);
ModifierStack.reset();
return true;
end

Varsuuk
June 17th, 2018, 21:01
Valarian - thank you, this is a perfectly enlightening example - I need to look at this when have time tonight! I also grabbed your pak for perusal :)

But while reading that, I did a forum search and ran across an example of custom dice I recalled and I was about to try something fast while waiting on something before heading back outside and I noticed... NO IDEA WHEN IT APPEARED (could been weeks, months or minutes... but I did nothing dice related today that I know of), but I saw this:

23772


I did a fast scan in my icons and corerpg icons for the png of this thing but didn't see. I probably did something when I connected the classes and other stuff messing around desktop manager and I will look at that later but huh?

(It had been just over 4-5 weeks since I had time to look at my ruleset project and I have memory issues... The work refactor project ramped up plus I was given a new macbookpro and I had to setup the whole development environment and get workflows off my old windows box to this etc, took 2 weeks nearly due to some issues before I switched fully. Love the new 38" curved dell ultrasharp too... big project budgets are nice. Hopefully I am back on an every other day min cycle now.)

Nickademus
June 17th, 2018, 23:00
That's the fudge die. I think it comes with CoreRPG but is turned off in most rulesets.
Ala 5E ruleset gameelements.xml:

<die name="dF" merge="delete" />

Varsuuk
June 18th, 2018, 03:36
Haha! Cool Nikademus, I JUST tried an early version of my SW ruleset and saw it there and was heeey, I barely knew how to create the first xml for the character sheet - how did I turn on new dice?

Then went...oh... checked CoreRPG and there it is. Such a simple answer. But of course, it just shows I worked on this constantly reloading to check my XML & char sheet and now classes ui and never noticed the weird dice until I decided to try creating dice and went ...???

Yup, I made the right call staying with software development when the NYPD finally called me up in my yute. lol...

Thanks!

Varsuuk
June 19th, 2018, 02:47
On related note - I tried to add a custom dice without reading up on how to do it... seemed self-explanatory... wasn't.


<die name="d4p1">
<model>d4</model>
<icon>d4icon</icon>
<script>
function onValue(result)
return result + 1;
end
</script>
<position>420,-70</position>
</die>


Didn't appear ... figured I guessed if I told it model and icon it would use icon for desktop and model for rolling.

Goofed around and removed the merge delete for DF and changed my dice to:

<die name="dF">
<model>d4</model>
<icon>d4icon</icon>
<script>
function onValue(result)
return result + 1;
end
</script>
<position>420,-70</position>
</die>


The weird fudge die appears with + - and when roll, it rolls values in 2-5 range as I desired (but HAD to name dF and didn't pay attn to my icon/model.

So, any thread or page explain these?

Varsuuk
June 19th, 2018, 02:54
OK - looking for something else, found the docs - was in the obvious place...

Custom Dice

Custom dice are die types based on one of the built-in dice, with the option to assign custom values to the die result. The built-in die on which the custom die is based is will be used as the 3D model for the roll. Custom dice do not appear on the campaign desktop, and the option to roll the custom die will be found in the right click menu of the associated built-in die.

A script function can be associated with a custom die. The script function receives the result of the built-in die rolled, and can apply modifications to the result before it is passed on for further processing.

An example below defines a d3 (three sided die), generating a value from 1 to 3, by dividing the result of a d6 by two.




So - yes, can define but cannot place on desktop (which I don't need for my use)

damned
June 19th, 2018, 03:18
Most custom dice are accessed via right click on an existing dice or by chat commands.

keytrose
June 20th, 2018, 06:53
If you want to add a custom die to the desktop take a look at the Warhammer Fantasy Roleplay v3 Ruleset by Neil Foster. It has some interesting dice as well as some desktop tokens that can modify a dice pools. I have no idea how the Warhammer system is supposed to play but found it when looking around at examples of non-5e systems.