主题
概述
hna-attribute 是通用的属性值判断条件,可以用于任何属性的值比较。
基本语法
yaml
- hna-attribute{参数} true/false参数列表
| 参数 | 别名 | 类型 | 默认值 | 说明 |
|---|---|---|---|---|
attribute | attr, a | 字符串 | - | 属性 ID(必填) |
value | amount, v | 数值 | - | 比较的目标值(必填) |
operator | op, o | 字符串 | >= | 比较操作符 |
比较操作符
| 操作符 | 别名 | 说明 |
|---|---|---|
>= | ge | 大于等于 |
> | gt | 大于 |
<= | le | 小于等于 |
< | lt | 小于 |
== | eq, = | 等于 |
!= | ne | 不等于 |
基本示例
yaml
# 检查攻击力是否 >= 50
- hna-attribute{attribute=attack_damage;value=50;operator=>=} true
# 短写形式
- hna-attribute{attr=attack_damage;v=50;op=>=} true常见使用场景
场景 1:法力值判断
yaml
FireballSkill:
Skills:
# 检查是否有至少 30 点法力值
- hna-attribute{attribute=current_mana;value=30;operator=>=} true
# 法力值足够,释放火球术
- hna-damage{amount=100;damage-type=fire;source-type=skill} @target
# 消耗 30 点法力值
- hna-attribute{attribute=current_mana;amount=-30;source=fireball_cost} @self场景 2:攻击力判断
yaml
PowerStrike:
Skills:
# 检查攻击力是否达到 50
- hna-attribute{attribute=attack_damage;value=50;operator=>=} true
- hna-damage{multiplier=2.0;source-type=skill} @target
# 攻击力不足
- hna-attribute{attribute=attack_damage;value=50;operator=<} true
- message{m="&c攻击力不足!"} @Self场景 3:生命值判断
yaml
ExecuteSkill:
Skills:
# 检查目标生命值是否低于 30%
- hna-attribute{attribute=current_health;value=30;operator=<} true
- hna-damage{amount=500;source-type=skill} @target
- message{m="&c斩杀!"} @Self场景 4:抗性判断
yaml
FireSpell:
Skills:
# 检查目标火焰抗性是否低于 20
- hna-attribute{attribute=fire_resistance;value=20;operator=<} true
- hna-damage{amount=200;damage-type=fire} @target
# 抗性太高
- hna-attribute{attribute=fire_resistance;value=20;operator=>=} true
- message{m="&e目标火焰抗性太高!"} @Self场景 5:多条件判断
yaml
ComplexSkill:
Skills:
# 检查法力值 >= 50
- hna-attribute{attribute=current_mana;value=50;operator=>=} true
# 检查攻击力 >= 100
- hna-attribute{attribute=attack_damage;value=100;operator=>=} true
# 条件满足,释放技能
- hna-damage{multiplier=3.0;source-type=skill} @target
- message{m="&a强力一击!"} @Self完整技能示例
yaml
ManaShield:
Cooldown: 30
Skills:
# 检查当前法力值是否 >= 100
- hna-attribute{attribute=current_mana;value=100;operator=>=} true
# 法力值足够,激活护盾
- hna-buff{key="法力护盾";time=200;level=1} @Self
- effect:particles{p=ENCHANTMENT_TABLE;a=50} @Self
- message{m="&b法力护盾已激活!"} @Self
# 消耗 100 点法力值
- hna-attribute{attribute=current_mana;amount=-100;source=mana_shield_cost} @self
# 法力值不足
- hna-attribute{attribute=current_mana;value=100;operator=<} true
- message{m="&c法力值不足!需要 100 点法力值。"} @Self适用属性
可以用于任何在 attributes.yml 中定义的属性:
max_health:最大生命值current_health:当前生命值max_mana:最大法力值current_mana:当前法力值mana_deficit:法力值缺失量attack_damage:攻击力fire_damage:火焰伤害ice_damage:冰霜伤害fire_resistance:火焰抗性physical_resistance:物理抗性crit_chance:暴击率crit_damage:暴击伤害- ... 以及所有自定义属性
与其他条件的区别
| 条件 | 用途 |
|---|---|
hna-attribute | 判断任意属性的值(通用) |
hna-hasbuff | 判断是否有某个 Buff |
hna-hasot | 判断是否有某个周期效果 |
注意事项
attribute必须是attributes.yml中定义的属性 ID- 属性名区分大小写
- 默认操作符是
>= - 可以用于任何实体(玩家、怪物等)
- 需要明确的目标选择器
调试方法
text
/hnattr inspect
/hnattr source
/hnattr trace <属性ID>