From 53294854a6acb6a158bf17395a0c14fb6cdca758 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 17:47:24 -0500 Subject: [PATCH 1/9] move `bounce` function to entity util functions directory - just moves the file location for better diffing in the next commit --- .../attack/dentata-snakes/bullet/loop => utils}/bounce.mcfunction | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename datapacks/omega-flowey/data/entity/functions/{hostile/omega-flowey/attack/dentata-snakes/bullet/loop => utils}/bounce.mcfunction (100%) diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction similarity index 100% rename from datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/bounce.mcfunction rename to datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction From c1b6d0847714a7e788a66d2f90f5573fe6873788 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:05:14 -0500 Subject: [PATCH 2/9] rename `math.0`/`math.1` in `bounce` function to be more descriptive --- .../entity/functions/utils/bounce.mcfunction | 27 ++++++++++--------- .../functions/setup/objectives.mcfunction | 5 ++++ 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index a07574cd2..cf863ea3f 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -1,4 +1,5 @@ -## Bounces the dentata-snake against the walls of the arena (flips x-direction/y-direction as necessary) +## Reflects an entity's facing direction (yaw only) against the walls of a specified bounding box +# i.e. (flips x-direction/z-direction as necessary) # TODO(42): adjust arena bounds based on new animated java model (visually, it clips into the wall right now) @@ -6,29 +7,29 @@ execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 # Save initial yaw -execute store result score @s math.0 run data get entity @s Rotation[0] -scoreboard players operation @s math.1 = @s math.0 +execute store result score @s util.bounce.yaw.initial run data get entity @s Rotation[0] +scoreboard players operation @s util.bounce.yaw = @s util.bounce.yaw.initial # Left wall facing flowey -execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=0..180] run scoreboard players operation @s math.0 *= #-1 mathf.const +execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=0..180] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const # Right wall facing flowey -execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run scoreboard players operation @s math.0 *= #-1 mathf.const +execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const # Top wall facing flowey # disable top-wall bouncing if has `can-escape-arena` tag -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s math.0 -= #180 mathf.const -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s math.0 *= #-1 mathf.const +execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s util.bounce.yaw -= #180 mathf.const +execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const # Bottom wall facing flowey -execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s math.0 -= #180 mathf.const -execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s math.0 *= #-1 mathf.const +execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s util.bounce.yaw -= #180 mathf.const +execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const # Store bounced angle -execute store result entity @s Rotation[0] float 1 run scoreboard players get @s math.0 +execute store result entity @s Rotation[0] float 1 run scoreboard players get @s util.bounce.yaw -# If `math.0 != math.1`, we bounced +# If `util.bounce.yaw != util.bounce.yaw.initial`, we bounced # If we bounced, play bounce sound # Only the bullet-head makes bounce sounds/shakes the player's screen -execute unless score @s math.0 = @s math.1 if entity @s[tag=attack-bullet-head] run playsound omega-flowey:attack.dentata-snakes.bounce hostile @a ~ ~ ~ 5 1 -execute unless score @s math.0 = @s math.1 if entity @s[tag=attack-bullet-head] as @a unless entity @s[team=!player,team=!dead,team=!spectator] at @s run function entity:utils/shake_screen +execute unless score @s util.bounce.yaw = @s util.bounce.yaw.initial if entity @s[tag=attack-bullet-head] run playsound omega-flowey:attack.dentata-snakes.bounce hostile @a ~ ~ ~ 5 1 +execute unless score @s util.bounce.yaw = @s util.bounce.yaw.initial if entity @s[tag=attack-bullet-head] as @a unless entity @s[team=!player,team=!dead,team=!spectator] at @s run function entity:utils/shake_screen diff --git a/datapacks/omega-flowey/data/omega-flowey/functions/setup/objectives.mcfunction b/datapacks/omega-flowey/data/omega-flowey/functions/setup/objectives.mcfunction index 33cb23086..9592ee18d 100644 --- a/datapacks/omega-flowey/data/omega-flowey/functions/setup/objectives.mcfunction +++ b/datapacks/omega-flowey/data/omega-flowey/functions/setup/objectives.mcfunction @@ -90,3 +90,8 @@ scoreboard objectives add player.shake.yaw dummy scoreboard objectives add random dummy scoreboard objectives add random.min dummy scoreboard objectives add random.range dummy + +# the final yaw an entity has after running bounce calculations +scoreboard objectives add util.bounce.yaw dummy +# the initial yaw an entity starts with before running bounce calculations +scoreboard objectives add util.bounce.yaw.initial dummy From 6c5bd5c5756f3de3cc7c7c025b361ade92f09eae Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:18:30 -0500 Subject: [PATCH 3/9] refactor shared bounce math / redundant target selectors into functions --- .../dentata-snakes/bullet/loop.mcfunction | 2 +- .../entity/functions/utils/bounce.mcfunction | 18 ++++++++---------- .../functions/utils/bounce/shared/x.mcfunction | 1 + .../functions/utils/bounce/shared/z.mcfunction | 2 ++ .../utils/bounce/x_negative.mcfunction | 1 + .../utils/bounce/x_positive.mcfunction | 1 + .../utils/bounce/z_negative.mcfunction | 1 + .../utils/bounce/z_positive.mcfunction | 1 + 8 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/x.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/z.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/x_negative.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/x_positive.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/z_negative.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/utils/bounce/z_positive.mcfunction diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction index 3d42a73f9..672a62644 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction @@ -5,7 +5,7 @@ data merge storage utils:damage { damage: 2.5 } function entity:utils/damage with storage utils:damage # Bounce if hit edge of arena -execute unless entity @s[x=-21,dx=42,z=-3,dz=21] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/bounce +execute unless entity @s[x=-21,dx=42,z=-3,dz=21] run function entity:utils/bounce # Move forward at defined `attack.speed.z` velocity execute store result storage utils:move z float 0.01 run scoreboard players get @s attack.speed.z diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index cf863ea3f..db5be58a7 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -10,20 +10,18 @@ execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-are execute store result score @s util.bounce.yaw.initial run data get entity @s Rotation[0] scoreboard players operation @s util.bounce.yaw = @s util.bounce.yaw.initial -# Left wall facing flowey -execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=0..180] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const +# -X wall +execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=0..180] run function entity:utils/bounce/x_negative -# Right wall facing flowey -execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const +# +X wall +execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run function entity:utils/bounce/x_positive -# Top wall facing flowey +# -Z wall # disable top-wall bouncing if has `can-escape-arena` tag -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s util.bounce.yaw -= #180 mathf.const -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const +execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run function entity:utils/bounce/z_negative -# Bottom wall facing flowey -execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s util.bounce.yaw -= #180 mathf.const -execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const +# +Z wall +execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive # Store bounced angle execute store result entity @s Rotation[0] float 1 run scoreboard players get @s util.bounce.yaw diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/x.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/x.mcfunction new file mode 100644 index 000000000..df2f8007e --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/x.mcfunction @@ -0,0 +1 @@ +scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/z.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/z.mcfunction new file mode 100644 index 000000000..5ae739e26 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/shared/z.mcfunction @@ -0,0 +1,2 @@ +scoreboard players operation @s util.bounce.yaw -= #180 mathf.const +scoreboard players operation @s util.bounce.yaw *= #-1 mathf.const diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_negative.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_negative.mcfunction new file mode 100644 index 000000000..6fb5552de --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_negative.mcfunction @@ -0,0 +1 @@ +function entity:utils/bounce/shared/x diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_positive.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_positive.mcfunction new file mode 100644 index 000000000..6fb5552de --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/x_positive.mcfunction @@ -0,0 +1 @@ +function entity:utils/bounce/shared/x diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_negative.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_negative.mcfunction new file mode 100644 index 000000000..f7d5b08f5 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_negative.mcfunction @@ -0,0 +1 @@ +function entity:utils/bounce/shared/z diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_positive.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_positive.mcfunction new file mode 100644 index 000000000..f7d5b08f5 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce/z_positive.mcfunction @@ -0,0 +1 @@ +function entity:utils/bounce/shared/z From 5e63a0829a8702946cfb202645b0577ab1b919f9 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:22:27 -0500 Subject: [PATCH 4/9] move "stop bouncing" logic out of `bounce` function - it shouldn't really exist here, the caller should handle any fancy "stop bouncing" logic --- .../attack/dentata-snakes/bullet/loop.mcfunction | 2 +- .../dentata-snakes/bullet/loop/maybe_bounce.mcfunction | 4 ++++ .../data/entity/functions/utils/bounce.mcfunction | 6 +----- 3 files changed, 6 insertions(+), 6 deletions(-) create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction index 672a62644..4580e66cd 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop.mcfunction @@ -5,7 +5,7 @@ data merge storage utils:damage { damage: 2.5 } function entity:utils/damage with storage utils:damage # Bounce if hit edge of arena -execute unless entity @s[x=-21,dx=42,z=-3,dz=21] run function entity:utils/bounce +execute unless entity @s[x=-21,dx=42,z=-3,dz=21] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce # Move forward at defined `attack.speed.z` velocity execute store result storage utils:move z float 0.01 run scoreboard players get @s attack.speed.z diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction new file mode 100644 index 000000000..ca1c661a6 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -0,0 +1,4 @@ +# Don't bounce if we've already escaped the arena (past top wall) +execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 + +function entity:utils/bounce diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index db5be58a7..633f619f4 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -3,9 +3,6 @@ # TODO(42): adjust arena bounds based on new animated java model (visually, it clips into the wall right now) -# Don't bounce if we've already escaped the arena (past top wall) -execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 - # Save initial yaw execute store result score @s util.bounce.yaw.initial run data get entity @s Rotation[0] scoreboard players operation @s util.bounce.yaw = @s util.bounce.yaw.initial @@ -17,8 +14,7 @@ execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_ execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run function entity:utils/bounce/x_positive # -Z wall -# disable top-wall bouncing if has `can-escape-arena` tag -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] unless entity @s[tag=can-escape-arena] run function entity:utils/bounce/z_negative +execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_negative # +Z wall execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive From 690ea296f7c757967a2ab24e80238d49aa339b4e Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:33:47 -0500 Subject: [PATCH 5/9] add macro parameter for function to run if the entity did bounce --- .../bullet/loop/after_bounce_as_bullet_head.mcfunction | 4 ++++ .../dentata-snakes/bullet/loop/maybe_bounce.mcfunction | 4 +++- .../data/entity/functions/utils/bounce.mcfunction | 5 +---- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head.mcfunction diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head.mcfunction new file mode 100644 index 000000000..7b22d6b19 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head.mcfunction @@ -0,0 +1,4 @@ +# 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 +execute as @a unless entity @s[team=!player,team=!dead,team=!spectator] at @s run function entity:utils/shake_screen diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction index ca1c661a6..d27a7309a 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -1,4 +1,6 @@ # Don't bounce if we've already escaped the arena (past top wall) execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 -function entity:utils/bounce +data merge storage utils:bounce { command_after_bouncing: 'execute if entity @s[tag=attack-bullet-head] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head' } + +function entity:utils/bounce with storage utils:bounce diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index 633f619f4..a0bb303a2 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -23,7 +23,4 @@ execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_ execute store result entity @s Rotation[0] float 1 run scoreboard players get @s util.bounce.yaw # If `util.bounce.yaw != util.bounce.yaw.initial`, we bounced -# If we bounced, play bounce sound -# Only the bullet-head makes bounce sounds/shakes the player's screen -execute unless score @s util.bounce.yaw = @s util.bounce.yaw.initial if entity @s[tag=attack-bullet-head] run playsound omega-flowey:attack.dentata-snakes.bounce hostile @a ~ ~ ~ 5 1 -execute unless score @s util.bounce.yaw = @s util.bounce.yaw.initial if entity @s[tag=attack-bullet-head] as @a unless entity @s[team=!player,team=!dead,team=!spectator] at @s run function entity:utils/shake_screen +$execute unless score @s util.bounce.yaw = @s util.bounce.yaw.initial run $(command_after_bouncing) From b04f7918036ccdff962185a06d329c5e6c0395c4 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:53:05 -0500 Subject: [PATCH 6/9] parameterize y/dy and X-wall bounds with macros --- .../bullet/loop/maybe_bounce.mcfunction | 3 +++ .../entity/functions/utils/bounce.mcfunction | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction index d27a7309a..eec741ab7 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -1,6 +1,9 @@ # Don't bounce if we've already escaped the arena (past top wall) execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 +data merge storage utils:bounce { x_negative_x: -21, x_negative_dx: 50 } +data merge storage utils:bounce { x_positive_x: 21, x_positive_dx: -50 } +data merge storage utils:bounce { y: 30, dy: 10 } data merge storage utils:bounce { command_after_bouncing: 'execute if entity @s[tag=attack-bullet-head] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head' } function entity:utils/bounce with storage utils:bounce diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index a0bb303a2..3aa766aff 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -1,5 +1,13 @@ ## Reflects an entity's facing direction (yaw only) against the walls of a specified bounding box # i.e. (flips x-direction/z-direction as necessary) +# --- +# params: +# * x_negative_x: x coordinate for the bounding box's safe region outside of the -X wall +# * x_negative_dx: x width for the bounding box's safe region outside of the -X wall +# * x_positive_x: x coordinate for the bounding box's safe region outside of the +X wall +# * x_positive_dx: x width for the bounding box's safe region outside of the +X wall +# * y/dy: generous y lower-bound + height for each bounding box +# (y/dy need to be generous because of target selectors being janky with volume selections) # TODO(42): adjust arena bounds based on new animated java model (visually, it clips into the wall right now) @@ -8,16 +16,16 @@ execute store result score @s util.bounce.yaw.initial run data get entity @s Rot scoreboard players operation @s util.bounce.yaw = @s util.bounce.yaw.initial # -X wall -execute unless entity @s[x=-21,dx=50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=0..180] run function entity:utils/bounce/x_negative +$execute unless entity @s[x=$(x_negative_x),dx=$(x_negative_dx),y=$(y),dy=$(dy),z=-1000,dz=2000] if entity @s[y_rotation=0..180] run function entity:utils/bounce/x_negative # +X wall -execute unless entity @s[x=21,dx=-50,y=30,dy=10,z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run function entity:utils/bounce/x_positive +$execute unless entity @s[x=$(x_positive_x),dx=$(x_positive_dx),y=$(y),dy=$(dy),z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run function entity:utils/bounce/x_positive # -Z wall -execute unless entity @s[x=-25,dx=50,y=30,dy=10,z=-3,dz=25] unless entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_negative +$execute unless entity @s[x=-25,dx=50,y=$(y),dy=$(dy),z=-3,dz=25] unless entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_negative # +Z wall -execute unless entity @s[x=-1000,dx=2000,y=30,dy=10,z=18,dz=-25] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive +$execute unless entity @s[x=-1000,dx=2000,y=$(y),dy=$(dy),z=18,dz=-25] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive # Store bounced angle execute store result entity @s Rotation[0] float 1 run scoreboard players get @s util.bounce.yaw From 23d401942c2aba65dbeed5a14b7c272036cd2b90 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 18:57:51 -0500 Subject: [PATCH 7/9] parameterize Z-wall bounds with macros - also fix -Z wall having wrong X-bounds due to old logic around `can-escape-arena` tag --- .../dentata-snakes/bullet/loop/maybe_bounce.mcfunction | 2 ++ .../data/entity/functions/utils/bounce.mcfunction | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction index eec741ab7..25aec8149 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -3,6 +3,8 @@ execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-are data merge storage utils:bounce { x_negative_x: -21, x_negative_dx: 50 } data merge storage utils:bounce { x_positive_x: 21, x_positive_dx: -50 } +data merge storage utils:bounce { z_negative_z: -3, z_negative_dz: 25 } +data merge storage utils:bounce { z_positive_z: 18, z_positive_dz: -25 } data merge storage utils:bounce { y: 30, dy: 10 } data merge storage utils:bounce { command_after_bouncing: 'execute if entity @s[tag=attack-bullet-head] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head' } diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index 3aa766aff..9fdcb618b 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -6,6 +6,10 @@ # * x_negative_dx: x width for the bounding box's safe region outside of the -X wall # * x_positive_x: x coordinate for the bounding box's safe region outside of the +X wall # * x_positive_dx: x width for the bounding box's safe region outside of the +X wall +# * z_negative_z: z coordinate for the bounding box's safe region outside of the -Z wall +# * z_negative_dz: z width for the bounding box's safe region outside of the -Z wall +# * z_positive_z: z coordinate for the bounding box's safe region outside of the +Z wall +# * z_positive_dz: z width for the bounding box's safe region outside of the +Z wall # * y/dy: generous y lower-bound + height for each bounding box # (y/dy need to be generous because of target selectors being janky with volume selections) @@ -22,10 +26,10 @@ $execute unless entity @s[x=$(x_negative_x),dx=$(x_negative_dx),y=$(y),dy=$(dy), $execute unless entity @s[x=$(x_positive_x),dx=$(x_positive_dx),y=$(y),dy=$(dy),z=-1000,dz=2000] if entity @s[y_rotation=-180..0] run function entity:utils/bounce/x_positive # -Z wall -$execute unless entity @s[x=-25,dx=50,y=$(y),dy=$(dy),z=-3,dz=25] unless entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_negative +$execute unless entity @s[x=-1000,dx=2000,y=$(y),dy=$(dy),z=$(z_negative_z),dz=$(z_negative_dz)] unless entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_negative # +Z wall -$execute unless entity @s[x=-1000,dx=2000,y=$(y),dy=$(dy),z=18,dz=-25] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive +$execute unless entity @s[x=-1000,dx=2000,y=$(y),dy=$(dy),z=$(z_positive_z),dz=$(z_positive_dz)] if entity @s[y_rotation=-90..90] run function entity:utils/bounce/z_positive # Store bounced angle execute store result entity @s Rotation[0] float 1 run scoreboard players get @s util.bounce.yaw From f20a69c18b95af91ea19303025e573a22c633ba4 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 19:03:54 -0500 Subject: [PATCH 8/9] use storage specific to `dentata-snakes` attack when calling bounce util function --- .../bullet/loop/maybe_bounce.mcfunction | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction index 25aec8149..5e4aafa42 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -1,11 +1,11 @@ # Don't bounce if we've already escaped the arena (past top wall) execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 -data merge storage utils:bounce { x_negative_x: -21, x_negative_dx: 50 } -data merge storage utils:bounce { x_positive_x: 21, x_positive_dx: -50 } -data merge storage utils:bounce { z_negative_z: -3, z_negative_dz: 25 } -data merge storage utils:bounce { z_positive_z: 18, z_positive_dz: -25 } -data merge storage utils:bounce { y: 30, dy: 10 } -data merge storage utils:bounce { command_after_bouncing: 'execute if entity @s[tag=attack-bullet-head] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head' } +data merge storage attack:dentata-snakes.bounce { x_negative_x: -21, x_negative_dx: 50 } +data merge storage attack:dentata-snakes.bounce { x_positive_x: 21, x_positive_dx: -50 } +data merge storage attack:dentata-snakes.bounce { z_negative_z: -3, z_negative_dz: 25 } +data merge storage attack:dentata-snakes.bounce { z_positive_z: 18, z_positive_dz: -25 } +data merge storage attack:dentata-snakes.bounce { y: 30, dy: 10 } +data merge storage attack:dentata-snakes.bounce { command_after_bouncing: 'execute if entity @s[tag=attack-bullet-head] run function entity:hostile/omega-flowey/attack/dentata-snakes/bullet/loop/after_bounce_as_bullet_head' } -function entity:utils/bounce with storage utils:bounce +function entity:utils/bounce with storage attack:dentata-snakes.bounce From f42b000a556c364dabcf6462918e18681ea867cc Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Tue, 20 Feb 2024 19:30:43 -0500 Subject: [PATCH 9/9] move TODO to dentata-snakes directory --- .../attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction | 1 + .../omega-flowey/data/entity/functions/utils/bounce.mcfunction | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction index 5e4aafa42..855658150 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/dentata-snakes/bullet/loop/maybe_bounce.mcfunction @@ -1,6 +1,7 @@ # Don't bounce if we've already escaped the arena (past top wall) execute if entity @s[x=-1000,dx=2000,y=30,dy=10,z=-4,dz=-1000,tag=can-escape-arena] run return 0 +# TODO(42): adjust arena bounds based on new animated java model (visually, it clips into the wall right now) data merge storage attack:dentata-snakes.bounce { x_negative_x: -21, x_negative_dx: 50 } data merge storage attack:dentata-snakes.bounce { x_positive_x: 21, x_positive_dx: -50 } data merge storage attack:dentata-snakes.bounce { z_negative_z: -3, z_negative_dz: 25 } diff --git a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction index 9fdcb618b..c533e8e1c 100644 --- a/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/utils/bounce.mcfunction @@ -13,8 +13,6 @@ # * y/dy: generous y lower-bound + height for each bounding box # (y/dy need to be generous because of target selectors being janky with volume selections) -# TODO(42): adjust arena bounds based on new animated java model (visually, it clips into the wall right now) - # Save initial yaw execute store result score @s util.bounce.yaw.initial run data get entity @s Rotation[0] scoreboard players operation @s util.bounce.yaw = @s util.bounce.yaw.initial