Chame como
addon.Platform:GetUnitThreatObservation(unit)
Disponível diretamente por meio de addon; nenhuma dependência é necessária.
O que faz
Observa em ordem a existência da unidade selecionada, a hostilidade a partir do jogador e depois o estado de ameaça do jogador sobre essa unidade. Ausência conhecida, não inimigo e um estado de ameaça nil lido com sucesso retornam false, preservando o predicado de sem ameaça. Números de estado finitos, incluindo zero, mantêm o significado de comparação original. Dados necessários ausentes, com falha, nil, restritos ou malformados retornam nil com um motivo. Nenhuma dedução de possibilidade de ataque, morte, combate ou veículo é adicionada.
Argumentos
| Nome | Tipo | O que faz |
|---|---|---|
self | RMPlatform | Adaptador de plataforma do Rotation Master (implícito nas chamadas com dois-pontos). |
unit | string | Token de unidade exato usado para a existência e como destinatário das consultas de hostilidade e ameaça do jogador. |
Retornos
| 1 | number | boolean | nil | Estado de ameaça nativo finito, false para ausência conhecida, não inimigo ou sem ameaça, ou nil para observações indisponíveis. |
|---|---|---|
| 2 | string | nil | Motivo de política, validação da consulta ou disponibilidade para uma observação de ameaça 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 jogo | |||||
|---|---|---|---|---|---|
UnitExists | |||||
UnitIsEnemy | |||||
UnitThreatSituation | |||||
canaccessvalue |
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 status = addon.Platform:GetUnitThreatObservation("target")
if status == nil then return nil end
-- false means no target, not an enemy, or no threat; 2 and 3 mean you are tanking
return status ~= false and status >= 2Código-fonte
Platform/threat.lua, linha 19. Somente leitura no jogo; Duplicar cria uma cópia editável.
Platform.threat.GetUnitThreatObservation(self, unit)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if type(UnitExists)~='function' then return nil,'missing-api' end
local existsOk,exists=pcall(UnitExists,unit)
if not existsOk then return nil,'api-error' end
if not self:CanReadValue(exists) then return nil,'restricted-value' end
if exists==nil then return nil,'unit-data-unavailable' end
if type(exists)~='boolean' then return nil,'invalid-api-result' end
if not exists then return false end
if type(UnitIsEnemy)~='function' then return nil,'missing-api' end
local enemyOk,enemy=pcall(UnitIsEnemy,'player',unit)
if not enemyOk then return nil,'api-error' end
if not self:CanReadValue(enemy) then return nil,'restricted-value' end
if enemy==nil then return nil,'unit-data-unavailable' end
if type(enemy)~='boolean' then return nil,'invalid-api-result' end
if not enemy then return false end
if type(UnitThreatSituation)~='function' then return nil,'missing-api' end
local threatOk,threat=pcall(UnitThreatSituation,'player',unit)
if not threatOk then return nil,'api-error' end
if not self:CanReadValue(threat) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(threat) then return nil,'restricted-value' end
if threat==nil then return false end
if type(threat)~='number' or threat~=threat or threat==math.huge or threat==-math.huge then return nil,'invalid-api-result' end
return threat




