Kaynağa Gözat

小游戏完成模式更改

LTCatt 6 yıl önce
ebeveyn
işleme
dab7e30508

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

@@ -14,6 +14,7 @@ gamerule doImmediateRespawn true
 gamerule mobGriefing false
 gamerule mobGriefing false
 gamerule randomTickSpeed 0
 gamerule randomTickSpeed 0
 gamerule fireDamage false
 gamerule fireDamage false
+gamerule doTileDrops false
 
 
 # 记分板
 # 记分板
 scoreboard objectives remove mem
 scoreboard objectives remove mem

+ 1 - 0
data/ltw/functions/main/player_enter_rejoin.mcfunction

@@ -9,6 +9,7 @@ tag @s add mini_rank4
 
 
 # 重新加入阶段
 # 重新加入阶段
 tag @s add rejoining
 tag @s add rejoining
+function mini:main/update_player_count
 execute if score $state mem matches 0 run function ltw:state/0/player_enter
 execute if score $state mem matches 0 run function ltw:state/0/player_enter
 execute if score $state mem matches 3 run function ltw:state/3/player_enter
 execute if score $state mem matches 3 run function ltw:state/3/player_enter
 execute if score $state mem matches 4 run function ltw:state/4/player_enter
 execute if score $state mem matches 4 run function ltw:state/4/player_enter

+ 0 - 2
data/ltw/functions/main/player_leave.mcfunction

@@ -3,5 +3,3 @@
 execute store result score $t_count mem if entity @a[tag=!watcher]
 execute store result score $t_count mem if entity @a[tag=!watcher]
 execute if score $state mem matches 1.. if score $game_type mem matches 1 if score $t_count mem matches ..2 run function ltw:main/game_end
 execute if score $state mem matches 1.. if score $game_type mem matches 1 if score $t_count mem matches ..2 run function ltw:main/game_end
 execute if score $state mem matches 1.. if score $game_type mem matches 1 if score $t_count mem matches ..2 run tellraw @a {"text": "由于玩家人数不足, 游戏直接结束!","color":"red"}
 execute if score $state mem matches 1.. if score $game_type mem matches 1 if score $t_count mem matches ..2 run tellraw @a {"text": "由于玩家人数不足, 游戏直接结束!","color":"red"}
-
-# TODO 小游戏结束逻辑可能导致卡住

+ 2 - 3
data/mini/functions/colormatch/game_init.mcfunction

@@ -9,10 +9,9 @@ fill 1075 11 3999 1049 40 3999 stone
 fill 1049 11 3999 1049 40 4025 stone
 fill 1049 11 3999 1049 40 4025 stone
 fill 1049 11 4025 1075 40 4025 stone
 fill 1049 11 4025 1075 40 4025 stone
 
 
-# 设置分数
+# 初始化
+scoreboard players set $finish_mode mem 0
 scoreboard players set $color_match_time mem 70
 scoreboard players set $color_match_time mem 70
-
-# 设置模式为地板消失
 scoreboard players set $color_match_type mem 0
 scoreboard players set $color_match_type mem 0
 
 
 # 刷新地基
 # 刷新地基

+ 0 - 14
data/mini/functions/hotpm/game/pm_boom.mcfunction

@@ -1,14 +0,0 @@
-# 玩家失败
-
-tellraw @a [{"text":">> ","color":"gold","bold": true},{"selector":"@s","color":"yellow","bold": false},{"text":" 爆炸了!","color":"white","bold": false}]
-# 玩家失去土豆
-function mini:hotpm/game/pm_lost
-# 特效
-summon minecraft:creeper ~ ~-1 ~ {ignited:1,ExplosionRadius:1,Fuse:0,Invulnerable:1}
-particle minecraft:explosion ~ ~1 ~ 0.4 0.4 0.4 0 5
-# 记录位置
-summon minecraft:area_effect_cloud ~ ~ ~ {Tags:["pm_boom"]}
-# 减少生命
-function mini:hotpm/player_lose_heart
-# 选新土豆
-execute if score $alive mem matches 2.. as @e[type=area_effect_cloud,tag=pm_boom] at @s run function mini:hotpm/game/pm_init

+ 3 - 2
data/mini/functions/hotpm/game/pm_init_first.mcfunction

@@ -1,2 +1,3 @@
-#第一次初始化土豆
-execute as @r[tag=mini_running] run function mini:hotpm/game/pm_init
+# 第一次初始化土豆
+execute as @r[tag=mini_running] run function mini:hotpm/game/pm_init
+# TODO : 选择 total_score 最高的玩家作为第一个土豆

+ 2 - 0
data/mini/functions/hotpm/game_init.mcfunction

@@ -1,6 +1,8 @@
 # 初始化热土豆地图
 # 初始化热土豆地图
 forceload add 1000 3000 1100 3100
 forceload add 1000 3000 1100 3100
 
 
