NPC ~ Design Document for NPC Generation in Openworld - uchicago-cs/chiventure GitHub Wiki

Issue: https://github.com/uchicago-cs/chiventure/issues/926

Introduction

Since NPCs in chiventure were designed to be a mix of players and items, they have inventories like players, and descriptions like items. Unlike items, however, they can move across rooms and participate in dialogue with the player. NPCs also possess a class struct which contains a stats struct and a skill tree like the player. Here, we outline a design document for NPC generation in the openworld module.

Outline for NPC Generation in Openworld

Level Oriented Generation:

In last week’s sprint, we added support for level oriented room generation where rooms were autogenerated based on the player’s level. Since each NPC also has a class_t struct that defines the class of the NPC, we can use that to select NPCs according to the player’s level and add them to the room using the add_npc_to_room function from rooms-npc.h. This can serve well as an added feature to level oriented generation.

Movement Across Rooms:

The NPC module currently supports movement across rooms for the NPCs for both static and dynamic room generations (see rooms-npc.h):

typedef union npc_mov_type {

npc_mov_definite_t *npc_mov_definite; // For static room generation

npc_mov_indefinite_t *npc_mov_indefinite; // For dynamic room generation (openworld)

} npc_mov_type_t;

For the openworld module, the extend_path_indefinite function from rooms-npc.h can be used to add a room to the linked list of rooms to move through for each NPC. This functionality may be supplied by our concurrent task autogeneration within a radius to load the rooms for the NPCs to visit. This indefinite move type simulates the openworld feature in that paths for the NPCs are not predefined but are instead produced dynamically.

Next Steps for NPCs Related to Openworld Generation

The NPC module is not yet integrated into chiventure and is still under development. The NPC teams are presently working on integrating with the battle module to make it possible for the player to battle NPCs. Furthermore, they are updating their npc-action module and their dialogue module to allow the player to speak to the NPCs and trade with them.

Moreover, the npcs_in_room struct needs to be further integrated into the room struct to hold a list of NPCs in the room. There is also an issue with room-to-room movement in cases where two rooms do not have the same room_tag, so that needs to be addressed before NPC movement can be implemented in openworld.

Given all this, we decided to postpone these considerations to a future sprint when the NPC module has been updated for chiventure and openworld integrations.