调用方式
addon.Platform:GetPlayerComboPointObservation(powerType, kind)
可直接通过 addon 使用,无需依赖项。
作用
观测显式选择的 TBC 玩家连击点传输方式。current 只使用 GetComboPoints(player,target);maximum 使用带原始选择器的 UnitPowerMax(player,powerType)。其他客户端系列在此不可用,必须使用其现有的点数能量观测器。保留可读的有限带符号、小数和零值。缺失、失败、受限或格式错误的数据保持为不可用;所选的连击点查询失败时绝不会回退到 UnitPower。这不会观测其他角色,也不会添加缓存。
参数
| 名称 | 类型 | 作用 |
|---|---|---|
self | RMPlatform | Rotation Master 平台适配器(使用冒号调用时隐含传入)。 |
powerType | number | 原始的显式、可读、有限的非负整数连击资源选择器(包括零);保留用于最大值查询。 |
kind | string | 只能是 current(对应玩家/目标连击点查询)或 maximum(对应玩家上限查询)。 |
返回值
| 1 | number | nil | 有限的原生资源数量,保留其符号和小数部分;不可用时为 nil。 |
|---|---|---|
| 2 | string | nil | 数量为 nil 时的策略、查询验证或所需观测的可用性原因。 |
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
- 该版本不可用(原因见提示)
- 仅在暴雪的弃用兼容层开启时
秘密值(正式服和永久服)
在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。
示例
-- TBC only; 4 is the combo point power type
local current = addon.Platform:GetPlayerComboPointObservation(4, "current")
if current == nil then return nil end
return current >= 5源码
Platform/points.lua,第 216 行。在游戏中为只读;“复制”会生成一份可编辑的副本。
Platform.points.GetPlayerComboPointObservation(self, powerType, kind)
local info=self:GetClientInfo()
if info.combatDataPolicy~='probe' then return nil,'unsupported-policy' end
local family
if self:CanReadValue(info) and type(info)=='table' then family=rawget(info,'family') end
if not self:CanReadValue(family) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(family) then return nil,'restricted-value' end
if family~='tbc' then return nil,'unsupported-point-transport' end
if not self:CanReadValue(powerType) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(powerType)~='number' or powerType~=powerType or powerType<0 or powerType==math.huge or powerType%1~=0 then return nil,'invalid-point-power-query' end
if kind~='current' and kind~='maximum' then return nil,'invalid-point-power-query' end
local api
if kind=='current' then api=GetComboPoints else api=UnitPowerMax end
if type(api)~='function' then return nil,'missing-api' end
local ok,result
if kind=='current' then ok,result=pcall(api,'player','target') else ok,result=pcall(api,'player',powerType) end
if not ok then return nil,'api-error' end
if not self:CanReadValue(result) then return nil,'restricted-value' end
if canaccessvalue and not canaccessvalue(result) then return nil,'restricted-value' end
if result==nil then return nil,'point-power-unavailable' end
if type(result)~='number' or result~=result or result==math.huge or result==-math.huge then return nil,'invalid-api-result' end
return result




