mirror of
https://github.com/bryanthaboi/gen1recomp.git
synced 2026-08-16 08:11:35 +02:00
Honor trainer battleTheme override (fixes #945)
trainers.battleTheme validated and merged onto the trainer record but was never read: battle music came solely from data.audio.battle[kind] where kind is computeMusicKind()'s final/gym/trainer/wild. Route both battle- theme start sites through a single choke point: - BattleState:playBattleTheme() cues Music.playBattle with the override (self.trainer.battleTheme via battleTheme()), defaulting to the kind when unset, so vanilla fights and #782's non-gym Giovanni are unchanged. - BattleState:enter() and OverworldController:pushBattle() both call it. - Music.playBattle gains an optional 4th song arg that overrides the kind default, and real call sites now populate the music.select trainerId. - Victory jingles stay kind-based: a custom battle theme has no derivable win-variant. New ROM-free T2 suite tests/engine/trainer_battle_theme_bug945.lua covers mod load, override resolution, the choke point, and the nil-override parity gate. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
+4
-3
@@ -368,11 +368,12 @@ function Music.setSurfing(data, surfing)
|
||||
if play then Music.play(data, play, nil, { reason = "map" }) end
|
||||
end
|
||||
|
||||
-- battle themes; kind = "wild"|"trainer"|"gym"|"final"
|
||||
function Music.playBattle(data, kind, trainerId)
|
||||
-- battle themes; kind = "wild"|"trainer"|"gym"|"final". `song`, when
|
||||
-- given, overrides the kind's default -- a mod-set trainer battleTheme.
|
||||
function Music.playBattle(data, kind, trainerId, song)
|
||||
local b = data.audio and data.audio.battle
|
||||
if b then
|
||||
Music.play(data, b[kind] or b.wild, nil,
|
||||
Music.play(data, song or b[kind] or b.wild, nil,
|
||||
{ reason = "battle", kind = kind, trainerId = trainerId })
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user