Aufruf als
addon.Platform:GetSpellRangeState(id, unit, bank)
Direkt über addon verfügbar; keine Abhängigkeit nötig.
Was sie bewirkt
Die zauberspezifische Reichweite für eine Einheit über die passende Client-API oder den Platz im Zauberbuch lesen. Ein Zauber ohne Reichweitenbeschränkung ergibt applicable=false; andernfalls applicable=true, und inRange gibt an, ob die Einheit in Reichweite ist. Unbekannte oder unzugängliche Beobachtungen ergeben nil mit einem Grund.
Argumente
| Name | Typ | Was sie bewirkt |
|---|---|---|
self | RMPlatform | Plattformadapter von Rotation Master. Ein Punktaufruf erfordert addon.Platform als erstes Argument; ein Doppelpunktaufruf übergibt ihn implizit. |
id | number | Zauber-ID, deren Reichweite geprüft werden soll. |
unit | string | nil | Einheitenkennung, etwa target; nil verwendet target. |
bank | string | Zauberbuch-Bereich: spell, pet oder any. |
Rückgabewerte
| 1 | table | nil | Reichweiten-Datensatz mit applicable und, falls zutreffend, inRange; nil, wenn nicht verfügbar. |
|---|---|---|
| 2 | string | nil | Verfügbarkeits- oder Validierungsgrund, wenn der Datensatz nil 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
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 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.inRangeAbhängigkeiten
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
Quelle
Platform/actions.lua, Zeile 120. Im Spiel schreibgeschützt; Duplizieren erstellt eine bearbeitbare Kopie.
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




