Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix UEF M6 mission failures #433

Merged
merged 3 commits into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SCCA_Coop_E06/SCCA_Coop_E06_AIBehaviors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -521,4 +521,4 @@ function HandleTempestLeftoverGuardingUnits(unit)
aiBrain:AssignUnitsToPlatoon(platoon, LeftoverUnits, 'Attack', 'NoFormation')
platoon:ForkAIThread(TempestChildBehavior, unit)
end
end
end
2 changes: 1 addition & 1 deletion SCCA_Coop_E06/SCCA_Coop_E06_CustomFunctions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1604,4 +1604,4 @@ function AreaReclaimCleanUp()
end
end
LOG('DEBUG: Reclaimables successfully damaged.')
end
end
2 changes: 1 addition & 1 deletion SCCA_Coop_E06/SCCA_Coop_E06_options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ options =
'15', '30', '60', '90', '120', '150', '180', '210', '240', '270', '300',
},
},
};
};
2 changes: 1 addition & 1 deletion SCCA_Coop_E06/SCCA_Coop_E06_save.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28385,4 +28385,4 @@ Scenario = {
},
},
},
}
}
2 changes: 1 addition & 1 deletion SCCA_Coop_E06/SCCA_Coop_E06_scenario.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ ScenarioInfo = {
},
},
},
}
}
31 changes: 18 additions & 13 deletions SCCA_Coop_E06/SCCA_Coop_E06_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ end
-----------------
-- Initialization
-----------------
function OnPopulate(scen)
function OnPopulate()
ScenarioUtils.InitializeScenarioArmies()
LeaderFaction, LocalFaction = ScenarioFramework.GetLeaderAndLocalFactions()

Expand Down Expand Up @@ -247,6 +247,7 @@ function SpawnPlayer()
ScenarioInfo.BlackSunCannon:SetCustomName(LOC '{i BlackSunCannon}')
ScenarioInfo.BlackSunCannon:SetReclaimable(false)
ScenarioInfo.BlackSunCannon:SetCapturable(false)
ScenarioInfo.BlackSunCannon:SetCanBeGiven(false)
ScenarioInfo.BlackSunCannon:RemoveToggleCap('RULEUTC_SpecialToggle')
ScenarioFramework.CreateUnitDestroyedTrigger(BlackSunCannonDestroyed, ScenarioInfo.BlackSunCannon)

Expand Down Expand Up @@ -301,7 +302,7 @@ function M3SpawnAeon()
AeonAI.M3AeonSWBaseAI()
end

function OnStart(scen)
function OnStart()
ScenarioFramework.SetUEFColor(Player1)
ScenarioFramework.SetUEFAllyColor(BlackSun)
ScenarioFramework.SetUEFAllyColor(Component)
Expand Down Expand Up @@ -372,14 +373,14 @@ end

function IntroMission1()
WaitSeconds(2.0)
ScenarioInfo.CoopCDR = {}
ScenarioInfo.HumanACUs = {}

-- Spawn in player ACUs, and insert them into the CoopCDR table
-- Spawn in player ACUs, and insert them into the HumanACUs table
ForkThread(function()
local tblArmy = ListArmies()
for name, _ in ScenarioInfo.HumanPlayers do
ScenarioInfo[name .. 'CDR'] = ScenarioFramework.SpawnCommander(name, name .. 'CDR', 'Warp', true, true, PlayerCommanderDestroyed)
table.insert(ScenarioInfo.CoopCDR, ScenarioInfo[name .. 'CDR'])
ScenarioInfo[name .. 'CDR'] = ScenarioFramework.SpawnCommander(name, name .. 'CDR', 'Warp', true, false, PlayerCommanderDestroyed) -- No pause on death, otherwise the death is registered too late
table.insert(ScenarioInfo.HumanACUs, ScenarioInfo[name .. 'CDR'])
WaitSeconds(2)
end
end)
Expand Down Expand Up @@ -1775,7 +1776,6 @@ function WinGame()
if ScenarioInfo.M3P3Obj then
ScenarioInfo.M3P3Obj:ManualResult(true)
end
-- ScenarioFramework.PlayEndGameMovie(1 , WinGame)

