Skip to content

Commit

Permalink
♻️ add volume bounds/room checks to most @a selectors
Browse files Browse the repository at this point in the history
- biggest change here is that only the active player + spectators will hear bossfight sounds and music
  • Loading branch information
TheAfroOfDoom committed Oct 12, 2024
1 parent c7e3fff commit fe13f87
Show file tree
Hide file tree
Showing 32 changed files with 100 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Play static sound
playsound omega-flowey:boss-fight.static ambient @a ~ ~ ~ 10
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:boss-fight.static ambient @s ~ ~ ~ 10' \
}

function animated_java:omegaflowey_tv_screen/variants/static/apply
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ execute as @e[ \
tag=omega-flowey-remastered \
] run function omegaflowey.entity:directorial/boss_fight/shared/stop/as_root

# TAG_SUMMIT_HARDCODED_GLOBAL_VOLUME
execute as @a[x=-186, dx=91, y=12, dy=93, z=12, dz=95, tag=omegaflowey.player.room.spectator_box] run \
function omegaflowey.entity:directorial/boss_fight/shared/stop/as_spectator

function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'execute unless entity @s[tag=omegaflowey.player.fighting_flowey] run \
function omegaflowey.entity:directorial/boss_fight/shared/stop/as_spectator' \
}
$execute as $(active_player_uuid) run function omegaflowey.entity:directorial/boss_fight/shared/stop/as_active_player

data modify storage omegaflowey:bossfight active_player_uuid set value "0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
scoreboard players set @s omegaflowey.boss-fight.attack.clock.total 463

# Play music
playsound omega-flowey:music.phase.0 record @a ~ ~ ~ 10 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:music.phase.0 record @s ~ ~ ~ 10 1' \
}

## Add tags
# Use logic to decrease chance of repeating attacks during `attack/random`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
scoreboard players set @s omegaflowey.boss-fight.attack.clock.total 414

# Play music
playsound omega-flowey:music.phase.1 record @a ~ ~ ~ 10 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:music.phase.1 record @s ~ ~ ~ 10 1' \
}

## Add tags
# Use logic to decrease chance of repeating attacks during `attack/random`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Play WARNING sound
$execute at $(bossfight_tvscreen_uuid) run playsound omega-flowey:boss-fight.alarm ambient @a ~ ~ ~ 10 1
$execute at $(bossfight_tvscreen_uuid) run function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:boss-fight.alarm ambient @s ~ ~ ~ 10 1' \
}

