变量类型
技能变量(variables)支持多种类型,用于定义技能在不同等级下的数值变化。
类型列表
| 类型 | 别名 | 说明 |
|---|---|---|
expression | — | 数学表达式,支持 %level% 等变量。最常用的类型。 |
string | str、text | 字符串值。 |
random_text | random_lines、random_line、text_lines、random_text_lines | 从列表中随机选一行。 |
random_char | random_chars、char_random、chars_random | 从候选中等概率随机选取一项。 |
weighted_random_char | weighted_random_chars、weighted_char、weighted_chars、weighted_char_random | 按权重随机选取一项。 |
conditional_char | condition_char、case_char、if_char | 按条件分支选取一项。 |
boolean | bool、flag | 布尔值,支持表达式判断。 |
constant | const、fixed | 固定值。无法识别的 type 也会回退到该类型。 |
range | — | 区间取值。 |
uniform | — | 均匀分布随机数(min~max 等概率)。 |
gaussian | normal | 高斯(正态)分布随机数。 |
skew_normal | skewnormal | 偏态正态分布随机数。 |
triangle | — | 三角分布随机数。 |
string、random_text、random_char、weighted_random_char、conditional_char、boolean 为非数值类型,min / max / decimals 对它们不生效。
参数字段
| 字段 | 类型 | 说明 |
|---|---|---|
type | string | 参数类型(见上表)。 |
value | string | 参数值或表达式。 |
min | double | 数值下限。计算结果低于此值时截断。 |
max | double | 数值上限。计算结果高于此值时截断。 |
decimals | integer | 小数位数。0 表示取整。 |
default | string | 默认值(表达式解析失败时使用)。 |
示例
expression 类型
yaml
variables:
damage:
type: expression
value: "10 + %level% * 5"
min: 10
max: 100
decimals: 0
range:
type: expression
value: "3 + %level% * 0.5"
max: 10
decimals: 1uniform 类型
yaml
variables:
bonus_damage:
type: uniform
value: "5~15"
decimals: 0random_text 类型
yaml
variables:
cast_message:
type: random_text
lines:
- "<red>火焰爆发!"
- "<red>燃烧吧!"
- "<red>烈焰之力!"候选列表的键名是 lines
random_text 只读取 lines。写成 values 不会报错,但候选列表为空。反之,只要写了 lines 且没写 type,类型会被自动判定为 random_text。
boolean 类型
yaml
variables:
is_aoe:
type: boolean
value: "%level% >= 5"在脚本中使用变量
变量解析后的值可在脚本动作、条件和文本中通过 %var.变量名% 引用:
yaml
script:
actions:
cast:
- 'trigger | damage amount=%var.damage%'
- 'trigger | where %var.is_aoe%==true | spawn_particle particle=EXPLOSION count=10'变量按声明顺序解析,后声明的变量可以引用先声明的变量:
yaml
variables:
damage:
type: expression
value: "10 + %level% * 5"
hit_message: "<red>造成 %damage% 点伤害"注入 MythicMobs
解析后的变量会注入 MythicMobs 技能元数据,在 MythicMobs 技能中通过 <skill.var.变量名> 读取。 另有 5 个内置变量始终注入:emaki_skill_id、emaki_skill_level、emaki_trigger_id、 emaki_is_passive、emaki_has_target。