Deep-Dovers / deep-divers

Retirees making a game
0 stars 0 forks source link

[Tech] Ability system #16

Closed waiteng-kwan closed 2 weeks ago

waiteng-kwan commented 1 month ago

To create an ability system.

An ability is defined as an active player skill, eg shooting a projectile, block, heal.

The ability system is in charge of:

  1. Executing abilities 1a. Abilities can be upgraded!
  2. Gaining abilities (whenever a relic gives new ability)
  3. Removing abilities (when a relic is destroyed/sacrificed/lost)

Relevant Documents

  1. Player Mechanics GDD
waiteng-kwan commented 1 month ago

Progress

  1. Finished basic ability system (more to follow)
  2. Left with applying modifiers to abilities

It is currently in the tech branch! Pending @Benson-Ma merge/integration with basic projectiles etc.

For designers

The main thing to note is how to create an ability. I will not talk about ability modifiers (i.e, relics) for now.

While the behaviour will have to be customised by programmers, the basic data & ability is ready to be used. An example is the BasicAttack, so named BasicAttackData in the project under Resources/Data folder.

This is the main thing designers will deal with.

In essence, every ability will spawn bullets as per the data there. For additional data, please contact a programmer!

To give abilities to a game object (i.e, player, npc, enemy, whatever):

  1. Attach an AbilityList component to the game object (e.g see PlayerCharacter prefab)
  2. Assign the appropriate abilities as needed in either Basic Attack Data field or Abilities list
  3. Viola! It works! (I hope)

Image

To create an ability:

  1. Right click on the project window and go to Create > Scriptable Objects > Ability > (Select something here)
  2. Input the new values in the new scriptable object!

Image

For tech

The ability system is comprised of several parts.

  1. AbilityList
  2. AbilityInstance
  3. AbilityData
  4. AbilityModifier (Ignore for now)

AbilityList An AbilityList is defined as the list of abilities that the game object can hold and execute. This is the main class/component that allows players or enemies to use abilities. It also keeps track of cooldowns. The character will use this class as an interface to execute any ability they wish to.

AbilityInstance Base class: AbilityInstanceBase Example: BasicAttack.cs On Awake(), the AbilityList will create instances of all abilities (i.e, an AbilityInstance) the character has. An AbilityInstance is defined as the actual behavioral instance of an ability. It holds the data and behavior execution logic, such as spawning of bullets or applying any modifiers. Because the data is gotten from a scriptable object instance of AbilityData, if the default constructor is used the data will not be accurate. The data used for an AbilityInstance is based off AbilityData and whatever AbilityModifier exists on this ability.

AbilityData This is the main class for the scriptable object. For use with designers, it mainly contains data that is necessary for any ability to execute. This class can be extended or inherited from as necessary.

AbilityModifier Scriptable object class. The data here will be added onto an ability instance.

waiteng-kwan commented 1 month ago

accidentally closed issue woops