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

Platform.actions.GetSpellRangeState

공개

호출 방법

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

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

하는 일

적절한 클라이언트 API나 주문서 칸으로 유닛에 대한 주문별 사거리를 읽습니다. 사거리 제한이 없는 주문은 applicable=false를 반환하며, 그렇지 않으면 applicable=true이고 inRange에 유닛이 사거리 내인지 기록됩니다. 알 수 없거나 접근할 수 없는 관찰은 nil과 이유를 반환합니다.

인수

이름유형하는 일
selfRMPlatformRotation Master 플랫폼 어댑터. 점 참조는 첫 번째 인수로 addon.Platform이 필요하며, 콜론 호출은 이를 암묵적으로 전달합니다.
idnumber사거리를 확인할 주문 ID.
unitstring | niltarget 같은 유닛 토큰. nil이면 target을 사용합니다.
bankstring주문서 범위: spell, pet, any.

반환값

1table | nilapplicable과, 해당되면 inRange를 담은 사거리 레코드. 사용할 수 없으면 nil.
2string | nil기록이 nil일 때의 사용 불가 또는 검증 이유.

버전

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

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

비공개 값 (Retail과 Forever)

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

예시

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

의존성

소스

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

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

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