Skip to main content

Skills

Skills manage all non-melee combat for players & NPCs. Skills are replicated to the client's SkillFX modules - which allows for easy, modular two-way communication between the client and server.

Relevant Files

Client

  • Client skill logic - src\StarterPlayer\StarterCharacterScripts\State\Abilities\ClientSkillHandler.lua
  • Skill FX main logic - src\StarterPlayer\StarterPlayerScripts\VFX\SkillFXHandler.client.lua
    • Skill FX utils - src\ReplicatedStorage\Modules\Utilities\SkillUtils\init.lua
    • Skill FX template - src\ReplicatedStorage\Modules\Skills\SkillFX\Fruits\Client_Template.lua
    • Skill FX folder - src\ReplicatedStorage\Modules\Skills\SkillFX

Server

  • Skill cooldowns - src\ServerStorage\Modules\Skills\SkillCooldownModule.lua
  • Skill main logic - src\ServerStorage\Modules\Skills\SkillModule\init.lua
    • Skill template - src\ServerStorage\Modules\Skills\SkillModule\Fruits\Server_Template.lua
  • Skill replication - src\ServerStorage\Modules\Replication\SkillReplicationModule.lua

Data

  • Combat, skill & cooldown data - src\ServerStorage\Data\SkillsetData
  • API data - src\ReplicatedStorage\Modules\Skills\SkillAPI

Shared

  • Skill base - src\ReplicatedStorage\Modules\DataStructures\SkillBase.lua

Minimum Requirements For Adding a Skill

  • A Server_SkillName file in the src\ServerStorage\Modules\Skills\SkillModule folder, copied from the server Server_Template file.
  • A Client_SkillName file in the src\ReplicatedStorage\Modules\Skills\SkillFX folder, copied from the client Client_Template file.
  • A SkillName file in the src\ServerStorage\Data\SkillsetData folder.
  • (If there are any methods with non-zero parameters) An API_SkillName file in the src\ReplicatedStorage\Modules\Skills\SkillAPI folder.

Skill API

To minimize the data size for replicating skill data to the client & reduce ping, every Skill:Fire[...] method call must have API data. This data is stored in the src\ReplicatedStorage\Modules\Skills\SkillAPI folder, and lets the client know what the parameters are for each method call. The t module is used to set each parameter's type, and each method table has a dictionary & array of the parameters. The dictionary is used to check if the parameters are valid, and the array determines the order of the parameters. Example:

return {
ExampleMethod = {
Origin = t.Vector3,
HitCharacter = t.Model,
"Origin",
"HitCharacter",
}
}

Skill FX

SkillFX objects are automatically created along with the server. The non-yieldable SkillFX:Start method is called, erroring upon yield.

Since the server-side Skill:Destroy method is meant to handle the internal cleanup of the Skill objects data, when the server replicates a Skill:Destroy method call to the client, the client will call SkillFX:Cancel instead. This method is meant to add additional cleanup logic for the client-side SkillFX object, and must also call SkillFX:Destroy thereafter.