NPC

There are two types of NPCs: regular NPCs and DMs.

NPCs possess distinct personalities, backgrounds, and in-game roles. Players can interact with them to gather clues.

DMs primarily drive the game's storyline and provide players with information about the current game goals and verification of game outcomes.

Chat with NPC & DM

Chat with NPCs or the DM in the game to gather clues or advance the gameplay.

POST https://api.rpggo.ai/open/game/chat

Request Body

Name
Type
Description

session_id*

String

game session's unique ID, which records the current game state and conversation history.

npc_id*

String

the ID of the NPC or DM you wish to engage in a conversation with.

message*

String

chat message

{
  "code": 0,
  "msg": "ok",
  "data": {
    "result": {
      "image": "",
      "text": "I am James, the loyal butler of Mr. John...",
      "epoch": {
        "current_count": 5,
        "max_chat_count": 10
      }
    },
    "game_status": {
      "game_id": "22",
      "goal_id": "1",
      "scene_id": "2",
      "action": 0
    }
  }
}

When conversing with an NPC, focus on the content of the "result" field in the response.

  • "text" contains the NPC's textual response, and "image" is reserved for future support of AI-generated images.

  • To enhance gameplay, each NPC has a limit on the number of chat rounds. Within the "epoch," "max_chat_count" represents the maximum dialogue rounds, while "current_count" tracks the current number of dialogues.

When conversing with the DM, in addition to the previously mentioned details, pay attention to the "game_status" field for advancing the game. The "action" field indicates the upcoming game state:

  • 0 - remaining in the current goal, requiring the user to continue exploring clues and provide the DM with the correct answers.

  • 1 - moving on to the next goal, indicating that the user has completed the current goal and should proceed to the next one based on the DM's response.

Players can obtain the current goal through chat with the DM, so developers don't need to handle this. The DM will automatically inform the player of the next stage's goals.

  • 2 - moving on to next scene, signifying that the user has successfully completed all objectives within the current scene and is moving on to the next one. You need to initiate a new scene by calling the "https://api.rpggo.ai/open/game/startgame " API, specifying the "game_id" and "scene_id."

In the "game_status," the IDs correspond to the next steps to take. If you need to proceed to the next scene, simply use these IDs.

  • 3 - indicating that the user has completed all goals in all scenes, successfully finishing the game.

Last updated