跳转至

LimbHealth 类型与事件

汇总 LimbHealth 暴露给外部的事件类、枚举与数据类型。


ApiEvents

可注册事件的枚举集合,通过 LimbHealthServerAPI.getApiEvents() 获取。

class LimbHealthServerAPI.ApiEvents(BaseEnum):
    LimbHealthUpdateEvent              # 部位血量变化
    LimbHealthMaxUpdateEvent           # 玩家某部位最大血量变化
    LimbHealthConfigMaxHealthUpdateEvent  # 配置层面的部位最大血量变化(全局)

每个枚举项是 ApiEvents.EnumObject,可通过 .getEventCls() 取出对应的事件类。ApiEvents 继承自 BaseEnum,可调用 values() / valueOf(name) 反射访问。


LimbHealthUpdateEvent

最常用:玩家某部位血量发生变化时触发。

属性 类型 说明
playerId str 玩家 ID
updatePosType LimbHealthPosTypeEnum.PosTypeValue 发生变化的部位
oldHealth float | int 变化前的血量
newHealth float | int 变化后的血量
isFromHurt bool 是否由受伤流程触发

Getter

方法 返回
getPlayerId() str
getUpdatePosType() LimbHealthPosTypeEnum.PosTypeValue
getOldHealth() float | int
getNewHealth() float | int
getIsFromHurt() bool

可通过便捷接口 registerLimbHealthUpdateEventHandler 直接订阅。


LimbHealthMaxUpdateEvent

玩家某部位的最大血量发生变化时触发(针对单个玩家)。

属性 类型 说明
playerId str 玩家 ID
updatePosType LimbHealthPosTypeEnum.PosTypeValue 发生变化的部位
newMaxHealth int 新的最大血量(构造时强制 int,否则抛 TypeError
isFromHurt bool 是否由受伤流程触发

Getter

方法 返回
getPlayerId() str
getUpdatePosType() LimbHealthPosTypeEnum.PosTypeValue
getNewMaxHealth() int
getIsFromHurt() bool

LimbHealthConfigMaxHealthUpdateEvent

全局配置层的部位最大血量发生变化时触发(影响所有玩家)。

属性 类型 说明
updatePosType LimbHealthPosTypeEnum.PosTypeValue 发生变化的部位
newMaxHealth int 新的全局最大血量

Getter

方法 返回
getUpdatePosType() LimbHealthPosTypeEnum.PosTypeValue
getNewMaxHealth() int

LimbHealthMaxUpdateEvent 的区别

  • LimbHealthConfigMaxHealthUpdateEvent全局变化(管理员调整配置等),不带 playerId
  • LimbHealthMaxUpdateEvent单个玩家的最大血量变化(玩家个人 buff、装备等导致)

LimbHealthPosTypeEnum

8 个肢体部位枚举。

from LimbHealthScripts.common.enum.LimbHealthPosTypeEnum import LimbHealthPosTypeEnum
常量 内部 value 说明
HEAD 0 头部
BODY 1 躯干
LEFT_ARM 2 左臂
RIGHT_ARM 3 右臂
LEFT_LEG 4 左腿
RIGHT_LEG 5 右腿
LEFT_FOOT 6 左脚
RIGHT_FOOT 7 右脚

每个常量都是 LimbHealthPosTypeEnum.PosTypeValue 实例。

PosTypeValue 实例方法

方法 返回 说明
getValue() int 取得内部数值(0–7)
__eq__(other) bool 比较两个 PosTypeValue 是否同 value
__hash__() int 基于 value 做哈希,可作 dict

LimbHealthPosTypeEnum 类方法

方法 返回 说明
values() list[PosTypeValue] 返回所有 8 个常量(继承自 BaseEnum
getByValue(posTypeValue) PosTypeValue | None 在已注册常量里查找匹配实例(仅做相等性检查),找不到返回 NoneposTypeValue 必须是 PosTypeValue,否则抛 TypeError

LimbHealthEventPriorityEnum

事件处理器执行优先级。slot 越小越先触发。

from LimbHealthScripts.common.enum.LimbHealthEventPriorityEnum import LimbHealthEventPriorityEnum
常量 slot 触发顺序
LOWEST 0 最先触发
LOW 1
NORMAL 2 默认值
HIGH 3
HIGHEST 4 最晚触发

CustomEffectIdentifierEnum

LimbHealth 注册的自定义状态/药水效果标识符。

from LimbHealthScripts.common.enum.CustomEffectIdentifierEnum import CustomEffectIdentifierEnum
常量 字符串值 含义
PAINKILLER "limb_health:limb_health_painkiller" 止痛药效果
BLEEDING "limb_health:limb_health_bleeding" 出血状态
STOMACH_STRENGTHENING_TABLET "limb_health:limb_health_stomach_strengthening_tablet" 健胃片效果

可直接作为字符串与原版/其他模组的状态效果系统配合使用。