YZUR
Year Zero Universal Roller
This is a collection of helper methods and classes for rolling Year Zero Engine dice in the Foundry VTT.
Features:
- Simple integration: add the
yzur.js
and the/templates
in your project and initialize them in your main init script - Documented methods
- Support for all Year Zero games
- Custom Roll class with many extra getters for stunts, banes, traumas, gear damage, mishaps, ammo, etc.
- Custom DiceTerm classes for each Year Zero dice
- Push support
- Custom roll template with push stack and push button
- Customisable settings
- Compatible with Foundry 0.8.8 and V9
- Compatible with Dice So Nice!
Not included:
- Roll dialog
- Chat Message push button listener (you have to create one and call the roll.push() method, see example below)
- Dice So Nice configuration
How to Set Up
-
Copy the
yzur.js
library (see releases) in your Foundry system (e.g. in a 'lib' folder). -
(optional) Copy the templates in your Foundry system:
templates/
dice/
infos.hbs
roll.hbs
tooltip.hbs
- In your main script, import the library:
import { YearZeroRollManager } from './lib/yzur.js';
- In your init hook, initialize the dice with the
.register()
method.
• Replace'<your_game>'
with the code of the game to be used.
• The second argument is an object of options. Add there the paths to the three templates and your own custom settings.
Hooks.once('init', function () {
YearZeroRollManager.register('<your_game>', {
'ROLL.chatTemplate': 'systems/your_system/templates/dice/roll.hbs',
'ROLL.tooltipTemplate': 'systems/your_system/templates/dice/tooltip.hbs',
'ROLL.infosTemplate': 'systems/your_system/templates/dice/infos.hbs',
});
});
-
The settings are stored in the Foundry's
CONFIG.YZUR
global variable. For more details and how to customize them, see the constant"YZUR"
in theyzur.js
library. -
Read the documentation.
How to Use
Roll
Use the YearZeroRoll
class, which extends the default Foundry's Roll class.
Either create your own formula with it, or use the .forge()
static method.
import { YearZeroRoll } from './lib/yzur.js';
// Set the dice quantities.
let dice = [
{
term: 'b', // Base dice
number: 5,
},
{
term: 's', // Skill dice
number: 3,
},
{
term: 'g' // Gear dice
number: 2
flavor: 'Sword'
}
];
// Set options for the roll.
let options = {
name: 'My Super Year Zero Roll',
maxPush: 1,
};
// Create a roll. Use any of the following methods:
let roll;
roll = Roll.create('<my_formula>', { yzur: true });
roll = YearZeroRoll.create('<my_formula>');
roll = new YearZeroRoll('<my_formula>', data, options);
roll = YearZeroRoll.forge(dice, data, options);
// Roll the roll, same methods as usual
await roll.roll({ async: true });
await roll.toMessage();
Modify
The .modify(n)
method allows you to add a difficulty modifier to the roll.
let roll = YearZeroRoll.forge(dice);
// Modify the roll.
let modifier = -1;
await roll.modify(modifier);
// Roll and send.
await roll.roll({ async: true });
await roll.toMessage();
There are also two other methods to change the quantity of dice in the roll:
// Add dice.
await roll.addDice(1, 'skill');
// Remove dice.
roll.removeDice(1, 'skill');
Push
let roll = YearZeroRoll.forge(dice);
// Push the roll.
await roll.push({ async: true });
Push from the Chat
Add a listener to the button in the chat to get the roll and push it. See example below.
Hooks.on('renderChatMessageHTML', (app, html, data) => {
html.on('click', '.dice-button.push', _onPush);
});
async function _onPush(event) {
event.preventDefault();
// Get the message.
let chatCard = event.currentTarget.closest('.chat-message');
let messageId = chatCard.dataset.messageId;
let message = game.messages.get(messageId);
// Copy the roll.
let roll = message.rolls[0].duplicate();
// Delete the previous message.
await message.delete();
// Push the roll and send it.
await roll.push({ async: true });
await roll.toMessage();
}
If you don't want to create a new message and instead edit the current message, you must call an update for the changes:
// Update the message (it triggers its rendering).
await message.update({ rolls: [roll.toJSON()] });
Custom Template
To dynamically use another template for the roll message, you can use this trick:
let templateData = {
template: "path_to_my_custom_template.hbs",
flavor: "my_custom_roll_flavor",
// ...more details see YearZeroRoll#render()...
};
let messageData = {
content: await roll.render(templateData):,
speaker: ChatMessage.getSpeaker({ actor });
};
let rollMode = game.settings.get('core', 'rollMode');
await roll.toMessage(messageData, { rollMode });
Read More
Read The Fucking Manual here!
Supported Games
Game | Code | Dice & Denominations |
---|---|---|
Alien RPG | alien |
skill: s stress: z |
Blade Runner RPG | br |
brD12: 12 brD10: 10 brD8: 8 brD6: 6 |
Coriolis: The Third Horizon | cor |
skill: s |
Forbidden Lands | fbl |
base: b skill: s gear: g neg: n artoD8: 8 artoD10: 10 artoD12: 12 |
Mutant: Year Zero | myz |
base: b skill: s gear: g neg: n |
Tales From the Loop | tales |
skill: s |
Twilight 2000 (4th Edition) | t2k |
a: 12 b: 10 c: 8 d: 6 ammo: m loc: l |
Vaesen | vae |
skill: s |
Examples of commands in the chat
FBL — Roll 5 base dice, 3 skill dice, 2 gear dice and one D12 artifact die:
/roll 5db + 3ds + 2dg + 1d12
Alien — Roll 7 dice and 1 stress die:
/roll 7ds + 1dz
Vaesen — Roll 6 dice:
/roll 6ds
Twilight 2000 — Roll a D10, a D8, 3 ammo dice and a location die:
/roll 1d10 + 1d8 + 3dm + 1dl
Custom Pushes — Set the max number of pushes:
/roll 5dbnp 5 base dice (no push)
/roll 3dsp0 3 skill dice (max 0 push)
/roll 3dgp3 3 gear dice (max 3 pushes)
/roll 3dbp3 + 3dsp2 + 3dgnp (can be combined)
Note: For full-auto fire, you can add the modifier p1000
.
Dice So Nice
DsN is supported but not configured. See the API for how to create a proper configuration for your custom dice.
Author
👤 Stefouch
🙏 Show Your Support
Give a ⭐️ if this project helped you!
