Gemstone IV Bestiary Creature Data System
This module provides a flexible, extensible framework for managing creature definitions, behaviors, and messaging for Lich scripting in Gemstone IV. It supports structured creature data, advanced templating for combat/emote messages, and a singleton-backed registry for efficient lookup.
- Structured creature data: levels, areas, loot, messaging, stats, spells, etc.
- Template-driven message systems with regex-ready placeholders and optional randomization.
- Boon adjective normalization for automatic creature name matching.
- Status and injury tracking for combat-state management.
- Singleton registry for efficient lookup by name or instance ID.
Main data structure for creatures. Holds combat stats, messaging, treasure, abilities, and injuries.
Structured message manager for events like spell prep, arrival, fleeing, death, etc.
Singleton registry to track creatures by name or instance ID.
Handles loading, caching, and normalization of creature templates from the /creatures/ folder.
creature = Lich::Gemstone::Creature.register_creature("Kobold", 12345)
creature = Lich::Gemstone::Creature[12345] # by ID
creature = Lich::Gemstone::Creature["immense gold-bristled hinterboar"] # by namecreature.level
creature.treasure.has_gems?
creature.defense_attributes.asgmsg = creature.messaging.flee
puts msg.to_display(direction: "north") # Fill in placeholders
regex = msg.to_regexPlaceholders like {pronoun}, {direction}, or {weapon} can appear in message templates.
- Use
.to_display(substitutions)to convert to a readable string. - Use
.to_regexto match against game output and extract values.
Multiple templates (arrays) are supported for random selection or regex union.
Example match:
if (match = creature.messaging.flee.to_regex.match("The wendigo flees north."))
puts match[:direction] # => "north"
endCreatures can maintain multiple active statuses and injuries, tracked by body location and severity.
creature.add_status("poisoned")
creature.add_status("webbed")
creature.status
# => ["poisoned", "webbed"]
creature.remove_status("poisoned")statusis an array of unique strings.- Adding the same status twice has no effect.
creature.append_injury("leftArm", 2)
creature.append_injury("rightLeg", 3)
creature.injured?("leftArm", 2)
# => true
creature.injured_locations(3)
# => [:rightLeg]- Injury values are integers.
- Overwrites unless manually incremented.
- Regex templates use named capture groups (
(?<name>...)) - Randomized message arrays supported
- Case-insensitive name handling
- Safe for real-time use during hunts