Referenz › Funktionsreferenz › Platform

Platform.mobinfo2.GetMobInfo2Observation

öffentlich

Aufruf als

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

Direkt über addon verfügbar; keine Abhängigkeit nötig.

Was sie bewirkt

Optionale historische Beobachtungen von MobInfo2 auf Clients mit Probe- oder Restricted-Richtlinie lesen. Nur die exakte Anwesenheit der ausgewählten Einheit wird zwischengespeichert; Ergebnis eins von UnitName, Ergebnis eins von UnitLevel und der Punktaufruf MI2_GetMobData(name,level,unit) mit drei Argumenten bleiben bei jedem Aufruf frisch. Bekannt abwesende Einheiten und erfolgreich nicht aufgezeichnete nil- oder fehlende Verläufe bleiben von nicht verfügbaren nativen Fakten und Anbieterfakten unterscheidbar. Lesbarer Wahrheitswert des runner-Skalars, Schulvorzeichen und der Standardwert eins bei fehlendem Hits bleiben erhalten. Positive Widerstandsquoten müssen endlich sein; vollständige Immunität verwendet endliche Hits, teilweise Immunität benötigt nur ihre negative Schulbeobachtung. Nie nativen Widerstand ableiten oder alte Datensätze übernehmen.

Argumente

NameTypWas sie bewirkt
selfRMPlatformPlattformadapter von Rotation Master (bei Doppelpunktaufrufen implizit).
unitstringAusgewählte nichtleere Einheitenkennung, in nativen Aufrufen und Anbieteraufrufen unverändert.
kindstringGeschlossene Art: runner, resist oder immune.
schoolstring | nilNichtleerer historischer Zauberschul-Schlüssel für resist/immune; für runner ungenutzt.
cachetable | nilNur Anwesenheits-Cache des Auswertungsdurchlaufs; Name, Stufe und Anbieterverlauf bleiben frisch.

Rückgabewerte

1table | nilDatensatz mit exists=false; recorded=false bei bekanntermaßen fehlendem Verlauf; oder runner, ratio oder immune mit hits/hitsReason. Nil bedeutet, dass eine erforderliche Beobachtung nicht verfügbar ist.
2string | nilVerfügbarkeitsgrund aus Richtlinie, Client-Unterstützung oder erforderlicher Beobachtung.

Editionen

Integrierte Hilfsfunktionen werden auf jeder Edition registriert. Unterschiedlich ist die Spiel-API, die sie lesen; fehlt eine, weicht die Hilfsfunktion aus oder gibt nil mit einem Grund zurück.

  • Auf dieser Edition nicht verfügbar (den Grund nennt der Tooltip)
  • Nur, solange Blizzards Ersatz für veraltete Funktionen aktiv ist
Spiel-APIClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitLevelClassic EraTBC AnniversaryClassic ProgressionForeverRetail
UnitNameClassic EraTBC AnniversaryClassic ProgressionForeverRetail
canaccessvalueClassic EraTBC AnniversaryClassic ProgressionForeverRetail

Geheime Werte (Retail und Forever)

Auf Retail und Forever übergibt das Spiel Addons geheime Werte. Diese Hilfsfunktion prüft, was sie liest (addon.Platform:CanReadValue), und gibt statt eines geheimen Werts, den sie nicht vergleichen kann, nil mit einem Grund wie restricted-value zurück. Behandeln Sie nil als nicht verfügbar, nicht als false.

Wie das Addon sie aufruft

  • Immun (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"immune",value.school,cache)
  • Widerstandsfähig (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"resist",value.school,cache)
  • Flüchtet (evaluate)
    local observation,reason=addon.Platform:GetMobInfo2Observation(value.unit,"runner",nil,cache)

Abhängigkeiten

Quelle

Platform/mobinfo2.lua, Zeile 79. Im Spiel schreibgeschützt; Duplizieren erstellt eine bearbeitbare Kopie.

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}

Zurück zu Funktionsreferenz