# Set tv screen to WARNING variant
$execute as $(bossfight_tvscreen_uuid) run function omegaflowey.entity:hostile/omega-flowey/animate/warning/tv_screen
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
stopsound @a hostile omega-flowey:attack.bomb.fall
playsound omega-flowey:attack.bomb.fall hostile @a ~ ~ ~ 5 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:hostile/omega-flowey/attack/bomb/bullet/loop/start_falling/as_player' \
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stopsound @s hostile omega-flowey:attack.bomb.fall
playsound omega-flowey:attack.bomb.fall hostile @s ~ ~ ~ 5 1
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ function omegaflowey.entity:directorial/boss_fight/summit/origin/at/y { \

# Play animation if we just stopped falling
execute unless entity @s[tag=is_done_falling] run function animated_java:omegaflowey_bomb/animations/omegaflowey_explode/play
execute unless entity @s[tag=is_done_falling] run stopsound @a hostile omega-flowey:attack.bomb.explode
execute unless entity @s[tag=is_done_falling] run playsound omega-flowey:attack.bomb.explode hostile @a ~ ~ ~ 5 1
execute unless entity @s[tag=is_done_falling] run function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:hostile/omega-flowey/attack/bomb/bullet/loop/stop_falling/as_player_once' \
}

# Add tags
tag @s add is_done_falling
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stopsound @s hostile omega-flowey:attack.bomb.explode
playsound omega-flowey:attack.bomb.explode hostile @s ~ ~ ~ 5 1
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Play summon sounds
playsound omega-flowey:attack.dentata-snakes.spawn hostile @a ~ ~ ~ 5 1
playsound omega-flowey:attack.dentata-snakes.summon hostile @a ~ ~ ~ 5 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:hostile/omega-flowey/attack/dentata-snakes/bullet/initialize/head/as_player' \
}

# Add tags
tag @s add attack-bullet-head
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Play summon sounds
playsound omega-flowey:attack.dentata-snakes.spawn hostile @s ~ ~ ~ 5 1
playsound omega-flowey:attack.dentata-snakes.summon hostile @s ~ ~ ~ 5 1
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# If we bounced, play bounce sound
# Only the bullet-head makes bounce sounds/shakes the player's screen (see `maybe_bounce.mcfunction`)
playsound omega-flowey:attack.dentata-snakes.bounce hostile @a ~ ~ ~ 5 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.dentata-snakes.bounce hostile @s ~ ~ ~ 5 1' \
}
# execute as @a unless entity @s[tag=!omegaflowey.player.fighting_flowey,team=!dead,tag=!omegaflowey.player.room.spectator_box] at @s run function omegaflowey.entity:utils/shake_screen
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ data merge entity @s {CustomName:"\"Finger-Guns Bullet\""}
scoreboard players operation @s omegaflowey.attack.speed.z = #omegaflowey.attack.finger-guns omegaflowey.attack.speed.z

# Play bullet shoot sound
stopsound @a hostile omega-flowey:attack.finger-guns.shoot
playsound omega-flowey:attack.finger-guns.shoot hostile @a ~ ~ ~ 5 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:hostile/omega-flowey/attack/finger-guns/bullet/initialize/as_player' \
}

# Add tags
tag @s add finger-guns
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stopsound @s hostile omega-flowey:attack.finger-guns.shoot
playsound omega-flowey:attack.finger-guns.shoot hostile @s ~ ~ ~ 5 1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ function omegaflowey.entity:hostile/omega-flowey/attack/shared/initialize
data modify entity @s CustomName set value '"Finger-Guns Laser"'

# Play laser sound (blink) once
playsound omega-flowey:attack.finger-guns.laser hostile @a ~ ~ ~ 5 1 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.finger-guns.laser hostile @s ~ ~ ~ 5 1 1' \
}

# Add tags
tag @s add finger-guns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ execute if score @s omegaflowey.attack.clock.i = @s omegaflowey.attack.indicator
function omegaflowey.entity:hostile/omega-flowey/attack/friendliness-pellets/indicator/loop/finished_blinking with entity @s data

# Play blinking sound before we summon bullets
execute if score @s omegaflowey.attack.clock.i matches ..-1 run playsound omega-flowey:attack.friendliness-pellets.blinking hostile @a ~ ~ ~ 3 1 1
execute if score @s omegaflowey.attack.clock.i matches ..-1 run \
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.friendliness-pellets.blinking hostile @s ~ ~ ~ 3 1 1' \
}

# Ignore bullet summoning logic while `omegaflowey.attack.clock.i` is negative
execute if score @s omegaflowey.attack.clock.i matches ..-1 run return 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ $tag $(corresponding_bullet_8_uuid) remove stationary
$tag $(corresponding_bullet_9_uuid) remove stationary

# Play activate sound
playsound omega-flowey:attack.friendliness-pellets.activate hostile @a ~ ~ ~ 3 1 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.friendliness-pellets.activate hostile @s ~ ~ ~ 3 1 1' \
}

kill @s
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ scoreboard players operation @s omegaflowey.attack.speed.z = #omegaflowey.attack

# Play bullet summon sound
# This also stops any already-playing summon sounds to accurately match what Undertale's homing-vines attack sounds like
stopsound @a hostile omega-flowey:attack.homing-vines.summon
playsound omega-flowey:attack.homing-vines.summon hostile @a ~ ~ ~ 5 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:hostile/omega-flowey/attack/homing-vines/bullet/initialize/as_player' \
}

# Add tags
tag @s add homing-vines
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stopsound @s hostile omega-flowey:attack.homing-vines.summon
playsound omega-flowey:attack.homing-vines.summon hostile @s ~ ~ ~ 5 1
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
$execute as $(blinking_lane_uuid) on passengers if entity @s[tag=aj.omegaflowey_homing_vine_blinking_lane.bone.root] run data modify entity @s view_range set value 1

# Play blinking sound once
playsound omega-flowey:attack.homing-vines.blinking hostile @a ~ ~ ~ 3 1 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.homing-vines.blinking hostile @s ~ ~ ~ 3 1 1' \
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
# TODO(36): maybe `particle minecraft:flash`?
particle minecraft:explosion ~ ~ ~ 0 0 0 10 1 force

playsound omega-flowey:attack.x-bullets.start hostile @a ~ ~ ~ 3 1 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.x-bullets.start hostile @s ~ ~ ~ 3 1 1' \
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
# TODO(36): maybe `particle minecraft:flash`?
particle minecraft:explosion ~ ~ ~ 0 0 0 10 1 force

playsound omega-flowey:attack.x-bullets.start hostile @a ~ ~ ~ 3 1 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:attack.x-bullets.start hostile @s ~ ~ ~ 3 1 1' \
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# NOTE: TAG_SUMMIT_HARDCODED_GLOBAL_VOLUME
$execute \
as @a[x=-186, dx=91, y=12, dy=93, z=12, dz=95] \
unless entity @s[tag=!omegaflowey.player.fighting_flowey, tag=!omegaflowey.player.room.spectator_box] \
run $(command)
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
# Update state flag
scoreboard players set #omegaflowey.soul.5.saved omegaflowey.soul.flag 1

# Stop event music
stopsound @a record omega-flowey:music.soul.5

# Play saved music + sound effect
playsound omega-flowey:soul.saved record @a ~ ~ ~ 10 1
playsound omega-flowey:soul.transition record @a ~ ~ ~ 10 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:soul/soul_5/executor/initialize/saved/as_player' \
}

# Flash each player's screen
$execute as $(active_player_uuid) at @s anchored eyes run particle minecraft:flash ^ ^ ^0.5
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Stop event music
stopsound @s record omega-flowey:music.soul.5

# Play saved music + sound effect
playsound omega-flowey:soul.saved record @s ~ ~ ~ 10 1
playsound omega-flowey:soul.transition record @s ~ ~ ~ 10 1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Loop logic for players
execute as @a[tag=omegaflowey.player.fighting_flowey] run function omegaflowey.entity:soul/soul_5/executor/loop/as_player
$execute as $(active_player_uuid) run function omegaflowey.entity:soul/soul_5/executor/loop/as_player

scoreboard players add @s omegaflowey.soul.clock.i 1

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
playsound omega-flowey:music.soul.5 record @a ~ ~ ~ 10 1
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'playsound omega-flowey:music.soul.5 record @s ~ ~ ~ 10 1' \
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ execute as @e[ \
tag=omega-flowey-remastered \
] run function omegaflowey.entity:soul/soul_5/executor/terminate/as_root

stopsound @a record omega-flowey:music.soul.5
stopsound @a record omega-flowey:soul.saved
effect clear @a[tag=omegaflowey.player.fighting_flowey] minecraft:resistance
function omegaflowey.entity:shared/run_as_active_player_or_spectator { command: \
'function omegaflowey.entity:soul/soul_5/executor/terminate/as_player' \
}
$effect clear $(active_player_uuid) minecraft:resistance

kill @s
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
stopsound @s record omega-flowey:music.soul.5
stopsound @s record omega-flowey:soul.saved
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
execute if entity @s[tag=act-button] run function omegaflowey.entity:soul/soul_5/act_button/loop
execute if entity @s[tag=soul-bullet] run function omegaflowey.entity:soul/soul_5/bullet/loop
execute if entity @s[tag=soul-executor] run function omegaflowey.entity:soul/soul_5/executor/loop
execute if entity @s[tag=soul-executor] run function omegaflowey.entity:soul/soul_5/executor/loop with storage omegaflowey:bossfight
execute if entity @s[tag=soul-healer] run function omegaflowey.entity:soul/soul_5/healer/loop
execute if entity @s[tag=soul-indicator] run function omegaflowey.entity:soul/soul_5/indicator/loop
execute if entity @s[tag=soul-locator] run function omegaflowey.entity:soul/soul_5/locator/loop
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,16 @@ schedule function omegaflowey.main:summit/room/cave/active_player_health_display
schedule function omegaflowey.entity:utils/damage/reset_immunity_flag 10t replace

# Show custom death message
execute if score #omegaflowey.bossfight.show_custom_death_message omegaflowey.global.flag matches 1 run tellraw @a [ \
{ "selector": "@s"}, \
" was slain by ", \
{ "text": "Omega Flowey", "color": "green" } \
]
# TAG_SUMMIT_HARDCODED_GLOBAL_VOLUME
execute if score #omegaflowey.bossfight.show_custom_death_message omegaflowey.global.flag matches 1 run \
tellraw @a[ \
x=-186, dx=91, y=12, dy=93, z=12, dz=95, \
tag=omegaflowey.player \
] [ \
{ "selector": "@s"}, \
" was slain by ", \
{ "text": "Omega Flowey", "color": "green" } \
]

# Re-enable `showDeathMessages` if it was enabled previously
execute if score #omegaflowey.bossfight.show_custom_death_message omegaflowey.global.flag matches 1 \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ function omegaflowey.entity:setup

# don't run room setup if there are no players on, as this duplicates entities due to them
# not being loaded
execute if entity @a run function omegaflowey.main:summit/room/setup
execute if entity @a[limit=1] run function omegaflowey.main:summit/room/setup

function omegaflowey.utils:log { text_component: '[ { "text": "Datapack initialized", "color": "aqua" } ]'}

0 comments on commit fe13f87

Please sign in to comment.