Aufruf als
addon.Platform:GetUnitCastObservation(unit, kind)
Direkt über addon verfügbar; keine Abhängigkeit nötig.
Was sie bewirkt
Wirken oder Kanalisieren einer Einheit auf Clients mit Probe- oder Restricted-Richtlinie beobachten. Eine bekannt abwesende Einheit oder ein lesbares inaktives Ergebnis ergibt active=false. Aktive Datensätze enthalten name, oder nameReason, wenn der Name geheim ist (die Einheit wirkt dennoch), sowie die unabhängig verfügbaren Felder remainingSeconds, durationSeconds, interruptible und spellID, mit remainingReason, durationReason, interruptibleReason oder spellReason, wenn ein optionales Feld nicht verfügbar ist. Fehlende, fehlgeschlagene oder eingeschränkte Anwesenheitsbeobachtungen ergeben nil mit einem Grund.
Argumente
| Name | Typ | Was sie bewirkt |
|---|---|---|
self | RMPlatform | Plattformadapter von Rotation Master (bei Doppelpunktaufrufen implizit). |
unit | string | Einheitenkennung, deren aktuelles Wirken oder Kanalisieren beobachtet werden soll. |
kind | string | Beobachtungsart: cast oder channel. Diese verwenden unterschiedliche Positionen im nativen Tupel für die Unterbrechbarkeit. |
Rückgabewerte
| 1 | table | nil | Frisch gelesener Datensatz mit active, dann name oder nameReason, remainingSeconds, durationSeconds, interruptible und spellID. Restzeit und Dauer sind in Sekunden angegeben; die Restzeit wird nach unten auf null begrenzt. Ein nicht verfügbares optionales Feld hat seinen eigenen Grund; es macht einen aktiven Datensatz nicht ungültig. |
|---|---|---|
| 2 | string | nil | Verfügbarkeits- oder Abfragevalidierungsgrund, wenn die gesamte Beobachtung nicht verfügbar ist. |
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-API | |||||
|---|---|---|---|---|---|
UnitCastingInfo | |||||
UnitChannelInfo | |||||
UnitExists |
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.
Beispiel
local cast = addon.Platform:GetUnitCastObservation("target", "cast")
if not cast then return nil end
if not cast.active then return false end
if cast.interruptible == nil or cast.remainingSeconds == nil then return nil end
return cast.interruptible and cast.remainingSeconds > 0.5Abhängigkeiten
durationSeconds→Platform.casting.durationSecondsinterruptibility→Platform.casting.interruptibilityremainingSeconds→Platform.casting.remainingSecondsspellIdentity→Platform.casting.spellIdentity
Quelle
Platform/casting.lua, Zeile 82. Im Spiel schreibgeschützt; Duplizieren erstellt eine bearbeitbare Kopie.
Platform.casting.GetUnitCastObservation(self, unit, kind)
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) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if kind~='cast' and kind~='channel' then return nil,'invalid-cast-query' 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 {active=false} end
local fn
if kind=='cast' then fn=UnitCastingInfo else fn=UnitChannelInfo end
if type(fn)~='function' then return nil,'missing-api' end
-- Capture into an owned tuple table without comparing native values. The
-- channel flag is slot7; casting includes castID and uses slot8 instead,
-- so the spell ID is slot9 for a cast and slot8 for a channel.
local ok,tuple=pcall(function() return {fn(unit)} end)
if not ok then return nil,'api-error' end
local name=tuple[1]
local record
if not self:CanReadValue(name) then
-- Retail and Forever make cast fields secret for a unit other than the
-- player or pet unless the spell is flagged never secret
-- (SecretWhenUnitSpellCastRestricted). A secret is a value, never nil:
-- the unit is casting, and only the name is hidden.
record={active=true,nameReason='restricted-value'}
else
if name==nil then return {active=false} end
if type(name)~='string' or name=='' then return nil,'invalid-api-result' end
record={active=true,name=name}
end
record.remainingSeconds,record.remainingReason=remainingSeconds(tuple[5])
record.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
record.interruptible,record.interruptibleReason=interruptibility(tuple[kind=='cast' and 8 or 7])
record.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
return record




