Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 0d07ccf

Browse files
committed
Added speedrun support to dday
Also fixed up CompleteSpeedrun so it can be called multiple times
1 parent b6a61a9 commit 0d07ccf

File tree

2 files changed

+71
-1
lines changed

2 files changed

+71
-1
lines changed

Data/Base.rte/Scripts/Shared/Activity_SpeedrunHelper.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ function ActivitySpeedrunHelper:InitializeSpeedrun()
5353
end
5454

5555
function ActivitySpeedrunHelper:CompleteSpeedrun()
56-
self.speedrunCompletionTime = self.speedrunTimer.ElapsedRealTimeMS;
56+
if self.speedrunCompletionTime == -1 then
57+
self.speedrunCompletionTime = self.speedrunTimer.ElapsedRealTimeMS;
58+
end
5759
end
5860

5961
function ActivitySpeedrunHelper:SpeedrunActive()

Data/Missions.rte/Activities/DecisionDay.lua

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package.loaded.Constants = nil;
22
require("Constants");
3+
require("Scripts/Shared/Activity_SpeedrunHelper")
34

45
function DecisionDayDeployBrainPieSliceActivation(pieMenuOwner, pieMenu, pieSlice)
56
ActivityMan:GetActivity():SaveNumber("DeployBrain", pieMenuOwner:GetController().Player + 1);
@@ -398,6 +399,8 @@ function DecisionDay:OnSave()
398399
end
399400

400401
function DecisionDay:StartNewGame()
402+
self.speedrunData = ActivitySpeedrunHelper.Setup(self, self.DoSpeedrunMode);
403+
401404
self:SetTeamFunds(0, self.humanTeam);
402405
self.BuyMenuEnabled = false;
403406

@@ -787,6 +790,11 @@ function DecisionDay:DoGameOverCheck()
787790
self.messageTimer:Reset();
788791
end
789792
end
793+
794+
if self.speedrunData and self.WinnerTeam == self.humanTeam then
795+
self.messageTimer:SetSimTimeLimitMS(10000);
796+
ActivitySpeedrunHelper.CompleteSpeedrun(self.speedrunData);
797+
end
790798

791799
if self.WinnerTeam ~= Activity.NOTEAM and self.messageTimer:IsPastSimTimeLimit() then
792800
if self.WinnerTeam == self.humanTeam then
@@ -800,6 +808,48 @@ function DecisionDay:DoGameOverCheck()
800808
end
801809
end
802810

811+
function DecisionDay:DoSpeedrunMode()
812+
self.Difficulty = Activity.MAXDIFFICULTY;
813+
self.difficultyRatio = 2;
814+
for _, bunkerRegionData in pairs(self.bunkerRegions) do
815+
bunkerRegionData.captureLimit = 600 * self.difficultyRatio;
816+
bunkerRegionData.aiRegionDefenseTimer:SetSimTimeLimitMS(60000 / self.difficultyRatio);
817+
bunkerRegionData.aiRegionDefenseTimer.ElapsedSimTimeMS = 60000 / self.difficultyRatio;
818+
bunkerRegionData.aiRegionAttackTimer:SetSimTimeLimitMS(90000 / self.difficultyRatio);
819+
end
820+
821+
self.aiData.externalSpawnTimer:SetSimTimeLimitMS(120000 / self.difficultyRatio);
822+
self.aiData.internalReinforcementsTimer:SetSimTimeLimitMS(100000 / self.difficultyRatio);
823+
self.aiData.internalReinforcementLimit = 12 * self.difficultyRatio;
824+
self.aiData.bunkerRegionDefenseRange = math.max(500, math.min(750 * self.difficultyRatio, 1000));
825+
self.aiData.attackerLimit = 10 * self.difficultyRatio;
826+
self.aiData.attackersPerSpawn = 4 * self.difficultyRatio;
827+
828+
self.aiData.brainDefenderSpawnTimer:SetSimTimeLimitMS(10000 / self.difficultyRatio);
829+
self.aiData.brainDefenderReplenishTimer:SetSimTimeLimitMS(30000 / self.difficultyRatio);
830+
self.aiData.brainDefendersTotal = 20 * self.difficultyRatio;
831+
self.aiData.brainDefendersRemaining = self.aiData.brainDefendersTotal;
832+
833+
self:SetTeamFunds(0, self.humanTeam);
834+
835+
self:SetTeamTech(self.humanTeam, "-All-");
836+
self.humanTeamTech = PresetMan:GetModuleID(self:GetTeamTech(self.humanTeam));
837+
self:SetTeamTech(self.aiTeam, "-All-");
838+
self.aiTeamTech = PresetMan:GetModuleID(self:GetTeamTech(self.aiTeam));
839+
840+
AudioMan:PlayMusic("Base.rte/Music/dBSoundworks/bossfight.ogg", -1, -1);
841+
842+
self.messageTimer:SetSimTimeLimitMS(1);
843+
844+
self.currentStage = self.stages.attackFrontBunker;
845+
846+
self.aiData.internalReinforcementsEnabled = true;
847+
self.internalReinforcementsData[self.bunkerIds.frontBunker].enabled = true;
848+
849+
self.bunkerRegions["Front Bunker Operations"].enabled = true;
850+
self.bunkerRegions["Front Bunker Small Vault"].enabled = true;
851+
end
852+
803853
function DecisionDay:UpdateCurrentStage()
804854
local previousStage = self.currentStage;
805855

@@ -939,6 +989,10 @@ function DecisionDay:UpdateCamera()
939989
CameraMan:SetScrollTarget(Vector(adjustedCameraMinimumX, CameraMan:GetScrollTarget(player).Y), 0.25, false, 0);
940990
end
941991
end
992+
993+
if self.speedrunData and ActivitySpeedrunHelper.SpeedrunActive(self.speedrunData) then
994+
return;
995+
end
942996

943997
local slowScroll = 0.0125;
944998
local mediumScroll = 0.05;
@@ -1050,6 +1104,12 @@ function DecisionDay:UpdateCamera()
10501104
end
10511105

10521106
function DecisionDay:UpdateMessages()
1107+
if self.speedrunData and ActivitySpeedrunHelper.SpeedrunActive(self.speedrunData) then
1108+
FrameMan:ClearScreenText(Activity.PLAYER_1);
1109+
FrameMan:SetScreenText(ActivitySpeedrunHelper.GetSpeedrunDuration(self.speedrunData), Activity.PLAYER_1, 0, 1, ActivitySpeedrunHelper.SpeedrunCompleted(self.speedrunData));
1110+
return;
1111+
end
1112+
10531113
if self.messageTimer:IsPastSimTimeLimit() then
10541114
if self.currentMessageNumber < self.numberOfMessagesForStage then
10551115
self.currentMessageNumber = self.currentMessageNumber + 1;
@@ -2064,6 +2124,14 @@ function DecisionDay:UpdateActivity()
20642124
if self.WinnerTeam ~= Activity.NOTEAM then
20652125
return;
20662126
end
2127+
2128+
if self.speedrunData and not ActivitySpeedrunHelper.SpeedrunActive(self.speedrunData) then
2129+
if self.currentStage == self.stages.followInitialDropShip then
2130+
ActivitySpeedrunHelper.CheckForSpeedrun(self.speedrunData);
2131+
else
2132+
self.speedrunData = nil;
2133+
end
2134+
end
20672135

20682136
if self.currentStage < self.stages.frontBunkerCaptured then
20692137
self:SpawnAndUpdateInitialDropShips();

0 commit comments

Comments
 (0)