Llamar como
addon.Platform:GetSpellRangeState(id, unit, bank)
Disponible directamente a través de addon; no se necesita ninguna dependencia.
Qué hace
Lee el alcance específico de un hechizo para una unidad usando la API del cliente adecuada o la casilla del libro de hechizos. Un hechizo sin restricción de alcance devuelve applicable=false; si no, applicable=true e inRange registra si la unidad está al alcance. Las observaciones desconocidas o inaccesibles devuelven nil con un motivo.
Argumentos
| Nombre | Tipo | Qué hace |
|---|---|---|
self | RMPlatform | Adaptador de plataforma de Rotation Master. Una referencia con punto requiere addon.Platform como primer argumento; una llamada con dos puntos lo proporciona de forma implícita. |
id | number | ID de hechizo cuyo alcance se debe comprobar. |
unit | string | nil | Token de unidad, como target; nil usa target. |
bank | string | Ámbito del libro de hechizos: spell, pet o any. |
Retornos
| 1 | table | nil | Registro de alcance con applicable y, cuando corresponde, inRange; nil si no está disponible. |
|---|---|---|
| 2 | string | nil | Motivo de disponibilidad o de validación cuando el registro es nil. |
Ediciones
Las funciones auxiliares integradas se registran en todas las ediciones. Lo que cambia es la API del juego que leen; donde falta alguna, la función auxiliar usa una alternativa o devuelve nil con un motivo.
- No disponible en esa edición (el motivo aparece en la información emergente)
- Solo mientras estén activas las alternativas de Blizzard para API obsoletas
Valores secretos (Retail y Forever)
En Retail y Forever, el juego les entrega a los addons valores secretos. Esta función auxiliar verifica lo que lee (addon.Platform:CanReadValue) y, en lugar de un secreto que no puede comparar, devuelve nil con un motivo como restricted-value. Trata nil como no disponible, no como falso.
Ejemplo
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.inRangeDependencias
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
Código fuente
Platform/actions.lua, línea 120. Solo lectura en el juego; Duplicar crea una copia editable.
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




