Skip to content

Commit

Permalink
Stop updating wardens when it's unneeded.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frustrated-Programmer committed Dec 31, 2024
1 parent cacd891 commit 52a0519
Showing 1 changed file with 58 additions and 30 deletions.
88 changes: 58 additions & 30 deletions Brilliance Datapack/data/do2/functions/per_level_actions.mcfunction
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,70 @@ execute if entity @a[scores={do2.utility.dungeonLocation=10}] run function do2:d


# Silence wardens when player is out of range
scoreboard objectives add do2.tests.shouldKeepWardensQuiet dummy
scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 1
execute as @e[type=warden,tag=L3Z1] run tag @s add do2.checkSilenceL3
execute as @e[type=warden,tag=L3Z2] run tag @s add do2.checkSilenceL3
execute as @e[type=warden,tag=L3Z3] run tag @s add do2.checkSilenceL3
execute as @e[type=warden,tag=L4Z1] run tag @s add do2.checkSilenceL4
execute as @e[type=warden,tag=L4Z2] run tag @s add do2.checkSilenceL4
execute as @e[type=warden,tag=L4Z3] run tag @s add do2.checkSilenceL4
scoreboard objectives add do2.tests.silenceL3Wardens dummy
scoreboard objectives add do2.tests.silenceL4Wardens dummy
scoreboard players set $dungeon do2.tests.silenceL3Wardens 1
scoreboard players set $dungeon do2.tests.silenceL4Wardens 1

# Unmute ALL wardens unless a player wants us to silence them.
execute as @a[team=do2.players] if entity @s[scores={do2.config.silenceWardens=0}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.config.silenceWardens=0}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0

# Only allow silencing wardens when a player wants them to.
execute as @a[team=do2.players] if entity @s[scores={do2.config.silenceWardens=0..}] as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 0b
execute as @a[team=do2.players] if entity @s[scores={do2.config.silenceWardens=0..}] as @e[type=warden,tag=do2.checkSilenceL4] run data modify entity @s Silent set value 0b
execute as @a[team=do2.players] unless entity @s[scores={do2.config.silenceWardens=1..}] run return 0

# Start them silenced, and remove silence them when ANY player are on certain areas
execute as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 1b
execute as @e[type=warden,tag=do2.checkSilenceL4] run data modify entity @s Silent set value 1b

# Unmute ALL wardens, when players are at special locations.
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=0}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=1}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=2}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=3}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=4}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=5}] run scoreboard players set $dungeon do2.tests.shouldKeepWardensQuiet 0
execute if score $dungeon do2.tests.shouldKeepWardensQuiet matches 0 as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 0b
execute if score $dungeon do2.tests.shouldKeepWardensQuiet matches 0 as @e[type=warden,tag=do2.checkSilenceL4] run data modify entity @s Silent set value 0b

execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=0}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=0}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=1}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=1}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=2}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=2}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=3}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=3}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=4}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=4}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=5}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=5}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
# Unmute L4 wardens when player is on L4
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=12}] as @e[type=warden,tag=do2.checkSilenceL4] run data modify entity @s Silent set value 0b

execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=12}] run scoreboard players set $dungeon do2.tests.silenceL4Wardens 0
# Unmute L3 wardens when player is at Stairs (L2 & L3)
# Unmute L3 wardens when player is at Passage (L4 -> L3)
# Unmute L3 wardens when player is on L3
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=7}] as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 0b
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=8}] as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 0b
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=11}] as @e[type=warden,tag=do2.checkSilenceL3] run data modify entity @s Silent set value 0b
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=7}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=8}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0
execute as @a[team=do2.players] if entity @s[scores={do2.utility.dungeonLocation=11}] run scoreboard players set $dungeon do2.tests.silenceL3Wardens 0

# Mute all L3 wardens who are unmuted & should be muted.
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z1,tag=!do2.muted] run data modify entity @s Silent set value 1b
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z2,tag=!do2.muted] run data modify entity @s Silent set value 1b
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z3,tag=!do2.muted] run data modify entity @s Silent set value 1b
# Note that the L3 wardens are muted.
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z1,tag=!do2.muted] run tag @s add do2.muted
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z2,tag=!do2.muted] run tag @s add do2.muted
execute if score $dungeon do2.tests.silenceL3Wardens matches 1 as @e[type=warden,tag=L3Z3,tag=!do2.muted] run tag @s add do2.muted
# Unmute all L3 wardens who are muted and should be unmuted.
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z1,tag=do2.muted] run data modify entity @s Silent set value 0b
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z2,tag=do2.muted] run data modify entity @s Silent set value 0b
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z3,tag=do2.muted] run data modify entity @s Silent set value 0b
# Note that the L3 wardens are unmuted.
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z1,tag=do2.muted] run tag @s remove do2.muted
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z2,tag=do2.muted] run tag @s remove do2.muted
execute if score $dungeon do2.tests.silenceL3Wardens matches 0 as @e[type=warden,tag=L3Z3,tag=do2.muted] run tag @s remove do2.muted

# Mute all L4 wardens who are unmuted & should be muted.
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z1,tag=!do2.muted] run data modify entity @s Silent set value 1b
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z2,tag=!do2.muted] run data modify entity @s Silent set value 1b
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z3,tag=!do2.muted] run data modify entity @s Silent set value 1b
# Note that the L4 wardens are muted.
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z1,tag=!do2.muted] run tag @s add do2.muted
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z2,tag=!do2.muted] run tag @s add do2.muted
execute if score $dungeon do2.tests.silenceL4Wardens matches 1 as @e[type=warden,tag=L4Z3,tag=!do2.muted] run tag @s add do2.muted
# Unmute all L4 wardens who are muted and should be unmuted.
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z1,tag=do2.muted] run data modify entity @s Silent set value 0b
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z2,tag=do2.muted] run data modify entity @s Silent set value 0b
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z3,tag=do2.muted] run data modify entity @s Silent set value 0b
# Note that the L4 wardens are unmuted.
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z1,tag=do2.muted] run tag @s remove do2.muted
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z2,tag=do2.muted] run tag @s remove do2.muted
execute if score $dungeon do2.tests.silenceL4Wardens matches 0 as @e[type=warden,tag=L4Z3,tag=do2.muted] run tag @s remove do2.muted


0 comments on commit 52a0519

Please sign in to comment.