diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop.mcfunction index 6ce073604..9c24c01e6 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop.mcfunction @@ -1,11 +1,14 @@ -scoreboard players add @s attack.clock.i 1 - data merge storage utils:damage { damage: 2, radius: 1 } execute positioned ~ ~ ~ run function entity:utils/damage with storage utils:damage # Move forward function entity:hostile/omega-flowey/attack/flies/bullet/loop/move -# TODO: validate/determine a value for how long until the flies bullets terminate -# Terminate after X seconds -execute if score @s attack.clock.i matches 60.. run function entity:hostile/omega-flowey/attack/flies/bullet/terminate +# Begin terminating after reaching the venus fly trap's mouth +execute unless entity @s[tag=is_terminating] run function entity:group/start +execute unless entity @s[tag=is_terminating] if entity @e[scores={group.id=0},tag=attack-indicator,tag=flies,distance=..4] run tag @s add is_terminating +execute unless entity @s[tag=is_terminating] run function entity:group/end +# guard against flies who move past the fly trap and outside the arena due to e.g. lag +execute unless entity @s[tag=is_terminating] unless entity @s[x=-25,dx=50,y=-100,dy=200,z=-7,dz=29] run tag @s add is_terminating + +execute if entity @s[tag=is_terminating] run function entity:hostile/omega-flowey/attack/flies/bullet/loop/terminating diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop/terminating.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop/terminating.mcfunction new file mode 100644 index 000000000..b69577566 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/loop/terminating.mcfunction @@ -0,0 +1,5 @@ +scoreboard players add @s attack.clock.i 1 + +# Start animation + +execute if score @s attack.clock.i matches 5.. run function entity:hostile/omega-flowey/attack/flies/bullet/terminate diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/terminate.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/terminate.mcfunction index e06eec111..109e9af8f 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/terminate.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/bullet/terminate.mcfunction @@ -1 +1,9 @@ +# Play sound +playsound omega-flowey:attack.flies.swallow hostile @a ~ ~ ~ 5 1 1 + kill @s + +# Check if indicator should terminate +function entity:group/start +execute as @e[scores={group.id=0},tag=attack-indicator,tag=flies] run function entity:hostile/omega-flowey/attack/flies/indicator/maybe_terminate +function entity:group/end diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop.mcfunction index fea2558e2..c82f8ee6b 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop.mcfunction @@ -1,4 +1,8 @@ -scoreboard players add @s attack.clock.i 1 +execute if entity @s[tag=flies_are_done] run function entity:hostile/omega-flowey/attack/flies/indicator/loop/flies_are_done +execute if entity @s[tag=flies_are_done] run return 0 + +# Increment attack.clock.i before all flies are done (have been summoned + terminated) +execute if score @s attack.clock.i matches ..-1 run scoreboard players add @s attack.clock.i 1 # Ignore bullet summoning logic while `attack.clock.i` is negative execute if score @s attack.clock.i matches ..-1 run return 0 @@ -7,7 +11,3 @@ execute if score @s attack.clock.i matches ..-1 run return 0 scoreboard players operation @s math.0 = @s attack.clock.i scoreboard players operation @s math.0 %= @s attack.indicator.rate execute if score @s attack.bullets.remaining matches 1.. if score @s math.0 matches 0 run function entity:hostile/omega-flowey/attack/flies/indicator/loop/bullet/presummon - -# Terminate after flies shoot animation finishes -# TODO should only run terminate check upon a bullet's termination -execute if score @s attack.bullets.remaining matches ..0 run function entity:hostile/omega-flowey/attack/flies/indicator/terminate diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop/flies_are_done.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop/flies_are_done.mcfunction new file mode 100644 index 000000000..aca7221aa --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/loop/flies_are_done.mcfunction @@ -0,0 +1,8 @@ +# After flies are done, continue incrementing attack.clock.i +scoreboard players add @s attack.clock.i 1 + +# Begin animation +# execute if score @s attack.clock.i matches 0 run + +# Terminate after X ticks (Y seconds) +execute if score @s attack.clock.i matches 9.. run function entity:hostile/omega-flowey/attack/flies/indicator/terminate diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/maybe_terminate.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/maybe_terminate.mcfunction new file mode 100644 index 000000000..efef0bdca --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/indicator/maybe_terminate.mcfunction @@ -0,0 +1,6 @@ +## terminate if there are no more associated flies +# (`function entity:group/start` has already been ran by the bullet who called this function) +scoreboard players set #attack.flies.count math.0 0 +execute as @e[scores={group.id=0},tag=attack-bullet,tag=flies] run scoreboard players add #attack.flies.count math.0 1 +execute if score #attack.flies.count math.0 matches 0 run scoreboard players set @s attack.clock.i -1 +execute if score #attack.flies.count math.0 matches 0 run tag @s add flies_are_done