Browse Source

金粒系统预装

LTCatt 6 years ago
parent
commit
7ef8ae0958

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

@@ -25,6 +25,7 @@ forceload add 0 0
 setblock 0 0 0 jukebox
 setblock 0 0 0 jukebox
 
 
 # 记分板
 # 记分板
+scoreboard objectives add gold dummy "金粒"
 scoreboard objectives remove temp
 scoreboard objectives remove temp
 scoreboard objectives add temp dummy
 scoreboard objectives add temp dummy
 scoreboard objectives remove countdown
 scoreboard objectives remove countdown
@@ -55,6 +56,7 @@ scoreboard players set $c_mini_total mem 7
 scoreboard players set #const_2 mem 2
 scoreboard players set #const_2 mem 2
 scoreboard players set #const_5 mem 5
 scoreboard players set #const_5 mem 5
 scoreboard players set #const_10 mem 10
 scoreboard players set #const_10 mem 10
+scoreboard players set #const_100 mem 100
 scoreboard players set $game_type mem 1
 scoreboard players set $game_type mem 1
 
 
 # 队伍
 # 队伍

+ 35 - 3
data/ltw/functions/main/game_end.mcfunction

@@ -17,10 +17,42 @@ scoreboard players set #score_max mem -2147483648
 execute as @a[tag=!total_rank1,tag=!total_rank2] run function ltw:main/get_max_score
 execute as @a[tag=!total_rank1,tag=!total_rank2] run function ltw:main/get_max_score
 execute as @a[tag=!total_rank1,tag=!total_rank2] unless entity @a[tag=total_rank3] if score @s total_score = #score_max mem run tag @s add total_rank3
 execute as @a[tag=!total_rank1,tag=!total_rank2] unless entity @a[tag=total_rank3] if score @s total_score = #score_max mem run tag @s add total_rank3
 
 
+# 计算金粒奖励
+scoreboard players set #total_gold mem 0
+execute as @a[tag=!watcher] run scoreboard players add #total_gold mem 800
+# 无名次
+execute as @a[tag=!total_rank1,tag=!total_rank2,tag=!total_rank3,tag=!watcher] run scoreboard players remove #total_gold mem 100
+# 计算总权重与单份奖励
+scoreboard players set #total_weight mem 0
+execute as @a[tag=total_rank1] run scoreboard players add #total_weight mem 3
+execute as @a[tag=total_rank2] run scoreboard players add #total_weight mem 2
+execute as @a[tag=total_rank3] run scoreboard players add #total_weight mem 1
+scoreboard players operation #total_gold mem /= #total_weight mem
+# 计算名次奖励
+scoreboard players set #rank1_gold mem 3
+scoreboard players operation #rank1_gold mem *= #total_gold mem
+scoreboard players operation #rank1_gold mem /= #const_100 mem
+scoreboard players set #rank2_gold mem 2
+scoreboard players operation #rank2_gold mem *= #total_gold mem
+scoreboard players operation #rank2_gold mem /= #const_100 mem
+scoreboard players set #rank3_gold mem 1
+scoreboard players operation #rank3_gold mem *= #total_gold mem
+scoreboard players operation #rank3_gold mem /= #const_100 mem
+
 # 显示排名
 # 显示排名
