跳到主要内容

逻辑动作

把一组动作包起来:看条件执行、随机抽、一个一个慢慢放、对所有人放。这一页的 4 种类型在编辑器的「逻辑」分类里,里面装的还是普通动作。

例子​

声望够高多给一份,再抽一次奖:

plugins/StarQuest/quests/示例/年终谢礼.yml
format: 1
id: 年终谢礼
name: '&6年终谢礼'
category: 示例
icon: CHEST
settings:
start: {command: true}
repeat: {mode: once}
rewards:
- {type: give, item: BREAD, amount: 16}
- type: if
conditions: [{type: point, point: 星月村声望, compare: '>=', value: 100}]
then: [{type: give, item: DIAMOND, amount: 3}]
else: [{type: message, text: '&7声望再高一点,村长会多给你一些东西。'}]
- type: random
pick: 1
actions:
- {type: give, item: EMERALD, amount: 5, weight: 3}
- {type: give, item: NETHERITE_SCRAP, amount: 1, weight: 1}
reward-display: ['面包 ×16', '声望 100 以上:钻石 ×3', '抽一份:绿宝石 ×5 或下界合金碎片']
nodes:
开始:
type: start
x: 0
y: 100
next: [道谢]
道谢:
type: objective
x: 260
y: 100
track-text: 去找村长道谢
goals:
- {type: npc, npc: 村长, display: '找村长'}
next: [完成]
完成:
type: end
x: 520
y: 100
result: complete

如果……就…… if​

条件满足执行 then,否则执行 else。

  • conditions(条件):必填,写法见 条件
  • then(满足时):必填,动作列表
  • else(不满足时):动作列表,可以不写
- type: if
conditions: [{type: tag, tag: 阵营_光}]
then: [{type: title, title: '&e光明与你同在'}]
else: [{type: title, title: '&8暗影在低语'}]

只有一个动作要看条件时,用通用栏位 if 更短:{type: give, item: DIAMOND, amount: 1, if: [...]}。

随机抽奖 random​

从一组动作里按权重抽几个执行,同一个不会被抽两次。

  • actions(候选动作):必填,每个可以加 weight 权重,默认 1
  • pick(抽几个):默认 1
- type: random
pick: 2
actions:
- {type: give, item: DIAMOND, amount: 1, weight: 1}
- {type: give, item: GOLD_INGOT, amount: 4, weight: 3}
- {type: give, item: IRON_INGOT, amount: 8, weight: 6}

依序执行(可延迟) sequence​

一组动作依序执行,每个之间隔一段时间,做小剧场很方便。

  • actions(动作):必填
  • interval(间隔):默认 1s
- type: sequence
interval: 2s
actions:
- {type: message, text: '&7地面开始震动……'}
- {type: sound, sound: entity.warden.emerge}
- {type: title, title: '&4它来了'}
- {type: mythic-spawn, mob: 深渊守望者}

对所有在线玩家 for-online​

对每个在线玩家各执行一次,可以只挑满足条件的人。

  • actions(动作):必填
  • where(只对满足条件的玩家):条件列表
- {type: global-var, var: 首杀者, value: '{player}'}
- type: for-online
where: [{type: world, world: [world]}]
actions:
- {type: title, title: '&6世界首杀', subtitle: '&7{global:首杀者}'}

actions 里的 {player} 是每个收到的玩家自己,所以上面先用 global-var 把打出首杀的人记下来,再用 {global:首杀者} 显示。

会踩的坑​

random 本身不会出现在奖励栏,玩家不知道能抽到什么。放在完成奖励里时记得写 reward-display,见 随机奖励。

if 写在完成奖励里时,奖励栏显示的是 then 那一组,不管玩家实际满不满足。条件奖励最好也写 reward-display 说清楚。

sequence 的间隔是从第一个动作开始算:第二个在 1 秒后、第三个在 2 秒后。玩家中途下线,没放完的就不放了。

0:000:00