主题
这页收集了 HNAttribute 里最常见的公式使用场景,尽量都用当前推荐格式来写。
Buff 相关
等级越高加成越大
yml
狂暴:
display: "&c狂暴"
default-time: 100
attributes:
attack_damage:
operation: ADD
formula: "level * level * 2"
# 1级 = 2
# 2级 = 8
# 3级 = 18
# 4级 = 32随时间衰减的 Buff
yml
衰减效果:
display: "&e衰减"
default-time: 100
attributes:
attack_damage:
operation: ADD
formula: "level * 10 * (time / duration)"
# 刚施加:100% 效果
# 剩余 50%:50% 效果
# 即将结束:接近 0随时间增强的 Buff
yml
蓄力:
display: "&a蓄力"
default-time: 100
attributes:
attack_damage:
operation: ADD
formula: "level * 10 * (1 - time / duration)"
# 刚施加:0% 效果
# 剩余 50%:50% 效果
# 即将结束:100% 效果时间阈值判断
yml
爆发:
display: "&6爆发"
default-time: 100
attributes:
attack_damage:
operation: ADD
formula: "time < 20 ? level * 50 : level * 10"
# 最后 1 秒(20 tick):50 倍加成
# 其他时间:10 倍加成属性映射相关
分段增长
yml
intellect:
display: "&9智力"
priority: 100
mapping:
targets:
magic_damage:
operation: ADD
formula: |-
if (total <= 50) {
return total * 0.8
} else if (total <= 100) {
return 40 + (total - 50) * 1.2
} else {
return 100 + (total - 100) * 1.5
}
# 0-50 智力:每点 = 0.8 魔法伤害
# 51-100 智力:每点 = 1.2 魔法伤害
# 100+ 智力:每点 = 1.5 魔法伤害递减增长(平方根)
yml
vitality:
display: "&a体质"
priority: 100
mapping:
targets:
max_health:
operation: ADD
formula: "10 * Math.sqrt(total)"
# 1 体质 = 10 生命
# 4 体质 = 20 生命
# 9 体质 = 30 生命
# 增长率递减指数增长
yml
level:
display: "&e等级"
priority: 200
mapping:
targets:
max_health:
operation: ADD
formula: "Math.pow(1.1, total) * 10"
# 等级越高,增长越快限制上限
yml
agility:
display: "&2敏捷"
priority: 100
mapping:
targets:
dodge_rate:
operation: ADD
formula: "Math.min(total * 0.5, 50)"
# 每点敏捷 = 0.5% 闪避率
# 最高 50% 闪避率限制范围
yml
luck:
display: "&6幸运"
priority: 100
mapping:
targets:
critical_rate:
operation: ADD
formula: "Math.max(5, Math.min(total * 0.3, 80))"
# 最低 5% 暴击率
# 最高 80% 暴击率周期效果相关
血量越低效果越强
yml
背水一战:
enabled: true
selector: players
interval: 20
condition: "target_health < target_max_health * 0.3"
actions:
- type: buff
buff-key: "背水Buff"
duration: 40
level: "Math.ceil((1 - target_health / target_max_health) * 5)"
# 血量 70%:1级
# 血量 50%:2级
# 血量 30%:3级
# 血量 10%:4级基于双方属性的伤害
yml
魔法反噬:
enabled: true
mode: instance
selector: mobs
interval: 40
instance:
source: nearest-player
interval: 20
duration: 100
actions:
- type: damage
amount: "Math.max(1, source_magic_damage - target_magic_resistance)"
# 伤害 = 施法者魔法伤害 - 目标魔法抗性
# 最少造成 1 点伤害基于目标属性的回复
yml
生命恢复:
enabled: true
selector: players
interval: 20
condition: "target_health < target_max_health"
actions:
- type: heal
amount: "target_health_regen + target_max_health * 0.01"
# 回复量 = 生命恢复属性 + 最大生命值的 1%基于来源属性的伤害
yml
流血:
enabled: true
mode: instance
selector: mobs
interval: 20
instance:
source: nearest-player
interval: 20
duration: 100
actions:
- type: damage
amount: "source_attack_damage * 0.1"
# 伤害 = 施法者攻击力的 10%战斗管线相关
按通道做门控
这个例子适合“有火焰数值,但只有火焰赋予开启时才允许打出火伤”的场景。
yml
# stages/fire_gate.yml
id: fire_gate
type: per_channel
description: "火焰通道门控"
formula: |-
if (channel_type == 'fire' && self_fire_imbue <= 0) {
return 0
}
return channel_value然后把它放进对应 Pipeline:
yml
# pipelines/melee.yml
id: melee
stages:
- hit
- dodge
- crit
- block
- collect
- damage
- fire_gate
- resist
- crit_damage
- lifesteal
- thorns暴击伤害修正
yml
# stages/crit_damage.yml
id: crit_damage
type: modifier
depends_on:
- damage
description: "暴击伤害修正"
formula: |-
if (!crit) {
return damage
}
return damage * Math.max(1, self_crit_multiplier / 100)斩杀判定 + 斩杀增伤
yml
# stages/execute_check.yml
id: execute_check
type: boolean
description: "斩杀判定"
formula: |-
if (target_max_health <= 0) {
return 0
}
return target_health / target_max_health <= 0.3 ? 1 : 0yml
# stages/execute_bonus.yml
id: execute_bonus
type: modifier
depends_on:
- damage
description: "斩杀增伤"
formula: |-
if (!execute_check) {
return damage
}
return damage * 1.2PVP 伤害调整
yml
# stages/pvp_reduction.yml
id: pvp_reduction
type: modifier
depends_on:
- damage
description: "PVP 伤害降低"
formula: |-
if (context_type != 'player-player') {
return damage
}
return damage * 0.7多条件增伤
yml
# stages/physical_combo.yml
id: physical_combo
type: modifier
depends_on:
- damage
description: "物理暴击斩杀连携"
formula: |-
if (damage_type != 'physical') {
return damage
}
if (!crit) {
return damage
}
if (target_max_health <= 0) {
return damage
}
if (target_health / target_max_health > 0.5) {
return damage
}
return damage * 1.5复杂组合
生命链接
yml
生命链接:
enabled: true
mode: instance
selector: players
interval: 20
instance:
source: nearest-player
interval: 20
duration: 100
condition: |-
target_health < target_max_health * 0.5 &&
source_health > source_max_health * 0.5
actions:
- type: heal
amount: "source_max_health * 0.05"
- type: damage
amount: "source_max_health * 0.05"
target: source
# 目标血量低于 50%,来源血量高于 50%
# 治疗目标,同时让来源承担代价多段映射计算
yml
strength:
display: "&c力量"
priority: 100
mapping:
targets:
attack_damage:
operation: ADD
formula: |-
double base = 0
if (total <= 100) {
base = total * 1.0
} else if (total <= 200) {
base = 100 + (total - 100) * 0.8
} else if (total <= 300) {
base = 180 + (total - 200) * 0.6
} else {
base = 240 + (total - 300) * 0.4
}
return Math.floor(base)
# 0-100:1.0 倍率
# 101-200:0.8 倍率
# 201-300:0.6 倍率
# 300+:0.4 倍率
# 最后向下取整相关文档
- 公式系统概述 - 了解公式语法
- 运算符与函数参考 - 查看可用的运算符和函数
- Buff 配置变量参考 - Buff 中可用的变量
- 周期效果配置变量参考 - 周期效果中可用的变量
- 属性映射配置变量参考 - 属性映射中可用的变量
- 战斗管线配置变量参考 - 战斗管线中可用的变量
