{
  "id": "tutorial_codex",
  "title": "The Drowned Bell",
  "version": 1,
  "description": "A bell rings beneath the ruined belfry outside Greyhaven. Find a missing courier's warning, recruit a local seer, and descend into the flooded crypt before the echoes claim the town.",
  "intro": {
    "title": "A Bell Where No Bell Stands",
    "subtitle": "Greyhaven, before the fourth toll",
    "text": [
      "Greyhaven has stopped sleeping.",
      "For three nights, a bell has sounded beneath the hills north of town. The old belfry collapsed generations ago, and no bronze remains in its tower, yet each toll rolls through the wells and floorboards as though the earth itself were ringing.",
      "At dawn, you reach the town road. Somewhere beyond the roofs, a fourth toll begins.",
      "Begin at Greyhaven's tavern. Speak with Mara Vey, the innkeeper, about the missing courier."
    ],
    "canSkip": true,
    "startLocation": {
      "x": 112,
      "y": 98,
      "mapId": "overworld"
    },
    "showMessage": "Begin at Greyhaven's tavern. Speak with Mara Vey about the missing courier.",
    "playSFX": "quest_progress"
  },
  "towns": {
    "tutorial_codex:greyhaven": {
      "id": "tutorial_codex:greyhaven",
      "name": "Greyhaven",
      "near": {
        "x": 112,
        "y": 96
      },
      "mainLandMass": true,
      "services": [
        "tavern",
        "blacksmith",
        "shrine",
        "sage"
      ],
      "serviceMinRadius": 3,
      "serviceRadius": 6,
      "safetyRadius": 10,
      "personality": "waterside"
    }
  },
  "dungeons": {
    "tutorial_codex:drowned_belfry": {
      "id": "tutorial_codex:drowned_belfry",
      "name": "The Drowned Belfry",
      "x": 124,
      "y": 84,
      "mainLandMass": true,
      "theme": "crypt",
      "maxLevels": 2,
      "levelNames": {
        "1": "The Drowned Belfry - The Sunken Steps",
        "2": "The Drowned Belfry - The Bell Chamber"
      }
    }
  },
  "npcs": {
    "tutorial_codex:mara_vey": {
      "id": "tutorial_codex:mara_vey",
      "name": "Mara Vey",
      "role": "innkeeper",
      "bark": "If you hear the bell, count the tolls—and pray it stops at three.",
      "dialogueRoot": "tutorial_codex:mara_vey_dialogue",
      "appearance": {
        "ageGroup": "adult",
        "presentation": "feminine"
      },
      "placement": {
        "target": "map:112,96:tavern"
      }
    },
    "tutorial_codex:brother_oren": {
      "id": "tutorial_codex:brother_oren",
      "name": "Brother Oren",
      "role": "shrine_keeper",
      "bark": "Some warnings are late. That does not make them useless.",
      "dialogueRoot": "tutorial_codex:brother_oren_dialogue",
      "placement": {
        "type": "town",
        "townId": "tutorial_codex:greyhaven"
      }
    }
  },
  "companions": {
    "tutorial_codex:lysa_fen": {
      "id": "tutorial_codex:lysa_fen",
      "name": "Lysa Fen",
      "class": "Seer",
      "hp": 62,
      "maxHp": 62,
      "str": 8,
      "dex": 11,
      "con": 10,
      "int": 16,
      "wis": 18,
      "cha": 13,
      "maxAether": 32,
      "weapon": "staff",
      "armor": "cloth",
      "knownSpells": [
        "cantrip_light",
        "cantrip_minorHeal"
      ],
      "bark": "The sound is not traveling through the air. It is traveling through memory.",
      "dialogueRoot": "tutorial_codex:lysa_fen_dialogue",
      "recruitmentDialogue": "tutorial_codex:lysa_fen_dialogue",
      "placement": {
        "target": "map:112,96:tavern"
      }
    }
  },
  "items": {
    "tutorial_codex:sealed_letter": {
      "id": "tutorial_codex:sealed_letter",
      "name": "Sealed Courier Letter",
      "type": "QUEST",
      "value": 0,
      "desc": "A damp letter bearing the wax seal of a neighboring shrine.",
      "tags": [
        "QUEST",
        "CAMPAIGN_ITEM",
        "LORE"
      ]
    }
  },
  "monsters": {
    "tutorial_codex:echo_warden": {
      "id": "tutorial_codex:echo_warden",
      "type": "tutorial_codex:echo_warden",
      "name": "Echo Warden",
      "hp": 85,
      "maxHp": 85,
      "attack": 11,
      "defense": 5,
      "speed": 4,
      "vision": 8,
      "xp": 125,
      "lootValue": 50,
      "lootTags": [
        "QUEST"
      ],
      "terrain": [
        "DUNGEON"
      ],
      "placement": {
        "type": "dungeon",
        "dungeonId": "tutorial_codex:drowned_belfry",
        "level": "final",
        "anchor": "final_room",
        "role": "dungeon_boss",
        "when": {
          "questActive": "tutorial_codex:silence_drowned_bell"
        },
        "revealEffect": "shimmer"
      },
      "preCombatMessage": "The figure beneath the bell arch raises its head. Water runs from an empty helm, and every memory you have of mourning speaks at once.",
      "sprite": [
        "            ",
        "    ssss    ",
        "   sDssDs   ",
        "   sssssss  ",
        "    bbbb    ",
        "   ddddddd  ",
        "  dd ddd dd ",
        "   ddddddd  ",
        "    HHHH    ",
        "   H HH H   ",
        "  H      H  ",
        "            "
      ]
    }
  },
  "dialogue": {
    "tutorial_codex:mara_vey_dialogue": {
      "id": "tutorial_codex:mara_vey_dialogue",
      "npcId": "tutorial_codex:mara_vey",
      "greeting": [
        {
          "when": {
            "hasFlag": "tutorial_codex:campaign_complete"
          },
          "text": "Mara looks rested for the first time. “Greyhaven slept through the night.”"
        },
        {
          "text": "Mara sets down a cup she has forgotten to fill. “You heard it too, then.”"
        }
      ],
      "topics": {
        "name": {
          "text": "Mara Vey. I keep the Greyhaven tavern open, even when nobody is sleeping."
        },
        "job": {
          "text": "I feed travelers, remember who came through town, and notice when one of them does not arrive."
        },
        "quest": [
          {
            "when": {
              "hasFlag": "tutorial_codex:campaign_complete"
            },
            "text": "The bell is silent. That is all the reward Greyhaven needed.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "questActive": "tutorial_codex:silence_drowned_bell"
            },
            "text": "Oren is right to send you to Lysa. She listens to things the rest of us would rather ignore.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "questActive": "tutorial_codex:missing_courier"
                },
                {
                  "hasItem": "tutorial_codex:sealed_letter"
                }
              ]
            },
            "text": "That is the courier's letter. The seal belongs to the neighboring shrine. Take it to Brother Oren.",
            "actions": [
              {
                "showMessage": "Mara directs you to Brother Oren near Greyhaven's town center."
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "questActive": "tutorial_codex:missing_courier"
            },
            "text": "The courier should have come from the north road. Search near town and look for a satchel or shrine seal.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "not": {
                    "questActive": "tutorial_codex:missing_courier"
                  }
                },
                {
                  "not": {
                    "questCompleted": "tutorial_codex:missing_courier"
                  }
                },
                {
                  "hasItem": "tutorial_codex:sealed_letter"
                }
              ]
            },
            "text": "You already found the courier's letter? Then the road was kinder to you than it was to them. Take it to Oren.",
            "actions": [
              {
                "startQuest": "tutorial_codex:missing_courier"
              },
              {
                "completeQuestObjective": [
                  "tutorial_codex:missing_courier",
                  "hear_maras_request"
                ]
              },
              {
                "showMessage": "The Missing Courier begins. The recovered letter already satisfies its search objective."
              },
              {
                "playSFX": "quest_progress"
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "not": {
                    "questActive": "tutorial_codex:missing_courier"
                  }
                },
                {
                  "not": {
                    "questCompleted": "tutorial_codex:missing_courier"
                  }
                }
              ]
            },
            "text": "A courier from the eastern shrine never reached Greyhaven. Search near the north road and bring back whatever they carried.",
            "actions": [
              {
                "startQuest": "tutorial_codex:missing_courier"
              },
              {
                "completeQuestObjective": [
                  "tutorial_codex:missing_courier",
                  "hear_maras_request"
                ]
              },
              {
                "showMessage": "The Missing Courier begins. Search near Greyhaven for the courier's satchel."
              },
              {
                "playSFX": "quest_progress"
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "text": "The north road is quiet now, but quiet and safe are not the same thing.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          }
        ]
      },
      "keywords": {}
    },
    "tutorial_codex:brother_oren_dialogue": {
      "id": "tutorial_codex:brother_oren_dialogue",
      "npcId": "tutorial_codex:brother_oren",
      "greeting": [
        {
          "when": {
            "hasFlag": "tutorial_codex:campaign_complete"
          },
          "text": "Oren closes the shrine archive. “Some silences must be tended, just like flames.”"
        },
        {
          "when": {
            "hasFlag": "tutorial_codex:warden_defeated"
          },
          "text": "Oren sees the water on your boots and understands before you speak."
        },
        {
          "text": "Oren watches the northern hills as though waiting for them to answer."
        }
      ],
      "topics": {
        "name": {
          "text": "Brother Oren. I keep Greyhaven's shrine and the records people prefer not to remember."
        },
        "job": {
          "text": "I tend the shrine, read its seals, and make certain old warnings are not mistaken for old superstitions."
        },
        "quest": [
          {
            "when": {
              "hasFlag": "tutorial_codex:campaign_complete"
            },
            "text": "The rite is complete. The letter will remain in the shrine archive, and the bell will remain below.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "questActive": "tutorial_codex:silence_drowned_bell"
                },
                {
                  "hasFlag": "tutorial_codex:warden_defeated"
                }
              ]
            },
            "text": "The guardian is at rest. I can finish the rite now, but Greyhaven will remember what you carried back from the dark.",
            "actions": [
              {
                "completeQuestObjective": [
                  "tutorial_codex:silence_drowned_bell",
                  "return_to_oren"
                ]
              },
              {
                "completeQuest": "tutorial_codex:silence_drowned_bell"
              },
              {
                "setFlag": "tutorial_codex:campaign_complete"
              },
              {
                "showMessage": "Brother Oren completes the shrine's rite. The Drowned Bell is silent."
              },
              {
                "playSFX": "quest_progress"
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "questActive": "tutorial_codex:silence_drowned_bell"
                },
                {
                  "lacksFlag": "tutorial_codex:lysa_recruited"
                }
              ]
            },
            "text": "Speak with Lysa in the tavern. She has heard the bell in dreams and knows how the belfry's lower stones were laid.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "questActive": "tutorial_codex:silence_drowned_bell"
            },
            "text": "Lysa has joined you. Prepare before leaving Greyhaven; the ruined belfry lies north of town.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "questActive": "tutorial_codex:missing_courier"
                },
                {
                  "objectiveCompleted": [
                    "tutorial_codex:missing_courier",
                    "recover_letter"
                  ]
                }
              ]
            },
            "text": "This is a funerary seal. The warning says the old guardian has awakened beneath the ruined belfry and must be put to rest before the fourth night.",
            "actions": [
              {
                "setFlag": "tutorial_codex:letter_read"
              },
              {
                "completeQuestObjective": [
                  "tutorial_codex:missing_courier",
                  "show_letter_to_oren"
                ]
              },
              {
                "completeQuest": "tutorial_codex:missing_courier"
              },
              {
                "startQuest": "tutorial_codex:silence_drowned_bell"
              },
              {
                "removeItem": "tutorial_codex:sealed_letter"
              },
              {
                "showMessage": "The Missing Courier is complete. Silence the Drowned Bell begins. Speak with Lysa in Greyhaven's tavern."
              },
              {
                "playSFX": "quest_progress"
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "questActive": "tutorial_codex:missing_courier"
            },
            "text": "Without the courier's letter, I can only tell you this: the bell beneath the belfry was never meant to summon the living.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "text": "The shrine has old records of the belfry, but no warning recent enough to explain tonight's toll.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          }
        ]
      },
      "keywords": {}
    },
    "tutorial_codex:lysa_fen_dialogue": {
      "id": "tutorial_codex:lysa_fen_dialogue",
      "npcId": "tutorial_codex:lysa_fen",
      "greeting": [
        {
          "when": {
            "hasFlag": "tutorial_codex:campaign_complete"
          },
          "text": "Lysa listens to the quiet. “Memory finally released its grip.”"
        },
        {
          "when": {
            "hasCompanion": "tutorial_codex:lysa_fen"
          },
          "text": "Lysa nods toward the door. “We should keep moving.”"
        },
        {
          "when": {
            "questActive": "tutorial_codex:silence_drowned_bell"
          },
          "text": "Lysa looks up before you speak. “Oren read the letter.”"
        },
        {
          "text": "Lysa watches the surface of her cup as though it contains a distant sky."
        }
      ],
      "topics": {
        "name": {
          "text": "Lysa Fen. I study visions, echoes, and the lies people tell themselves about both."
        },
        "job": {
          "text": "I listen for patterns. The bell is not traveling through air; it is traveling through memory."
        },
        "join": [
          {
            "when": {
              "hasCompanion": "tutorial_codex:lysa_fen"
            },
            "text": "I am already with you.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "all": [
                {
                  "questActive": "tutorial_codex:silence_drowned_bell"
                },
                {
                  "lacksCompanion": "tutorial_codex:lysa_fen"
                }
              ]
            },
            "text": "The belfry's lower chamber was built to guide the dead home. If the guardian has forgotten that purpose, you will need someone who can hear what it remembers.",
            "actions": [
              {
                "recruitCompanion": "tutorial_codex:lysa_fen"
              },
              {
                "endDialogue": true
              }
            ]
          },
          {
            "text": "Not yet. Oren must first read whatever warning the courier carried.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          }
        ],
        "quest": [
          {
            "when": {
              "hasFlag": "tutorial_codex:campaign_complete"
            },
            "text": "The Echo Warden is quiet. Greyhaven will still dream of the bell, but dreams are allowed to end.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "when": {
              "questActive": "tutorial_codex:silence_drowned_bell"
            },
            "text": "The deepest chamber will be shaped by memory more than stone. Light will help. So will refusing to listen when it speaks in a familiar voice.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          },
          {
            "text": "The bell is awake, but the road to it is not yours yet.",
            "actions": [
              {
                "endDialogue": true
              }
            ]
          }
        ]
      },
      "keywords": {}
    }
  },
  "quests": {
    "tutorial_codex:missing_courier": {
      "id": "tutorial_codex:missing_courier",
      "title": "The Missing Courier",
      "summary": "Mara Vey is waiting for a courier who never reached Greyhaven. Search near the town and recover whatever the courier was carrying.",
      "objectives": [
        {
          "id": "hear_maras_request",
          "text": "Speak with Mara about the missing courier.",
          "detail": "Find Mara Vey inside Greyhaven's tavern and ask about the missing courier.",
          "marker": {
            "targetId": "tutorial_codex:mara_vey"
          }
        },
        {
          "id": "recover_letter",
          "text": "Recover the courier's sealed letter.",
          "detail": "Search near Greyhaven for the courier's satchel. The objective recognizes the letter even if you found it before accepting the quest.",
          "marker": {
            "targetId": "tutorial_codex:courier_satchel"
          }
        },
        {
          "id": "show_letter_to_oren",
          "text": "Bring the sealed letter to Brother Oren.",
          "detail": "Brother Oren can identify the shrine seal and explain the warning.",
          "marker": {
            "targetId": "tutorial_codex:brother_oren"
          }
        }
      ]
    },
    "tutorial_codex:silence_drowned_bell": {
      "id": "tutorial_codex:silence_drowned_bell",
      "title": "Silence the Drowned Bell",
      "summary": "Recruit Lysa Fen, descend into the Drowned Belfry, defeat the Echo Warden, and return to Brother Oren.",
      "objectives": [
        {
          "id": "recruit_lysa",
          "text": "Ask Lysa Fen to join you.",
          "detail": "Lysa is waiting in Greyhaven's tavern. Her knowledge of the bell may help in the crypt.",
          "marker": {
            "targetId": "tutorial_codex:lysa_fen"
          },
          "completeWhen": {
            "hasFlag": "tutorial_codex:lysa_recruited"
          }
        },
        {
          "id": "enter_belfry",
          "text": "Enter the Drowned Belfry.",
          "detail": "Travel north of Greyhaven and descend into the ruined belfry.",
          "marker": {
            "targetId": "tutorial_codex:drowned_belfry"
          },
          "completeWhen": {
            "hasFlag": "tutorial_codex:belfry_entered"
          }
        },
        {
          "id": "defeat_warden",
          "text": "Defeat the Echo Warden.",
          "detail": "Reach the Bell Chamber on the final level and put the drowned guardian to rest.",
          "marker": {
            "targetId": "tutorial_codex:echo_warden"
          },
          "completeWhen": {
            "hasFlag": "tutorial_codex:warden_defeated"
          }
        },
        {
          "id": "return_to_oren",
          "text": "Return to Brother Oren.",
          "detail": "Tell Oren that the Echo Warden has fallen so he can finish the shrine's rite.",
          "marker": {
            "targetId": "tutorial_codex:brother_oren"
          }
        }
      ]
    }
  },
  "spells": {},
  "shrines": {},
  "lootTables": {},
  "worldRules": {},
  "townServices": [],
  "safetyZones": [],
  "worldPlacements": [
    {
      "id": "tutorial_codex:courier_satchel_scene",
      "placement": {
        "type": "town",
        "townId": "tutorial_codex:greyhaven"
      },
      "contents": [
        {
          "type": "chest",
          "id": "tutorial_codex:courier_satchel",
          "name": "Courier's Satchel",
          "loot": {
            "gold": 0,
            "food": 0,
            "items": [
              "tutorial_codex:sealed_letter"
            ]
          }
        }
      ]
    },
    {
      "id": "tutorial_codex:sunken_steps_scene",
      "placement": {
        "type": "dungeon",
        "dungeonId": "tutorial_codex:drowned_belfry",
        "level": 1,
        "anchor": "stairs_up"
      },
      "contents": [
        {
          "type": "feature",
          "id": "tutorial_codex:cracked_inscription",
          "name": "Cracked Funerary Inscription",
          "featureType": "inscription",
          "text": "The stone reads: “Ring once for the lost. Ring twice for the remembered. Never ring a fourth time.”",
          "actions": [
            {
              "setFlag": "tutorial_codex:inscription_read"
            },
            {
              "showMessage": "The inscription suggests the bell was meant to guide the dead home, not call them back."
            }
          ]
        }
      ]
    }
  ],
  "triggers": [
    {
      "id": "tutorial_codex:fragile_letter_event",
      "event": "itemAcquired",
      "targetId": "tutorial_codex:sealed_letter",
      "once": true,
      "when": {
        "questActive": "tutorial_codex:missing_courier"
      },
      "actions": [
        {
          "completeQuestObjective": [
            "tutorial_codex:missing_courier",
            "recover_letter"
          ]
        }
      ]
    },
    {
      "id": "tutorial_codex:record_lysa_recruited",
      "event": "companionRecruited",
      "targetId": "tutorial_codex:lysa_fen",
      "once": true,
      "actions": [
        {
          "setFlag": "tutorial_codex:lysa_recruited"
        },
        {
          "showMessage": "Lysa Fen joins the expedition to the Drowned Belfry."
        },
        {
          "playSFX": "quest_progress"
        }
      ]
    },
    {
      "id": "tutorial_codex:record_belfry_entry",
      "event": "enterDungeon",
      "targetId": "tutorial_codex:drowned_belfry",
      "once": true,
      "when": {
        "questActive": "tutorial_codex:silence_drowned_bell"
      },
      "actions": [
        {
          "setFlag": "tutorial_codex:belfry_entered"
        },
        {
          "showMessage": "Cold water moves across the Sunken Steps as though disturbed by a distant toll."
        },
        {
          "playSFX": "quest_progress"
        }
      ]
    },
    {
      "id": "tutorial_codex:resolve_echo_warden",
      "event": "combatVictory",
      "targetId": "tutorial_codex:echo_warden",
      "once": true,
      "when": {
        "questActive": "tutorial_codex:silence_drowned_bell"
      },
      "actions": [
        {
          "completeQuestObjective": [
            "tutorial_codex:silence_drowned_bell",
            "defeat_warden"
          ]
        },
        {
          "setFlag": "tutorial_codex:warden_defeated"
        },
        {
          "openMessageBox": {
            "title": "The Fourth Toll",
            "text": "The Echo Warden collapses beneath the broken arch.\n\nFor one breath, the bell sounds from everywhere—the flooded stones, the dark water, the memories of the dead—and then the chamber falls silent.\n\nFar above, Greyhaven's windows stop trembling.",
            "position": "center",
            "blocking": true,
            "buttons": [
              {
                "label": "Continue",
                "action": [
                  {
                    "showMessage": "Return to Brother Oren so he can complete the shrine's rite."
                  }
                ]
              }
            ]
          }
        },
        {
          "playSFX": "quest_progress"
        }
      ]
    }
  ],
  "ending": {
    "id": "tutorial_codex:when_the_bell_falls_silent",
    "title": "When the Bell Falls Silent",
    "completeWhen": {
      "hasFlag": "tutorial_codex:campaign_complete"
    },
    "actions": [
      {
        "playSong": "fanfare"
      },
      {
        "openMessageBox": {
          "title": "When the Bell Falls Silent",
          "text": "Greyhaven sleeps through the night.\n\nAt dawn, Mara opens the tavern shutters without first listening for the bell. Oren seals the courier's letter inside the shrine archive, and Lysa watches the northern hills until the last mist leaves the ruined tower.\n\nNo one calls the silence a victory. In Greyhaven, silence is simply something worth keeping.\n\nVictory: you have completed The Drowned Bell. Free-roam exploration is now available, and you may continue adventuring throughout the world.",
          "position": "center",
          "blocking": true,
          "buttons": [
            {
              "label": "Continue Exploring"
            }
          ]
        }
      },
      {
        "showMessage": "The Drowned Bell is complete."
      }
    ]
  }
}
