Skip to content

Commit

Permalink
More control over cutscenes in the Generated Episode
Browse files Browse the repository at this point in the history
  • Loading branch information
Knuxfan24 committed Sep 11, 2022
1 parent 653955d commit cb43b80
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
9 changes: 6 additions & 3 deletions MarathonRandomiser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -426,24 +426,27 @@
<hc:TabItem Header="Generated Episode" BorderBrush="#B146C2" >
<Grid Background="#FF181818" Name="Grid_Episode">
<!--Random Episode Configuration Checkboxes/Controls-->
<StackPanel HorizontalAlignment="Left" Width="210" Name="StackPanel_Episode">
<StackPanel HorizontalAlignment="Left" Width="226" Name="StackPanel_Episode">
<StackPanel.Resources>
<Style BasedOn="{StaticResource CheckBoxBaseStyle}" TargetType="{x:Type CheckBox}">
<Setter Property="Margin" Value="10,10,0,0" />
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</StackPanel.Resources>
<CheckBox x:Name="CheckBox_Episode_Generate" Content="Generate Random Episode" Click="Dependency_CheckBox_Changed"/>
<CheckBox x:Name="CheckBox_Episode_TownMissions" Content="Include Town Missions" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_TownMissions" Content="Include Town Missions" IsEnabled="False" Click="Dependency_CheckBox_Changed"/>
<Label x:Name="Label_Episode_TownMissionCount" Content="Amount:" Background="{x:Null}" BorderBrush="{x:Null}" IsEnabled="False"/>
<hc:NumericUpDown x:Name="NumericUpDown_Episode_TownMissionCount" Margin="10,0,10,0" SelectionBrush="#FFB146C2" Increment="1" Minimum="1" Maximum="53" Value="53" IsEnabled="False"/>
<Label x:Name="Label_Episode_CutsceneChance" Content="Cutscene Chance:" Background="{x:Null}" BorderBrush="{x:Null}" IsEnabled="False"/>
<hc:NumericUpDown x:Name="NumericUpDown_Episode_CutsceneChance" Margin="10,0,10,0" SelectionBrush="#FFB146C2" Increment="1" Minimum="0" Maximum="100" Value="100" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_CutsceneTownMissions" Content="Allow Cutscenes in Town Missions" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_SonicVH" Content="Enable Very Hard ~ Sonic" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_ShadowVH" Content="Enable Very Hard ~ Shadow" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_SilverVH" Content="Enable Very Hard ~ Silver" IsEnabled="False"/>
<CheckBox x:Name="CheckBox_Episode_GoAMusic" Content="Use GoA Music in Randomisation" IsEnabled="False"/>
</StackPanel>

<hc:TabControl Style="{StaticResource TabControlInLine}" Margin="210,0,0,60" HorizontalAlignment="Stretch" Name="TabControl_Episode" IsEnabled="False">
<hc:TabControl Style="{StaticResource TabControlInLine}" Margin="226,0,0,60" HorizontalAlignment="Stretch" Name="TabControl_Episode" IsEnabled="False">
<hc:TabItem Header="Very Hard DLC Paths" BorderBrush="#B146C2">
<Grid>
<!--Very Hard Mode ~ Sonic-->
Expand Down
17 changes: 14 additions & 3 deletions MarathonRandomiser/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,13 +685,22 @@ private void Dependency_CheckBox_Changed(object sender, RoutedEventArgs e)

case "CheckBox_Episode_Generate":
CheckBox_Episode_TownMissions.IsEnabled = NewCheckedStatus;
Label_Episode_TownMissionCount.IsEnabled = NewCheckedStatus;
NumericUpDown_Episode_TownMissionCount.IsEnabled = NewCheckedStatus;
Label_Episode_CutsceneChance.IsEnabled = NewCheckedStatus;
NumericUpDown_Episode_CutsceneChance.IsEnabled = NewCheckedStatus;
CheckBox_Episode_SonicVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_ShadowVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_SilverVH.IsEnabled = NewCheckedStatus;
CheckBox_Episode_GoAMusic.IsEnabled = NewCheckedStatus;
TabControl_Episode.IsEnabled = NewCheckedStatus;
// Hack to make the town mission stuff disable in chain.
CheckBox_Episode_TownMissions.IsChecked = false;
NumericUpDown_Episode_TownMissionCount.IsEnabled = false;
CheckBox_Episode_CutsceneTownMissions.IsEnabled = false;
break;
case "CheckBox_Episode_TownMissions":
Label_Episode_TownMissionCount.IsEnabled = NewCheckedStatus;
NumericUpDown_Episode_TownMissionCount.IsEnabled = NewCheckedStatus;
CheckBox_Episode_CutsceneTownMissions.IsEnabled = NewCheckedStatus;
break;

