Skip to content

Commit

Permalink
add soul event infrastructure for boss fight (#84)
Browse files Browse the repository at this point in the history
supplementarily:
- make `datapack/test` workflow run regardless of if `datapack/lint` passes -- [`f36d384` (#84)](f36d384)
- add objective setup and `reset_scores` functions to run on `/reload` -- [`d5ac716` (#84)](d5ac716)
- refactor AJ removal function calls into standalone function -- [`1a3a311` (#84)](1a3a311)
- add convenience function to stop the boss fight -- [`26db866` (#84)](26db866)
- let `attack-flies` trigger next boss-fight attack sooner -- [`1a73212` (#84)](1a73212)
- add missing models to `remove_animated_java_models` -- [`a0d30c5` (#84)](a0d30c5)
  • Loading branch information
TheAfroOfDoom authored Feb 29, 2024
1 parent 1fa99b3 commit e4dca8e
Show file tree
Hide file tree
Showing 53 changed files with 1,288 additions and 36 deletions.
1 change: 0 additions & 1 deletion .github/workflows/datapack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ jobs:

test:
runs-on: ubuntu-latest
needs: lint
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
Expand Down
1 change: 1 addition & 0 deletions datapacks/omega-flowey/data/_/functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This directory contains convenience functions for developers for quicker calls t
- `attack`: runs the pre-defined attack's `start` function
- `attack/random/n`: randomly starts an attack from the `boss_fight`'s attack phase `n` (e.g. `n = 0`)
- `boss_fight`: starts the vanilla boss fight
- `boss_fight/stop`: stops any currently running boss fights
- `heal`: heals the executing player to full, fills the hunger bar, and applies infinite night vision
- `reset_scores`: resets the `omega-flowey` boss's attack score parameters
- `reset`: calls `omega-flowey:reset`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
function entity:remove_animated_java_models
kill @e[tag=boss_fight]
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ scoreboard players set @s boss-fight.attack.phase.total 6
scoreboard players set @s boss-fight.progress.phase.i 0
scoreboard players set @s boss-fight.progress.phase.total 6

# Add tags
tag @s add boss_fight.phase.attack

# Remove tag
tag @s remove boss_fight_new

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

# Run loop logic based on what phase the boss_fight is in
execute if entity @s[tag=boss_fight.phase.attack] run function entity:directorial/boss_fight/vanilla/phase/attack/loop
execute if entity @s[tag=boss_fight.phase.soul] run function entity:directorial/boss_fight/vanilla/phase/soul/loop
execute if entity @s[tag=boss_fight.phase.warn] run function entity:directorial/boss_fight/vanilla/phase/warn/loop
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ execute if score @s boss-fight.attack.phase.i matches 1 run function entity:dire

# Set scores
scoreboard players set @s boss-fight.attack.clock.i -1

# Add tags
tag @s add boss_fight.phase.attack

# Remove tv_screen.soul model(s) if they exist
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.soul] run function animated_java:tv_screen/remove/this
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Set scores
# Length of music (up to the WARNING sound)
scoreboard players set @s boss-fight.attack.clock.total 410
scoreboard players set @s boss-fight.attack.clock.total 414

# Play music
playsound omega-flowey:music.phase.1 record @a ~ ~ ~ 10 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ scoreboard players add @s boss-fight.attack.phase.i 1
# Wrap around total phases (6)
scoreboard players operation @s boss-fight.attack.phase.i %= @s boss-fight.attack.phase.total

# Next phase
function entity:directorial/boss_fight/vanilla/phase/warn/initialize

# Remove tags
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Split on phase score
execute if score @s boss-fight.progress.phase.i matches 0 run function entity:directorial/boss_fight/vanilla/phase/soul/initialize/0

## Set scores
# the negative time duration is how long the static length lasts (25 ticks)
scoreboard players set @s boss-fight.progress.clock.i -26
scoreboard players set @s boss-fight.progress.clock.total 27

function entity:directorial/boss_fight/vanilla/phase/soul/static

# Move players to soul arena
execute as @a at @s unless entity @s[team=!player,team=!spectator] run teleport @s ~ ~ ~-75.0

# Add tags
tag @s add boss_fight.phase.soul

# Delete main flowey models for performance reasons
function entity:hostile/omega-flowey/summon/remove_preexisting_models/except_tv_screen
execute as @e[tag=aj.soul.root,tag=soul.warning] run function animated_java:soul/remove/this
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.boss_fight] run function animated_java:tv_screen/remove/this
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# we check the score's larger range first because we could otherwise unintentionally
# run both loop functions in one tick if `pre_static` incremented the score from -1 -> 0
execute if score @s boss-fight.progress.clock.i matches 0.. run function entity:directorial/boss_fight/vanilla/phase/soul/loop/post_static
execute if score @s boss-fight.progress.clock.i matches ..-1 run function entity:directorial/boss_fight/vanilla/phase/soul/loop/pre_static
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
tag @s remove has_active_soul_event

function entity:directorial/boss_fight/vanilla/phase/soul/static

# Delete floating soul model
execute as @e[tag=aj.soul.root,tag=soul.soul_event] run function animated_java:soul/remove/this
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Split on phase score
execute if score @s boss-fight.progress.phase.i matches 0 run function entity:directorial/boss_fight/vanilla/phase/soul/loop/next_event/0

# Change tv screen variant
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.soul] run function animated_java:tv_screen/apply_variant/default

# Summon and begin animating soul heart model in front of soul screen
execute store result storage animate:soul soul_index int 1 run scoreboard players get @s boss-fight.progress.phase.i
function entity:hostile/omega-flowey/summon/soul/soul with storage animate:soul
execute as @e[tag=aj.soul.root,tag=soul.soul_event] run function entity:hostile/omega-flowey/animate/soul/soul
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function entity:soul/soul_0/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# wait until the soul event finishes before continuing the boss_fight's loop
execute if entity @s[tag=has_active_soul_event] run return 0

scoreboard players add @s boss-fight.progress.clock.i 1

execute if score @s boss-fight.progress.clock.i = @s boss-fight.progress.clock.total run function entity:directorial/boss_fight/vanilla/phase/soul/terminate
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Initial TV screen static, before the soul event starts
scoreboard players add @s boss-fight.progress.clock.i 1

# Start new soul event at clock index 0
execute if score @s boss-fight.progress.clock.i matches 0 run function entity:directorial/boss_fight/vanilla/phase/soul/loop/next_event

# Add tags
tag @s add has_active_soul_event
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.soul] at @s run function entity:directorial/boss_fight/vanilla/phase/soul/static/as_root
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Play static sound
playsound omega-flowey:boss-fight.static ambient @a ~ ~ ~ 10

function animated_java:tv_screen/apply_variant/static
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Remove tags
tag @s remove boss_fight.phase.soul

# Next phase
function entity:directorial/boss_fight/vanilla/phase/attack/initialize

# Move players to main arena
execute as @a at @s unless entity @s[team=!player,team=!spectator] run teleport @s ~ ~ ~75.0

# Re-summon main Omega Flowey models
function entity:hostile/omega-flowey/summon
function entity:hostile/omega-flowey/animate
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
# Play WARNING sound
execute at @e[tag=aj.tv_screen.root] run playsound omega-flowey:boss-fight.alarm hostile @a ~ ~ ~ 10 1
execute at @e[tag=aj.tv_screen.root,tag=tv_screen.boss_fight] run playsound omega-flowey:boss-fight.alarm ambient @a ~ ~ ~ 10 1

# Set Omega Flowey to WARNING variant
function entity:hostile/omega-flowey/animate/tv-screen/warning
# Set tv screen to WARNING variant
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.boss_fight] run function entity:hostile/omega-flowey/animate/warning/tv_screen

execute store result storage animate:soul soul_index int 1 run scoreboard players get @s boss-fight.progress.phase.i

# Set applicable petal-pipe to soul-color variant
execute store result storage animate:pipe soul_index int 1 run scoreboard players get @s boss-fight.progress.phase.i
function entity:hostile/omega-flowey/animate/pipe with storage animate:pipe
function entity:hostile/omega-flowey/animate/pipe with storage animate:soul

# Summon and begin animating soul heart model in front of WARNING screen
function entity:hostile/omega-flowey/summon/warning/soul with storage animate:soul
execute as @e[tag=aj.soul.root,tag=soul.warning] run function entity:hostile/omega-flowey/animate/warning/soul

# Summon and begin animating soul tv_screen in other arena
function entity:hostile/omega-flowey/summon/soul/tv_screen
execute as @e[tag=aj.tv_screen.root,tag=tv_screen.soul] run function entity:hostile/omega-flowey/animate/soul/tv_screen
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
# Remove tags
tag @s remove boss_fight.phase.warn

# Next phase
function entity:directorial/boss_fight/vanilla/phase/soul/initialize
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function animated_java:soul/animations/float/play
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
function animated_java:tv_screen/animations/move/play
function animated_java:tv_screen/apply_variant/default

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
function animated_java:soul/animations/shake/play
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
function animated_java:tv_screen/apply_variant/warning
execute on passengers if entity @s[tag=aj.tv_screen.bone.screen] run data merge entity @s { brightness: { block: 15, sky: 0 } }
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
## terminate if there are no more associated flies
## terminate indicator 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 1 run scoreboard players set @s attack.clock.i -1
execute if score #attack.flies.count math.0 matches 1 run tag @s add flies_are_done

# let boss fight perform next attack if there are 5 flies remaining
execute if score #attack.flies.count math.0 matches 5 as @e[tag=boss_fight] run function entity:hostile/omega-flowey/attack/flies/indicator/terminate/boss_fight
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
execute as @e[tag=boss_fight] run function entity:hostile/omega-flowey/attack/flies/indicator/terminate/boss_fight

function animated_java:venus_fly_trap/remove/this
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ execute positioned 0 37 -13 rotated 0 10 run function animated_java:nose/summon

## TV-screen
execute positioned 0 49 -6 rotated 0 45 run function animated_java:tv_screen/summon
tag @e[tag=aj.tv_screen.root,tag=!tv_screen.soul,tag=!tv_screen.boss_fight] add tv_screen.boss_fight

## Upper eyes
# Right-eye
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
function animated_java:large_side_vine/remove/all
function animated_java:lower_eye/remove/all
function animated_java:nose/remove/all
function animated_java:petal_pipe_circle/remove/all
function animated_java:petal_pipe_middle/remove/all
function entity:hostile/omega-flowey/summon/remove_preexisting_models/except_tv_screen
function animated_java:tv_screen/remove/all
function animated_java:upper_eye/remove/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
function animated_java:large_side_vine/remove/all
function animated_java:lower_eye/remove/all
function animated_java:nose/remove/all
function animated_java:petal_pipe_circle/remove/all
function animated_java:petal_pipe_middle/remove/all
function animated_java:upper_eye/remove/all
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Soul heart (soul_event)
$execute at @e[tag=aj.tv_screen.locator.soul_event] run function animated_java:soul/summon/$(soul_index)
tag @e[tag=aj.soul.root,tag=!soul.soul_event,tag=!soul.warning] add soul.soul_event
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
execute positioned 0 49 -81 rotated 0 45 run function animated_java:tv_screen/summon
tag @e[tag=aj.tv_screen.root,tag=!tv_screen.soul,tag=!tv_screen.boss_fight] add tv_screen.soul
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Soul heart (warning)
$execute at @e[tag=aj.tv_screen.locator.warning] run function animated_java:soul/summon/$(soul_index)
tag @e[tag=aj.soul.root,tag=!soul.soul_event,tag=!soul.warning] add soul.warning
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Omega Flowey model
function entity:hostile/omega-flowey/summon/remove_preexisting_models

# Attack models
function animated_java:bomb/remove/all
function animated_java:dentata_snake_ball/remove/all
function animated_java:finger_gun/remove/all
function animated_java:finger_gun_bullet/remove/all
function animated_java:finger_gun_laser/remove/all
function animated_java:friendliness_pellet/remove/all
function animated_java:friendliness_pellet_ring/remove/all
function animated_java:homing_vine/remove/all
function animated_java:homing_vine_blinking_lane/remove/all
function animated_java:housefly/remove/all
function animated_java:projectile_star/remove/all
function animated_java:venus_fly_trap/remove/all

# Soul models
function animated_java:soul/remove/all
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
## Remove all animated java entities
# Omega Flowey model
function entity:hostile/omega-flowey/summon/remove_preexisting_models

# Attack models
function animated_java:dentata_snake_ball/remove/all
function animated_java:friendliness_pellet/remove/all
function animated_java:friendliness_pellet_ring/remove/all
function animated_java:projectile_star/remove/all
function entity:remove_animated_java_models

## Kill all `omega-flowey-remastered` entities
kill @e[tag=omega-flowey-remastered]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"replace": false,
"values": [
"omega-flowey:setup/objectives",
"_:reset_scores"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ scoreboard objectives add boss-fight.attack.delay dummy
scoreboard objectives add boss-fight.attack.phase.i dummy
# total number of attack phases before we wrap the index
scoreboard objectives add boss-fight.attack.phase.total dummy
scoreboard objectives add boss-fight.progress.clock.i dummy
# total duration (in ticks) of the progress phase
scoreboard objectives add boss-fight.progress.clock.total dummy
# index of the progress phase
scoreboard objectives add boss-fight.progress.phase.i dummy
# total number of progress phases in the boss fight
Expand All @@ -81,9 +84,9 @@ scoreboard objectives add math.0 dummy
scoreboard objectives add math.1 dummy
scoreboard objectives add math.2 dummy

scoreboard objectives add player.shake.pitch dummy
scoreboard objectives add player.shake.yaw dummy

scoreboard objectives add random dummy
scoreboard objectives add random.min dummy
scoreboard objectives add random.range dummy

scoreboard objectives add player.shake.pitch dummy
scoreboard objectives add player.shake.yaw dummy
Loading

0 comments on commit e4dca8e

Please sign in to comment.