-
Notifications
You must be signed in to change notification settings - Fork 13
Stats ~ RPG stats implementation: Current stats struct design
This wiki page is devoted to documenting how the player stats team designs and implements the stats and effects struct. *** Note that it's still a work in progress and will be updated once there are new changes.
Idea for our implementation comes from
Player Stats Implementation
The implementation is as follows
typedef struct stats {
char *key;
stats_global_t *global;
double val;
double max;
double modifier;
UT_hash_handle hh;
} stats_t;
typedef struct stats stats_hash_t;
global
stats_global_t *global;
Note that the stats_global_t is a struct covered in version 1.1, where the pointer points to the global list of stats that will be available in the game.
Value and Max
Any stat will have a base value, i.e.,double val;
and a maximal value, i.e.,
double max;
For example, we could have a player with a health stat that has 50/100 as the player's health stat. The 50 here denotes the base value, and 100 denotes the max value. Keep in mind that the max value inside the stats struct differs from the max value from global stat struct. The max in stats struct specifies the current maximal value of a given stat, so it could vary based on the level or other factors, whereas the max value from global stat struct denotes the maximal value that any such stat could ever have, regardless of levels and player class.
Modifier
double modifier;
Going back to the example we had under the Value and Max. Let's say the cumulative health modifier entry is 1.2, and the player has health 50/100. The final calculation will give 50 * 1.2 = 60 as the final stat value.
Player effects Implementation
The implementation is as follows
typedef struct effects{
char *key;
effects_global_t *global;
stat_mod_t *stat_list;
UT_hash_handle hh;
} stat_effect_t;
typedef struct effects effects_hash_t;
Status
bool status;
indicates if an effect is on or off.
Stat_list
stat_mod *stat_list;
Because one effect could be affecting multiple stats, we used the UT list struct to keep track of the connections between stats and effects. Further explanation could be found below.
Linking an effect to multiple stats
The implementation is as follows
typedef struct stat_mod {
stats_t *stat;
double modifier;
int duration;
struct stat_mod *next;
} stat_mod_t;
Modifier
double modifier;
The way that the final value of a stat is calculated is through multiplying it with the modifier. Note the difference between modifier in stat struct and modifier in effect struct: the modifier in stat struct is used to calculate the final value of a stat, whereas modifier in effect struct is used for a specific effect on the stat. In other words, the stat modifier is cumulative in that it takes all of the modifiers from the effect struct, gets multiplied by each of the effect modifiers, and computes a cumulative modifier.
For example, let's say we two effects "stunned" and "poisoned". Each of them affects the player's health by a modifier of 0.8. The modifier will be passed into the stats struct's modifier entry, which will be 0.8 * 0.8 = 0.64. The final value of the health stat will be the base value times 0.64.
Duration
int duration;
The duration is supposed to indicate the turns that are left for the effect to be on, since the battle system wants a pokemon style game. Hence we have the duration as an int.
After meeting with Borja, we want to introduce the global stats and effects struct, which ensures the devs will be able to specify the possible stats and effects with the maximal value they could have in the game. The struct has not been finalized but it's partially implemented.
The Global stats
The implementation is as follows
typedef struct stats_global {
char *name;
double max;
UT_hash_handle hh;
} stats_global_t;
typedef struct stats_global stats_global_hash_t;
Max
double max;
To disambiguate, the max in the global struct differs from the max in stat struct. See Max under Stats struct for more details.
Global effect
// GLOBAL EFFECTS STRUCT DEFINITION ----------------------------------------------------
/* This struct represents the effects table that keeps track of all available effects
* It contains:
* the name of the effect,
* which is also the key to the hashtable
* */
typedef struct effects_global {
char *name;
UT_hash_handle hh;
} effects_global_t;
typedef struct effects_global effects_global_hash_t;
-
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