Riferimento › Riferimento delle funzioni › Platform

Platform.mobinfo2.GetMobInfo2Observation

pubblica

Chiamala come

addon.Platform:GetMobInfo2Observation(unit, kind, school, cache)

Disponibile direttamente tramite addon; non serve alcuna dipendenza.

Cosa fa

Legge le osservazioni storiche facoltative di MobInfo2 sui client con policy di sondaggio o ristretta. Memorizza in cache solo la presenza esatta dell'unità selezionata; il primo risultato di UnitName, il primo risultato di UnitLevel e la chiamata con punto a tre argomenti MI2_GetMobData(name,level,unit) vengono rieseguiti a ogni chiamata. Le unità accertate come assenti e una cronologia nil o omessa restituita con successo restano distinte dai dati nativi/del fornitore non disponibili. Preserva la veridicità dello scalare runner leggibile, i segni delle scuole e il valore predefinito uno per Hits mancante. I rapporti di resistenza positivi devono essere finiti; l'immunità completa consuma Hits finito, mentre l'immunità parziale richiede solo l'osservazione negativa della propria scuola. Non dedurre mai la resistenza nativa né prendere in prestito record vecchi.

Argomenti

NomeTipoCosa fa
selfRMPlatformAdattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti).
unitstringIdentificativo unità selezionato non vuoto, invariato nelle chiamate native/del fornitore.
kindstringTipo chiuso: runner, resist o immune.
schoolstring | nilChiave storica non vuota della scuola per resist/immune; non usata per runner.
cachetable | nilCache solo della presenza per il passaggio di valutazione; nome, livello e cronologia del fornitore vengono sempre riletti.

Valori restituiti

1table | nilRecord con exists=false; recorded=false se è accertata l'assenza di cronologia; oppure runner, ratio o immune con hits/hitsReason. Nil indica che un'osservazione richiesta non è disponibile.
2string | nilMotivo di policy, di funzionalità o di indisponibilità di un'osservazione richiesta.

Edizioni

Le funzioni di supporto integrate sono registrate su ogni edizione. Ciò che cambia è l'API di gioco che leggono; dove ne manca una, la funzione di supporto ripiega su un'alternativa o restituisce nil con un motivo.

  • Non disponibile su quell'edizione (il motivo è nel suggerimento)
  • Solo mentre sono attivi i ripieghi di Blizzard per le API deprecate
API di giocoClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitLevelClassic EraTBC AnniversaryClassic progressionForeverRetail
UnitNameClassic EraTBC AnniversaryClassic progressionForeverRetail
canaccessvalueClassic EraTBC AnniversaryClassic progressionForeverRetail

Valori segreti (Retail e Forever)

Su Retail e Forever il gioco fornisce agli addon valori segreti. Questa funzione di supporto controlla ciò che legge (addon.Platform:CanReadValue) e restituisce nil con un motivo come restricted-value invece di un valore segreto che non può confrontare. Considera nil come non disponibile, non come false.

Come la chiama l'addon

  • Immune (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"immune",value.school,cache)
  • Resistente (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"resist",value.school,cache)
  • In fuga (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"runner",nil,cache)

Dipendenze

Sorgente

Platform/mobinfo2.lua, riga 79. Nel gioco è in sola lettura; Duplica crea una copia modificabile.

Platform.mobinfo2.GetMobInfo2Observation(self, unit, kind, school, cache)
    local policy=self:GetCombatDataPolicy()
    if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
    if not self:CanReadValue(unit) or not self:CanReadValue(kind) or not self:CanReadValue(cache) then return nil,'restricted-value' end
    if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
    if kind~='runner' and kind~='resist' and kind~='immune' then return nil,'invalid-mobinfo2-kind' end
    if cache~=nil and type(cache)~='table' then return nil,'invalid-mobinfo2-cache' end
    if kind~='runner' then
        if not self:CanReadValue(school) then return nil,'restricted-value' end
        if type(school)~='string' or school=='' then return nil,'invalid-mobinfo2-school' end
    end
    local exists,reason=addon.Functions.cache.getCached(cache,presence,self,unit)
    if exists==nil then return nil,reason end
    if not exists then return {exists=false} end
    local query,queryReason=readField(self,_G,'MI2_GetMobData')
    if queryReason then return nil,queryReason end
    if type(query)~='function' then return nil,'missing-api' end
    if type(UnitName)~='function' then return nil,'missing-api' end
    local nameOk,name=pcall(UnitName,unit)
    if not nameOk then return nil,'api-error' end
    if not self:CanReadValue(name) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(name) then return nil,'restricted-value' end
    if name==nil then return nil,'unit-name-unavailable' end
    if type(name)~='string' or name=='' then return nil,'invalid-api-result' end
    if type(UnitLevel)~='function' then return nil,'missing-api' end
    local levelOk,level=pcall(UnitLevel,unit)
    if not levelOk then return nil,'api-error' end
    if not self:CanReadValue(level) then return nil,'restricted-value' end
    if canaccessvalue and not canaccessvalue(level) then return nil,'restricted-value' end
    local valid,why=finite(self,level)
    if not valid then return nil,why end
    local ok,data=pcall(query,name,level,unit)
    if not ok then return nil,'mobinfo2-provider-error' end
    if not self:CanReadValue(data) then return nil,'restricted-value' end
    -- A successful nil lookup means unrecorded data in the publisher API.
    if data==nil then return {exists=true,recorded=false} end
    if type(data)~='table' then return nil,'invalid-mobinfo2-data' end
    if kind=='runner' then
        local action,actionReason=readField(self,data,'lowHpAction')
        if actionReason then return nil,actionReason end
        local actionType=type(action)
        if actionType=='number' then
            valid,why=finite(self,action)
            if not valid then return nil,why end
        elseif actionType~='nil' and actionType~='boolean' and actionType~='string' then
            return nil,'invalid-mobinfo2-action'
        end
        -- Preserve readable scalar truthiness, including numeric zero and ''.
        return {exists=true,recorded=true,runner=action and true or false}
    end
    local resists,resistsReason=readField(self,data,'resists')
    if resistsReason then return nil,resistsReason end
    if resists==nil then return {exists=true,recorded=false} end
    local count,countReason=readField(self,resists,school)
    if countReason then return nil,countReason end
    if count==nil then return {exists=true,recorded=false} end
    valid,why=finite(self,count)
    if not valid then return nil,why end
    if kind=='resist' then
        if count<=0 then return {exists=true,recorded=false} end
        local hits,hitsReason=hitCount(self,resists,school)
        if hits==nil then return nil,hitsReason end
        local ratio=count/hits
        valid,why=finite(self,ratio)
        if not valid then return nil,why end
        return {exists=true,recorded=true,ratio=ratio}
    end
    if count>=0 then return {exists=true,recorded=false} end
    local hits,hitsReason=hitCount(self,resists,school)
    -- Partial immunity needs only the negative observation. Full immunity
    -- separately requires this optional count, including meaningful zero.
    return {exists=true,recorded=true,immune=true,hits=hits,hitsReason=hitsReason}

Torna a Riferimento delle funzioni