实现功能
- 首次对话初始化对应权限,跳转对应聊天框
- 完成 任务1:破坏10个石头
- 完成 任务2:收集10个泥土
- 完成 任务3:击杀10只牛
- 完成 任务123 后解锁对话 任务4
- 完成任务4 移动指定坐标 领取最终奖励
任务配置
任务文件:core/quest/quest_pre.yml
任务1:破坏10个石头
break_stone_10:
meta:
name: "破坏10个石头"
description: "破坏10个石头作为任务1"
objective:
1:
event: "block break"
node:
material:
- "STONE"
amount: 10
addon:
ui:
display:
- "&r目标:破坏10个石头"
- "&7- 已完成 {progress_1}/10 {is_complete_1}"
trigger:
accept: |
tell "任务已接取:破坏10个石头!"
complete: |
tell "任务完成!继续完成其他任务来解锁最终目标"
command papi "lp user %player_name% permission set break_stone_10 true" as console
command papi "storage remove %player_name% break_stone_10" as console
任务文件:core/quest/quest_pre.yml
任务2:收集10个泥土
collec_dirt_10:
meta:
name: "收集10个泥土"
description: "收集10个泥土作为任务2"
objective:
1:
event: "player collect"
node:
item: minecraft -material dirt
consume: false #是否开启收集物品后自动扣除
amount: 10
addon:
ui:
display:
- "&r目标:收集10个泥土"
- "&7- 已完成 {progress_1}/10 {is_complete_1}"
trigger:
accept: |
tell "任务已接取:收集10个泥土!"
complete: |
tell "任务完成!继续完成其他任务来解锁最终目标。"
command papi "lp user %player_name% permission set collec_dirt_10 true" as console
command papi "storage remove %player_name% collec_dirt_10" as console
任务文件:core/quest/quest_pre.yml
任务3:击杀10只牛
kill_cow_10:
meta:
name: "击杀10只牛"
description: "击杀10只牛作为任务3"
objective:
1:
event: "player kill"
node:
entity:
- "minecraft:cow"
amount: 10
addon:
ui:
display:
- "&r目标:击杀10只牛"
- "&7- 已完成 {progress_1}/10 {is_complete_1}"
trigger:
accept: |
tell "任务已接取:击杀10只牛!"
complete: |
tell "任务完成!继续完成其他任务来解锁最终目标。"
command papi "lp user %player_name% permission set kill_cow_10 true" as console
command papi "storage remove %player_name% kill_cow_10" as console
任务文件:core/quest/quest_pre.yml
最终任务4:移动到指定目标坐标
move_to_location:
meta:
name: "移动到指定位置"
description: "完成前置任务后,移动到指定位置 (55, 55, 128)。"
objective:
1:
event: "player move"
node:
position: "world 55 55 128 ~ 5"
agent:
track:
navigate:
title: "&6目标:移动到 (55, 55, 128)"
location: "world 55 55 128"
addon:
ui:
display:
- "&r目标:前往指定位置"
trigger:
accept: |
tell "任务已接取:移动到世界 world 的坐标 (55, 55, 128)。"
complete: |
tell "恭喜你完成最终任务!"
command papi "give %player_name% minecraft:diamond 1" as console
对话配置
对话文件:core/conversation/npc_quest_pre.yml
#绑定 npc 对话,检测之后自动跳转对应的对话框
npc_quest_dialogue:
when:
# 首次对话,初始化权限后跳转到前置对话框
- if: not storage has initialized_quest
open: initialize_permissions
# 检测是否完成所有前置任务,跳转到最终对话框
- if: |
all [
permission break_stone_10
permission collec_dirt_10
permission kill_cow_10 ]
open: final_quest_dialogue
# 默认跳转到前置对话框
- open: pre_quest_dialogue
#初始化权限对话
initialize_permissions:
content:
- "你好冒险者,开始接受我的考验吧!"
answer:
- text: "好的,接受任务!"
action: |
command papi "lp user %player_name% permission set break_stone_10 false" as console
command papi "lp user %player_name% permission set collec_dirt_10 false" as console
command papi "lp user %player_name% permission set kill_cow_10 false" as console
command papi "storage set %player_name% initialized_quest true" as console
# 等待一秒跳转任务对话框 pre_quest_dialogue
sleep 1s
session open pre_quest_dialogue
# 默认跳转到前置对话框
pre_quest_dialogue:
content:
- "你还未完成所有任务,请继续努力!"
answer:
- text: "接受任务1:破坏10个石头"
if: all [ not storage has break_stone_10 not permission break_stone_10 ]
action: |
choose quest break_stone_10 quest accept
command papi "storage set %player_name% break_stone_10 true" as console
- text: "接受任务2:收集10个泥土"
if: all [ not storage has collec_dirt_10 not permission collec_dirt_10 ]
action: |
choose quest collec_dirt_10 quest accept
command papi "storage set %player_name% collec_dirt_10 true" as console
- text: "接受任务3:击杀10只牛"
if: all [ not storage has kill_cow_10 not permission kill_cow_10 ]
action: |
choose quest kill_cow_10 quest accept
command papi "storage set %player_name% kill_cow_10 true" as console
- text: "再见~"
action: |
tell "拜拜~"
final_quest_dialogue:
content:
- "恭喜完成了所有考验,现在可以接受我的最终试炼"
answer:
- text: "接受最终任务:移动到指定坐标"
#接受任务之后防止被薅羊毛
#检测是否有 薅羊毛 键值;没有接受该任务
if: storage not 薅羊毛
action: |
choose quest move_to_location quest accept
command papi "storage set %player_name% 薅羊毛 true" as console
- text: "再见~"
action: |
tell "拜拜~"