Files
YataiDONNijiiro/Scripts/background/bg_collabs/a3.lua
T
2026-09-02 14:25:04 -04:00

232 lines
8.1 KiB
Lua

-- YataiDON-HSS override of PyTaikoGreen/background/bg_collabs/a3.lua: petal period/tile step use petal_info.x2[1]
local DonBGBase = require("background/bg_objects/donbg/base")
local Dancer = require("background/bg_objects/dancer")
local RendaController = require("background/bg_objects/renda")
local ChibiController = require("background/bg_objects/chibi")
local DancerModel = require("background/bg_objects/collab_dancer_model")
local COLLAB_PATH = "background/collab/a3"
local MAX_DANCERS = 4
-- Custom DonBG: looping screen-width tile scroll
local A3DonBG = setmetatable({}, { __index = DonBGBase })
A3DonBG.__index = A3DonBG
function A3DonBG.new(player_num)
local self = setmetatable({}, A3DonBG)
local base = DonBGBase.new(1, player_num, COLLAB_PATH)
for k, v in pairs(base) do self[k] = v end
self.move = anim.move(10000, { total_distance = -tex.get_screen_width(), loop = true })
return self
end
function A3DonBG:draw_textures(fade, y, frame)
local sw = tex.get_screen_width()
local sc = tex.get_screen_scale()
for i = 0, math.floor(2 * sc) - 1 do
tex.draw_texture(self._id_bg, {
frame = frame,
fade = fade,
x = (i * sw) + self.move.attribute
})
end
end
-- BGNormal: flicker overlay (anim 9) + curtain
local A3BGNormal = {}
A3BGNormal.__index = A3BGNormal
function A3BGNormal.new()
local self = setmetatable({}, A3BGNormal)
self.name = "bg_0"
tex.load_folder(COLLAB_PATH, "bg_normal/" .. self.name)
self.flicker = tex.get_animation(9)
self._id_bg = tex.get_id(self.name, "background") or 0
self._id_overlay = tex.get_id(self.name, "overlay") or 0
self._id_curtain = tex.get_id(self.name, "curtain") or 0
return self
end
function A3BGNormal:update(current_time_ms)
self.flicker:update(current_time_ms)
end
function A3BGNormal:draw()
tex.draw_texture(self._id_bg)
tex.draw_texture(self._id_overlay, { fade = self.flicker.attribute })
tex.draw_texture(self._id_curtain)
end
function A3BGNormal:destroy()
tex.unload_folder(COLLAB_PATH, "bg_normal/" .. self.name)
end
-- BGFever: extends BGFever4 pattern with petals tiling
-- Uses anims 16-18 for slide-in (same as BGFever3/Python BGFever4),
-- then a new looping vertical_move (duration 1300 = anim 15 duration) for petals.
local A3BGFever = {}
A3BGFever.__index = A3BGFever
function A3BGFever.new()
local self = setmetatable({}, A3BGFever)
self.name = "bg_fever_0"
tex.load_folder(COLLAB_PATH, "bg_fever/" .. self.name)
self.transitioned = false
self.horizontal_move = tex.get_animation(16)
self.bg_texture_move_down = tex.get_animation(17)
self.bg_texture_move_up = tex.get_animation(18)
local petal_info = tex.get_texture_info(self.name, "petals")
self.petal_width = petal_info and petal_info.x2[1] or 0
self.vertical_move = anim.move(1300, { total_distance = self.petal_width, loop = true })
self._id_overlay = tex.get_id(self.name, "overlay") or 0
self._id_petals = tex.get_id(self.name, "petals") or 0
return self
end
function A3BGFever:start()
self.bg_texture_move_down:start()
self.bg_texture_move_up:start()
end
-- ROUND 52: falling-edge re-arm -- the next start() replays the slide-in
-- (anim:start() rewinds; BaseAnimation::start -> restart).
function A3BGFever:reset()
self.transitioned = false
end
function A3BGFever:update(current_time_ms)
self.bg_texture_move_down:update(current_time_ms)
self.bg_texture_move_up:update(current_time_ms)
if self.bg_texture_move_up.is_finished and not self.transitioned then
self.transitioned = true
self.horizontal_move:restart()
end
if self.transitioned then
self.horizontal_move:update(current_time_ms)
end
self.vertical_move:update(current_time_ms)
end
function A3BGFever:draw()
local sc = tex.get_screen_scale()
local w = self.petal_width
tex.draw_texture(self._id_overlay)
for i = 0, math.floor(10 * sc) - 1 do
for j = 0, 1 do
tex.draw_texture(self._id_petals, {
x = (i * w) - self.horizontal_move.attribute,
y = (j * w) + self.vertical_move.attribute
})
end
end
end
function A3BGFever:destroy()
tex.unload_folder(COLLAB_PATH, "bg_fever/" .. self.name)
end
-- Custom Dancer: BaseDancer + shadow overlay
local BaseDancer = Dancer.Base
local A3Dancer = setmetatable({}, { __index = BaseDancer })
A3Dancer.__index = A3Dancer
function A3Dancer.new(name, index, bpm)
local self = setmetatable({}, A3Dancer)
local base = BaseDancer.new(name, index, bpm)
for k, v in pairs(base) do self[k] = v end
self._id_shadow = tex.get_id(self.name, "shadow") or 0
return self
end
function A3Dancer:draw(x)
BaseDancer.draw(self, x)
tex.draw_texture(self._id_shadow, { x = x, fade = 0.50 })
end
-- Background
local A3Background = {}
A3Background.__index = A3Background
function A3Background.new(player_num, bpm)
local self = setmetatable({}, A3Background)
self.donbg = A3DonBG.new(player_num)
self.bg_normal = A3BGNormal.new()
self.bg_fever = A3BGFever.new()
self.dancer = Dancer.BaseDancerGroup.new(0, bpm, MAX_DANCERS, COLLAB_PATH, A3Dancer)
self.renda = RendaController.new(COLLAB_PATH, 0)
self.chibi = ChibiController.new(bpm, COLLAB_PATH, 0)
self.is_clear = false
self.is_rainbow = false
-- ROUND 52 (r52-lua-divergence-fixes): reference dance_b_* count model (see
-- collab_dancer_model.lua). The old pre-R18 milestone counter and the
-- 3-dancer pre-seed are gone: the troupe is an absolute function of the
-- gauge every frame, starting at 1 (EnsoGraphicDancer.obj.c:2741).
self.dancer_model = DancerModel.new(MAX_DANCERS)
return self
end
function A3Background:update(current_ms, bpm)
self.donbg:update(current_ms)
self.bg_normal:update(current_ms)
self.bg_fever:update(current_ms)
self.dancer:update(current_ms, bpm)
self.renda:update(current_ms)
self.chibi:update(current_ms, bpm)
end
function A3Background:handle_good(player_num) self.chibi:add_chibi(player_num, false) end
function A3Background:handle_ok(player_num) self.chibi:add_chibi(player_num, false) end
function A3Background:handle_bad(player_num) self.chibi:add_chibi(player_num, true) end
function A3Background:handle_drumroll(player_num) self.renda:add_renda() end
-- ROUND 52: no renda on balloons/kusudama -- the reference build RendaEffect::Process fires
-- for note kinds 6/9 (drumrolls) only; see background.lua's note.
function A3Background:handle_balloon(player_num) end
function A3Background:handle_gauge(player_num, progress, is_clear, is_rainbow, clear_progress)
self.donbg:set_clear(is_clear)
-- ROUND 52: both edges, re-triggerable (the reference build BgFever::Process).
if is_clear and not self.is_clear then self.bg_fever:start() end
if not is_clear and self.is_clear and self.bg_fever.reset then self.bg_fever:reset() end
self.is_clear = is_clear
self.is_rainbow = is_rainbow
-- ROUND 52: reference dance_b_* model, symmetric every frame.
self.dancer_model:apply(self.dancer, progress, is_clear, clear_progress)
end
function A3Background:draw_back()
if self.is_clear then
if not self.bg_fever.transitioned then
self.bg_normal:draw()
self.bg_fever:draw()
else
self.bg_fever:draw()
end
else
self.bg_normal:draw()
end
self.donbg:draw()
self.renda:draw()
self.dancer:draw()
self.chibi:draw()
end
function A3Background:draw_fore() end
function A3Background:destroy()
self.donbg:destroy()
self.bg_normal:destroy()
self.bg_fever:destroy()
self.dancer:destroy()
self.renda:destroy()
self.chibi:destroy()
end
return A3Background