Morwen's Encounter Generator
Encounter Generator[edit]
The PawScript Encounter Generator is a randomization feature that creates weighted creature encounters for tabletop-style gameplay. It produces a list of encounters based on probability weights, then calculates dynamic challenge ratings from group size, creature type variants, and elemental affinities. The final list is automatically sorted by challenge rating for balanced progression / easier reading.
Configuration[edit]
Definition[edit]
- Name: Encounter Config
- Type: YAML
- Initial Value: see basic configuration sample below / complex example at the end of the page
- Visibility: Hidden from Player and AI
Structure[edit]
The generator uses a YAML configuration with this hierarchy:
- Top-Level Settings
-
- encounter_list_size
- : Number of encounters to generate (default: 0)
- include_naming
- : Boolean - Include creature names in output
- include_type_naming
- : Boolean - Prefix names with type (e.g., "evolved goblin")
- include_details
- : Boolean - Include descriptive text
- Encounter Definitions
Each entry in the encounters list requires:
- creature - Base creature name (string)
- disposition - Behavioral description (string)
- probability - Selection weight, 0-1 (at least one must be 1)
- details - Optional flavor text (string)
- groups - Array of possible group sizes with base challenge ratings
- types - Array of type variants with CR modifiers
- affinities - Array of elemental traits with CR modifiers
Challenge Rating Calculation[edit]
Final CR = group.challenge_rating + (group.size × (type.challenge_rating + affinity.challenge_rating))
This formula allows for dynamic scaling where larger groups, stronger types, or powerful affinities create appropriately challenging encounters.
Basic Configuration Example[edit]
encounter_list_size: 10
include_naming: true
include_type_naming: true
include_details: true
encounters:
- creature: goblin
disposition: aggressive
details: Small opportunistic humanoids
probability: 1
groups:
- size: 1
challenge_rating: 1
- size: 3
challenge_rating: 3
types:
- name: weak
challenge_rating: -0.5
- name: ''
challenge_rating: 0
- name: evolved
challenge_rating: 1
affinities:
- name: fire
challenge_rating: 1
details: Glowing red eyes
- creature: wolf
disposition: territorial
probability: 0.8
groups:
- size: 1
challenge_rating: 2
- size: 4
challenge_rating: 8
types:
- name: dire
challenge_rating: 1
affinities:
- name: ''
challenge_rating: 0
Tracked Item Setup[edit]
Create a tracked item to store generated encounters:
- Name: Encounter List
- Type: YAML
- Initial Value: empty
- Visibility: optional, depending on specific usage
- Description: Generated encounters sorted by challenge rating
Encounter Entry Fields[edit]
Each generated encounter contains:
- name - Formatted creature name (if naming enabled)
- creature - Base creature type
- group_size - Number of creatures
- disposition - Creature behavior
- type - Selected type variant
- affinity - Selected elemental affinity
- challenge_rating - Calculated difficulty
- details - Combined description (if details enabled)
Example Generated Entry[edit]
- name: evolved goblin (3)
creature: goblin
group_size: 3
disposition: aggressive
type: evolved
affinity: fire
challenge_rating: 8
details: Small opportunistic humanoids, the fire affinity shows in glowing red eyes
Usage in Game[edit]
Get a random entry: <<$encounter_list.random()>>
Access individual encounters: <<$encounter_list.item(n)>>
Include the whole list: <<$encounter_list>>
List of encounters with a challenge rating less than 3: <<$encounter_list.where(challenge_rating < 3)>>
To give the lowest-CR encounter higher selection probability:
<<list(list($encounter_list.item(1), $encounter_list.last($encounter_list.count() -1)).random()).flatten().random()>>
This expression implements weighted randomness where the first entry (always the lowest-CR encounter due to sorting) has a 50% selection chance, while all remaining encounters share the other 50% equally. Useful for ensuring easier encounters appear more frequently.
Script Implementation[edit]
# Encounter Generator Script
# Generates randomized encounters from encounter_config
# CR = group.base_CR + (group.size × (type.CR + affinity.CR))
$encounter_list = list()
set $list_size = try($encounter_config.encounter_list_size, 0)
for each $index in range($list_size)
set $probability_list = $encounter_config.encounters.where(probability > random())
set $encounter = $probability_list.item(random_between(1, $probability_list.count()))
set $group = $encounter.groups.item(random_between(1, $encounter.groups.count()))
set $type = $encounter.types.item(random_between(1, $encounter.types.count()))
set $affinity = $encounter.affinities.item(random_between(1, $encounter.affinities.count()))
set $cr = $group.challenge_rating + $group.size * ($type.challenge_rating + $affinity.challenge_rating)
set $encounter_entry = record()
if $encounter_config.include_naming
set $name = $encounter.creature & ' (' & $group.size & ')'
if $encounter_config.include_type_naming and $type.name != ''
$name = $type.name & ' ' & $name
$encounter_entry.name = $name
if $encounter_config.include_details
set $details = try($encounter.details & ', ', '')
$details = $details & try($type.details & ', ', '')
$details = $details & try($affinity.details, '')
$encounter_entry.details = $details
$encounter_entry.creature = $encounter.creature
$encounter_entry.group_size = $group.size
$encounter_entry.disposition = $encounter.disposition
$encounter_entry.type = $type.name
$encounter_entry.affinity = $affinity.name
$encounter_entry.challenge_rating = $cr
$encounter_list.append($encounter_entry)
if $encounter_list.count() > 0
$encounter_list = $encounter_list.sort_by(challenge_rating)Full Commented Configuration[edit]
# Encounter Generator Configuration
# This configuration defines the pool of possible encounters and their generation parameters
# Top-level settings
encounter_list_size: 10 # Number of encounters to generate in each list
include_naming: true # Include creature names in output (e.g., "goblin (3)")
include_type_naming: true # Include type prefixes when available (e.g., "evolved goblin (3)")
include_details: true # Include descriptive text for creatures, types, and affinities
# Encounter definitions
# NOTE: At least one creature MUST have probability: 1 to ensure selection
encounters:
# ===== COMMON CREATURES =====
# Base creatures with higher probability
- creature: goblin
disposition: aggressive
details: Goblins are smaller humanoids that are very opportunistic, aggressive towards anything weaker and fearful towards anything they perceive as stronger or dangerous
probability: 1
groups:
- size: 1
challenge_rating: 1
- size: 2
challenge_rating: 2
- size: 3
challenge_rating: 4
- size: 4
challenge_rating: 6
types:
- name: weak
challenge_rating: -0.5
- name: ''
challenge_rating: 0
- name: evolved
challenge_rating: 1
affinities:
- name: ''
challenge_rating: 0
- name: ''
challenge_rating: 0
- name: fire
challenge_rating: 2
details: the fire affinity shows in glowing red eyes and boiling hot blood
- creature: orc
disposition: enslaving
details: Orcs are powerful humanoids with green to brown skin and large tusks, they prefer enslaving to killing, and see a loss as dishonorable
probability: 0.3
groups:
- size: 1
challenge_rating: 3
- size: 2
challenge_rating: 6
- size: 3
challenge_rating: 10
types:
- name: weak
challenge_rating: -1
- name: ''
challenge_rating: 0
- name: evolved
challenge_rating: 1
affinities:
- name: ''
challenge_rating: 0
- creature: slime
disposition: aggressive
probability: 1
groups:
- size: 1
challenge_rating: 1
- size: 3
challenge_rating: 3
types:
- name: ''
challenge_rating: 0
- name: ''
challenge_rating: 0
- name: ''
challenge_rating: 0
- name: oozing
challenge_rating: 1
details: oozing slimes can cover a much larger area
affinities:
- name: ''
challenge_rating: 0
- name: poison
challenge_rating: 1
- name: corrosive
challenge_rating: 1
- name: fire
challenge_rating: 2
- name: ice
challenge_rating: 2
- name: lightning
challenge_rating: 2
- creature: elemental
disposition: aggressive
probability: 0.4
groups:
- size: 1
challenge_rating: 5
- size: 2
challenge_rating: 10
types:
- name: minor
challenge_rating: -1
- name: ''
challenge_rating: 0
- name: greater
challenge_rating: 2
- name: ancient
challenge_rating: 5
affinities:
- name: 'air'
challenge_rating: 0
- name: 'earth'
challenge_rating: 0
- name: 'water'
challenge_rating: 0
- name: 'wood'
challenge_rating: 0
- creature: wolf
disposition: aggressive
probability: 0.8
groups:
- size: 1
challenge_rating: 2
- size: 2
challenge_rating: 4
- size: 3
challenge_rating: 7
- size: 4
challenge_rating: 10
types:
- name: weak
challenge_rating: -0.5
- name: ''
challenge_rating: 0
- name: dire
challenge_rating: 1
affinities:
- name: ''
challenge_rating: 0
# ===== MYTHICAL CREATURES =====
- creature: fairy
disposition: playful
details: Fairies are diminutive humanoids with insectoid wings, their magic is focused on trickery, fate and illusion
probability: 0.25
groups:
- size: 2
challenge_rating: 6
- size: 3
challenge_rating: 8
types:
- name: ''
challenge_rating: 0
- name: dark
challenge_rating: 2
affinities:
- name: magic
challenge_rating: 0
- creature: satyr
disposition: hedonistic
probability: 0.25
groups:
- size: 1
challenge_rating: 5
types:
- name: ''
challenge_rating: 0
- name: drunk
challenge_rating: -1
affinities:
- name: ''
challenge_rating: 0
- creature: dryad
disposition: curious and defensive
probability: 0.25
groups:
- size: 1
challenge_rating: 10
types:
- name: ''
challenge_rating: 0
- name: corrupted
challenge_rating: 4
affinities:
- name: nature
challenge_rating: 0
- creature: nymph
disposition: curious and playful
probability: 0.25
groups:
- size: 2
challenge_rating: 4
- size: 3
challenge_rating: 6
- size: 4
challenge_rating: 8
types:
- name: forest
challenge_rating: 0
- name: water
challenge_rating: 0
affinities:
- name: ''
challenge_rating: 0
- creature: myconoid
disposition: parasitic
probability: 0.4
groups:
- size: 1
challenge_rating: 4
- size: 2
challenge_rating: 8
- size: 1
challenge_rating: 4
- size: 4
challenge_rating: 16
types:
- name: ''
challenge_rating: 0
- name: spore-releasing
challenge_rating: 1
- name: giant
challenge_rating: 2
affinities:
- name: ''
challenge_rating: 0
- name: ''
challenge_rating: 0
- name: poison
challenge_rating: 1