# 5E Lab

A Verse world at https://openagents.com/worlds/5e-lab, not listed on the worlds page. It's the test bench for the shared SRD 5e rules engine: two sides of 24, the Circle of Moss and the Ember Pact, each with two of every one of the twelve SRD 5e classes at level 6, fight each other while an army of 160 Skeletons (the Restless Dead) stands against both sides, on a grid of 5-foot squares, seen either in 3D in a painterly glade like Everglade's or as a bare flat grid. Every attack roll, saving throw, damage roll and death save comes from the engine, and the log shows each one.

## Controls

- V, or the 2D VIEW / 3D VIEW button, switches between the 3D glade (the default) and the flat grid.
- M, or the ACTION COMBAT / SRD ROUNDS button, switches the clock (action combat in the 3D glade is the default) and starts a new battle. SRD rounds give each creature a full turn every 6 seconds, spent slots and uses come back only on a rest. Action combat plays like the Neverwinter MMO: each creature gets a turn's worth (action, Bonus Action, its share of movement) every 1.5 seconds, and spent spell slots, Rages and Focus Points come back on a cooldown (9 seconds; 4.5 for a Focus Point). Dice, Armor Class and spell durations are the SRD's either way, and repeat saves, death saves and Rage upkeep stay on 6-second rounds.
- In the glade, drag or hold the arrow keys to orbit the camera. Shift-drag or a two-finger drag pans it, and holding W, A, S or D flies it smoothly over the grid. The mouse wheel, a pinch, or holding + or - zooms it. C puts the camera back. The frame rate shows in the scene's bottom-right corner.
- Space pauses and resumes.
- F switches between normal speed and four times as fast.
- R starts a new battle.
- WORLDS at the top right, or Escape, goes to the [worlds list](https://openagents.com/worlds).

## What you are watching

- Each creature takes a turn every 6 seconds, in initiative order. In a turn it has one action, one Bonus Action, its Speed and one spell slot to spend.
- Every hero is level 6: Proficiency Bonus +3, an Ability Score Improvement at 4 (+2 to its main score, twice for a Fighter), Extra Attack at 5 for the martial classes, 3rd-level spell slots for the casters, and its subclass's level 6 feature.
- Each side has two of each class. The six spellcasting classes (Druid, Wizard, Warlock, Sorcerer, Bard and Cleric) stand in the two back files, and the Fighter, Paladin, Barbarian, Monk, Rogue and Ranger stand in front of them.
- Druids are on the Circle of the Land (a polar land): Produce Flame, Starry Wisp and Poison Spray; Cure Wounds, Healing Word, Thunderwave, Entangle, Faerie Fire and Hold Person. Land's Aid spends a Wild Shape use for 2d6 Necrotic in a 10-foot sphere and heals one creature there. Call Lightning drops a 3d10 bolt on the swarm and calls another each turn it lasts. Wild Resurgence trades a spell slot for a Wild Shape use, and Natural Recovery casts Hold Person once without a slot.
- Wizards are Evokers in Mage Armor (AC 15): Fire Bolt, Thunderwave, Scorching Ray and Hold Person. Potent Cantrip deals half damage on a miss or a successful save, and Shield adds 5 to AC as a Reaction. Fireball (8d6 Fire in a 20-foot sphere) goes where it catches the most foes; Sculpt Spells keeps friends in it safe.
- Warlocks have the Fiend Patron: Armor of Shadows (AC 15), Agonizing Blast and Repelling Blast on Eldritch Blast, and Dark One's Blessing. They cast Chill Touch, Hex, Hold Person, Scorching Ray and the Fiend's Fireball with two level 3 Pact Magic slots. Dark One's Own Luck adds 1d10 to a failed save.
- Sorcerers have Draconic Sorcery (3 more Hit Points, AC 10 + Dex + Cha): Fire Bolt, Thunderwave and Scorching Ray. Innate Sorcery adds 1 to their spell save DC and gives Advantage on spell attacks. Sorcery Points pay for Quickened Spell (a second Fire Bolt as a Bonus Action) and Seeking Spell (a missed spell attack rerolled). They also cast Shield and Fireball, and Elemental Affinity adds Charisma to their Fire damage and gives them Resistance to Fire.
- Bards are on the College of Lore: Bardic Inspiration (a d8 added to a friend's failed roll; Font of Inspiration buys a use back with a spell slot), Cutting Words (a Reaction that subtracts the die from a foe's hit), Vicious Mockery, Healing Word, Thunderwave, Hold Person and Hypnotic Pattern, which leaves a crowd Charmed and Incapacitated. Magical Discoveries adds Fireball and Spirit Guardians.
- Clerics are on the Life Domain, in a Chain Shirt with a Shield (AC 16) and a Mace. They cast Sacred Flame, Guiding Bolt (the next attack against the target has Advantage) and Healing Word, which Disciple of Life strengthens. Channel Divinity powers Turn Undead (Skeletons that fail the save flee, and Sear Undead burns them first) or Preserve Life. Spirit Guardians wounds the dead that come within 15 feet and halves their Speed, and Blessed Healer heals the Cleric when it heals someone else.
- Fighters are Champions in Chain Mail with the Defense style (AC 17), with a Greatsword and its Graze mastery. They have Second Wind, Action Surge, Improved Critical (a 19 or 20 is a Critical Hit), Remarkable Athlete, Tactical Mind and Tactical Shift.
- Paladins are on the Oath of Devotion, in Chain Mail with a Shield (AC 18), with a Longsword and its Sap mastery. They have Lay On Hands, Divine Smite (once without a slot), Sacred Flame (Blessed Warrior), Sacred Weapon, and an Aura of Protection that adds Charisma to the saves of friends within 10 feet.
- Rangers are Hunters with a Longbow (Slow mastery) and Archery, and a Shortsword (Vex mastery) at close range. Favored Enemy casts Hunter's Mark without a slot, and Colossus Slayer adds 1d8 against a wounded foe. Roving adds 10 feet of Speed.
- Rogues are Thieves in Leather Armor with a Shortsword and a Shortbow (Vex mastery). They have Sneak Attack (3d6), Cunning Action (a Dash as a Bonus Action), Steady Aim, Cunning Strike (trip a foe Prone, or withdraw) and Uncanny Dodge.
- Barbarians are on the Path of the Berserker: unarmored (AC 13), a Greataxe with the Cleave mastery, Rage (resistance to Bludgeoning, Piercing and Slashing, +2 damage), Reckless Attack, Danger Sense, Frenzy, Fast Movement (+10 feet) and Mindless Rage (no Charmed or Frightened while raging).
- Monks are Warriors of the Open Hand: unarmored (AC 15), Speed 40, Unarmed Strikes with the Martial Arts die, three Focus Points for Flurry of Blows (each hit can knock a foe Prone or push it 15 feet), Patient Defense, Step of the Wind, Deflect Attacks, Slow Fall, Stunning Strike, Empowered Strikes (Force damage) and Wholeness of Body.
- Skeletons use the SRD's Skeleton stat block: Undead, AC 14, 13 Hit Points, a Shortsword and a Shortbow (+5, 1d6 + 3 Piercing), Vulnerability to Bludgeoning (a monk's fists do double), Immunity to Poison, and no Hold Person (it works only on Humanoids). All 160 stand in the middle of the glade from the start. Half close in with swords and half shoot from range, and like any SRD monster they die the instant they drop to 0 Hit Points. The heroes fight each other first and fight the dead when they come close. The last side standing wins.
- Some class features don't change a battle: skills and checks (Expertise, Jack of All Trades, a Thief's Fast Hands), rests and rituals (Arcane Recovery, Magical Cunning, Natural Recovery's slot recovery, Font of Inspiration's rest refill), senses and travel (Divine Sense, Deft Explorer, Slow Fall without a fall), and companions (Wild Companion, Find Steed). The engine keeps them on the creature's record. Some spells the level 6 classes have aren't in the engine yet, so nobody casts them: Haste, Counterspell, Lightning Bolt, Mass Healing Word, Revivify, Sleet Storm, Slow, Stinking Cloud, and the Oath of Devotion's spells. The engine has no Opportunity Attacks, so Disengage does nothing here.
- The CHARACTERS panel lists each hero's Hit Points, AC and what it has left: spell slots, Rages, Focus Points, Bardic Inspiration (INSP), Channel Divinity, Second Wind and Action Surge, Lay On Hands, Hunter's Marks without a slot (MARKS), Sneak Attack dice, Sorcery Points and Land's Aid. Slots read lowest level first (4+3+3). When a row has no room, its conditions are left off.
- A ring of light marks whoever just took a turn. The ring at each figure's feet shows its side: green for the Circle of Moss, blue for the Ember Pact. The figures are the Quaternius villagers Everglade's people are made from (CC0), men and women, each class in its own clothes: Druids in leaf-green leathers, Wizards in deep blue robes, Warlocks in ember-crimson robes and hoods, Sorcerers in copper robes with red hair, Bards in plum, Clerics in white vestments, Fighters in steel grey, Paladins in silver and blue, Rangers hooded in forest green, Rogues hooded in black, Monks in saffron, and Barbarians in fur brown with beards. The Skeletons are the same body made bone, gaunt, with gaps between the ribs and glowing eye sockets, half of them under a ragged hood. A figure stands idle, walks or runs as it moves, swings a blow at close range, casts a spell or looses a shot with an outstretched arm, flinches when it's hit, and falls when it dies; the dead lie a few seconds and then fade.
- Marks on a figure show its conditions. A green tangle marks a Restrained creature, a green cast a Poisoned one, a dark band over the eyes a Blinded one, grey an enfeebled one, a red rim Temporary Hit Points, a gold sheen a Paralyzed one, a flickering violet rim a hexed one, a violet glow an outlined one, and a small flame a lit Produce Flame. The thin line under the hit-point bar is the spell it's concentrating on.
- In the glade, every spell and class feature has its own effect: fire, rays and bolts fly; Action Surge bursts gold, Second Wind rises in pale light, Sneak Attack slashes dark with a violet flash, Cunning Action leaves shadows behind, Steady Aim closes a reticle, Flurry of Blows lands six quick blows, Stunning Strike knocks off gold rings and leaves stars, Patient Defense and Step of the Wind swirl wind, Divine Smite drops a hammer of light (bigger from a higher slot), Lay On Hands sends golden motes, Sacred Weapon lights the blade, Preserve Life runs a radiant wave over the ground, Land's Aid raises thorns and flowers, Bardic Inspiration sends notes of light, Vicious Mockery bursts purple, Innate Sorcery crackles, Dark One's Blessing wreathes a Warlock in fire, Hold Person closes golden bands, Blindness snuffs out a light, False Life draws in crimson motes, Shield flashes a hexagonal barrier and Guiding Bolt leaves its target glimmering. While they last, a Poisoned creature trails green bubbles, a Stunned or Paralyzed one has stars round its head, a Frightened one sheds pale drops, a Charmed one gives off pink hearts, a concentrating caster has a mote circling it, and Rage, Sacred Weapon, Innate Sorcery, a flame in hand and Dark One's Blessing each keep a small glow.
- A creature at 0 Hit Points is Unconscious and makes a death saving throw at the start of each of its turns: green ticks are successes, red ticks failures.
- The battle ends when one side has nobody standing. A new one starts 6 seconds later.

