Custom Scripts ~ Possible uses to make changes in the game state. - uchicago-cs/chiventure GitHub Wiki
“Game State is responsible for managing the state of the game, such that all data within the game may be returned at any given moment, as the player travels through the world of the game. Due to the nature of this portion of the project, all work serves to provide a foundation for interaction between the work of Action Management, Command-Line Interface, World Description Language, Checkpointing, and User Interface. This entails the implementation of a number of important data structures and accompanying functions that alter these structures as the game progresses. These structures, divided into the modules outlined below, include an overall game struct, which contains a player, room, and item struct.”
The main three entities regarding the game-state are players, rooms, and items. The focus of this wiki is the player entity.
Player:
typedef struct player {
/* hh is used for hashtable, as provided in uthash.h*/
UT_hash_handle hh;
char *player_id;
int level;
int health;
int xp;
item_hash_t *inventory;
} player_t;
The struct for the player contains essential attributes of the player. Custom scripts can be used to edit and perform actions on these attributes.
Health
Custom scripts may be useful to make changes in player’s health in the case of a random attack or health boost from an item or NPC. Also, some weapons and attacks may hurt the player that performs them as well, which could also be implemented using custom scripts.
Inventory
The inventory of a player is kept as a hash table linked list containing all the items they have collected previously. Custom scripts may be used to clear the inventory of the player in certain scenarios. In addition, the size of the inventory may be altered in relation to level or xp using custom scripts. Though I couldn’t find a limitation to the inventory in the existing code, this may be implemented to obtain a more realistic gameplay.
Player ID
Players might be able to change their player_id at a certain level, location, or purchase the ability with coins. This could be implemented using a script.
Helpful Links:
Game-State Documentation: https://github.com/uchicago-cs/chiventure/blob/5445dca25271fc0729ae45a61edb0c7c0dc8b24c/docs/game_state.md
Player structs (player.h): https://github.com/uchicago-cs/chiventure/blob/master/include/game-state/player.h