Skip to content

Commit

Permalink
force indicator to summon on opposite side if another indicator still…
Browse files Browse the repository at this point in the history
… exists

- errors if both exist
  • Loading branch information
TheAfroOfDoom committed Jan 29, 2024
1 parent d013ee9 commit 48701ed
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 48701ed

Please sign in to comment.