DnDGen.CreatureGen
2.0.0
dotnet add package DnDGen.CreatureGen --version 2.0.0
NuGet\Install-Package DnDGen.CreatureGen -Version 2.0.0
<PackageReference Include="DnDGen.CreatureGen" Version="2.0.0" />
<PackageVersion Include="DnDGen.CreatureGen" Version="2.0.0" />
<PackageReference Include="DnDGen.CreatureGen" />
paket add DnDGen.CreatureGen --version 2.0.0
#r "nuget: DnDGen.CreatureGen, 2.0.0"
#:package DnDGen.CreatureGen@2.0.0
#addin nuget:?package=DnDGen.CreatureGen&version=2.0.0
#tool nuget:?package=DnDGen.CreatureGen&version=2.0.0
CreatureGen
Generates a random, fleshed-out creature for Dungeons and Dragons 3.5
Installing CreatureGen
The project is on NuGet. It targets .NET 10.
dotnet add package DnDGen.CreatureGen
Getting the Generators
You can obtain generators from the IoC namespace within the domain project. Because the generators are very complex and are decorated in various ways, there is not a (recommended) way to build these generators manually. Please use the Module Loader in the IoC namespace. Note: This will also load dependencies of CreatureGen, including RollGen, Infrastructure, and TreasureGen.
var kernel = new StandardKernel();
var creatureGenModuleLoader = new CreatureGenModuleLoader();
creatureGenModuleLoader.LoadModules(kernel);
var creatureGenerator = kernel.Get<ICreatureGenerator>();
var creatureVerifier = kernel.Get<ICreatureVerifier>();
Your particular syntax for how the Ninject injection should work will depend on your project (class library, web site, etc.)
Use
Generating a specific creature
var ogre = creatureGenerator.Generate(false, CreatureConstants.Ogre);
var zombieOgre = creatureGenerator.Generate(false, CreatureConstants.Ogre, null, CreatureConstants.Templates.Zombie);
var humanCharacter = await creatureGenerator.GenerateAsync(true, CreatureConstants.Human);
The first argument, asCharacter, says whether the creature is generated as a character (a playable race that will take class levels) or as a monster.
Only creatures that can be characters may be generated as characters.
For example, a 1-Hit-Die humanoid such as a Human has its racial Hit Die replaced by class levels when generated as a character.
Chaining templates
Templates are passed as the last arguments, and are applied in the order given. Each template must be compatible with the creature as it is after the templates before it have been applied.
var halfDragonHalfFiend = creatureGenerator.Generate(
false,
CreatureConstants.Human,
null,
CreatureConstants.Templates.HalfDragon_Black,
CreatureConstants.Templates.HalfFiend);
Ability scores
When no AbilityRandomizer is passed in, abilities are rolled with the default roll (1d2+9, or 10-11) with no other modifications.
var abilityRandomizer = new AbilityRandomizer(AbilityConstants.RandomizerRolls.BestOfFour);
abilityRandomizer.PriorityAbility = AbilityConstants.Intelligence;
var elfLich = creatureGenerator.Generate(true, CreatureConstants.Elf_High, abilityRandomizer, CreatureConstants.Templates.Lich);
//INFO: Set rolls are used as-is instead of rolling
var setRandomizer = new AbilityRandomizer();
setRandomizer.SetRolls[AbilityConstants.Strength] = 18;
setRandomizer.SetRolls[AbilityConstants.Charisma] = 8;
var strongDwarf = creatureGenerator.Generate(true, CreatureConstants.Dwarf_Hill, setRandomizer);
The available rolls are in AbilityConstants.RandomizerRolls:
| Roll | Dice | Range |
|---|---|---|
Poor |
3d3 | 3-9 |
Default |
1d2+9 | 10-11 |
Average |
3d2+7 | 10-13 |
Good |
3d2+10 | 13-16 |
Heroic |
3d2+12 | 15-18 |
BestOfFour |
4d6, keep the highest 3 | 3-18 |
OnesAsSixes |
3d6, with 1s counted as 6s | 6-18 |
Raw |
3d6 | 3-18 |
Wild |
2d10 | 2-20 |
Some templates require a minimum ability score: a Ghost needs Charisma 6, and a Half-Celestial or Half-Fiend needs Intelligence 4.
When you generate one of these, any rolled score that would fall short is raised to meet the minimum.
If the randomizer can never reach the minimum (for example, a set roll that is too low), the creature is not compatible and an InvalidCreatureException is thrown.
Random creatures
var (creatureName, templates) = creatureGenerator.GenerateRandomName(false);
var randomCreature = creatureGenerator.GenerateRandom(false);
var randomCharacter = await creatureGenerator.GenerateRandomAsync(true);
//INFO: A random creature with the given template(s)
var randomGhost = creatureGenerator.GenerateRandom(false, null, null, CreatureConstants.Templates.Ghost);
//INFO: Pass the None template to only get creatures without a template
var randomNonTemplated = creatureGenerator.GenerateRandom(false, null, null, CreatureConstants.Templates.None);
When no templates are passed in, the random creature may or may not have a template, weighted heavily in favor of creatures without a template.
Filters
Filters narrow down which random creatures are valid. They are checked against the creature after all of its templates are applied.
- A creature satisfies a filter if it matches any of the values in that filter's list.
- A creature must satisfy every filter that has values.
- Null and empty filters are ignored, so
new Filters()allows anything.
var filters = new Filters
{
Types = [CreatureConstants.Types.Humanoid],
ChallengeRatings = [ChallengeRatingConstants.CR3, ChallengeRatingConstants.CR4],
Alignments = [AlignmentConstants.NeutralEvil, AlignmentConstants.ChaoticEvil],
};
var randomNameWithFilters = creatureGenerator.GenerateRandomName(false, filters);
var randomWithFilters = creatureGenerator.GenerateRandom(false, null, filters);
var randomHalfFiend = await creatureGenerator.GenerateRandomAsync(false, abilityRandomizer, filters, CreatureConstants.Templates.HalfFiend);
Types matches both creature types and subtypes, such as CreatureConstants.Types.Subtypes.Reptilian.
Creatures generated with a challenge rating filter are never advanced, so their challenge rating stays predictable.
Checking compatibility
If the creature, templates, ability randomizer, and filters can't produce a valid creature, the generator throws an InvalidCreatureException.
To check ahead of time, use the ICreatureVerifier:
var canBeGhost = creatureVerifier.VerifyCompatibility(false, CreatureConstants.Ogre, null, null, CreatureConstants.Templates.Ghost);
var anyValidCreature = creatureVerifier.VerifyCompatibility(false, null, abilityRandomizer, filters);
When no templates are given, VerifyCompatibility returns true if any template (or no template) gives a valid creature.
Include CreatureConstants.Templates.None to only check creatures without a template.
Upgrading from 1.x
Version 2.0.0 has breaking changes to the public API:
- Targets .NET 10. Version 1.x targeted .NET 8, which reaches end of support on November 10, 2026.
- Templates moved out of
Filters. Pass templates as the trailingparams string[] templatesargument ofGenerateRandomName,GenerateRandom, andGenerateRandomAsyncinstead ofFilters.Templates. - Filters are now lists.
Filters.Type,Filters.ChallengeRating, andFilters.Alignmentare replaced byFilters.Types,Filters.ChallengeRatings, andFilters.Alignments. A creature matches if it matches any value in a list. Filters.GetDescription(bool asCharacter)is nowFilters.GetDescription().AbilityRandomizer.Rollis set through the constructor, for examplenew AbilityRandomizer(AbilityConstants.RandomizerRolls.Good). The parameterless constructor still uses the default roll.ICreatureVerifier.VerifyCompatibilitynow takes the ability randomizer and the templates:VerifyCompatibility(asCharacter, creature, abilityRandomizer, filters, templates).InvalidCreatureExceptionconstructors now takeFilters, anAbilityRandomizer, and templates, and the message includes all of them.CreaturePrototypeis now internal.- New challenge ratings
ChallengeRatingConstants.CR28,CR29, andCR30.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- DnDGen.Infrastructure (>= 7.0.6)
- DnDGen.RollGen (>= 16.0.7)
- DnDGen.TreasureGen (>= 12.0.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
2.0.0 contains breaking changes. See "Upgrading from 1.x" in the README.
- Targets .NET 10 (previously .NET 8)
- Templates are passed as trailing params arguments instead of through Filters.Templates
- Filters.Type, ChallengeRating, and Alignment are now the lists Types, ChallengeRatings, and Alignments, matching any value in each list
- AbilityRandomizer.Roll is set through the constructor
- ICreatureVerifier.VerifyCompatibility takes the ability randomizer and templates
- Fixed alignment generation when chaining multiple templates or filtering by alignment
- Template minimum ability scores (Ghost, Half-Celestial, Half-Fiend) are honored for the given ability randomizer, and rolled abilities are raised to meet them
- Template compatibility checks use precomputed creature groups, making verification and random generation much faster
- Added challenge ratings 28 through 30