## How it is made

- `aethyr/rules/srd/` is the engine: `engine.coax` (dice, abilities, hit points, death saves), `spells.coax` (the spell records and their effect steps), and `battle.coax` (the grid, casting, concentration, conditions and the real-time turn clock). `docs/dnd/README.md` is the specification.
- `apps/openagents-web/fivelab.coax` is the world: each class's decisions, the drawing and its checks. `fivelab-face.c` binds it for the browser, and `fivelab.wgsl` (from `gpu/fivelab.coax`) draws either view: the flat grid, or the glade's ground, trees and sky traced per pixel and lit with the painterly style's functions (`verse/style.coax`), with the figures drawn over it from Everglade's asset pack. `fivelab-bodies.coax` chooses each figure's parts and clip: seven of Everglade's clips (`verse/everglade/people-rig.coax`) are baked once into a table of joint matrices, and the GPU skins every figure from it, in one instanced draw for each part.

This work includes material from the System Reference Document 5.2.1 ("SRD 5.2.1") by Wizards of the Coast LLC, available at https://www.dndbeyond.com/srd. The SRD 5.2.1 is licensed under the Creative Commons Attribution 4.0 International License, available at https://creativecommons.org/licenses/by/4.0/legalcode.

## The Horde

The Horde is the default battle. All 48 heroes fight as one company, the Living, in the middle of the glade: the casting classes inside an 8 by 6 block and the rest round its rim. 160 Skeletons start on the grid's two outer rings and run at them, taking the Dash action until they're within reach. When one falls, a fresh Skeleton runs in from a free square on the edge a second later, until the Horde has sent 1,000. The Living win if they outlast all 1,000. Press H to switch between the Horde and the two armies.

## Playing a hero

Press P, or the SPECTATOR button at the top, to switch to Player mode. You play one hero of the Living: pick its class on the bar along the top of the scene, or with [ and ]. W, A, S and D walk your hero on its turn, and the camera follows it. Click one of the dead to make it your target (a red ring); your hero has a gold ring. The hotbar at the foot of the scene holds your class's own abilities, up to nine, on keys 1 to 9 (or click a slot): its spells by name, its class features, Attack and Dash. A slot's top-left number is what it has left (spell slots at its level, uses, Rages or Focus); a spent slot goes dim; the picked one is gold and fires on your next turn, then the bar goes back to Attack. Every slot fills from its foot as your turn comes round. A bonus-action ability (Rage, Second Wind, Healing Word and so on) leaves your action, which attacks.

If your hero falls, pick a class to play another. Press P again to go back to watching.
