Chiamala come
addon.Platform:GetUnitCastObservation(unit, kind)
Disponibile direttamente tramite addon; non serve alcuna dipendenza.
Cosa fa
Osserva il lancio o la canalizzazione di un'unità sui client con policy di sondaggio o ristretta. Un'unità accertata come assente o un risultato inattivo leggibile restituisce active=false. I record attivi contengono name, oppure nameReason quando il nome è segreto (l'unità sta comunque lanciando), e i campi remainingSeconds, durationSeconds, interruptible e spellID, disponibili in modo indipendente, con remainingReason, durationReason, interruptibleReason o spellReason quando un campo facoltativo non è disponibile. Le osservazioni di presenza mancanti, non riuscite o limitate restituiscono nil con un motivo.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
self | RMPlatform | Adattatore di piattaforma di Rotation Master (implicito nelle chiamate con due punti). |
unit | string | Identificativo dell'unità di cui osservare il lancio o l'incanalamento attuale. |
kind | string | Tipo di osservazione: cast o channel. Usano posizioni diverse nella tupla nativa di interrompibilità. |
Valori restituiti
| 1 | table | nil | Record aggiornato e leggibile con active, poi name o nameReason, remainingSeconds, durationSeconds, interruptible e spellID. Il tempo rimanente e la durata sono in secondi; il tempo rimanente viene limitato a zero. Un campo facoltativo non disponibile ha il proprio motivo; non invalida un record attivo. |
|---|---|---|
| 2 | string | nil | Motivo di indisponibilità o di convalida della query quando l'intera osservazione non è disponibile. |
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 gioco | |||||
|---|---|---|---|---|---|
UnitCastingInfo | |||||
UnitChannelInfo | |||||
UnitExists |
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.
Esempio
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.5Dipendenze
durationSeconds→Platform.casting.durationSecondsinterruptibility→Platform.casting.interruptibilityremainingSeconds→Platform.casting.remainingSecondsspellIdentity→Platform.casting.spellIdentity
Sorgente
Platform/casting.lua, riga 82. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
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




