Pluggable Ability System

I am trying to develop an ability system that allows for complete designing in the editor. Cooldowns, channeling with tiers, animations, states.
Some abilities are automatic

  • control movement by changing the state of the move controller.
  • Activate self healing after time elapsed after exiting combat.
  • Etc

Some abilities are manual:

  • Activated by using items/weapons
  • Keystroke for jump/crouch/etc

I’m going off of a github I found when googling the topic which appears to be for a turn based game. It uses a scriptable object to design the ability and then it’s converted to the actual Ability class via a shared data class. I’m modifying things to work with a 3d shooter environment.

AbilityData - stores name, description, icon and action and behaviors of the ability.
AbilityTemplate - sealed scriptable object with ability data field.
Ability - sealed class with ability data field and is used to control the actions.

Sort of the structure I’m following. Abilities will be controlled through the profile class where you can assign abilities in the editor or at runtime.

Profile - controller class, optional reference to the following:

  • MoveController - state machine, handles and modified input per state needs
  • CombatController - controls health
  • Inventory

Having trouble in a couple spots. Have to have a way to trigger the events an ability has. This concern is mainly with projectile but I’ll have the ability listen to the object it spawns. Maybe have an AbilityObject monobehavior to subscribe to. I also want to have channel tiers to allow for weaker spells or attacks for how long its held.

Maybe its my way of thinking. I cant figure out how I’m going to make some abilities triggered automatically or triggered by their respective weapon or item. I can have a scriptable object class return true per condition using inheritance but this wouldn’t be good for items or weapons.

So I just need help to wrap my head about this

I wouldn’t reach for inheritance here… look into implementing interfaces, things like:

IHealthAbility (tells details about a health ability)
IAttackAbility
IDefenseAbility

IActivateableAbility (requires the player to activate)
IAutomaticAbility (automatically triggers)
ITimedAbility (has a timer that counts down, notifies when expires, etc)
IDependantAbility (dependent on some other condition)

That way you can mix and match what an Ability is, how it behaves.

1 Like

How would using interfaces work for a pluggable/modular system?

My thought was to do a composition data design with limited inheritance. But I was thinking an abstract AbilityActivator that has a CanActivate method to return true. That way I drag in or select with a custom editor how I want it to activate.
The profile class would loop through the abilities to try to start and execute them.
However, id have to figure a different way for item/weapon dependent abilities. Or a different way to make my system pluggable and modular in the editor.