Wx78 Abilitycooldowns
Based on game build 722832 | Last updated: 2026-04-28
Overview
Wx78_AbilityCooldowns tracks active ability cooldowns for the WX-78 character. It manages cooldown entities (prefab wx78_abilitycooldown) that handle the actual timing and network replication. The component ensures only one cooldown per ability exists at a time and provides query methods for UI and logic checks. Modification methods are server-only; clients can query status via read-only methods.
Usage example
local inst = CreateEntity()
inst:AddComponent("wx78_abilitycooldowns")
-- Server: Start a cooldown for "overclock" ability
if TheWorld.ismastersim then
inst.components.wx78_abilitycooldowns:RestartAbilityCooldown("overclock", 30)
end
-- Check cooldown status (client or server)
if inst.components.wx78_abilitycooldowns:IsInCooldown("overclock") then
local percent = inst.components.wx78_abilitycooldowns:GetAbilityCooldownPercent("overclock")
print("Cooldown progress: "..percent)
end
Dependencies & tags
External dependencies:
TheWorld-- checksismastersimto gate server-only logicSpawnPrefab-- instantiateswx78_abilitycooldownentities for tracking
Components used:
- None identified
Tags:
- None identified
Properties
| Property | Type | Default Value | Description |
|---|---|---|---|
inst | entity | --- | The entity instance that owns this component. |
ismastersim | boolean | --- | Caches TheWorld.ismastersim; gates server-only logic. |
cooldowns | table | {} | Maps ability hash to active cooldown entity. |
_onremovecd | function | --- | Callback triggered when a cooldown entity is removed; cleans up cooldowns table. |
Main functions
IsInCooldown(abilityname)
- Description: Checks if a specific ability is currently on cooldown.
- Parameters:
abilityname-- string ability name or number hash.
- Returns:
trueif cooldown exists,falseotherwise. - Error states: None.
GetAbilityCooldownPercent(abilityname)
- Description: Returns the completion percentage of an ability's cooldown.
- Parameters:
abilityname-- string ability name or number hash.
- Returns: Number between
0and1(0% to 100%), ornilif no cooldown exists. - Error states: None.
RegisterAbilityCooldown(cd)
- Description: Registers a cooldown entity with the component. Starts listening for the entity's removal to clean up internal state.
- Parameters:
cd-- cooldown entity instance (prefabwx78_abilitycooldown).
- Returns: nil
- Error states: Logs error if
cd:GetAbilityName()returns0(invalid) or if the ability is already registered (duplicate). Does not crash, but state may be inconsistent if duplicates are forced.
RestartAbilityCooldown(abilityname, duration)
- Description: Server only. Starts or resets a cooldown for the specified ability. If a cooldown entity already exists, it restarts the timer. If not, it spawns a new
wx78_abilitycooldownprefab. - Parameters:
abilityname-- string ability name or number hash.duration-- number duration in seconds.
- Returns: nil
- Error states: No-op if called on client (
ismastersimis false). Logs error ifabilitynameis invalid (hash0).
StopAbilityCooldown(abilityname)
- Description: Server only. Immediately stops and removes the cooldown entity for the specified ability.
- Parameters:
abilityname-- string ability name or number hash.
- Returns: nil
- Error states: No-op if called on client (
ismastersimis false).
GetDebugString()
- Description: Returns a formatted string listing all active cooldowns, their names, progress percentages, and durations. Used for console debugging.
- Parameters: None
- Returns: String or
nilif no cooldowns are active. - Error states: None.
_onremovecd(cd)
- Description: Internal callback. Removes the cooldown entry from the
cooldownstable when the associated cooldown entity is removed from the world. Validates the ability name before removal. - Parameters:
cd-- cooldown entity instance triggering the event.
- Returns: nil
- Error states: Logs error if
cd:GetAbilityName()returns0or if the ability name is not found inself.cooldowns.
Events & listeners
- Listens to:
onremove(on cooldown entitycd) -- triggers_onremovecdto clean up thecooldownstable when a cooldown entity is removed.