case "CheckBox_Misc_EnemyHealth":
Expand Down Expand Up @@ -1748,6 +1757,8 @@ private async void Randomise(object sender, RoutedEventArgs e)
bool? episodeGenerate = CheckBox_Episode_Generate.IsChecked;
bool? episodeTownMissions = CheckBox_Episode_TownMissions.IsChecked;
int episodeTownMissionCount = (int)NumericUpDown_Episode_TownMissionCount.Value;
int episodeCutsceneChance = (int)NumericUpDown_Episode_CutsceneChance.Value;
bool? episodeTownMissionsCutscene = CheckBox_Episode_CutsceneTownMissions.IsChecked;
bool? episodeGoAMusic = CheckBox_Episode_GoAMusic.IsChecked;

// Set up a level order for later.
Expand All @@ -1774,7 +1785,7 @@ private async void Randomise(object sender, RoutedEventArgs e)

UpdateLogger($"Generating random episode.");
string unpackedArchive = await Task.Run(() => Helpers.ArchiveHandler(archive));
LevelOrder = await Task.Run(() => EpisodeGenerator.Process(unpackedArchive, corePath, sonicVH, shadowVH, silverVH, episodeTownMissions, episodeTownMissionCount));
LevelOrder = await Task.Run(() => EpisodeGenerator.Process(unpackedArchive, corePath, sonicVH, shadowVH, silverVH, episodeTownMissions, episodeTownMissionCount, episodeCutsceneChance, episodeTownMissionsCutscene));
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions MarathonRandomiser/Randomisers/EpisodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ internal class EpisodeGenerator
/// <param name="silverVH">The path to Silver's Very Hard Mode Arc.</param>
/// <param name="townMissions">Whether or not to use Town Missions in the Generated Episode.</param>
/// <param name="townMissionCount">How many Town Missions should be included in the Generated Episode.</param>
public static async Task<Dictionary<string, int>> Process(string archivePath, string corePath, string? sonicVH, string? shadowVH, string? silverVH, bool? townMissions, int townMissionCount)
/// <param name="cutsceneChance">Percentage chance to add a cutscene at the start of a stage.</param>
/// <param name="missionCutscene">Whether or not Town Missions can have cutscenes too.</param>
public static async Task<Dictionary<string, int>> Process(string archivePath, string corePath, string? sonicVH, string? shadowVH, string? silverVH, bool? townMissions, int townMissionCount, int cutsceneChance, bool? missionCutscene)
{
Dictionary<string, int> LevelOrder = new();

Expand Down Expand Up @@ -257,9 +259,9 @@ public static async Task<Dictionary<string, int>> Process(string archivePath, st
#endregion

#region Town Missions
// Shuffle a list of all the used town missions.
if (townMissions == true)
{
// Shuffle a list of all the used town missions.
List<string> TownMissions = await Task.Run(() => Helpers.ShuffleList(new() { "1001", "1003", "1004", "1005", "1008", "1010", "1011", "1012", "1013", "1014", "1018", "1019", "1024", "1025", "1027", "1029", "1030", "1031", "1032", "1033", "1103", "1104", "1107", "1108", "1109", "1112", "1114", "1117", "1118", "1119", "1126", "1128", "1130", "1131", "1132", "1201", "1203", "1208", "1211", "1212", "1214", "1215", "1216", "1218", "1219", "1220", "1221", "1226", "1232", "1237", "1238", "1239", "1240" }));

// Trim the list down to the specified count.
Expand Down Expand Up @@ -450,9 +452,13 @@ public static async Task<Dictionary<string, int>> Process(string archivePath, st
lua[i] = $" SetNextMission(a1, \"scripts/mission/rando/{Path.GetFileNameWithoutExtension(nextLua)}.lua\")\r\n{lua[i]}";
}

// Select a random cutscene to start the mission with.
if (lua[i].Contains("mission_event_start = "))
// Select a random cutscene to start the mission with if the number rolled meets the chance criteria.
if (lua[i].Contains("mission_event_start = ") && (MainWindow.Randomiser.Next(0, 101) <= cutsceneChance))
{
// If this is a Town Mission and we're not allowing cutscenes in them, then skip this one.
if (lastLua.Contains("_town") && missionCutscene == false)
continue;

// Determine if we need to add a comma.
bool hasComma = lua[i].Contains(',');

Expand Down

0 comments on commit cb43b80

Please sign in to comment.