From 48701ed2f712fd2f3dbf6cc4a3ee1f6ab4b41d95 Mon Sep 17 00:00:00 2001 From: TheAfroOfDoom Date: Sun, 28 Jan 2024 19:28:54 -0500 Subject: [PATCH] force indicator to summon on opposite side if another indicator still exists - errors if both exist --- .../initialize/indicator/error.mcfunction | 2 ++ .../initialize/indicator/presummon.mcfunction | 25 +++++++++++-------- .../indicator/presummon/flipped.mcfunction | 7 ++++++ .../indicator/presummon/normal.mcfunction | 10 ++++++++ .../indicator/presummon/random.mcfunction | 4 +++ 5 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/error.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal.mcfunction create mode 100644 datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/random.mcfunction diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/error.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/error.mcfunction new file mode 100644 index 000000000..f58f5ebdc --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/error.mcfunction @@ -0,0 +1,2 @@ +data merge storage utils:error { error: '[ {"text": "Cannot start another ", "color":"yellow"}, {"text": "flies ", "color": "red"}, {"text":"attack when two are already running.","color":"yellow"} ]'} +function utils:error with storage utils:error diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon.mcfunction index f4bca86e7..ac5283054 100644 --- a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon.mcfunction +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon.mcfunction @@ -1,16 +1,19 @@ -# x-position will summon at either x: -20.00 or x: +20.00 -scoreboard players set @s attack.position.x 2000 -execute store result score @s math.0 run random value -1..0 -execute if score @s math.0 matches -1 run scoreboard players operation @s attack.position.x *= @s math.0 +# check for pre-existence of flipped/non-flipped indicators +scoreboard players set #attack.flies.flipped_exists math.0 0 +execute if entity @e[tag=attack-indicator,tag=flies,tag=is_flipped] run scoreboard players set #attack.flies.flipped_exists math.0 1 +scoreboard players set #attack.flies.nonflipped_exists math.0 0 +execute if entity @e[tag=attack-indicator,tag=flies,tag=!is_flipped] run scoreboard players set #attack.flies.nonflipped_exists math.0 1 -# face east if at -20.00, face west if at +20.00 -scoreboard players set @s attack.indicator.yaw 9000 -execute if score @s math.0 matches -1 run scoreboard players operation @s attack.indicator.yaw *= @s math.0 +# throw an error if both indicators (flipped + non-flipped) already exist +execute if score #attack.flies.nonflipped_exists math.0 matches 1 if score #attack.flies.flipped_exists math.0 matches 1 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/error +execute if score #attack.flies.nonflipped_exists math.0 matches 1 if score #attack.flies.flipped_exists math.0 matches 1 run return fail -# y-position will summon at y: 33.00 -scoreboard players set @s attack.position.y 3300 -# z-position will summon at z: 17.00 -scoreboard players set @s attack.position.z 1700 +# if a flipped indicator already exists, summon a non-flipped one (and vice-versa) +execute if score #attack.flies.nonflipped_exists math.0 matches 0 if score #attack.flies.flipped_exists math.0 matches 1 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal +execute if score #attack.flies.nonflipped_exists math.0 matches 1 if score #attack.flies.flipped_exists math.0 matches 0 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped + +# if neither exist, randomly pick one (50-50) +execute if score #attack.flies.nonflipped_exists math.0 matches 0 if score #attack.flies.flipped_exists math.0 matches 0 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/random # Store new position and yaw execute store result storage attack:flies x double 0.01 run scoreboard players get @s attack.position.x diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped.mcfunction new file mode 100644 index 000000000..629611b00 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped.mcfunction @@ -0,0 +1,7 @@ +function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal + +# flip x +scoreboard players operation @s attack.position.x *= #-1 mathf.const + +# flip yaw +scoreboard players operation @s attack.indicator.yaw *= #-1 mathf.const diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal.mcfunction new file mode 100644 index 000000000..31ab5ae0c --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal.mcfunction @@ -0,0 +1,10 @@ +# x: 20.00 +scoreboard players set @s attack.position.x 2000 + +# face west +scoreboard players set @s attack.indicator.yaw 9000 + +# y-position will summon at y: 33.00 +scoreboard players set @s attack.position.y 3300 +# z-position will summon at z: 17.00 +scoreboard players set @s attack.position.z 1700 diff --git a/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/random.mcfunction b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/random.mcfunction new file mode 100644 index 000000000..310bf88c6 --- /dev/null +++ b/datapacks/omega-flowey/data/entity/functions/hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/random.mcfunction @@ -0,0 +1,4 @@ +execute store result score @s math.0 run random value 0..1 + +execute if score @s math.0 matches 0 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/normal +execute if score @s math.0 matches 1 run function entity:hostile/omega-flowey/attack/flies/executor/initialize/indicator/presummon/flipped