Difference between revisions of "Ability pack"
(Added implementation details)
|Line 19:||Line 19:|
== Code ==
== Code ==
== Data ==
== Data ==
Revision as of 02:51, 8 October 2021
This page is part of the IAUS Manual. ♦ Brain ♦ Behavior ♦ Behavior Type ♦ Decision ♦ AI Entity ♦
An Ability Pack is similar to a Behavior Pack in that it is a collection of Behaviors that is named and given a description. They are then assigned to one or more Brains to indicate that the agent has access to the behaviors in it. Typically, Ability Packs are "conceptual" in that they contain similar behaviors or behaviors that are part of a large idea.
The difference between a Behavior Pack and an Ability Pack is that the Ability Pack is, rather than a simple list of Behaviors, it is a combination of a Behavior matched with an Ability. The way to think of this is that the Behavior is "why" something would be done and the Ability is "what" to do.
In a way, this is similar to how a Behavior has a Behavior Type as part of its data. In this case, the Behavior Type for the Behavior in question is "Ability". That is because it is meant to be matched up with the Ability in the pack.
The use case for this is that different character types may have different actions they perform for largely the same reason. For example, the default melee attack for an orc, a warrior, and a dragon would be largely different and would be dealt with by the game logic differently. If we were to do this in the Behavior data alone, we would have to create three different Behavior Types -- one for each of the three agent types. In this way, however, we can create a single "Default Melee" behavior that specifies the relevant reasons (via Considerations) we would want to conduct a melee attack. The Ability Pack would match up the "Default Melee" behavior with the ability for that particular agent type and would be saved with a name that specifies that it is meant for that particular type. By doing this, a Brain can be assigned the appropriate Ability Pack depending on the type of character.
An Ability Pack may therefore have multiple Behavior Ability Pairs in it. The Behaviors (i.e. the "whys") themselves may be the same but the abilities would be different to show that they are being executed in the agent-specific way. For example, the behaviors in the Ability Pack may be:
- Default Melee
- Special Melee
- Ranged Attack
However, all three of the above character types would have different abilities matched with them. (e.g. "throw rock", "shoot bow", "breathe fireball").
Because of this organization by concept, more than one Ability Pack can be assigned to a Brain but often there will only be one that specifies the abilities that the Brain is allowed to use and the reasons it would do so.
The implementation for an ability pack is kept in the class, AbilityPackage. It is merely a name, description and a list of behavior ability pairs.
In addition to standard accessor functions, there are functions for adding an ability to the package, removing one from the package, and seeing if an selected ability is already in the list.
Ability packages are created in the data tool and abilities (with their associated behaviors) are assigned to them there. Once they have been created, they can be assigned to a brain which has the effect of allowing that brain to use all the abilities in the ability pack.