PDA

View Full Version : Dice string with "macros" exist already?



celestian
February 12th, 2018, 20:25
So I'm beginning to hack at a part of the 5e ruleset that has been something I've been asked about a lot and that is dice strings with "macros", specifically things like damage for spells based on level of caster. So instead of having to adjust the spells damage when you level it will automatically do it for something like fireball with "LVLd6" damage string.

Has any other ruleset or extension done this sorta thing before? I'm curious how it was handled and the UI portion. Wanting to see what worked and what didn't.

Right now I'm looking at having a toggle for Dice or Text "mode" for the spell. I "store" the "ArcaneLevel" or "DivineLevel" as the character levels up so depending on the type I'll replace the "LVL" or "Level" with the level for that type of spell.

Sorta like this.

https://i.imgur.com/GpQ5bxF.png

And the "Text" version looks like this.

https://i.imgur.com/BF9AOD5.png

Eventually I plan to do the same thing for duration.

Trenloe
February 12th, 2018, 20:29
Have a look at spell actions for 3.5E/PF - there are some adjustments based of CL (Caster Level).

Bidmaron
February 12th, 2018, 20:43
If part of your question involves the input mechanism for dice:
I am doing that in the Generators extension. I could not figure out a way through the interface to get a mixture of dice in the drag, so I have a text field where you can enter a dice expression (e.g. 2d2+3d4+5, for a ridiculous example). To do this, I overrode the onClick on the existing dice field (which was just a drop zone for dice) so it invoked my own string field to enter the dice. This is the template necessary for the dice entry:


<template name="dice_input_string">
<stringcontrol>
<anchored to="dice" position="over" />
<script>
local aSaveDice;
function onGainFocus()
if aSaveDice then
return;
end
local nodeWindow=window.getDatabaseNode();
aSaveDice=DB.getValue(nodeWindow,"dice",{});
if #aSaveDice~=0 then
local sDice=StringManager.convertDiceToString(aSaveDice) ;
setValue(sDice);
end
TableManager.setRollGuard(true);
DB.setValue(nodeWindow,"dice","dice",{});
TableManager.setRollGuard(true);
end
function onLoseFocus()
if StringManager.trim(getValue())=="" then
TableManager.setRollGuard(true);
DB.setValue(nodeWindow,"dice",aSaveDice);
TableManager.setRollGuard(false);
destroy();
elseif textOK() then
local aDice, nMod = StringManager.convertStringToDice(getValue());
local nodeWindow=window.getDatabaseNode();
TableManager.setRollGuard(true);
DB.setValue(nodeWindow,"dice","dice",aDice);
TableManager.setRollGuard(false);
DB.setValue(nodeWindow,"mod","number",nMod);
destroy();
else
setFocus();
end
end
function textOK()
if StringManager.isDiceMathString(getValue()) then
return true;
else
TableManager.notifyError("error_gen_bad_dice");
return false;
end
end
</script>
</stringcontrol>
</template>


Here is the modification to the existing dice drop zone: (note that I use join=merge in the parent window so that my modified "dice" inherits everything except the below stuff from the CoreRPG ruleset)


<basicdice name="dice">
<script>
function onClickDown(button,x,y)
return true;
end
function onClickRelease(button,x,y)
window.createControl("dice_input_string","user_dice_input");
window.user_dice_input.setFocus();
return true;
end
</script>
</basicdice>


So, when the user clicks and releases, the code adds a new control that is the dice input string. Once that control loses focus, it updates the database field and destroys itself. The original dice control picks up the database update through its own handler and updates the dice content of that control. Note that the calls to TableManager are my own code. One of them is a semaphore to prevent infinite looping associated with update events (SetRollGuard), and the other handles displaying an error message. You would need to put your own stuff in there for mine.

celestian
February 12th, 2018, 21:52
Have a look at spell actions for 3.5E/PF - there are some adjustments based of CL (Caster Level).

That is exactly what I was looking for. Much more mechanical input with less dependence on "formatting" knowledge to make it work. Even deals with "max" size. I like it a lot.


If part of your question involves the input mechanism for dice:
I am doing that in the Generators extension. I could not figure out a way through the interface to get a mixture of dice in the drag, so I have a text field where you can enter a dice expression (e.g. 2d2+3d4+5, for a ridiculous example). To do this, I overrode the onClick on the existing dice field (which was just a drop zone for dice) so it invoked my own string field to enter the dice.

So, when the user clicks and releases, the code adds a new control that is the dice input string. Once that control loses focus, it updates the database field and destroys itself. The original dice control picks up the database update through its own handler and updates the dice content of that control. Note that the calls to TableManager are my own code. One of them is a semaphore to prevent infinite looping associated with update events (SetRollGuard), and the other handles displaying an error message. You would need to put your own stuff in there for mine.

Thanks Bidmaron. I'll review the code and see how I might be able to use it.

celestian
February 13th, 2018, 06:24
This seems to somewhat match the PF/3.5 e version and meets the needs of AD&D.

https://i.imgur.com/mNdB0dh.png

Bidmaron
February 13th, 2018, 11:00
As long as all you want is a set of dice of the form xdy, where x is number of dice and y is sides, that will work. The code I posted lets you do arbitrarily complex dice expressions (not really sure when you would need them though honestly for this.)

dulux-oz
February 13th, 2018, 11:06
Just out of interest - you guys do know that a lot of this has already been done (no, not all of it, but a hell of a lot) with the UDR (Universal Die Roller) in the new DORCore Ruleset - don't you?

Bidmaron
February 13th, 2018, 11:08
Dulux, can you (meaning me) change the inheritance of PF or another nested ruleset to include DORCore? Sounds dangerous.

dulux-oz
February 13th, 2018, 11:22
Dulux, can you (meaning me) change the inheritance of PF or another nested ruleset to include DORCore? Sounds dangerous.

You could try it - with a new campaign, obviously - but I'm not sure what will break (if anything).

You actually have two options:

Change the DORCore to be a child of PF, or
Change the 3.5E to be a child of DORCore - as the DORCore was designed to be at a "low-level" in the Ruleset-Stack this is what I'd be looking at, BUT it hasn't been tested (primarily because I'm not arrogant enough to believe that SW would change the Ruleset-Stack for their "official" Rulesets - I'm arrogant, yes, but not THAT arrogant :) )


In either case, my expectation straight off the bat is that "something" will break - but yes, it can be done.

As a side-note, my vision for the DORCore was for all of the Community Ruleset Devs to consider it for their Ruleset-Stack for new (or newly-ported) Rulesets. All of my Community Rulesets, for example, use the DORCore as the basis on which to build their own Rules. What I had not considered was people might want to "slip it into" the Ruleset-Stack of SW's "offical" Rulesets - however, if people want to try then the Ruleset-Stack should run CoreRPG=>DORCore=>"offical" Ruleset.

damned
February 13th, 2018, 12:41
You could try it - with a new campaign, obviously - but I'm not sure what will break (if anything).

You actually have two options:

Change the DORCore to be a child of PF, or
Change the 3.5E to be a child of DORCore - as the DORCore was designed to be at a "low-level" in the Ruleset-Stack this is what I'd be looking at, BUT it hasn't been tested (primarily because I'm not arrogant enough to believe that SW would change the Ruleset-Stack for their "official" Rulesets - I'm arrogant, yes, but not THAT arrogant :) )


In either case, my expectation straight off the bat is that "something" will break - but yes, it can be done.

As a side-note, my vision for the DORCore was for all of the Community Ruleset Devs to consider it for their Ruleset-Stack for new (or newly-ported) Rulesets. All of my Community Rulesets, for example, use the DORCore as the basis on which to build their own Rules. What I had not considered was people might want to "slip it into" the Ruleset-Stack of SW's "offical" Rulesets - however, if people want to try then the Ruleset-Stack should run CoreRPG=>DORCore=>"offical" Ruleset.

DORCore breaks stuff even on a simple ruleset like MoreCore.
The Universal Dice Roller you have coded Dulux_Oz is awesome but it isnt really what this is looking to do.

celestian
February 13th, 2018, 16:35
As long as all you want is a set of dice of the form xdy, where x is number of dice and y is sides, that will work. The code I posted lets you do arbitrarily complex dice expressions (not really sure when you would need them though honestly for this.)

I was initially thinking of something very complex that would require a "by hand" dice string that would be parsed and handled... but after re-looking at things... there really isn't anything in damage or duration that I could find that required anything beyond what I ended up using. That makes it much harder for a user enter in a non-valid dice string and has "all the options" right there in their face when doing it. If there is something that can't be done (I missed a type) this at least deals with 90% of what I could find....

Where Level is level, or level/2 or similar AD&D damage seemed to mostly be (Level)dSomeDice for damage and (Level) * SomeValue +(someOther statics) for durations.