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

Platform.actions.GetSpellRangeState

pública

Chame como

addon.Platform:GetSpellRangeState(id, unit, bank)

Disponível diretamente por meio de addon; nenhuma dependência é necessária.

O que faz

Lê o alcance específico de um feitiço para uma unidade usando a API do cliente apropriada ou o espaço do grimório. Um feitiço sem restrição de alcance retorna applicable=false; caso contrário, applicable=true e inRange registra se a unidade está ao alcance. Observações desconhecidas ou inacessíveis retornam nil com um motivo.

Argumentos

NomeTipoO que faz
selfRMPlatformAdaptador de plataforma do Rotation Master. Uma referência com ponto exige addon.Platform como primeiro argumento; uma chamada com dois-pontos o fornece implicitamente.
idnumberID de feitiço cujo alcance deve ser verificado.
unitstring | nilToken de unidade, como target; nil usa target.
bankstringEscopo do grimório: spell, pet ou any.

Retornos

1table | nilRegistro de alcance com applicable e, quando aplicável, inRange; nil quando indisponível.
2string | nilMotivo de disponibilidade ou de validação quando o registro é nil.

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
C_Spell.IsSpellInRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
C_Spell.SpellHasRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
IsSpellInRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail
SpellHasRangeClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Valores secretos (Retail e Forever)

No Retail e no Forever, o jogo entrega valores secretos aos addons. Esta função auxiliar verifica o que lê (addon.Platform:CanReadValue) e retorna nil com um motivo como restricted-value em vez de um valor secreto que não consegue comparar. Trate nil como indisponível, não como false.

Exemplo

local record = addon.Platform:GetSpellRangeState(value.spell, "target", "any")
if not record then return nil end
-- A spell with no range restriction can always reach the target.
return not record.applicable or record.inRange

Dependências

Código-fonte

Platform/actions.lua, linha 120. Somente leitura no jogo; Duplicar cria uma cópia editável.

Platform.actions.GetSpellRangeState(self, id, unit, bank)
    local valid,reason=spellID(id)
    if not valid then return nil,reason end
    if not self:CanReadValue(unit) or not self:CanReadValue(bank) then return nil,"restricted-value" end
    if unit~=nil and (type(unit)~="string" or unit=="") then return nil,"invalid-unit" end
    if bank~="spell" and bank~="pet" and bank~="any" then return nil,"invalid-spell-bank" end
    unit=unit or "target"
    local nativeRange=C_Spell and C_Spell.IsSpellInRange
    local nativeShape=C_Spell and C_Spell.SpellHasRange
    local slot,book,slotReason
    local hasRange,why,queriedShape
    if type(nativeShape)=="function" then
        queriedShape=true
        hasRange,why=call(nativeShape,id)
    elseif type(nativeRange)~="function" and type(SpellHasRange)=="function" then
        if not slot then slot,book,slotReason=findSlot(id,bank) end
        if not slot then return nil,slotReason end
        queriedShape=true
        hasRange,why=call(SpellHasRange,slot,book)
    end
    if why then return nil,why end
    if hasRange~=nil then
        if type(hasRange)~="boolean" then return nil,"invalid-api-result" end
        if not hasRange then return rangeNotApplicable end
    elseif queriedShape then return nil,"invalid-api-result" end
    local inRange
    if type(nativeRange)=="function" then
        inRange,why=call(nativeRange,id,unit)
        if why then return nil,why end
        if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
    else
        if type(IsSpellInRange)~="function" then return nil,"missing-api" end
        if not slot then slot,book,slotReason=findSlot(id,bank) end
        if not slot then return nil,slotReason end
        inRange,why=call(IsSpellInRange,slot,book,unit)
        if why then return nil,why end
        if inRange==0 then inRange=false elseif inRange==1 then inRange=true end
        if inRange~=nil and type(inRange)~="boolean" then return nil,"invalid-api-result" end
    end
    if inRange==nil then return nil,"invalid-range-check" end
    return inRange and rangeIn or rangeOut

Voltar para Referência de funções