Skip to content

Commit

Permalink
Arena selection now has a 3 second cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
Moesh committed Apr 22, 2021
1 parent 8116411 commit 32513fb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion resourcepacks/calamity/assets/calamity/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"arena.shattering.name": "Shattering",
"book.pageIndicator": "\u00a7ov5.0.0",
"by.author": "by %s",
"calamity.arena.error.sameArena": "This arena is already selected.",
"calamity.arena.error.sameArena": "This arena is already selected",
"calamity.arena.error.cooldown": "Arena selection is on cooldown",
"calamity.book.cancelStart": "Cancel",
"calamity.book.forfeit": "Forfeit",
"calamity.book.hover.cancel": "Cancel match start",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,22 @@ scoreboard objectives add craftedObjItem32 minecraft.crafted:minecraft.tripwire_
# This objective is removed and reset after each round to ensure no hanky panky has occurred.
scoreboard objectives remove gameVariable
scoreboard objectives add gameVariable dummy
scoreboard players set TimeToStartMatch gameVariable 300
# Setup visible variables
scoreboard players set ArenaSelectCooldown gameVariable 0
scoreboard players set BluePoints gameVariable 0
scoreboard players set RedPoints gameVariable 0
scoreboard players set ReadyBlue gameVariable 0
scoreboard players set ReadyRed gameVariable 0
# oreLeft is polled from calamity:player/update_displays
scoreboard players set OreLeft gameVariable 0
scoreboard players set #tableCandle gameVariable 0
scoreboard players set #tableCandleSmoke gameVariable 0
scoreboard players set ReadyBlue gameVariable 0
scoreboard players set ReadyRed gameVariable 0
scoreboard players set RedPoints gameVariable 0
scoreboard players set TimeToStartMatch gameVariable 300
# Setup hidden variables
scoreboard players set #arenaAction gameVariable 0
scoreboard players set #selectedArena gameVariable 0
scoreboard players set #currentArena gameVariable 1
scoreboard players set #currentArena gameVariable 1
scoreboard players set #selectedArena gameVariable 0
scoreboard players set #tableCandle gameVariable 0
scoreboard players set #tableCandleSmoke gameVariable 0

# Game starts in lobby mode by default.
scoreboard players set GameState gameVariable 0
Expand All @@ -309,4 +313,4 @@ scoreboard players set GameState gameVariable 0
# Used to determine whether or not the game has started.
# This variable is accessed from calamity:tick, calamity:game_state/start_match,
# calamity:player/trigger_cancel_start, and calamity:player/trigger_start_match
scoreboard players set StartingMatch gameVariable 0
scoreboard players set StartingMatch gameVariable 0
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
#> Purpose: A player has tried to use the /trigger arena command.
#>--------------------------------------------------------------------------------------------------

# If an arena was recently switched, continue the cooldown timer
execute if score ArenaSelectCooldown gameVariable matches 1.. run scoreboard players remove ArenaSelectCooldown gameVariable 1

# Check if the arena has been switched recently and is still on cooldown
execute if entity @a[scores={arena=1..},limit=1] if score ArenaSelectCooldown gameVariable matches 1.. run tellraw @a {"translate":"system.message","color": "red","with":[{"translate":"calamity.arena.error.cooldown"}]}
execute if entity @a[scores={arena=1..},limit=1] if score ArenaSelectCooldown gameVariable matches 1.. run scoreboard players reset @a arena
execute if entity @a[scores={arena=1..},limit=1] if score ArenaSelectCooldown gameVariable matches 1.. run scoreboard players enable @a arena

# If the #currentArena gameVariable matches trigger number, the current arena is already selected.
# Advise the player that they've made a mistake
execute if score @a[scores={arena=1..},limit=1] arena = #currentArena gameVariable run tellraw @a[scores={arena=1..}] {"translate":"system.message","color":"red","with":[{"translate": "calamity.arena.error.sameArena"}]}
Expand All @@ -21,6 +29,10 @@ scoreboard players enable @a arena
execute if score #selectedArena gameVariable matches 1.. run scoreboard players set #arenaAction gameVariable 1
execute if score #selectedArena gameVariable matches 1.. run function calamity:arena/handler

# Switching arenas too quickly can cause a crash because of how many blocks are loading and
# unloading. Let's limit this to every 5 seconds and advise the player.
execute if score #selectedArena gameVariable matches 1.. run scoreboard players set ArenaSelectCooldown gameVariable 60

# Calamity's arena makers must load and unload their own levels. The default action for the arena
# handler is to load the level, so we will not need to define #actionAction gameVariable for
# this action to run correctly.
Expand Down

0 comments on commit 32513fb

Please sign in to comment.