-execute if entity @a[tag=total_rank2] if entity @a[tag=total_rank3] run tellraw @a ["",{"text":"\n\n----- 游戏结束 -----\n\n","color":"gold","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第二名 - ","color":"green"},{"selector": "@a[tag=total_rank2]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank2]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第三名 - ","color":"green"},{"selector": "@a[tag=total_rank3]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank3]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n"]
-execute if entity @a[tag=total_rank2] unless entity @a[tag=total_rank3] run tellraw @a ["",{"text":"\n\n\n----- 游戏结束 -----\n\n","color":"gold","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第二名 - ","color":"green"},{"selector": "@a[tag=total_rank2]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank2]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n\n"]
-execute unless entity @a[tag=total_rank2] run tellraw @a ["",{"text":"\n\n\n\n----- 游戏结束 -----\n\n","color":"gold","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n\n"]
+execute if entity @a[tag=total_rank2] if entity @a[tag=total_rank3] run tellraw @a ["",{"text":"\n\n----- 游戏结束 -----\n\n","color":"green","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第二名 - ","color":"green"},{"selector": "@a[tag=total_rank2]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank2]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第三名 - ","color":"green"},{"selector": "@a[tag=total_rank3]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank3]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n"]
+execute if entity @a[tag=total_rank2] unless entity @a[tag=total_rank3] run tellraw @a ["",{"text":"\n\n\n----- 游戏结束 -----\n\n","color":"green","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},{"text": "\n第二名 - ","color":"green"},{"selector": "@a[tag=total_rank2]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank2]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n\n"]
+execute unless entity @a[tag=total_rank2] run tellraw @a ["",{"text":"\n\n\n\n----- 游戏结束 -----\n\n","color":"green","bold":true},{"text": "第一名 - ","color":"green"},{"selector": "@a[tag=total_rank1]","color":"white"},{"text":" (","color":"gray"},{"score":{"name": "@p[tag=total_rank1]","objective": "total_score"},"color":"gray"},{"text":")","color":"gray"},"\n\n\n"]
+
+# 给予金粒奖励
+execute as @a[tag=total_rank1] run scoreboard players operation @s gold += #rank1_gold mem
+tellraw @a[tag=total_rank1] ["",{"text": ">> ","color":"green","bold": true},"由于获得第一名, 你得到了 ",{"selector": "#rank1_gold","color":"green"},{"text": " 金粒","color":"green"}]
+execute as @a[tag=total_rank2] run scoreboard players operation @s gold += #rank2_gold mem
+tellraw @a[tag=total_rank2] ["",{"text": ">> ","color":"green","bold": true},"由于获得第二名, 你得到了 ",{"selector": "#rank2_gold","color":"green"},{"text": " 金粒","color":"green"}]
+execute as @a[tag=total_rank3] run scoreboard players operation @s gold += #rank3_gold mem
+tellraw @a[tag=total_rank3] ["",{"text": ">> ","color":"green","bold": true},"由于获得第三名, 你得到了 ",{"selector": "#rank3_gold","color":"green"},{"text": " 金粒","color":"green"}]
+scoreboard players add @a[tag=!total_rank1,tag=!total_rank2,tag=!total_rank3,tag=!watcher] gold 1
+tellraw @a[tag=!total_rank1,tag=!total_rank2,tag=!total_rank3,tag=!watcher] ["",{"text": ">> ","color":"aqua","bold": true},"由于没有获得名次, 你得到了 ",{"text": " 1 金粒","color":"aqua"}]
 
 
 # 返回主大厅
 # 返回主大厅
 schedule function ltw:state/0/state_enter 2t replace
 schedule function ltw:state/0/state_enter 2t replace

+ 4 - 3
data/ltw/functions/state/0/player_enter.mcfunction

@@ -3,9 +3,6 @@ function lib:sounds/music/hub
 title @s clear
 title @s clear
 title @s actionbar ""
 title @s actionbar ""
 
 
-# 清理物品
-clear @s[tag=!debug]
-
 # 重置玩家血量上限
 # 重置玩家血量上限
 attribute @s generic.max_health base set 20
 attribute @s generic.max_health base set 20
 
 
@@ -25,3 +22,7 @@ gamemode adventure @s[tag=!debug]
 
 
 # 传送玩家
 # 传送玩家
 tp @s[tag=!debug] 10 16 10
 tp @s[tag=!debug] 10 16 10
+
+# 刷新物品
+clear @s[tag=!debug]
+function ltw:state/0/shop/refresh_gold

+ 14 - 0
data/ltw/functions/state/0/shop/refresh_gold.mcfunction

@@ -0,0 +1,14 @@
+# 刷新单个玩家背包中的金粒
+
+clear @s gold_ingot
+clear @s gold_nugget
+
+# 获取金锭数,存于 temp
+scoreboard players operation @s temp = @s gold
+scoreboard players operation @s temp /= #count_9 mem
+# 给予金锭
+
+# 获取金粒数,存于 temp
+scoreboard players operation @s temp = @s gold
+scoreboard players operation @s temp %= #count_9 mem
+# 给予金粒

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

@@ -4,7 +4,7 @@ execute as @a run function ltw:state/0/player_enter
 
 
 # HUD
 # HUD
 scoreboard objectives setdisplay belowName
 scoreboard objectives setdisplay belowName
-scoreboard objectives setdisplay sidebar
+scoreboard objectives setdisplay sidebar gold
 scoreboard objectives setdisplay list
 scoreboard objectives setdisplay list
 
 
 # 伤害管理
 # 伤害管理

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


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

@@ -1,14 +0,0 @@
-# 要求系统进入状态 1(主阶段准备)
-scoreboard players set $state mem 1
-execute as @a run function ltw:state/1/player_enter
-
-# HUD
-scoreboard objectives setdisplay belowName total_score_disp
-scoreboard objectives setdisplay sidebar total_score
-scoreboard objectives setdisplay list total_score_disp
-
-# 初始化倒计时
-scoreboard players set $countdown mem 10
-
-# 生成地图
-function ltw:state/1/generate_map