概览
minecraft:behavior.delayed_attack 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 近战 AI 目标:伤害在攻击动画进行到一半时才生效,而不是立刻生效,比如劫掠兽的撕咬。
字段
| 字段 | 类型 | 默认值 | 说明 |
|---|---|---|---|
attack_duration | number | 0.75 | 攻击动画持续的秒数,同时也决定两次攻击之间的间隔。范围:0 到 … |
hit_delay_pct | number | 0.5 | 伤害在动画进行到哪个位置时生效。0.5 表示一半。范围:0 到 1 |
sound_event | LevelSoundEvent | "attack.strong" | 攻击开始时播放的声音事件。 |
reach_multiplier | number | 1.5 | 与生物体型相乘,得出它需要多近才能击中。范围:0 到 … |
on_kill | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | 此生物杀死目标时触发的事件。 |
melee_fov | number | 90 | 用于发现可攻击目标的视野角度。范围:0 到 … |
x_max_rotation | number | 30 | 注视目标时生物最多能上下倾斜的角度。范围:0 到 … |
y_max_head_rotation | number | 30 | 注视目标时生物头部最多能左右转动的角度。范围:0 到 … |
random_stop_interval | integer | 0 | 有 N 分之 1 的几率停止攻击,N 就是这个数字。范围:0 到 … |
attack_once | boolean | false | 为 true 时,生物只会进行一次这种攻击。 |
can_spread_on_fire | boolean | false | 为 true 时,空手且着火的生物击中目标时会把目标点燃。 |
min_path_time | number | 0.2 | 重新计算通往目标的路径前最短等待秒数。范围:0 到 … |
max_path_time | number | 0.55 | 重新计算通往目标的路径前最长等待秒数。范围:0 到 … |
path_fail_time_increase | number | 0.75 | 生物被卡住时,路径等待时间增加的秒数。范围:0 到 … |
inner_boundary_time_increase | number | 0.25 | 目标超出 path_inner_boundary 时,路径等待时间增加的秒数。范围:0 到 … |
outer_boundary_time_increase | number | 0.5 | 目标超出 path_outer_boundary 时,路径等待时间增加的秒数。范围:0 到 … |
path_inner_boundary | number | 16 | 超过此距离后应用 inner_boundary_time_increase。范围:0 到 … |
path_outer_boundary | number | 32 | 超过此距离后应用 outer_boundary_time_increase。范围:0 到 … |
speed_multiplier | number | 1 | 朝目标移动时的速度倍率。范围:0 到 … |
require_complete_path | boolean | false | 为 true 时,只有存在通往目标的完整路径,生物才会追击。 |
track_target | boolean | true | 为 true 时,即使没有感知组件,生物也会持续追踪目标。 |
attack_types | string | "" | 此生物会攻击哪些实体类型。 |
on_attack | ActorDefinitionTrigger | {"event":"","filters":{"AND":null,"NOT":null,"OR":null,"all":null,"all_of":null,"any":null,"any_of":null,"none_of":null},"target":"self"} | 每次攻击命中时触发的事件。 |
priority | integer | 0 | 数字越小越先执行:两个目标冲突时,priority 更小的那个胜出。范围:0 到 … |
control_flags | Goal's control flags[] | 无 | 此目标接管哪些身体部分(移动、看向、跳跃),占用相同部分的目标不能同时运行。 |
示例
写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):
BP/entities/<name>.json
{
"minecraft:behavior.delayed_attack": {
"attack_duration": 0.75,
"hit_delay_pct": 0.5,
"sound_event": "attack.strong",
"reach_multiplier": 1.5,
"on_kill": {
"event": "",
"filters": {
"AND": null,
"NOT": null,
"OR": null,
"all": null,
"all_of": null,
"any": null,
"any_of": null,
"none_of": null
},
"target": "self"
},
"melee_fov": 90,
"x_max_rotation": 30,
"y_max_head_rotation": 30
}
}