Modding:Activated Abilities

Any part can add activated abilities, including mutations, skills, or even equipment (see: Hologram Bracelet and Rocket Skates for examples). All parts add abilities through the same interface.

Registering your Ability
To start, you must register your event in 2 ways. For an example, let's look at Cudgel_Slam.cs, which adds the Slam ability:

The important fields to note in the AddAbility function call are the first 3. This tells the game object to add a new ability called "Slam[attack]", and to fire the "CommandCudgelSlam" event when it is used. This ability will show up under the "Skill" category in the ability menu. This function returns a Guid, which can be used to identify the ability when you need to reference or remove it, as seen in the RemoveSkill function.

Note that the AddSkill and RemoveSkill functions are unique to skills. For mutations, you would add your ability in the Mutate and UnMutate functions, and on equipment, you would listen for the OnEquipped and OnUnequipped messages.

However, this only tells the parent object to send an event, to receive the event, you must sign up to listen for the event as shown below:

In addition to registering for the activated ability event, this class also registers for "AIGetOffensiveMutationList". This event allows you to implement logic for AI to use this activated ability as an attack in combat.

Activating Abilities
Finally, let's look at some of the details of how the ability is activated. The above section implements the logic for when AI will attempt to use this ability.

The above section shows some of the checks the skill performs to validate that the player can use the attack. It also gets an attacking direction.

The UseEnergy call sets the amount of time the ability takes to activate. 1000 energy is equivalent to 1 turn, and should be used for most regular skills. 2000 energy would be 2 turns, and 500 would be half a turn. Free actions do not need to call this function.

To set a cooldown, you simply set the cooldown property on the ability. 10 cooldown is equivalent to 1 turn (at 16 willpower). Cudgel adds 10 to its cooldown counter, because the cooldown will count down by 1 in the time it takes to use the ability.