+scoreboard players set $finish_mode mem 0
+
 # 关闭伤害
 # 关闭伤害
 gamerule fallDamage false
 gamerule fallDamage false
 
 

+ 13 - 1
data/mini/functions/hotpm/player_lose_heart.mcfunction

@@ -1,2 +1,14 @@
 # 玩家失败时由玩家自己触发
 # 玩家失败时由玩家自己触发
-function mini:main/player_lose_heart
+
+tellraw @a [{"text":">> ","color":"gold","bold": true},{"selector":"@s","color":"yellow","bold": false},{"text":" 爆炸了!","color":"white","bold": false}]
+# 玩家失去土豆
+function mini:hotpm/game/pm_lost
+# 特效
+summon minecraft:creeper ~ ~-1 ~ {ignited:1,ExplosionRadius:1,Fuse:0,Invulnerable:1}
+particle minecraft:explosion ~ ~1 ~ 0.4 0.4 0.4 0 5
+# 记录位置
+summon minecraft:area_effect_cloud ~ ~ ~ {Tags:["pm_boom"]}
+# 减少生命
+function mini:main/player_lose_heart
+# 选新土豆
+execute if score $player_alive mem matches 2.. as @e[type=area_effect_cloud,tag=pm_boom] at @s run function mini:hotpm/game/pm_init

+ 1 - 1
data/mini/functions/hotpm/tick2.mcfunction

@@ -3,4 +3,4 @@ execute if score $countdown_fast mem matches 1.. run title @a[tag=pm_hoding] act
 execute if score $countdown_fast mem matches 1.. run title @a[tag=!pm_hoding] actionbar [{"text":"土豆爆炸: ","color":"green","bold": true},{"score": { "name": "$countdown_fast","objective": "mem"}}]
 execute if score $countdown_fast mem matches 1.. run title @a[tag=!pm_hoding] actionbar [{"text":"土豆爆炸: ","color":"green","bold": true},{"score": { "name": "$countdown_fast","objective": "mem"}}]
 
 
 # 爆炸
 # 爆炸
-execute if score $countdown_fast mem matches 0 as @a[tag=pm_hoding] at @s run function mini:hotpm/game/pm_boom
+execute if score $countdown_fast mem matches 0 as @a[tag=pm_hoding] at @s run function mini:hotpm/player_lose_heart

+ 6 - 0
data/mini/functions/main/check_game_end.mcfunction

@@ -0,0 +1,6 @@
+# 检查游戏是否可以结束
+
+function mini:main/update_player_count
+
+execute if score $state mem matches 5 if score $finish_mode mem matches 1 if score $player_finish mem matches 3.. run function mini:main/game_end
+execute if score $state mem matches 5 if score $player_alive mem matches ..1 run function mini:main/game_end

+ 2 - 3
data/mini/functions/main/player_enter.mcfunction

@@ -1,12 +1,11 @@
 # 单个玩家开始小游戏时执行
 # 单个玩家开始小游戏时执行
+
 tag @s remove mini_running
 tag @s remove mini_running
 tag @s[tag=!rejoining,tag=!watcher] add mini_running
 tag @s[tag=!rejoining,tag=!watcher] add mini_running
 scoreboard players set @s mini_score 0
 scoreboard players set @s mini_score 0
 scoreboard players set @s[tag=rejoining] mini_score -1000
 scoreboard players set @s[tag=rejoining] mini_score -1000
 scoreboard players set @s[tag=watcher] mini_score -1000000
 scoreboard players set @s[tag=watcher] mini_score -1000000
-
-# 计算玩家数量
-execute store result score $alive mem if entity @a[tag=mini_running,tag=!watcher]
+function mini:main/update_player_count
 
 
 execute if score $mini_type mem matches 1 run function mini:parkour/player_enter
 execute if score $mini_type mem matches 1 run function mini:parkour/player_enter
 execute if score $mini_type mem matches 2 run function mini:tntrun/player_enter
 execute if score $mini_type mem matches 2 run function mini:tntrun/player_enter

+ 4 - 6
data/mini/functions/main/player_failed.mcfunction

@@ -2,11 +2,10 @@
 
 
 # 计数
 # 计数
 tag @s remove mini_running
 tag @s remove mini_running
-execute store result score $alive mem if entity @a[tag=mini_running,tag=!watcher]
-execute store result score $t_finish mem if entity @a[tag=!mini_running,tag=!watcher]
+function mini:main/update_player_count
 
 
 # 显示提示
 # 显示提示
-execute if entity @s[tag=!rejoining] if score $alive mem matches 1.. run tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$alive","objective": "mem"}}," 人!"]
+execute if entity @s[tag=!rejoining] if score $player_alive mem matches 1.. run tellraw @a [{"selector": "@s","color":"red"}," 已失败! 剩余 ",{"score": {"name": "$player_alive","objective": "mem"}}," 人!"]
 execute as @a at @s run function lib:sounds/error
 execute as @a at @s run function lib:sounds/error
 
 
 # 给存活的玩家加分
 # 给存活的玩家加分
