diff --git a/data/mob_dash/functions/assign_teams_menu.mcfunction b/data/mob_dash/functions/assign_teams_menu.mcfunction new file mode 100644 index 0000000..4f5ec7c --- /dev/null +++ b/data/mob_dash/functions/assign_teams_menu.mcfunction @@ -0,0 +1,14 @@ +# Show team switching menu to @s + +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 1"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=1}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 2"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=2}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 3"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=3}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 4"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=4}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 5"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=5}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 6"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=6}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 7"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=7}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 8"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=8}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign player to ", "color":"white","clickEvent":{"action":"suggest_command", "value":"/scoreboard players set PlayerName SetTeam 9"},"extra":[{"selector":"@e[type=area_effect_cloud,scores={md_team=9}]"}]},{"text":"]","color":"gold", "bold": true}] +tellraw @s [{"text": "\nSelect an option and replace PlayerName on the command with the player to assign."}] + +scoreboard players set @s md_ticks -1800 diff --git a/data/mob_dash/functions/display_menu.mcfunction b/data/mob_dash/functions/display_menu.mcfunction index 934965e..c6d7b0b 100644 --- a/data/mob_dash/functions/display_menu.mcfunction +++ b/data/mob_dash/functions/display_menu.mcfunction @@ -4,6 +4,7 @@ function mob_dash:welcome tellraw @s "" tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Tutorial", "color":"green","clickEvent":{"action":"run_command", "value":"/trigger md_action set 1"}},{"text":"]","color":"gold", "bold": true}] tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Switch Teams", "color":"green","clickEvent":{"action":"run_command", "value":"/trigger md_action set 2"}},{"text":"]","color":"gold", "bold": true}] +execute if score $OpOnly md_state matches 1 run tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Assign Teams", "color":"green","clickEvent":{"action":"run_command", "value":"/trigger md_action set 7"}},{"text":"]","color":"gold", "bold": true}] execute if score $Win md_state matches 0 run tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Win Score Limit: ", "color":"green", "extra": [{"text": "None", "color": "aqua"}],"clickEvent":{"action":"suggest_command","value":"/trigger WinScore set "}},{"text":"]","color":"gold", "bold": true}] execute if score $Win md_state matches 1.. run tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Win Score Limit: ", "color":"green", "extra": [{"score":{"objective":"md_state","name":"$Win"}, "color": "aqua"}],"clickEvent":{"action":"suggest_command","value":"/trigger WinScore set "}},{"text":"]","color":"gold", "bold": true}] execute if score $Timeout md_state matches 0 run tellraw @s [{"text":"- "},{"text":"[","color":"gold","bold": true},{"text":"Time Limit: ", "color":"green", "extra": [{"text": "None", "color": "aqua"}],"clickEvent":{"action":"suggest_command","value":"/trigger TimeLimit set "}},{"text":"]","color":"gold", "bold": true}] diff --git a/data/mob_dash/functions/join_team.mcfunction b/data/mob_dash/functions/join_team.mcfunction index 1797367..8e16d34 100644 --- a/data/mob_dash/functions/join_team.mcfunction +++ b/data/mob_dash/functions/join_team.mcfunction @@ -1,7 +1,8 @@ # Join a team based on value in md_action -scoreboard players operation @s md_team = @s md_action -scoreboard players remove @s md_team 100 +execute if score @s md_action matches 100.. run scoreboard players operation @s md_team = @s md_action +execute if score @s md_action matches 100.. run scoreboard players remove @s md_team 100 +execute if score @s SetTeam matches 1.. run scoreboard players operation @s md_team = @s SetTeam execute if score @s md_team matches 1 run team join red @s execute if score @s md_team matches 2 run team join green @s @@ -17,4 +18,6 @@ tag @s add md_current execute as @e[type=area_effect_cloud,tag=md_team] if score @s md_team = @p[tag=md_current] md_team run tellraw @a ["", {"selector":"@p[tag=md_current]"}, {"text":" has joined "}, {"selector": "@s"}] tag @s remove md_current +scoreboard players reset @s SetTeam + function mob_dash:display_menu diff --git a/data/mob_dash/functions/load.mcfunction b/data/mob_dash/functions/load.mcfunction index 6414dde..a4159f0 100644 --- a/data/mob_dash/functions/load.mcfunction +++ b/data/mob_dash/functions/load.mcfunction @@ -7,6 +7,8 @@ scoreboard objectives add md_ticks dummy "Mob Dash Menu Ticks" scoreboard objectives add md_action trigger "Mob Dash Menu Actions" scoreboard objectives add WinScore trigger "Mob Dash Win Score" scoreboard objectives add TimeLimit trigger "Mob Dash Time Limit" +scoreboard objectives add OpControl trigger "Op-only control" +scoreboard objectives add SetTeam dummy "Set Team for player" # Game states scoreboard objectives add md_target dummy "Mob Dash Target ID" @@ -36,6 +38,8 @@ scoreboard players add $Timeout md_state 0 scoreboard players add $Scoring md_state 0 scoreboard players add $Difficulty md_state 0 +scoreboard players add $OpOnly md_state 0 + execute store result score $Temp md_state run difficulty execute if score $Temp md_state matches 1.. run scoreboard players operation $GameDifficulty md_state = $Temp md_state diff --git a/data/mob_dash/functions/new_player.mcfunction b/data/mob_dash/functions/new_player.mcfunction index 2315247..d2894cc 100644 --- a/data/mob_dash/functions/new_player.mcfunction +++ b/data/mob_dash/functions/new_player.mcfunction @@ -1,12 +1,8 @@ # Runs for every player on first join_team -scoreboard players set $Random md_state 0 +execute if score $OpOnly md_state matches 1 run function mob_dash:welcome -function mob_dash:randomize_bit -function mob_dash:randomize_bit -function mob_dash:randomize_bit - -scoreboard players add $Random md_state 101 -scoreboard players operation @s md_action = $Random md_state +execute unless score @s SetTeam matches 1.. run function mob_dash:randomize_team +function mob_dash:join_team tag @s add md_assigned diff --git a/data/mob_dash/functions/op.mcfunction b/data/mob_dash/functions/op.mcfunction new file mode 100644 index 0000000..078c00f --- /dev/null +++ b/data/mob_dash/functions/op.mcfunction @@ -0,0 +1,6 @@ +# Authenticate @s as an op and put the game into op-control mode + +execute if score $OpOnly md_state matches 0 run tellraw @a [{"text": "The game is now in op-only mode.", "color": "gold"}] + +scoreboard players set $OpOnly md_state 1 +tag @s add md_op diff --git a/data/mob_dash/functions/op_auth.mcfunction b/data/mob_dash/functions/op_auth.mcfunction new file mode 100644 index 0000000..73581cc --- /dev/null +++ b/data/mob_dash/functions/op_auth.mcfunction @@ -0,0 +1,6 @@ +# Prompt to authenticate @s as an op and put the game into op-control mode + +execute if score $OpOnly md_state matches 0 run tellraw @s [{"text": "Click here to place the game into op-only mode and authenticate as an operator", "color": "green", "clickEvent": {"action": "run_command", "value": "/function mob_dash:op"}}] +execute if score $OpOnly md_state matches 1 run tellraw @s [{"text": "The game is already in op-only mode. Click here to authenticate as an operator", "color": "green", "clickEvent": {"action": "run_command", "value": "/function mob_dash:op"}}] + +scoreboard players reset @s OpControl diff --git a/data/mob_dash/functions/randomize_team.mcfunction b/data/mob_dash/functions/randomize_team.mcfunction new file mode 100644 index 0000000..fed444a --- /dev/null +++ b/data/mob_dash/functions/randomize_team.mcfunction @@ -0,0 +1,10 @@ +# Store a random team id into md_team + +scoreboard players set $Random md_state 0 + +function mob_dash:randomize_bit +function mob_dash:randomize_bit +function mob_dash:randomize_bit + +scoreboard players add $Random md_state 1 +scoreboard players operation @s SetTeam = $Random md_state diff --git a/data/mob_dash/functions/tick_menu.mcfunction b/data/mob_dash/functions/tick_menu.mcfunction index 96eac46..a3abbeb 100644 --- a/data/mob_dash/functions/tick_menu.mcfunction +++ b/data/mob_dash/functions/tick_menu.mcfunction @@ -20,35 +20,46 @@ effect give @a minecraft:weakness 1 100 true effect give @a minecraft:mining_fatigue 1 100 true effect give @a minecraft:saturation 1 1 true +# Op-only mode + +scoreboard players enable @a OpControl +execute as @a[scores={OpControl=1}] run function mob_dash:op_auth + # Menu handling +tag @a remove md_menu +execute if score $OpOnly md_state matches 0 run tag @a add md_menu +execute if score $OpOnly md_state matches 1 run tag @a[tag=md_op] add md_menu + scoreboard players add @a md_ticks 0 execute as @a[tag=!md_assigned] run function mob_dash:new_player scoreboard players add @a md_ticks 1 -scoreboard players enable @a md_action +scoreboard players enable @a[tag=md_menu] md_action -execute as @a[scores={md_ticks=600..},tag=!md_tutorial] run function mob_dash:push_menu +execute as @a[scores={md_ticks=600..},tag=!md_tutorial,tag=md_menu] run function mob_dash:push_menu execute as @a[tag=md_tutorial] run function mob_dash:tick_tutorial -execute as @a[scores={WinScore=-2147483647..2147483647}] run function mob_dash:set_win_score -scoreboard players enable @a WinScore -scoreboard players set @a WinScore -2147483648 +execute as @a[scores={WinScore=-2147483647..2147483647},tag=md_menu] run function mob_dash:set_win_score +scoreboard players enable @a[tag=md_menu] WinScore +scoreboard players set @a[tag=md_menu] WinScore -2147483648 -execute as @a[scores={TimeLimit=-2147483647..2147483647}] run function mob_dash:set_time_limit -scoreboard players enable @a TimeLimit -scoreboard players set @a TimeLimit -2147483648 +execute as @a[scores={TimeLimit=-2147483647..2147483647},tag=md_menu] run function mob_dash:set_time_limit +scoreboard players enable @a[tag=md_menu] TimeLimit +scoreboard players set @a[tag=md_menu] TimeLimit -2147483648 # React to menu action clicks -execute as @a[scores={md_action=1}] run function mob_dash:trigger_tutorial -execute as @a[scores={md_action=2}] run function mob_dash:display_teams_menu -execute as @a[scores={md_action=3}] if entity @p[scores={md_team=1..8}] run function mob_dash:start_game -execute as @a[scores={md_action=3}] unless entity @p[scores={md_team=1..8}] run tellraw @s [{"text": "No players on any team, cannot start", "color": "red"}] -execute as @a[scores={md_action=4}] run function mob_dash:cycle_scoring -execute as @a[scores={md_action=5}] run function mob_dash:cycle_difficulty -execute as @a[scores={md_action=6}] run function mob_dash:cancel_tutorial -execute as @a[scores={md_action=101..109}] run function mob_dash:join_team +execute as @a[scores={md_action=1},tag=md_menu] run function mob_dash:trigger_tutorial +execute as @a[scores={md_action=2},tag=md_menu] run function mob_dash:display_teams_menu +execute as @a[scores={md_action=3},tag=md_menu] if entity @p[scores={md_team=1..8}] run function mob_dash:start_game +execute as @a[scores={md_action=3},tag=md_menu] unless entity @p[scores={md_team=1..8}] run tellraw @s [{"text": "No players on any team, cannot start", "color": "red"}] +execute as @a[scores={md_action=4},tag=md_menu] run function mob_dash:cycle_scoring +execute as @a[scores={md_action=5},tag=md_menu] run function mob_dash:cycle_difficulty +execute as @a[scores={md_action=6},tag=md_menu] run function mob_dash:cancel_tutorial +execute as @a[scores={md_action=7},tag=md_menu] run function mob_dash:assign_teams_menu +execute as @a[scores={md_action=101..109},tag=md_menu] run function mob_dash:join_team +execute as @a[scores={SetTeam=1..9},tag=md_menu] run function mob_dash:join_team scoreboard players set @a md_action 0