Skip to content

Procedural Name Generation

nxkhxl-04 edited this page Sep 24, 2026 · 1 revision

Overview

The Procedural Name Generation feature automatically assigns names to NPCs when they are created. Instead of manually defining a name for every NPC, the system combines a randomly selected prefix and suffix to create a formatted name.

Examples of generated names include:

  • Grimfang
  • Ashbane
  • Dreadclaw
  • Nightshade
  • Bonecrusher

Generated names are stored with the NPC and displayed above the NPC in the game world.

Core Workflow

When an NPC is spawned, the following process occurs:

  1. The NPCFactory creates the NPC.
  2. NameGenerator selects a random prefix and suffix.
  3. The two parts are combined to create the NPC's name.
  4. The generated name is stored in a NameComponent.
  5. NameDisplay retrieves the name from the NPC.
  6. The name is positioned above the NPC and displayed in the game world.

Team Dependencies

The feature integrates with the existing NPC and game-area systems.

  • NPCFactory generates and assigns names when supported NPCs are created.
  • NameComponent stores the generated NPC name.
  • LevelGameArea adds the name display when spawning NPCs.
  • NameDisplay uses the existing UI and camera systems to display the name above the NPC.
  • The existing rendering camera is used to keep the displayed name positioned relative to the NPC.

Behind The Scenes

Naming Rules

Names are generated by combining one prefix with one suffix.

Prefixes

  • Grim
  • Ash
  • Dread
  • Blood
  • Night
  • Iron
  • Dark
  • Bone

Suffixes

  • fang
  • bane
  • claw
  • crusher
  • walker
  • shade
  • heart
  • skull

The resulting name follows a capitalised prefix followed by a lowercase suffix, such as Grimfang or Ashbane.

Name Generation

NameGenerator uses Java's Random class to independently select a prefix and suffix.

This allows multiple names to be generated without manually defining every possible combination.

NPC Integration

Each supported NPC receives a NameComponent containing its generated name when it is created through NPCFactory.

The name is therefore stored directly on the NPC entity and can be accessed by other systems.

Name Display

NameDisplay is responsible for presenting the generated name to the player.

The display uses the existing Scene2D UI system and projects the NPC's world position onto the screen. The label is positioned above the NPC and follows its location as the game camera moves.

Testing

The procedural name generation system includes unit tests covering:

  • Name generation
  • Generated name formatting
  • Invalid random-number-generator input
  • Multiple name-generation calls

NameComponent is also tested to ensure that names can be stored and updated correctly and that null or blank names are rejected.

The feature was also manually tested in-game to verify that generated NPC names are visible above NPCs during gameplay.

Clone this wiki locally