AbilitySkill - golden-coconut-studio/TikiAdventuresWiki GitHub Wiki

The ability system is a system that allows actors to call and run customized skills made by designers, in a structured and controlled manner. It has been made to facilitate the designer's work as much as possible. Through the use of conditionals. Designers can choose when a skill runs, who it affects, and finally, what it will do.

This ability system makes use of 3 blueprints: Ability, Effect and Behavior. This section will cover the Ability.

AbilitySkill is a script from which all ability blueprints will inherit. An ability is a way of deciding whether the skill can or cannot be used. It does so by creating a collision area around the caster of the skill. this area makes use of a Query System, which is a set of combined conditionals that can either return true or false. Basically, you can select a number of tags defined in project settings, and give it a condition of what should be done with those tags, whether ALL tags need to match, ANY tags need to match or NO tags need to match. The collision then detects actors with those tags and if it finds an actor(s) that matches the conditional, it will return true.

Below is a compilation of all the variables that make up the ability skill, with their explanations


Cooldowns

 Cooldown:          When the ability has fired successfully, the cooldown will start counting down. while it is 
                    counting down, the ability cannot be used again until the given duration has passed.

 CooldownDelay:     Before the cooldown starts counting down, the cooldown delay will count first. This makes it so 
                    the cooldown has to wait before counting down. Can be used for skills that do something over time, 
                    and should only start the cooldown once the skill is done.

In blueprint, this looks like this:


Name

 Name:             The name of the ability. It is VERY important that every ability has its own unique name for the 
                   following reason: When you use an ability, an instance of that ability is created and stored in an 
                   array. If you use that ability again, the script checks if that ability is in the array. if so, it 
                   will not need to create another instance of that ability. 

                   SO NOTE THIS EXAMPLE: ability1 and ability2 are 2 different abilities, but their 'name' variable is 
                   the same. When you use ability1, an instance of it is created and stored in the array of abilities. 
                   When you use ability2, since it has the same 'name' variable as ability1, the script will see that 
                   that name already exists, and thus will not create an instance of ability2, and it will run the 
                   skill of ability1.

In blueprint, this looks like this:


Query System the Query system is a system of validators that is used to decide whether the ability can or cannot fire. It does so by using a list of tags, paired with a conditional for those tags. A query system is basically a collection of IF-statements.

Let's start with the easiest part, the collision.

Query Detection Area is a customizable collision that is used to detect actors around the caster of the skill. this collision will detect all actors around the caster, and look at what tags they contain. This way the query system can compare the detected tags with the given tags in its conditional. The query detection area has settings for collision shapes:

Collision Types:

 Sphere:          A spherically shaped collision. You can change its size with a radius

 Capsule:         A capsule shaped collision. Has a height and radius.

 Box:             A cubical shape collision. you can change its size amongst each axis.

Lastly, the query detection area has a duration. which decides how long the collision will prevail. This way if the collision does not find a valid target for the conditionals, it still has time to find one.

Effects with Validators is the query systems themselves. You can create a query (a series of conditions to decide if the ability can run), along with an effect(s) that it will run if it returns true, and the amount of actors it needs to detect that are validated by the query for the effect to run. You can create as many effects with validators as you want. each of these will have its own query, as well as its own effect(s) to run. That way you can run different skills depending on what has been detected by the query

Lets see the variables in more depth.

Effects to call

 In here, we put our Effect blueprints that will be run if the query system has returned true. It can run multiple 
 effects if need be.

NumActors

 The number of actors that have been detected that need to match the query system requirements. For example, if 
 there's a query that wants to detect actors with the tag Tiki, and you put 'NumActors' to 2, then it will need to 
 detect at least 2 actors with the tag tiki. If the query is left empty, then you can ignore this variable.

Query this is where the magic happens. Inside the query you will have the option to create an expression. an expression is basically like a conditional statement (IF, IF-AND, IF-NOT):

Each expression here is a different if statement version:

ALL Tags Match:

 there must be '_NumActors_' Actors that have ALL the tags inside this expression for this expression to return true.

ANY Tags Match:

 there must be '_NumActors_' Actors that have at least 1 of the tags inside this expression for this expression to 
 return true.

NO Tags Match:

 there must be '_NumActors_' Actors that have at NONE of the tags inside this expression for this expression to 
 return true.

You can also make an array of expressions. This is basically an expression that contains expressions. Try seeing it as multiple if statements inside an if statement.

ALL Expressions Match:

 ALL the expressions inside this expression array must return TRUE or else this expression will not return TRUE.

ANY Expressions Match:

 At least 1 of the expressions inside this expression array must return TRUE or else this expression will not return 
 TRUE.

NO Expressions Match:

 NONE of the expressions inside this expression array must return TRUE or else this expression will not return TRUE.

NOTE: if you leave a Query empty, the ability will fire the 'effect with validator' has put in 'Effects to call', regardless of anything in the collision.

Once you've made an expression, you can start putting Tags inside of it. These are the tags that your query collision will look for in all the actors it overlaps. If the collision detects at least 'NumActors' actors in its collision that match the given expression, it will do the effect(s) of that 'effect with validator' that was put inside 'Effects to call'.


Once you've done all of this, your ability blueprint is ready to be used and call the effect(s) that you've put inside of it. All you need to do, is add inside your blueprint from where you want to do the skill, the TK_AbilityComponent. Then call the function DoAbility() from that component in whatever input or event you want it to be ran, don't forget to choose your abilityskill blueprint: