Chiamala come
addon.Platform:GetSpellRangeState(id, unit, bank)
Disponibile direttamente tramite addon; non serve alcuna dipendenza.
Cosa fa
Legge la portata specifica di un incantesimo per un'unità usando l'API del client appropriata o lo slot del libro degli incantesimi. Un incantesimo senza limite di portata restituisce applicable=false; altrimenti applicable=true e inRange indica se l'unità è entro portata. Osservazioni sconosciute o inaccessibili restituiscono nil con un motivo.
Argomenti
| Nome | Tipo | Cosa fa |
|---|---|---|
self | RMPlatform | Adattatore di piattaforma di Rotation Master. Un riferimento con punto richiede addon.Platform come primo argomento; una chiamata con due punti lo fornisce implicitamente. |
id | number | ID dell'incantesimo di cui controllare la portata. |
unit | string | nil | Identificativo unità, ad esempio target; con nil usa target. |
bank | string | Ambito del libro degli incantesimi: spell, pet o any. |
Valori restituiti
| 1 | table | nil | Record di portata con applicable e, se applicabile, inRange; nil se non disponibile. |
|---|---|---|
| 2 | string | nil | Motivo di indisponibilità o di convalida quando il record è nil. |
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
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 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.inRangeDipendenze
call→Platform.actions.callfindSlot→Platform.actions.findSlotrangeIn(builtin:Platform/actions.lua:rangeIn)rangeNotApplicable(builtin:Platform/actions.lua:rangeNotApplicable)rangeOut(builtin:Platform/actions.lua:rangeOut)spellID→Platform.actions.spellID
Sorgente
Platform/actions.lua, riga 120. Nel gioco è in sola lettura; Duplica crea una copia modificabile.
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




