LTCatt пре 6 година
родитељ
комит
d507924f27

+ 1 - 0
data/ltw/functions/init.mcfunction

@@ -90,6 +90,7 @@ scoreboard objectives add stat_win dummy "总胜场"
 # 常量与变量初始化
 scoreboard players set #mini_total mem 5
 scoreboard players set #const_2 mem 2
+scoreboard players set #const_4 mem 4
 scoreboard players set #const_5 mem 5
 scoreboard players set #const_9 mem 9
 scoreboard players set #const_10 mem 10

+ 1 - 1
data/ltw/functions/state/0/state_enter.mcfunction

@@ -29,4 +29,4 @@ scoreboard players set $tempo_enable mem 1
 function ltw:state/0/parkour/tempo_block/marker_spawn
 
 # 重置开始倒计时
-scoreboard players set $countdown mem 0
+scoreboard players set #start_countdown mem 9999

+ 2 - 29
data/ltw/functions/state/0/tick20.mcfunction

@@ -1,30 +1,3 @@
 
-# 检查已准备人数
-execute store result score $count mem if entity @a[tag=lobby_ready]
-
-# 开始:提示开始
-execute if score $count mem matches 3.. if score $countdown mem matches 99.. run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]
-execute if score $count mem matches 3.. if score $countdown mem matches 99.. as @a at @s run function lib:sounds/levelup
-execute if score $count mem matches 3.. if score $countdown mem matches 99.. run scoreboard players set $countdown mem 40
-
-# 取消:提示取消
-execute if score $count mem matches ..2 if score $countdown mem matches ..99 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","bold": true},"已准备人数不足, 游戏取消!"]
-execute if score $count mem matches ..2 if score $countdown mem matches ..99 as @a at @s run function lib:sounds/error
-execute if score $count mem matches ..2 if score $countdown mem matches ..99 run scoreboard players set $countdown mem 999
-
-# 20s:提示未准备
-execute if score $countdown mem matches 20 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
-
-# 30、10s:提示玩家数量过多
-execute if score $countdown mem matches 30 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
-execute if score $countdown mem matches 10 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
-
-# 10-:播放音效
-execute if score $countdown mem matches 1..10 run execute as @a at @s run function lib:sounds/hit2
-
-# 0:开始游戏
-execute if score $countdown mem matches 0 run function ltw:state/0/start_game
-
-# 显示信息
-execute if score $countdown mem matches ..99 run title @a actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#time","objective":"mem"}}," 秒后开始游戏"]
-execute if score $countdown mem matches 99.. run title @a actionbar [{"text":"","color":"red"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | 准备人数不足"]
+# 播放倒计时音效
+execute if score #start_countdown mem matches 0..40 run execute as @a at @s run function lib:sounds/hit2

+ 36 - 0
data/ltw/functions/state/0/tick5.mcfunction

@@ -9,3 +9,39 @@ execute as @a at @s if entity @s[x=0,y=28,z=-46,distance=..4] run advancement gr
 # 隐藏/显示老板的名片
 execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s if entity @a[distance=..5] run data modify entity @s CustomNameVisible set value true
 execute as @e[type=piglin,tag=shop_piglin_11,tag=lobby_entity] at @s unless entity @a[distance=..5] run data modify entity @s CustomNameVisible set value false
+
+# ————————————————————————————————————————————————————————————————————————————
+# 游戏准备检查部分
+# ————————————————————————————————————————————————————————————————————————————
+
+# 检查已准备人数
+execute store result score $count mem if entity @a[tag=lobby_ready]
+
+# 开始:提示开始
+execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run tellraw @a [{"text":"","color":"green"},{"text": ">> ","bold": true},"游戏即将开始, 请使用快捷栏最后一格确定自己是否参与!"]
+execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. as @a at @s run function lib:sounds/levelup
+execute if score $count mem matches 3.. if score #start_countdown mem matches 999.. run scoreboard players set #start_countdown mem 161
+
+# 取消:提示取消
+execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run tellraw @a [{"text":"","color":"red"},{"text": ">> ","bold": true},"已准备人数不足, 游戏取消!"]
+execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 as @a at @s run function lib:sounds/error
+execute if score $count mem matches ..2 if score #start_countdown mem matches ..999 run scoreboard players set #start_countdown mem 9999
+
+# 计算实际时间
+scoreboard players remove #start_countdown mem 1
+scoreboard players operation #start_sec mem = #start_countdown mem
+scoreboard players operation #start_sec mem %= #const_4 mem
+
+# 20s:提示未准备
+execute if score #start_sec mem matches 20 run tellraw @a[tag=!lobby_ready] [{"text":"","color":"red"},{"text":">> ","bold": true},"你现在还没有准备, 如果要参加游戏, 请丢出快捷栏最后一格的物品!"]
+
+# 30、10s:提示玩家数量过多
+execute if score #start_sec mem matches 30 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
+execute if score #start_sec mem matches 10 if score $count mem matches 9.. run tellraw @a [{"text":"","color":"gold"},{"text":">> ","bold": true},"游戏最多支持 8 人, 当前已有 ",{"score": { "name": "$count","objective": "mem"}}, " 人, 将随机抽取 8 人开始游戏!"]
+
+# 0s:开始游戏
+execute if score #start_sec mem matches 0 run function ltw:state/0/start_game
+
+# 显示信息
+execute if score #start_countdown mem matches ..999 run title @a actionbar [{"text":"","color":"green"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | ","将在 ",{"score":{"name":"#start_sec","objective":"mem"}}," 秒后开始游戏"]
+execute if score #start_countdown mem matches 999.. run title @a actionbar [{"text":"","color":"red"},{"score":{"name":"$count","objective":"mem"}}," 人已准备 | 人数不足"]