Guides

Fantasy MUDs with open-source tools

This guide outlines the technical implementation of a multi-tiered deity and faction system for fantasy MUDs. By moving beyond flavor text to hardcoded mechanics, you can create a world where player allegiance to specific gods or kingdoms directly impacts character stats, quest availability, and world interactions.

12-18 hours of development and configuration6 steps
Fantasy MUDs with open-source tools hero illustration
1

Define the Deity and Faction Data Structures

Create a centralized data structure to store deity attributes. This should be decoupled from individual player files to allow for global updates to deity status or alignment. Use an ID-based system to reference these entities in room, NPC, and item flags.

deity.h
struct deity_type {
    char *name;
    long vnum;
    short alignment; /* -1000 to 1000 */
    long domains;    /* Bitvector: FIRE, WAR, LIFE, etc. */
    long enemies;    /* Bitmask of rival deity IDs */
    int favor_mod;   /* Global multiplier for piety gain */
};

⚠ Common Pitfalls

  • Hardcoding names instead of IDs, making future lore renames difficult.
  • Forgetting to initialize default values for new players.
2

Implement the Piety/Favor Variable

Add a 'piety' or 'favor' variable to the player object. This value must be persistent and should have a decay rate to prevent players from maxing out every faction. Create a function to handle the modification of this value that checks for conflicting allegiances.

piety_handler.py
def adjust_piety(ch, deity_id, amount):
    # Check if this deity has rivals
    rivals = get_deity_rivals(deity_id)
    for rival in rivals:
        # Reduce favor with rivals by 50% of the gain
        ch.piety[rival] -= amount * 0.5
    
    ch.piety[deity_id] += amount
    ch.piety[deity_id] = clamp(ch.piety[deity_id], -1000, 1000)

⚠ Common Pitfalls

  • Allowing piety to go negative without mechanical consequences (e.g., hostile NPCs).
  • Lack of a 'neutral' floor, causing players to become accidentally hated by all factions.
3

Integrate Deity Checks into the Combat and Spell Engines

Modify your spell-casting and combat functions to check for deity alignment. Clerics or Paladins should receive bonuses or penalties based on their current favor. For example, a 'Cure Light' spell should be 20% more effective if the player has high favor with a Life-domain deity.

magic.c
int calculate_spell_power(CHAR_DATA *ch, int sn) {
    int power = ch->level;
    if (skill_table[sn].type == SKILL_DIVINE) {
        if (ch->pcdata->piety[ch->deity] > 500) {
            power *= 1.2;
        } else if (ch->pcdata->piety[ch->deity] < 0) {
            power *= 0.5;
        }
    }
    return power;
}

⚠ Common Pitfalls

  • Over-buffing high-favor players, leading to game imbalance.
  • Ignoring the 'atheist' or 'unaligned' path, making it unviable for non-religious classes.
4

Configure NPC Reaction and Aggro Logic

Update the mobile (NPC) AI to evaluate player piety. Temple guards should be neutral to most but aggressive to players with high favor in a rival deity. Use your codebase's 'spec_prog' or 'trigger' system to implement these checks upon a player entering a room.

⚠ Common Pitfalls

  • Setting aggro flags on essential quest-givers, potentially soft-locking players.
  • Failing to provide a way for players to 'atone' and reset their reputation.
5

Develop World-State Triggers and OLC Integration

Add fields to your Area Editor (OLC) that allow builders to tag rooms or items with deity IDs. A 'Consecrated Ground' room might provide faster mana regeneration to followers of a specific god. Ensure these flags are saved in the area files.

area_file_sample.are
Room Vnum: [1001]
Name: The Sun Temple Altar
Deity_ID: [2] (Solara)
Room_Flags: [CONSECRATED, NO_UNDEAD]
Regen_Bonus: [15%]

⚠ Common Pitfalls

  • Creating area-specific mechanics that aren't documented in the 'help' files.
  • Redundant flag checks that increase CPU load in high-traffic rooms.
6

Implement Player Commands for Worship and Rituals

Create the interface for players to interact with the system. Commands like 'worship', 'sacrifice', and 'piety' allow players to track their progress. Sacrificing items should provide a piety boost scaled by the item's value or level.

⚠ Common Pitfalls

  • Allowing players to 'spam' sacrifices of low-value trash items to max out favor quickly.
  • Vague feedback; players should know why their favor changed (e.g., 'You feel the gaze of Solara turn away as you slay the innocent').

What you built

A robust deity system transforms a fantasy MUD from a simple dungeon crawl into a dynamic political and spiritual landscape. By ensuring that every action—from killing a mob to casting a spell—filters through the lens of factional favor, you create a more immersive and replayable world for your players.