Referência › Referência de funções › Conditions

Conditions.weapon.swingSpeed

dependência

Chame como

Conditions.weapon.swingSpeed(value, cache)

Registre a dependência Conditions.weapon.swingSpeed e depois chame-a por esse nome. Uma chamada com namespace não passa self: use uma chamada com dois-pontos ou passe o objeto você mesmo.

O que faz

Reads the player's main-hand, or off-hand when value.offhand is set, attack speed from the cached UnitAttackSpeed for the swing timer conditions. An off-hand check with no off-hand speed returns false.

Argumentos

NomeTipoO que faz
valuetableCondition settings; a truthy offhand field selects the off hand.
cachetable | nilEvaluation-pass cache passed to getCached, or nil to read directly.

Retornos

1number | boolean | nilSwing speed in seconds, false when there is no off-hand weapon, or nil when unavailable.
2string | nilReason for nil: missing-api, api-error, restricted-value or invalid-weapon-observation.

Edições

As funções auxiliares integradas são registradas em todas as edições. O que muda é a API do jogo que elas leem; quando uma está ausente, a função auxiliar recorre a uma alternativa ou retorna nil com um motivo.

  • Indisponível nessa edição (o motivo está na dica)
  • Só enquanto as alternativas da Blizzard para APIs obsoletas estiverem ativas
API do jogoClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitAttackSpeedClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitRangedDamageClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Como o addon a chama

Dependências

Código-fonte

Conditions/weapon.lua, linha 96. Somente leitura no jogo; Duplicar cria uma cópia editável.

Conditions.weapon.swingSpeed(value, cache)
    -- Ranged: the Auto Shot or wand interval (UnitRangedDamage), false with no
    -- ranged attack; the melee hands read UnitAttackSpeed.
    if value.ranged then
        local speed,reason=Functions.cache.getCached(cache,addon.Platform.GetRangedSwingSpeed,addon.Platform)
        if speed==nil then return nil,reason end
        return speed
    end
    if type(UnitAttackSpeed)~="function" then return nil,"missing-api" end
    -- pcall forwards the mainhand and offhand speeds from the observation.
    ---@diagnostic disable-next-line: unbalanced-assignments
    local ok,main,off=pcall(addon.getCached,cache,UnitAttackSpeed,"player")
    if not ok then return nil,"api-error" end
    local speed=main
    if value.offhand then
        speed=off
        -- No off-hand weapon: the API returns no off-hand speed. That is a
        -- reading (nothing to swing), so off-hand checks are false.
        if speed==nil then return false end
    end
    return numericObservation(speed)

Voltar para Referência de funções