ScenarioInfo.OpComplete = true
ScenarioFramework.EndOperation(ScenarioInfo.OpComplete, ScenarioInfo.OpComplete, true)
Expand All @@ -1784,10 +1784,10 @@ end
-- Player ACU died, but if other player ACUs are still alive, continue
function PlayerCommanderDestroyed(unit)
-- Abnormally, you don't necessarily 'lose' if you're killed on this mission: so long as Black Sun survives, and at least 1 player ACU remains

-- REMINDER: This won't work if there's a pause set on ACU death
-- Are all the ACUs dead?
for k, commander in ScenarioInfo.CoopCDR do
if not commander:IsDead() then
for index, unit in ScenarioInfo.HumanACUs do
if not unit.Dead then
-- Somebody is still alive
return
end
Expand All @@ -1798,6 +1798,7 @@ function PlayerCommanderDestroyed(unit)
return
end

ScenarioInfo.CDRDeath = true
ScenarioFramework.PlayerDeath(unit, OpStrings.E06_D01_010)
end

Expand All @@ -1819,8 +1820,13 @@ function BlackSunCannonDestroyed(unit)
if not ScenarioInfo.CDRDeath then
ScenarioFramework.EndOperationSafety()
ScenarioFramework.FlushDialogueQueue()
ScenarioFramework.Dialogue(OpStrings.E06_M02_110, false, true)
ScenarioFramework.Dialogue(ScenarioStrings.PObjFail, ScenarioFramework.PlayerLose, true)

-- There are 2 ways to do this, both should have the same results:
-- First, we fire off the dialogue, last param indicates if it is a critical dialogue, which forces it to play over any other queued ones.
--ScenarioFramework.Dialogue(OpStrings.E06_M02_110, ScenarioFramework.PlayerLose, true)

-- Second, we call the lose function with the dialogue, add the table of objectives to manually set to failed, last param indicates if we want to ignore an already ongoing mission failure event
ScenarioFramework.PlayerLose(OpStrings.E06_M02_110, {ScenarioInfo.M1P1Obj}, true)
end
end

Expand Down Expand Up @@ -1878,4 +1884,3 @@ function PlayTaunt()
end
end
end

5 changes: 2 additions & 3 deletions SCCA_Coop_E06/SCCA_Coop_E06_strings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ E06_M02_105 = {

-- If Black Sun is destroyed
E06_M02_110 = {
{text = '<LOC E06_M02_110_010>[{i Clarke}]: Attention UEF Forces, this is General Clarke. We have lost Black Sun, but we will never surrender! All units return to Earth Command. We will make our final stand there. Clarke out.\n\n', vid = 'E06_Clarke_M02_0294.sfd', bank = 'E06_VO', cue = 'E06_Clarke_M02_0294', faction = 'UEF'},
{text = '<LOC E06_M02_110_010>[{i Clarke}]: Attention UEF Forces, this is General Clarke. We have lost Black Sun, but we will never surrender! All units return to Earth Command. We will make our final stand there. Clarke out.', vid = 'E06_Clarke_M02_0294.sfd', bank = 'E06_VO', cue = 'E06_Clarke_M02_0294', faction = 'UEF'},
}

-- Objective Reminders for PO1, #1
Expand Down Expand Up @@ -643,5 +643,4 @@ TAUNT21 = {
-- ArielTaunt6
TAUNT22 = {
{text = '<LOC A05_T01_010_010>[{i Ariel}]: The Avatar will bring peace to the galaxy.', vid = 'A05_Ariel_T01_00938.sfd', bank = 'A05_VO', cue = 'A05_Ariel_T01_00938', faction = 'Aeon'},
}

}