dialogue-systems
它能做什么
该技能指导包含分支、选项和记忆状态的游戏对话的设计与连接。适合制作 NPC 对话或剧情分支的游戏编剧和开发者。
适用场景
- ✓当你设计带有分支和玩家选项的对话时。
- ✓当前面的选择应当改变角色之后的说话内容时。
- ✓当你需要在 Ink、Yarn Spinner 或自定义对话格式之间做选择时。
技能链接
https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/disciplines/dialogue-systems/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想要一段 NPC 对话,有三个选项,其中一个选项会改变 NPC 之后的说话方式。我应该用哪种对话工具?”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会把对话建模为由台词和选项组成的图,添加条件和变量,并根据你的需要建议使用 Ink、Yarn Spinner 或简单的自定义运行器。然后将脚本接入你的游戏循环。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Dialogue systems
Model conversations as a graph: nodes hold lines, choices branch the flow,
conditions gate options, and variables remember what the player did. The first
real decision is build vs. buy — adopt a proven authoring tool (Ink or
Yarn Spinner) or write a small data-driven runner. This skill owns both Ink
and Yarn; the visual-novel and rpg genres consume it.
When to use
- Use to design branching conversations, choice menus, or narrative state (flags, relationship values) that affect later dialogue.
- Use to decide between Ink, Yarn Spinner, and a custom JSON/resource format.
- Use to wire a dialogue script into your game loop (advance line, present choices, run commands, resolve variables).
When not to use: for engine UI (text boxes, portraits, choice buttons), use
godot-ui-control or the engine's UI skill. For persisting narrative variables
across sessions, use save-systems. For data-as-resources in Godot/Unity, see
godot-resources / unity-scriptableobjects.
Core workflow
- Choose the authoring approach.
- Ink — prose-first, writer-friendly, weave/gather flow; great for dialogue-heavy or CYOA narrative. Integrate via ink runtime / inkle plugins.
- Yarn Spinner — node-based, explicit
<<commands>>, strong for game-driven dialogue with lots of engine hooks. - Custom runner — a JSON/resource graph + a small interpreter when you need full control or minimal dependencies. Don't build a language; build a graph.
- Define the node contract. A node yields one of: a line (speaker + text), a set of choices, a command/side-effect, or an end/jump. The runner advances through nodes and hands lines/choices to the UI.
- Separate variables from flow. Keep a variable store (booleans, numbers, strings) the dialogue reads/writes; gate choices with conditions over it.
- Localize from the start. Author with line IDs, not raw strings, so the displayed text comes from a string table keyed by locale.
- Drive it from the game loop. The runner is a state machine:
currentnode → emit content → wait for input (continue or choice) → advance. - Verify by walking branches. Exercise each choice path; confirm conditions, variable writes, and that every branch reaches an end or a valid jump.
Patterns
1. Engine-neutral dialogue graph (data, not code)
{
"start": "guard_intro",
"nodes": {
"guard_intro": {
"speaker": "Guard", "line": "DLG_GUARD_001",
"choices": [
{ "text": "DLG_OPT_BRIBE", "to": "bribe", "if": "gold >= 50",
"set": { "gold": "gold - 50" } },
{ "text": "DLG_OPT_LEAVE", "to": "end" }
]
},
"bribe": {
"speaker": "Guard", "line": "DLG_GUARD_BRIBED",
"set": { "gate_open": true },
"next": "end"
},
"end": { "end": true }
}
}
line/text are string-table IDs (localization), not literal text. if
gates a choice; set mutates the variable store. The gold cost sits on the
choice, so it is paid once per pick even if the bribe node is revisited; the
idempotent gate_open write can live on the node. A string set value is an
expression, so a literal string needs inner quotes: "mood": "'angry'". The full
interpreter that walks this graph is in references/runner.md.
2. Runner step (a state machine over the graph)
# Godot 4.7. The runner holds the current node and a variable store. Every line
# waits for the player: the UI calls choose() or the continue callback.
func goto(id: String) -> void:
current = graph.nodes[id]
apply_set(current.get("set", {}))
if current.get("end", false):
ui.close()
return
if current.has("line"):
ui.show_line(current.get("speaker", ""), localize(current.line))
if current.has("choices"):
var shown = current.choices.filter(func(c): return eval_cond(c.get("if", "")))
ui.show_choices(shown) # only choices whose condition passes
elif current.has("next"):
var next_id: String = current.next
ui.show_continue(func(): goto(next_id)) # advance when the player continues
func choose(choice: Dictionary) -> void: # called when the player picks a choice
apply_set(choice.get("set", {})) # write on the transition (revisit-safe)
goto(choice.to)
3. Ink — branching with knots, choices, and variables (inkle)
// Ink: '*' = once-only
常见问题
我应该自己开发对话系统吗?
该技能指出,首先要决定自研还是采用现成工具,并将成熟工具描述为常见选择。
它涵盖对话框和按钮吗?
不涵盖。引擎界面技能负责这些,而本技能只涵盖对话逻辑。
它会保存剧情标记吗?
跨会话保存这些标记属于存档系统技能的范围。
详情
作者的原始描述
Build branching dialogue and narrative — a node/choice graph with conditions, variables, and localization hooks — and choose between authoring tools Ink and Yarn Spinner or a custom data-driven runner. Engine-neutral. Use when the user mentions dialogue system, branching dialogue, conversation tree, choices, Ink (.ink), Yarn Spinner (.yarn), or NPC dialogue.
热度
- GitHub 星标
- 6.6k
- 排名
- #13795
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/28
评论
- …