# AbilityService

Example usage:

```lua
AbilityService.createAbility("script_speed", "MiscPrimary", {
    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, abilityInputType: [AbilityInputType](/scripting/bedwars-scripting/types/abilityinputtype.md), config: [AbilityConfig](/scripting/bedwars-scripting/objects/abilityconfig.md))

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

#### enableAbility(player: [Player](/scripting/bedwars-scripting/objects/player.md), 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](/scripting/bedwars-scripting/objects/player.md), abilityName: string)

Removes the custom ability from the player.

#### setProgressRate(player: [Player](/scripting/bedwars-scripting/objects/player.md), abilityName: string, progressRate: number | nil)

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

#### getProgress(player: [Player](/scripting/bedwars-scripting/objects/player.md), abilityName: string): number

Returns the current progress of the ability.

#### addProgress(player: [Player](/scripting/bedwars-scripting/objects/player.md), abilityName: string, amount: number)

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

#### subProgress(player: [Player](/scripting/bedwars-scripting/objects/player.md), abilityName: string, amount: number)

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

#### setProgress(player: [Player](/scripting/bedwars-scripting/objects/player.md), abilityName: string, amount: number)

Sets the progress for the ability to the given amount.

#### getAbilities(player: [Player](/scripting/bedwars-scripting/objects/player.md)): string\[]

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.easy.gg/scripting/bedwars-scripting/services/abilityservice.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
