-
Notifications
You must be signed in to change notification settings - Fork 12
NPC ~ Loading NPCs from WDL Files
This document will outline how to load NPCs from WDL files. Modules: load_npc.h, load_npc.c
Before we can load NPCs into the game from WDL files, a few things have to be done by other modules:
- The WDL file (essentially, a text file) is converted into a JSON object.
- The JSON object is parsed to create individual, nested game objects. (See: load.h, obj.h)
- It is from these nested game objects that we retrieve the information from the WDL file to create our NPCs.
- We use the
obj_get
family of functions (in obj.h) to retrieve the game objects we want.
This document will, unfortunately, not go through how exactly NPC loading is implemented. If you would like to understand that, please have a look at the code in load_npc.c
.
NPCs should be specified in WDL files in the following ways:
{
"GAME":
...
"NPCS": {
"ALICE": {
"short_desc": "This is Alice",
"long_desc": "She wants to talk to you.",
"in": "room_A"
},
"BOB": {
"short_desc": "This is Bob",
"long_desc": "He wants to talk to you.",
"in": "room_B"
}
}
}
{
"GAME":
...
"ITEMS": {
"APPLE": {
"short_desc": "An apple",
"long_desc": "A juicy red fruit",
"in": "npc",
"actions": []
}
},
"NPCS": {
"ALICE": {
"short_desc": "This is Alice",
"long_desc": "She wants to talk to you.",
"in": "room_A",
"inventory": [
{
"item_id": "APPLE"
}
],
"dialogue": {
"nodes": [
{
"id": "1",
"npc_dialogue": "I have an apple. Do you want it?"
},
{
"id": "2a",
"npc_dialogue": "Here you go."
},
{
"id": "2b",
"npc_dialogue": "That's too bad."
}
],
"edges": [
{
"quip": "Yes",
"from_id": "1",
"to_id": "2a"
},
{
"quip": "No",
"from_id": "1",
"to_id": "2b"
}
]
}
}
}
}
Notice that the "in"
field in the item APPLE
has "npc"
as its value. If you would like to understand how dialogue works, feel free to look at the dialogue Wiki page.
Note: This implementation does not actually make Alice give the player the Apple. To achieve that, we will need advanced dialogue functionalities, discussed below.
NEW: QUESTS
NPCs can also be given Quests
and Tasks
with unique dialogue. If this feature is omitted, NPCs can still be loaded, but a couple warning messages will occur beforehand. For sample NPCs with lists of quests and tasks, see "pokemon_plus.wdl"
Currently, only inventory conditions (not attribute) can be loaded into the game. Multiple conditions are possible. Conditions loading is done in the load_condition module.
"dialogue": {
"nodes": [
{
"id": "1",
"npc_dialogue": "I'll trade this Apple for an Orange."
},
{
"id": "2a",
"npc_dialogue": "Here you go."
},
{
"id": "2b",
"npc_dialogue": "That's too bad."
}
],
"edges": [
{
"quip": "I have an Orange right here.",
"from_id": "1",
"to_id": "2a",
"conditions": [
{
"type": "INVENTORY",
"item_id": "ORANGE"
}
]
},
{
"quip": "Sorry, I don't have an Orange",
"from_id": "1",
"to_id": "2b"
}
]
}
Notice the "conditions"
field under the first edge.
Currently, only two actions are available: (1) GIVE_ITEM, (2) TAKE_ITEM. Important: TAKE_ITEM must be prefaced by a conditional edge leading to it. Otherwise, an error will result if the player doesn't have the item.
"dialogue": {
"nodes": [
{
"id": "1",
"npc_dialogue": "I'll trade this Apple for an Orange."
},
{
"id": "2a",
"npc_dialogue": "Here you go.",
"actions": [
{
"action": "TAKE_ITEM",
"action_id": "ORANGE"
},
{
"action": "GIVE_ITEM",
"action_id": "APPLE"
}
]
},
{
"id": "2b",
"npc_dialogue": "That's too bad."
}
],
"edges": [
{
"quip": "I have an Orange right here.",
"from_id": "1",
"to_id": "2a",
"conditions": [
{
"type": "INVENTORY",
"item_id": "ORANGE"
}
]
},
{
"quip": "Sorry, I don't have an Orange",
"from_id": "1",
"to_id": "2b"
}
]
}
-
Action Management
-
Battles
- Design Document
- Text Based Combat in Other Games
- User Stories
- Wishlist
- Battle Planning 2022
- Battle User Stories Review 2022
- Structs in Other Modules Related to Battles 2022
- Stat Changes Design Document
- Run Function Design Document
- CLI Integration Design Document
- Move Changes Design Document
- Unstubbing Stubs Design Document
- Battle Items and Equipment Design Document
- Battle Item Stats
- Battles Demo Design Document
- Battles Testing Moves, Items, and Equipment Design Document
- Sound integration with battle (design document)
-
Custom Actions
-
Custom Scripts
-
DSL
-
CLI
-
Enhanced CLI
-
Game-State
-
Graphics
- Design Plan
- Design document for integrating split screen graphics with chiventure
- GDL (Graphical Description Language)
- Graphics Sandbox
- Design Document for NPC Graphics and Dialogue
- Feature Wishlist (Spring 2021)
- Installing and Building raylib on a VM
- LibSDL Research
- Module Interactions
- Working with Raylib and SSH
- raylib
- GDL
-
Linking the Libzip and Json C to chiventure on CSIL machines
-
Lua
-
NPC
- Dependencies: Player class, Open world, Battle
- Action Documentation
- Design Document for NPC Generation in Openworld
- Design and Planning
- Establishing Dependencies
- Implementation of Custom Scripts
- Independent Feature: NPC Movement Design Document
- Player Interaction Design and Planning
- Dialogue
- Design Document for NPC Dialogue and Action Implementation
- Loading NPCs from WDL Files
- NPC Battle Integration Design Document
- NPC Battle Integration Changes Design Document
-
Open World
- Autogeneration and Game State
- Deciding an integration approach
- Designing approach for static integration into chiventure
- Feature Wishlist
- Generation Module Design layout
- Potential connections to the rest of chiventure
- Single Room Generation Module Design
- Source Document
- User Stories
- World Generation Algorithm Plan
- Loading OpenWorld Attribute from WDL
-
Player Class
-
Player
-
Quests
-
Rooms
-
Skill Trees
- Avoiding soft locks in skill tree integration
- Components of Exemplary Skill Trees
- Design Document and Interface Guide
- Environment interactions based on skill characteristics
- Integrating complex skill (combined, random, sequential, etc.) implementation
- Integration of a Leveling System
- Potential Integration with existing WDL
- Research on game balancing in regards to skill trees
- Research on skill tree support in modern day game engines
- SkillTree Wiki Summary
- Skilltree "effect" implementation and roadmap
- Summary of md doc file for skilltrees
- Design ideas in connection to other features
- Summary of Skill Tree Integration 2022
- The Difficulty of the Reading the World
- Complex Skills Summary
-
Sound
-
Stats
-
WDL