1. Wiki
  2. /实体
  3. /minecraft:behavior.nearest_attackable_target

minecraft:behavior.nearest_attackable_target

不想手写?在 GodCraft 里打开一个开关,就能帮你设置好 minecraft:behavior.nearest_attackable_target。Get GodCraft

概览

minecraft:behavior.nearest_attackable_target 是一个实体组件:写在自定义生物的 components 对象中,或其中某个组件组里。 从你列出的实体类型中选出最近的有效目标,并让生物去追击。这是敌对生物猎杀玩家或其他生物最常用的目标。

字段

字段类型默认值说明
reselect_targetsbooleanfalse设为 true 时,出现更近的目标就立即切换,而不是等下一次扫描。
attack_intervalFloatRange{"max":0,"min":0}两次寻找目标之间的随机时间范围(秒)。保持为 0 则改用 scan_interval。
scan_intervalinteger10未使用 attack_interval 时,两次寻找目标之间的刻数。数值太小可能让游戏变卡。范围:1 到 …
target_search_heightnumber-1在上下方向上寻找目标的范围。负值会使用 entity_types 中最大的 max_dist。范围:-1 到 …
target_invisible_multipliernumber0.7根据隐身目标穿戴的盔甲多少,缩小对它的侦测范围。
target_sneak_visibility_multipliernumber0.8目标潜行时侦测范围的倍率。用小于 1 的值让潜行的玩家更难被发现。
set_persistentbooleanfalse设为 true 时,生物锁定玩家后就不会消失。
target_acquisition_probabilitynumber1生物真正选中已发现目标的几率(0 到 1)。调低可以让生物不那么好斗。
attack_ownerbooleanfalse设为 true 时,被驯服的生物可以攻击自己的主人。
must_reachbooleanfalse设为 true 时,生物只选择能走到的目标。
must_seebooleanfalse设为 true 时,生物必须能看见目标,光在范围内还不够。
within_radiusnumber0目标走多远后生物会放弃。只在生物没有 minecraft:follow_range 时使用。范围:0 到 …
must_see_forget_durationnumber3目标离开视线多少秒后生物会忘记它。只在 must_see 为 true 时使用。范围:0 到 …
persist_timenumber0目标失效后生物继续攻击的秒数。范围:0 到 …
entity_typesEntityTypes无生物可以锁定哪些实体,每项都可设置过滤器和可选的最大距离。
priorityinteger0多个目标同时想运行时决定谁优先:数字越小越先运行。范围:0 到 …
control_flagsGoal's control flags[]无列出这个目标要控制的身体部分(比如移动、看向或跳跃),这样需要同一部分的目标就不会同时运行。

示例

写在 BP/entities/<name>.json 的 components 对象中(值为默认值或占位值):

BP/entities/<name>.json
{
  "minecraft:behavior.nearest_attackable_target": {
    "reselect_targets": false,
    "attack_interval": {
      "max": 0,
      "min": 0
    },
    "scan_interval": 10,
    "target_search_height": -1,
    "target_invisible_multiplier": 0.7,
    "target_sneak_visibility_multiplier": 0.8,
    "set_persistent": false,
    "target_acquisition_probability": 1
  }
}

We use cookies to improve your experience and analyse site traffic. Learn more