ðŸŽ―AbilityService

Service for creating and enabling abilities.

Example usage:

AbilityService.createAbility("script_speed", KeyCode.X, {
    maxProgress = 10,
    progressPerUse = 5,
})

AbilityService.enableAbility(MatchService.getHost(), "script_speed")

Events.UseAbility(function (event)
    if (event.abilityName == "script_speed") then
        StatusEffectService.giveEffect(event.entity, StatusEffectType.SPEED, 2)
    end
end)

Functions

createAbility(abilityName: string, keyCode: KeyCode, config: AbilityConfig)

Creates a new custom ability that can be enabled for players.

enableAbility(player: Player, abilityName: string, progressRate: number | nil)

Enables the custom ability for the player. Use the optional progressRate parameter to set the rate (in seconds) at which progress is restored to the custom ability.

removeAbility(player: Player, abilityName: string)

Removes the custom ability from the player.

setProgressRate(player: Player, abilityName: string, progressRate: number | nil)

Sets the rate (in seconds) at which progress is restored to the cstom ability.

getProgress(player: Player, abilityName: string): number

Returns the current progress of the ability.

addProgress(player: Player, abilityName: string, amount: number)

Adds the given amount of progress to the current progress on the ability.

subProgress(player: Player, abilityName: string, amount: number)

Subtracts the given amount of progress from the current progress on the ability.

setProgress(player: Player, abilityName: string, amount: number)

Sets the progress for the ability to the given amount.

getAbilities(player: Player): string[]

Returns a list of custom abilities that the player currently has enabled.

Last updated