stole_score.mcfunction 1.7 KB

12345678910111213141516171819202122
  1. # as player
  2. execute store result score #bonus_stole_score mem run data get storage item:bonus item.tag.bonus_stole_score
  3. # 获取有效的最高分玩家
  4. function ltw:main/get_max_score
  5. tag @a remove highest
  6. tag @a remove may_highest
  7. execute as @a if score @s total_score = #score_max mem if score @s total_score >= #bonus_stole_score mem run tag @s add may_highest
  8. tag @s remove may_highest
  9. execute as @a[tag=may_highest,limit=1,sort=random,team=playing] run tag @s add highest
  10. execute unless entity @a[tag=highest] run tag @s add highest
  11. # 更改得分
  12. scoreboard players operation @s total_score += #bonus_stole_score mem
  13. scoreboard players operation @s total_score_disp += #bonus_stole_score mem
  14. scoreboard players operation @a[tag=highest] total_score -= #bonus_stole_score mem
  15. scoreboard players operation @a[tag=highest] total_score_disp -= #bonus_stole_score mem
  16. # 显示提示
  17. execute if entity @s[tag=highest] run tellraw @a ["",{"text": ">> ","color":"aqua","bold": true},{"selector": "@s","color":"aqua"}," 没能偷到任何人的分数……"]
  18. execute if entity @s[tag=!highest] run tellraw @a ["",{"text": ">> ","color":"red","bold": true},{"selector": "@a[tag=highest]","color":"red"}," 被偷取了 ",{"score": {"name": "#bonus_stole_score","objective": "mem"},"color":"red"},{"text": " 分","color":"red"},", 当前共有 ",{"score": {"name": "@a[tag=highest,limit=1]","objective": "total_score"}}, " 分"]
  19. execute if entity @s[tag=!highest] run tellraw @a ["",{"text": ">> ","color":"green","bold": true},{"selector": "@s","color":"green"}," 偷取了 ",{"score": {"name": "#bonus_stole_score","objective": "mem"},"color":"green"},{"text": " 分","color":"green"},", 当前共有 ",{"score": {"name": "@s","objective": "total_score"}}, " 分"]