呼叫方式
addon.Platform:IsSpellReady(spell, now)
可直接透過 addon 使用,不需要相依項目。
作用
檢查某個法術現在能否被建議,允許剩餘冷卻時間隨目前共用冷卻一同結束的法術。在正式版與永久中,戰鬥中的冷卻時間是機密值,因此改為依據永不為機密的 isEnabled、isActive 與 isOnGCD 旗標判斷是否就緒。此函式只檢查冷卻是否就緒;不檢查是否已學會、距離或資源是否足夠。請傳入來自 evalStart 或 GetTime() 的評估時間。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台轉接器。點號參照需要將 addon.Platform 作為第一個參數;冒號呼叫會隱含提供它。 |
spell | number | string | 要檢查其冷卻的法術 ID 或用戶端可辨識的法術名稱。 |
now | number | 目前評估時間,單位為秒,取自 GetTime(),通常為 evalStart。 |
傳回值
| 1 | boolean | nil | 在共用冷卻結束時已就緒則為 true;因其自身冷卻而無法建議時為 false;用戶端無法提供可讀結果時為 nil。 |
|---|---|---|
| 2 | string | nil | 結果為 nil 時的可用性或驗證原因。 |
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
- 該版本無法使用(原因請見提示)
- 僅在暴雪的棄用相容層開啟時
| 遊戲 API | |||||
|---|---|---|---|---|---|
GetTime |
機密值(正式版與永久)
在正式版與永久上,遊戲交給插件的是機密值。此輔助函式會檢查它讀取的內容(addon.Platform:CanReadValue),遇到無法比較的機密值時,會傳回 nil 並附上原因(例如 restricted-value),而不是傳回該機密值。請將 nil 視為無法使用,而非假。
範例
local ready = addon.Platform:IsSpellReady(value.spell, evalStart)
if ready == nil then return nil end
return ready相依項目
cooldownValues→Platform.spells.cooldownValuesflagReadiness→Platform.spells.flagReadinessgcdSpell(builtin:Platform/spells.lua:gcdSpell)
原始碼
Platform/spells.lua,第 575 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Platform.spells.IsSpellReady(self, spell, now)
if not self:CanReadValue(now) then return nil, "restricted-value" end
if type(now)~="number" or now~=now or now==math.huge or now==-math.huge then
return nil, "invalid-time"
end
local start,duration,enabled,reason,active,onGCD=cooldownValues(self,spell)
if start==nil then
if active==nil then return nil,reason end
return flagReadiness(self,enabled,active,onGCD,now)
end
if not enabled then return false end
local expires=start+duration
if duration==0 or expires<=now then return true end
if not gcdSpell then self:GetGlobalCooldown() end
local gcdStart,gcdDuration,gcdEnabled,why,gcdActive=cooldownValues(self,gcdSpell)
if gcdStart==nil then
-- The GCD's times are hidden: one known not to be running cannot
-- cover this spell's own, still running, cooldown.
if gcdActive~=nil and (not gcdEnabled or not gcdActive) then return false end
return nil,why
end
if not gcdEnabled or gcdDuration==0 then return false end
-- modRate controls cooldown animation; API timestamps/duration already
-- describe expiration in GetTime seconds, so do not divide them by it.
local gcdExpires=gcdStart+gcdDuration
return gcdExpires>now and expires<=gcdExpires+0.001




