Skip to content

Bossbar related functions

9thCore edited this page Nov 20, 2024 · 4 revisions

The functions on this page are available by loading the bossbar.lua extension. It is loaded by default.

level:newbossbar(room, patienthp, virushp, gameoverbar, gameoverfunc = function(beat) end, applyweight = false, hpflash = 0.5, hpeaseduration = 1, hpease = 'OutCubic', patienthpvar = 'f0', virushpvar = 'f1', weightvar = 'f2')

Creates a new boss bar for room index room, with two components: the patient and virus bars. On hit, the virus takes damage, and on miss, the patient takes damage. The bars start off enabled, but the object as a whole is not.

patienthp is the starting/max hp of the patient bar, and virushp is the starting/max hp of the virus. By default, this correlates 1:1 to the amount of hits/misses required for the bar to fully drain.

gameoverbar is the bar that the level will jump to on a game over, or when the patient hp bar reaches 0.

gameoverfunc is a function that will take the first beat of gameoverbar as a parameter.

applyweight, if supplied and set to true, will read from weightvar instead of damaging a constant 1 from the hp on hit/miss. If not supplied, weightvar will not be set or used at all.

hpflash is the duration for the regular low hp flashing animation and duration of the white flash on bar damage.

hpeaseduration and hpease are the duration and ease for the damage animation, when the bar smoothly lowers in size.

patienthpvar, virushpvar and weightvar are variables that will be used by the bars to store the patient's and virus' health, and the hit weight respectively.

The bar uses a few tags and conditionals for its functionality, all with the prefix dn.bossbar(room), with room being the index of the bar's room. The tags used are:

  • [onMiss]dn.bossbar(room) is the tag used to handle misses on the bar.
  • [onHit]dn.bossbar(room) is the tag used to handle hits on the bar.
  • dn.bossbar(room).patientupdatehp is the tag used to handle updating the patient's hp.
  • dn.bossbar(room).virusupdatehp is the tag used to handle updating the virus' hp.

And the conditionals are:

  • dn.bossbar(room).stillalive is a conditional that returns true if patienthpvar is above 0.
  • dn.bossbar(room).onetime is a Times Executed conditional that only runs once.
  • dn.bossbar(room).patientnegative is a conditional that returns true if patienthpvar is below 0.
  • dn.bossbar(room).virusnegative is a conditional that returns true if virushpvar is below 0.
  • dn.bossbar(room).patientlow is a conditional that returns true if patienthpvar is below 1/3 of its capacity.
  • dn.bossbar(room).viruslow is a conditional that returns true if virushpvar is below 1/3 of its capacity.

Returns a bossbar object.

Example:

bossbar = level:newbossbar(0, 40, 116, 65, function(beat)
    level:getrow(0):playexpression(beat, 'gameover') -- Play the 'gameover' animation on Cole (the first row)
end)
-- Create a new boss bar object for room 0, where the patient's hp is 40, virus' hp is 116, the game over bar is 65 and adds a Play Expression event on the first beat of bar 65

bossbar:setroom(beat, room)

Moves the bars to room at beat beat.

Example:

bossbar:setroom(2, 1) -- Move the bars to room 1 at beat 2

bossbar:setpatientstate(beat, state)

Disable or enable the patient bar according to state at beat beat.
If disabled, misses will not lower the patient's hp.
Will not move the bars into view.

Example:

bossbar:setpatientstate(1, false) -- Disable the patient bar at beat 1

bossbar:setvirusstate(beat, state)

Disable or enable the virus bar according to state at beat beat.
If disabled, hits will not lower the virus' hp.
Will not move the bars into view.

Example:

bossbar:setvirusstate(2, false) -- Disable the virus bar at beat 2

bossbar:setstate(beat, state)

Disable or enable the bossbar object according to state at beat beat.
Will not move the bars into view.

Example:

bossbar:setstate(3, true) -- Enable the object at beat 3

bossbar:show(beat, duration = 0, ease = 'Linear')

Shows the enabled bars, moving them into view and enabling the object.

Example:

bossbar:show(1, 1, 'OutCubic') -- Move both bars into view
bossbar:hide(3, 1, 'OutCubic') -- Move both bars out of view
bossbar:setpatientstate(4, false) -- Disable the patient bar
bossbar:show(4, 1, 'OutCubic') -- Move only the virus bar into view (as the patient bar was disabled)
bossbar:hide(6, 1, 'OutCubic') -- Move only the virus bar out of view (more on this function later)
bossbar:setvirusstate(7, false) -- Disable the virus bar..
bossbar:setpatientstate(7, true) -- ..reenable the patient bar..
bossbar:show(7, 1, 'OutCubic') -- ..and show the patient bar

bossbar:hide(beat, duration = 0, ease = 'Linear')

Hides the enabled bars, moving them out of view and disabling the object at beat beat + duration.

Example:

bossbar:show(1, 1, 'OutCubic') -- Bars appear, hi!
bossbar:hide(2, 1, 'OutCubic') -- Bars disappear, bye...

bossbar:adjustposition(beat, duration, ease)

Adjusts the position of the patient bar at beat beat, moving it over duration beats with ease ease.
Intended to be used if bossbar:setvirusstate() is called while the bar is shown, leaving the patient bar lower than it otherwise would be.

bossbar:setweight(beat, weight)

Only has an effect if applyweight is true.
Sets the weight of the hits and misses from beat onward to weight. This can be used to make a very difficult section less dangerous (or perhaps more dangerous, to raise the tension?).
This makes both the virus bar and patient bar take weight damage every hit/miss, respectively.

Example:

bossbar:setweight(16, 0.5) -- Very difficult section, so make it a bit more lenient
bossbar:setweight(32, 1) -- Back to normal
bossbar:setweight(48, 2) -- Last section, so make it tougher! Raise the stakes!

bossbar:sethp(beat, target, hp)

Sets the hp of target to hp at beat beat. hp is clamped between 0 and the bar's max hp.
target can be 'patient' or 'virus', referring to the patient and virus, respectively.

Example:

bossbar:sethp(48, 'virus', 32) -- Last section, so make sure the virus has at least 32 hits left

bossbar:addhp(beat, target, hp)

Adds hp to the hp of target at beat beat. This time, hp is not clamped, so using this can lead to the bar going outside the limit.
target can be 'patient' or 'virus', referring to the patient and virus, respectively.

Example:

bossbar:addhp(16, 'virus', -4) -- remove 4 from the virus' hp lol

level:getbossbar(room)

Returns the boss bar assigned to room index room, or nil if not yet created.