← All Workshops

MudEngine Part 9: The Twin Guardians

Cooperative Quest Design

So far players can walk, chat, and pick up items — but there's no shared goal. In this part we add a cooperative quest that requires two players to work together.

The Twin Guardians — Three Heroes, One Quest

A grand quest stirs in the realm. King Aldric of the Town Square has sent out a call for heroes. Deep beneath the square lies the Ancient Vault, sealed by two magical guardians. Inside rests the legendary Star Fragment — the king needs it to restore the realm's ancient wards.

The quest unfolds in three phases:

Phase 1 — The Gate Opens Two players stand on the Sun Pedestal (Temple Courtyard) and the Moon Pedestal (Dark Forest) simultaneously. A shimmering portal appears in the Town Square floor.

Phase 2 — The Retrieval A third player descends through the portal into the Ancient Vault, grabs the Star Fragment, and ascends back to Town Square.

Phase 3 — The Reward When the Star Fragment arrives in Town Square (in the hero's inventory or dropped before the King), King Aldric acknowledges the deed and the quest is complete. A celebratory broadcast fires for all.

When either guardian leaves their pedestal before the fragment is retrieved:

  • The portal closes and vanishes
  • Anyone inside the vault is teleported back to Town Square

But once the Star Fragment is safely in Town Square, the quest is won — the guardians can leave their posts.

What you'll learn

  • Quest data in game.toml — quest configuration alongside rooms and items
  • Dynamic room exits — exits that appear and disappear based on game state
  • Server-side quest logic — checking conditions on every player move, item action, and disconnect
  • Quest event broadcasting — real-time announcements when quest state changes
  • Quest completion detection — tracking when a specific item arrives at a specific location
  • NPC interaction — King Aldric's dialog changes based on quest state
  • Client-side quest UI — showing quest phases, King dialog, and completion state

Architecture

Phase 1 — Portal Opens           Phase 2 — Retrieval             Phase 3 — Complete
────────────────────────          ──────────────────────          ─────────────────────
Player A: Sun Pedestal            Player C descends               Star Fragment enters
Player B: Moon Pedestal           into Ancient Vault              Town Square (room 4)
         │                                │                              │
         └── both occupied? ──yes──►  Portal opens              King Aldric acknowledges
                │                 room 4 → room 9                quest_completed = true
         no: portal closes         Player C takes                 Broadcast celebration
           kick from room 9       "Star Fragment"
                                  ascends back
"Phase 1: Gate" "Phase 2: Retrieval" "Phase 3: Reward" "Yes" "No" Player A: Sun Pedestal (room 5) Player B: Moon Pedestal (room 3) "Both occupied?" Portal opens room 4 → room 9 Player C descends to Ancient Vault Takes Star Fragment Ascends to Town Square King Aldric in Town Square Quest Complete! Broadcast celebration Portal closes Kick from vault