landing.lua 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. -- First combat slice. Wave composition and in-game sequencing still require a live playtest.
  2. local Encounter = require("mission_ember.encounter")
  3. local NAMES = {
  4. "LANDING_MERCURY_ANCHOR_SQUAD",
  5. "LANDING_MERCURY_BONUS_ANCHOR_A_SQUAD",
  6. "LANDING_MERCURY_SUPPORT_A_SQUAD",
  7. "LANDING_MERCURY_SUPPORT_B_SQUAD",
  8. "LANDING_MERCURY_SUPPORT_C_SQUAD",
  9. "LANDING_MERCURY_RANGED_A_SQUAD",
  10. "LANDING_MERCURY_RANGED_B_SQUAD",
  11. "LANDING_MERCURY_BONUS_SUPPORT_A_SQUAD",
  12. "LANDING_MERCURY_BONUS_SUPPORT_B_SQUAD",
  13. "LANDING_MERCURY_BONUS_SUPPORT_C_SQUAD",
  14. "LANDING_MERCURY_BONUS_SUPPORT_D_SQUAD",
  15. }
  16. local BRIDGE_DEVICES = {
  17. "POWERHOUSE_BRIDGE_ARM_MERCURY_DEVICE",
  18. "POWERHOUSE_BRIDGE_GEAR_MERCURY_BOTTOM_DEVICE",
  19. "POWERHOUSE_BRIDGE_GEAR_MERCURY_TOP_DEVICE",
  20. "POWERHOUSE_BRIDGE_ARM_SUN_DEVICE",
  21. "POWERHOUSE_BRIDGE_GEAR_SUN_BOTTOM_DEVICE",
  22. "POWERHOUSE_BRIDGE_GEAR_SUN_TOP_DEVICE",
  23. }
  24. local function required(value, name)
  25. assert(value ~= nil, "mission_ember: missing SDK binding " .. name
  26. .. "; regenerate the SDK with the scenario-scoped squad linker")
  27. return value
  28. end
  29. return function(mission)
  30. local squads = {}
  31. for index, name in ipairs(NAMES) do
  32. squads[index] = {
  33. name = name,
  34. id = required(mission.Squad[name], "Squad." .. name),
  35. sensor = required(mission.Slot[name], "Slot." .. name),
  36. }
  37. end
  38. local entry = required(mission.states.STATE_80B3C09E_0008_0000_80B3C09C, "powerhouse state")
  39. local bridge = {}
  40. for index, name in ipairs(BRIDGE_DEVICES) do
  41. bridge[index] = required(mission.Slot[name], "Slot." .. name)
  42. end
  43. local bridge_objective = required(mission.Slot.EMBER_POWERHOUSE_BRIDGE_OBJECTIVE,
  44. "bridge objective")
  45. local directive = required(mission.Slot.M_DIRECTIVE_SENSOR_80B3C90A, "directive sensor")
  46. local clear = required(mission.Directive.FIND_AND_DISABLE_THE_ALMIGHTY_S_WEAPONS_A70DA4A6,
  47. "landing clear directive")
  48. local controls = required(mission.Directive.FIND_AND_DISABLE_THE_ALMIGHTY_S_WEAPONS_2700C0C5,
  49. "bridge controls directive")
  50. local encounter = Encounter.new("ember.landing", squads, function(context)
  51. context:slot(directive):set_directive{directive = controls}
  52. context:slot(mission.Slot.M_DIALOG_SENSOR_80B3C90A):play_dialogue_cue{
  53. cue = mission.DialogueCue.M_DIALOG_SENSOR_80B3C90A.CUE_3,
  54. }
  55. context:set_phase(3)
  56. -- The bridge must wait for its authored interaction. Combat clear does not open it.
  57. end)
  58. local function initialize(context)
  59. for _, device in ipairs(bridge) do
  60. context:slot(device):transition{transition = context.sdk.device_transitions.close, snap = true}
  61. end
  62. context:slot(bridge_objective):reset_objectives{}
  63. end
  64. return {
  65. initial_state = entry,
  66. region = entry.region_index,
  67. enter = function(context, state)
  68. if encounter:phase(state) ~= 0 then
  69. return
  70. end
  71. initialize(context)
  72. context:set_phase(2)
  73. encounter:enter(context, state)
  74. context:slot(directive):set_directive{directive = clear}
  75. end,
  76. client_state = function(context, state, event)
  77. if event.teleport_state == 0 then context:set_variable("ember.spawned", true) end
  78. if state:variable("ember.spawned") and not state:variable("ember.guidance")
  79. and event.region_index == nil and event.current_region_index == nil
  80. and event.spawn_state == nil and event.teleport_state == nil then
  81. context:set_variable("ember.guidance", true)
  82. context:slot(mission.Slot.M_DIALOG_SENSOR_80B3C90A):play_dialogue_cue{
  83. cue = mission.DialogueCue.M_DIALOG_SENSOR_80B3C90A.CUE_0,
  84. }
  85. end
  86. end,
  87. on_squad_state = function(context, state, event)
  88. encounter:on_squad_state(context, state, event)
  89. end,
  90. }
  91. end