music.lua 1.9 KB

12345678910111213141516171819202122232425262728293031323334
  1. -- Native music sections from 80B3C904: one choice group, 29 ordered sections.
  2. -- The bank owns musical transitions; scripts only select a section at milestones.
  3. -- Section 5's authored name resolves to tumbler_exit. Later section-to-encounter
  4. -- pacing is reconstructed from package order and needs an audible full-route test.
  5. return function(m)
  6. local M = {}
  7. function M.update(c, s)
  8. local section
  9. local region = s:variable("ember.region")
  10. if s:variable("ember.ending") then section = -1
  11. elseif region == 0 then
  12. local p = s:variable("ember.apex.phase") or 0
  13. section = ({[0]=19,[1]=19,[2]=20,[3]=22,[4]=25,[5]=27,[6]=28,[7]=-1})[p]
  14. if p == 2 and s:variable("ember.r.electron_controllers.phase") == 2 then section = 21 end
  15. if p == 3 and s:variable("ember.r.cue.41") then section = 23 end
  16. if p == 3 and (s:variable("ember.apex.dead.EAST") or s:variable("ember.apex.dead.WEST")) then section = 24 end
  17. if p == 4 and s:variable("ember.r.cue.46") then section = 26 end
  18. elseif region == 40 then
  19. local p = s:variable("ember.cinder.phase") or 0
  20. section = ({[0]=5,[1]=6,[2]=6,[3]=7,[4]=7,[5]=8,[6]=9,[7]=10,[8]=11,
  21. [9]=12,[10]=13,[11]=15,[12]=16,[13]=16,[14]=17})[p]
  22. elseif region == 56 then
  23. section = ({[0]=3,[1]=3,[2]=3,[3]=4,[4]=5})[s:variable("ember.processing.phase") or 0]
  24. elseif region == 64 then
  25. section = s:variable("ember.bridge.extended") and 2
  26. or ((s:variable("ember.route.progress") or 0) >= 5 and 1 or 0)
  27. end
  28. if section == nil or s:variable("ember.music.section") == section then return end
  29. c:slot(assert(m.Slot.M_MUSIC_SENSOR_80B3C90A)):set_music_section{
  30. section = math.max(section, 0), enabled = section >= 0}
  31. c:set_variable("ember.music.section", section)
  32. end
  33. return M
  34. end