HackMD
    • Create new note
    • Create a note from template
    • Options
    • Versions
    • Transfer ownership
    • Delete this note
    • Template
    • Save as template
    • Insert from template
    • Export
    • Dropbox
    • Google Drive
    • Gist
    • Import
    • Dropbox
    • Google Drive
    • Gist
    • Clipboard
    • Download
    • Markdown
    • HTML
    • Raw HTML
    • ODF (Beta)
    • PDF (Beta)
    • 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
      Owners
      • Owners
      • Signed-in users
      • Everyone
      Owners Signed-in users Everyone
    • Write
      Owners
      • Owners
      • Signed-in users
      • Everyone
      Owners Signed-in users Everyone
    • More (Comment, Invitee)
    • Publishing

      After the note is published, everyone on the web can find and read this note.
      See all published notes on profile page.

    • More (Comment, Invitee)
    • Commenting Enable
      Disabled Forbidden Owners Signed-in users Everyone
    • Permission
      Owners
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Invitee
    • No invitee
Menu Sharing Create Help
Create Create new note Create a note from template
Menu
Options
Versions Transfer ownership Delete this note
Export
Dropbox Google Drive Gist
Import
Dropbox Google Drive Gist Clipboard
Download
Markdown HTML Raw HTML ODF (Beta) PDF (Beta)
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
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
More (Comment, Invitee)
Publishing

After the note is published, everyone on the web can find and read this note.
See all published notes on profile page.

More (Comment, Invitee)
Commenting Enable
Disabled Forbidden Owners Signed-in users Everyone
Permission
Owners
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Invitee
No invitee
   Published      
   owned this note    owned this note
   Linked with GitHub
  • Watch - Be notified of any changes
  • Never - Never be notified
--- 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

Editing is for members only

With current role, you can only comment.
Learn how

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.

Transfer ownership

    or

      Create a note from template

      Create a note from template

      Oops...
      This template is not available.
      All
      • All
      • Team
      No template found.

      Create a template

      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 Facebook Sign in via GitHub Sign in via Google

      New to HackMD? Sign up

      Help

      Documents

      Features
      YAML Metadata
      Slide Example
      Book Example

      Cheatsheet

      Example
      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~~
      19th 19^th^
      H2O H~2~O
      Inserted text ++Inserted text++
      Marked text ==Marked text==
      Link [link text](https:// "title")
      Image ![image alt](https:// "title")
      Code `Code`
      var i = 0;
      ```javascript
      var i = 0;
      ```
      :smile: :smile:
      Externals {%youtube youtube_id %}
      LaTeX $L^aT_eX$

      This is a alert area.

      :::info
      This is a alert area.
      :::

      Versions

      Versions

      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?