레퍼런스 › 함수 레퍼런스 › Platform

Platform.threat.GetUnitThreatObservation

공개

호출 방법

addon.Platform:GetUnitThreatObservation(unit)

addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.

하는 일

선택한 유닛의 존재, 플레이어에 대한 적대 여부, 그 유닛에 대한 플레이어 위협 상태를 순서대로 관찰합니다. 없음, 적이 아님, 성공적으로 읽은 nil 위협 상태는 false를 반환해 위협 없음 조건식을 유지합니다. 0을 포함한 유한한 상태 숫자는 원래의 비교 의미를 유지합니다. 필수 정보가 없거나, 실패하거나, nil이거나, 제한되거나, 잘못되면 nil과 이유를 반환합니다. 공격 가능 여부, 죽음, 전투, 탈것 추론은 추가하지 않습니다.

인수

이름유형하는 일
selfRMPlatformRotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적).
unitstring존재 확인과 플레이어의 적대 및 위협 조회 수신자로 쓰이는 정확한 유닛 토큰.

반환값

1number | boolean | nil유한한 기본 위협 상태, 없음/적 아님/위협 없음으로 알려지면 false, 관찰을 사용할 수 없으면 nil.
2string | nilnil인 위협 관찰에 대한 정책, 조회 검증 또는 사용 불가 이유.

버전

기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.

  • 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
  • Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
게임 APIClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitExistsClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitIsEnemyClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitThreatSituationClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic EraTBC AnniversaryClassic progressionForeverRetail

비공개 값 (Retail과 Forever)

Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.

예시

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 >= 2

소스

Platform/threat.lua, 19번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.

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

함수 레퍼런스(으)로 돌아가기