Skip to content

NPC ~ Implementation of Custom Scripts

Borja Sotomayor edited this page May 15, 2021 · 3 revisions

Overview

Following a meeting with the custom scripts team, who approached us with what they have been implementing with the lua framework that they have created, our team wants to see what opportunities may exist for custom scripts to work on features that our team has created. For now there are two key features and possible room for involvement, they are: npc room management and quests.

NPC Room Management

For now we only feature one key struct in this feature which is:

/* A non-playable character in game */
typedef struct npc {
    /* hh is used for hashtable, as provided in uthash.h */
    UT_hash_handle hh;
    char *npc_id;
    int health;
    convo_t *dialogue; // placeholder for incoming dialogue module
    item_hash_t *inventory;
} npc_t;

 typedef struct npc npc_hash_t;

With the implementation of npc movement between rooms, we have included the addition of several more structs as mentioned in this wiki. With these new structs, this offers many more opportunities for the custom scripts team to amend the types specified in the structs, such as char* and int to allow the author to create their own custom functions that do certain actions when npcs move from room to room. For example, the npc team can take our following struct:

typedef struct time_in_room {
    UT_hash_handle hh;
    char *room_id;
    int sec;
} time_in_room_t;

And change the int into their own int_t type which allows for example the author to make an npc perform a certain action after a certain interval in a room. Specific actions such as these is what will be able to be implemented once custom scripts can engage with this struct, and create a get_time function.

This is further explained in the following feature design wiki: https://github.com/uchicago-cs/chiventure/wiki/RPG-NPC:-Independent-Feature:-NPC-Movement-Design-Document

Quests

For quests there are many more structs that are required for the feature of which many seem to be potentially implementable with Lua. A full description of each struct can be found on the following wiki: https://github.com/uchicago-cs/chiventure/wiki/RPG-NPC:-Independent-Feature:-Quests-Design-Document.

With these structs this offers much more opportunity for flexibility with the custom scripts team given that there are many more types for the custom scripts to apply functions which in turn allow many more possibilities for the end user to create custom functions that can specify how the quests should work. These examples may range from changing the bool type of bool completed to the custom scripts team bool_t which would then allow the author to customize what may happen when an achievement is created, for example it may trigger a certain animation or a sudden encounter with a boss battle. These possibilities are opened by adjusting the types and implementing custom script specific functions that would allow for this.

Clone this wiki locally