HackMD
    • Sharing Link copied
    • /edit
    • View mode
      • Edit mode
      • View mode
      • Book mode
      • Slide mode
      Edit mode View mode Book mode Slide mode
    • Note Permission
    • Read
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • Write
      • Only me
      • Signed-in users
      • Everyone
      Only me Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
    • Options
    • Versions
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Google Drive Export to Google Drive
    • Gist
    • Import
    • Google Drive Import from Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
Menu Sharing Help
Menu
Options
Versions Transfer ownership Delete this note
Export
Google Drive Export to Google Drive Gist
Import
Google Drive Import from Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML
Back
Sharing
Sharing Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
More (Comment, Invitee)
Publishing
More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   owned this note    owned this note      
Published Linked with
Like BookmarkBookmarked
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
--- title: "2D Online Chat: Story Line Feature" tags: "2d-online-chat" --- # 2D Online Chat: Story Line Feature Code base (WIP): https://github.com/g0v/greatescape2035/tree/story-line ## Proposal This is a proposal for the "story line" or "mission" framework in 2d-online-chat. Key features we want to support: - [x] Talk to an NPC to trigger the next step. - [x] Go to a specific region on the map to trigger the next step. - [ ] Branches. For example, - [x] Go to different branch when a user select a different answer. - [ ] Go to different branch when a user go to different region on the map. - [ ] Game states - [x] Global state (e.g. a counter of some choices) - [x] Choices made by the current user - [ ] Randomly generated state ## Detail Design ### File schema We use JSON format, since it is natively supported by javascript. However, I'll use YAML in the example, since it is easier to type. The file contains multiple missions, each "mission" will have a title, multiple steps. "steps" is a mapping from `step-id` to step definition. "steps" forms a directed graph (a state machine). ``` missions: <mission-id>: # repeated title: <mission-title> description: <...> depend: - [ "<mission>/<step>/done", { "storeKey": "<key>", "value": "<expected value>" } ] - ... firstStep: <step-id> steps: <step-id>: # repeated title: <step-title> description: <...> nextStep: <step-id> # the default next step npcId: <npc-id> # Trigger this step by pressing ENTER near this NPC. # NPC can be an object (e.g. a box). locationId: <locationId> # Trigger this step by move close to a # location on the map. # if none of <npcId> and <locationId> are given, the conversation # will be triggered immediately. dialog: - name: "NPC name" or $player # who is talking line: "hello, $player" id: <line-id> # optional nextLine: <line-id> # optional: if we don't want to fallthrough. "$EOD" means "end of dialog" - name: "NPC name" or $player type: "input.select" # declare a multiple choice question storeKey: "<key>" # field name to save the answer question: "Red pill or blue pill?" choices: - text: "Red" nextLine: <line-id> - text: "Blue" nextLine: <line-id> - name: ... type: "input.text" # declare a open-ended question. storeKey: "<key>" # answer will be saved in this field. question: "what is your name?" ``` #### Example You can also check out this [JSON file](https://github.com/g0v/IDystopia/blob/builder/static/story-lines/regular.json). ``` missions: mission-find-axe: # mission definition title: "打電話" description: "收到法院的通知,銀行帳戶被列為警示帳戶..." firstStep: step-1 steps: step-1: title: "打給爸爸" description: "到法院的通知,銀行帳戶被列為警示帳戶...打給爸爸" npcId: "lost-and-found-npc" nextStep: step-2 dialog: - name: 玩家 line: 爸,我的手機剛剛收到一個通知說我的銀行帳戶被列為警示帳戶,怎麼辦!! - name: 父親 line: 你想想看是不是有亂簽名或者是有做過什麼事情 - name: 玩家 line1:沒有阿 Line2:好像有在... step-2: title: "和媽媽對話" description: "收到法院的通知,銀行帳戶被列為警示帳戶...打給媽媽" npcId: "Lady of Lake" nextStep: step-3 dialog: - name: $player line: 不好意思,請問您有撿到我的斧頭嗎? - name: 湖中女神 question: 我最近確實撿到了一些斧頭,請問你掉的是金斧頭還是銀斧頭? choices: - text: 銀色的 nextLine: label-bad - text: 金色的 nextLine: label-bad - text: 都不是 nextLine: label-good - id: label-bad name: 湖中女神 line: 騙子!受死吧! nextLine: $EOD # "EOD" is a special label, which means end of dialog. nextStep: step-5 # override the default next step - id: label-good name: 湖中女神 line: 那我沒撿到你的斧頭,自己去找吧! nextLine: $EOD ``` ### Game Mechanism All missions of a given map should be collected into one single file. Each player will have a new property: `story_line_states`, which is a list of strings `"<mission-id>:<step-id>"`. For each step, there is an NPC id, players have to find these NPCs (active NPC) to trigger the next step. In render function, active NPCs will have exclamation marks ("!") on their heads. When a player is standing next to an active NPC, a dialog will be shown to select a dialog (because there might be multiple steps of missions assigned to the same NPC). * Save user state to local storage * Global state 1. there are `n` people online that has finished mission `m1`, mission `m2` will be enabled. * this might be easier, because we only need to maintain the "current state". 3. there are `n` people finished mission `m1` (accumulative), then mission `m2` will be enabled. * this is more difficult, we need to save this info somewhere. ### Game State ## Alternatives ## Required Works ## Open Questions

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lost their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.


Upgrade

All
  • All
  • Team
No template.

Create a template


Upgrade

Delete template

Do you really want to delete this template?

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

Sign in via GitHub

New to HackMD? Sign up

Help

  • English
  • 中文
  • 日本語

Documents

Tutorials

Book Mode Tutorial

Slide Example

YAML Metadata

Resources

Releases

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions

Versions

Upgrade now

Version named by    

More Less
  • Edit
  • Delete

Note content is identical to the latest version.
Compare with
    Choose a version
    No search result
    Version not found

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.