@@ -16,6 +15,5 @@ scoreboard players add @a[tag=mini_running] mini_score 1
 gamemode spectator @s
 gamemode spectator @s
 spectate @r[tag=mini_running]
 spectate @r[tag=mini_running]
 
 
-# 如果只有一个玩家没有失败,则游戏结束
-# 这里设置成等于就不会触发多次 game_end 了
-execute if score $alive mem matches 1 run function mini:main/game_end
+# 检查游戏是否结束
+function mini:main/check_game_end

+ 4 - 7
data/mini/functions/main/player_finished.mcfunction

@@ -2,11 +2,10 @@
 
 
 # 计数
 # 计数
 tag @s remove mini_running
 tag @s remove mini_running
-execute store result score $alive mem if entity @a[tag=mini_running,tag=!watcher]
-execute store result score $t_finish mem if entity @a[tag=!mini_running,tag=!watcher]
+function mini:main/update_player_count
 
 
 # 显示提示
 # 显示提示
-execute if entity @s[tag=!rejoining] if score $t_finish mem matches ..3 run tellraw @a [{"selector": "@s","color":"green"}," 已成功! 第 ",{"score": {"name": "$t_finish","objective": "mem"}}," 名!"]
+execute if entity @s[tag=!rejoining] if score $player_finish mem matches ..3 run tellraw @a [{"selector": "@s","color":"green"}," 已成功! 第 ",{"score": {"name": "$player_finish","objective": "mem"}}," 名!"]
 execute as @a at @s run function lib:sounds/error
 execute as @a at @s run function lib:sounds/error
 
 
 # 给已完成的玩家加分
 # 给已完成的玩家加分
@@ -16,7 +15,5 @@ scoreboard players add @a[tag=!mini_running] mini_score 1
 gamemode spectator @s
 gamemode spectator @s
 spectate @r[tag=mini_running]
 spectate @r[tag=mini_running]
 
 
-# 如果有三个玩家成功,或只有一个玩家未成功,则游戏结束
-# 这里设置成等于就不会触发多次 game_end 了
-execute if score $t_finish mem matches 3 run function mini:main/game_end
-execute if score $t_finish mem matches ..2 if score $alive mem matches 1 run function mini:main/game_end
+# 检查游戏是否结束
+function mini:main/check_game_end

+ 2 - 1
data/mini/functions/main/tick5.mcfunction

@@ -1,4 +1,5 @@
 execute if score $mini_type mem matches 1 run function mini:parkour/tick5
 execute if score $mini_type mem matches 1 run function mini:parkour/tick5
 execute if score $mini_type mem matches 2 run function mini:tntrun/tick5
 execute if score $mini_type mem matches 2 run function mini:tntrun/tick5
 execute if score $mini_type mem matches 3 run function mini:hotpm/tick5
 execute if score $mini_type mem matches 3 run function mini:hotpm/tick5
-execute if score $mini_type mem matches 4 run function mini:colormatch/tick5
+execute if score $mini_type mem matches 4 run function mini:colormatch/tick5
+function mini:main/check_game_end

+ 4 - 0
data/mini/functions/main/update_player_count.mcfunction

@@ -0,0 +1,4 @@
+# 更新存活与结束的玩家数量
+
+execute store result score $player_alive mem if entity @a[tag=mini_running,tag=!watcher]
+execute store result score $player_finish mem if entity @a[tag=!mini_running,tag=!watcher]

+ 2 - 0
data/mini/functions/parkour/game_init.mcfunction

@@ -1,6 +1,8 @@
 # 初始化跑酷地图
 # 初始化跑酷地图
 forceload add 1000 1000 1050 1050
 forceload add 1000 1000 1050 1050
 
 
+scoreboard players set $finish_mode mem 1
+
 # 生成地图
 # 生成地图
 setblock 1000 10 1000 minecraft:structure_block{mode:"LOAD",name:"mini:parkour"}
 setblock 1000 10 1000 minecraft:structure_block{mode:"LOAD",name:"mini:parkour"}
 setblock 1000 11 1000 minecraft:redstone_block
 setblock 1000 11 1000 minecraft:redstone_block

+ 2 - 0
data/mini/functions/tntrun/game_init.mcfunction

@@ -1,6 +1,8 @@
 # 初始化 TNT Run 地图
 # 初始化 TNT Run 地图
 forceload add 1000 2000 1050 2050
 forceload add 1000 2000 1050 2050
 
 
+scoreboard players set $finish_mode mem 0
+
 # 生成地图
 # 生成地图
 setblock 1000 10 2000 minecraft:structure_block{mode:"LOAD",name:"mini:tntrun"}
 setblock 1000 10 2000 minecraft:structure_block{mode:"LOAD",name:"mini:tntrun"}
 setblock 1000 11 2000 minecraft:redstone_block
 setblock 1000 11 2000 minecraft:redstone_block