Skill Trees ~ Complex Skills Summary - uchicago-cs/chiventure GitHub Wiki

Complex Skill Types

There are currently four complex skill types:

Combined complex skills: These execute each of its subskills. ex: deal 50 damage and incapacitate the victim for 50 seconds and throw a fireball.

Sequential complex skills: These execute each of its subskills in order, stopping execution once a subskill fails. Ex: deal 50 damage, then incapacitate the victim for 50 seconds, then throw a fireball.

Conditional complex skills: These check if a condition is met and, if so, executes its subskills. Ex: If the player is an orc, then deal 30 damage to the opponent.

Random complex skills: There are a few ways these skills can be used but this is currently being implemented, so more details will be added later; for now, one example of this skill would be a random chance complex skill which executes its subskills a certain percent of the time. Ex: Deals 30 damage and throws a fireball 50% of the time.

There are more specific details here: https://github.com/uchicago-cs/chiventure/wiki/Skill-Trees-~-Integrating-complex-skill-(combined,-random,-sequential,-etc.)-implementation

Fields in complex_skill_t

typedef struct complex_skill{
   //Type of complex skill
   complex_skill_type_t type;
 
   //List of sub-skills used in complex skill
   skill_t** skills;
 
   //Number of sub-skills in skills list
   int num_skills;
 
} complex_skill_t;

A complex_skill_t includes:

  1. an enum indicating the type of the complex skill (Sequential, Combined, Random, or Conditional)
  2. a list of sub-skills that are used by that complex skill
  3. an integer indicating the number of sub-skills used by the overall complex skill

Nested Complex Skills

As mentioned in the beginning section, the addition of the complex_skill field to the skill_t struct allows for the usage of nesting complex skills. Looking at the implementation of complex_skills:

typedef struct complex_skill{
   //Type of complex skill
   complex_skill_type_t type;
 
   //List of sub-skills used in complex skill
   skill_t** skills;
 
   //Number of sub-skills in skills list
   int num_skills;
 
} complex_skill_t;

For most circumstances, each skill within the skills struct will be a simple skill. However, due to the addition of the complex_skill_t struct, users could make one or all of the skills within the list a complex skill, allowing for the nesting of complex skills. It is not recommended to nest a large amount of complex skills, due to the complexity of storage, comprehension, and processing power of executing such a skill, but the functionality has been included.

Explanation for new field in skill_t

As a part of the implementation of complex skills, the skill_t struct has been updated to include a new field for the complex_skill_t struct. This change does mean that all instances of skill_new() will need to be updated. However, the structure of it has purposely been made to be an easy update, by just adding a NULL parameter to the end. All simple skills will have a NULL parameter for the complex_skill field, so previous implementations won’t be changed very much.

The reason this design decision was made as opposed to just using the complex_skill_t struct as a separate kind of skill_t is for 2 reasons:

1.) To allow the updating of previous functions like skill_execute() and skill_level_up() to use complex skills so that projects that have already implemented them can more easily be updated to handle complex skills. For example, the skilltrees module has nodes that store skill_t, and this implementation won’t require the addition of a complex_skill_t struct to add support for them.

2.) It allows for the ability to nest complex skills within complex skills (Further explanation of this later in the article)

As a result of these design decisions, the complex_skill_t struct should not be viewed as a separate kind of skill than the skill_t struct, but rather as a way of storing all of the information needed if a skill is complex. Since this information is only required for complex skills, we created the complex_skill_t struct to store all that information in one place, allowing for the creation of simple skills to remain simple, adding one field that won’t be used rather than the three required for the complex_skills_t struct.