Learn R Programming

⚠️There's a newer version (3.1.0) of this package.Take me there.

dndR: Dungeons & Dragons Functions for Players and Dungeon Masters

The goal of dndR is to provide a suite of Dungeons & Dragons (Fifth Edition a.k.a. “5e”) related functions to help both players and Dungeon Masters (DMs). Below are short descriptions of the functions currently included in dndR. I am always willing to expand that list though so if you have a D&D-related task that could be cool as a function, please post it as an Issue on this package’s GitHub repository!

Installation

You can install the development version of dndR from GitHub with:

# install.packages("devtools")
devtools::install_github("njlyon0/dndR")

Function Descriptions

Dice Rolling

  • roll – Roll specified number of dice and sums their outcomes. Supports returning the individual die results as a message and/or re-rolling 1s via optional arguments.

Character Creation

  • pc_creator – Stat out a character of specified race and class using your preferred method of rolling ability scores

    • Run dnd_races() or dnd_classes() to see which races/classes are currently supported by pc_creator
  • ability_scores – Roll for six ability scores using specified method (e.g., 4d6 drop lowest, 3d6, or 1d20). Agnostic to character race and/or class

  • mod_calc – Calculate roll modifier for given ability score(s)

  • pc_level_calc – Identify the current level of a player character based on earned experience points (XP). Also returns the proficiency modifier to be used at that level

    • Thank you to Humberto Nappo for contributing this function!
  • npc_creator – Pick a job and race for any number of non-player characters (NPCs). Hopefully this provides a useful starting point when describing the patrons of a tavern or the travelers players glimpse on the edge of the flickering light cast by their campfire

Creatures

  • creature_list – Identify all creatures that fit certain criteria (e.g., experience point value, creature type, size, etc.)

  • creature_text – Retrieve full information and ability/action information text for specified creature(s)

  • monster_stats – Return generic monster stat block of specified experience point (XP) value or challenge rating (CR)

  • monster_creator – Generate a homebrew monster with additional immunities and vulnerabilities of specified difficulty (adjustment for these is performed automatically)

  • cr_convert – Converts challenge rating into equivalent experience point value

Spells

  • spell_list – Identify all spells that fit certain criteria (e.g., spell level, school of magic, character class list, etc.)

  • spell_text – Retrieve full information and description text for specified spell(s)

Encounters

  • encounter_creator – Pick set of creature experience point values that constitute a balanced encounter of specified difficulty and given party composition information

  • xp_pool – Identify experience point total for desired encounter difficulty at a specified player level and party size

  • xp_cost – Find “realized” experience point amount by applying appropriate multiplier for “raw” XP based on number of enemy creatures and party size

Visual Tools

  • party_diagram – Create a ggplot2 diagram of party ability scores separated either by player or by score. This plot can be useful in identifying the strengths and weaknesses of the party as a whole to help you (the DM) create encounters with that in mind
  • probability_plot – Generate a ggplot2 plot of the frequency of roll outcomes for the specified type and number of dice. You can also specify the number of times to roll those dice to inform the plot

Contributing to dndR

If you’d like to contribute function scripts or ideas, that is more than welcome! For specific instructions check out CONTRIBUTING.md but at a glance:

Copy Link

Version

Install

install.packages('dndR')

Monthly Downloads

311

Version

2.0.0

License

MIT + file LICENSE

Maintainer

Nicholas J Lyon

Last Published

April 26th, 2024

Functions in dndR (2.0.0)

dndR-package

dndR: Dungeons & Dragons Functions for Players and Dungeon Masters
party_diagram

Generate a Diagram of a Party's Ability Scores
npc_creator

Create a Non-Player Character (NPC)
encounter_creator

Balance a Combat Encounter for Given Party Composition and Difficulty
dnd_races

Return Vector of Supported DnD Races
monster_table

Dungeons and Dragons Quick Table for Creature Statistics
monster_stats

Quickly Identify Monster Statistics
spell_text

Retrieve Full Spell Description Text by Spell Name
spell_list

List Spells Based on Criteria
pc_level_calc

Calculate Player Character (PC) Level from Current Experience Points (XP)
xp_pool

Calculate Total XP of Monsters for Given Party Level and Difficulty
pc_creator

Create a Player Character (PC)
roll

Roll Any Number of Dice
reroll

Re-Roll 1s from a Prior Dice Roll
monster_creator

Creates a Monster for Given Party Level and Size
d6

Roll a Six-Sided Dice ("d6")
race_mods

Identify Race-Based Ability Modifiers
spells

Dungeons and Dragons Spell Information
mod_calc

Calculate Modifier for Specified Ability Score
probability_plot

Generate a Plot of the Frequency of Roll Outcomes
xp_cost

Adjust the XP Total by Number of Monsters and Party Size
d100

Roll a One Hundred-Sided Dice ("d100")
creature_text

Retrieve Full Creature Description Text by Creature Name
ability_scores

Roll for All Ability Scores
class_block

Assign Ability Scores Based on Class
cr_convert

Convert Challenge Rating to Experience Points
d12

Roll a Twelve-Sided Dice ("d12")
d2

Roll a Two-Sided Dice
d10

Roll a Ten-Sided Dice ("d10")
creature_list

List Creatures Based on Criteria
ability_singular

Rolls for a Single Ability Score
coin

Flip a Coin
creatures

Dungeons and Dragons Creature Information
d4

Roll a Four-Sided Dice ("d4")
d20

Roll a Twenty-Sided Dice ("d20")
d3

Roll a Three-Sided Dice
d8

Roll an Eight-Sided Dice ("d8")
dnd_classes

Return Vector of Accepted Classes
dnd_damage_types

Return Vector of Supported DnD Damage Types