Skip to content

Commit

Permalink
Add support for randomizing predators and other features.
Browse files Browse the repository at this point in the history
  • Loading branch information
ComplexRobot committed Dec 27, 2024
1 parent dab3e11 commit 2387a83
Show file tree
Hide file tree
Showing 7 changed files with 406 additions and 134 deletions.
2 changes: 1 addition & 1 deletion Palworld Randomizer.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Version>2.9</Version>
<Version>2.10</Version>
<TargetFramework>net8.0-windows</TargetFramework>
<UseWPF>True</UseWPF>
<Nullable>enable</Nullable>
Expand Down
322 changes: 223 additions & 99 deletions Randomize.cs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions UAssetData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public static Dictionary<string, CharacterData> CreatePalData()
StructPropertyData dummyData = (StructPropertyData) referenceData.Clone();
CharacterData rowNameData = new CharacterData(PalDataAsset, dummyData)
{
IsPal = true,
ZukanIndex = -1,
OverrideNameTextID = null,
IsBoss = false
Expand Down
181 changes: 151 additions & 30 deletions Window/MainPage.xaml

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion Window/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public FormData() : this(MainPage.Instance) { }
public bool RandomizeDungeons = window.randomizeDungeons.IsChecked == true;
public bool RandomizeDungeonBosses = window.randomizeDungeonBosses.IsChecked == true;
public bool RandomizeFieldBosses = window.randomizeFieldBosses.IsChecked == true;
public bool RandomizePredators = window.randomizePredators.IsChecked == true;
public int PredatorChance = int.Parse(window.predatorChance.Text);
public bool EqualizeAreaRarity = window.equalizeAreaRarity.IsChecked == true;
public bool MethodFull = window.methodFull.IsChecked == true;
public bool MethodCustomSize = window.methodCustomSize.IsChecked == true;
Expand Down Expand Up @@ -82,6 +84,7 @@ public FormData() : this(MainPage.Instance) { }
public bool BossesEverywhere = window.bossesEverywhere.IsChecked == true;
public int BossesEverywhereChance = int.Parse(window.bossesEverywhereChance.Text);
public bool SeparateFlying = window.separateFlying.IsChecked == true;
public bool PredatorConstraint = window.predatorConstraint.IsChecked == true;
public bool WeightTypeUniform = window.weightTypeUniform.IsChecked == true;
public bool WeightTypeCustom = window.weightTypeCustom.IsChecked == true;
public int WeightUniformMin = int.Parse(window.weightUniformMin.Text);
Expand All @@ -104,6 +107,7 @@ public FormData() : this(MainPage.Instance) { }
}))();
public string WeightCustomMode = window.weightCustomMode.Text;
public int HumanRarity = int.Parse(window.humanRarity.Text);
public int HumanBossRarity = int.Parse(window.humanBossRarity.Text);
public bool WeightAdjustProbability = window.weightAdjustProbability.IsChecked == true;
public int HumanWeight = int.Parse(window.humanWeight.Text);
public int HumanWeightAggro = int.Parse(window.humanWeightAggro.Text);
Expand All @@ -116,6 +120,7 @@ public FormData() : this(MainPage.Instance) { }
public bool SpawnTraders = window.spawnTraders.IsChecked == true;
public bool SpawnPalTraders = window.spawnPalTraders.IsChecked == true;
public bool SpawnTowerBosses = window.spawnTowerBosses.IsChecked == true;
public bool SpawnAlphas = window.spawnAlphas.IsChecked == true;
public bool SpawnRaidBosses = window.spawnRaidBosses.IsChecked == true;
public bool SpawnPredators = window.spawnPredators.IsChecked == true;
public bool SpawnHumanBosses = window.spawnHumanBosses.IsChecked == true;
Expand All @@ -124,6 +129,7 @@ public FormData() : this(MainPage.Instance) { }
public int DungeonLevel = int.Parse(window.dungeonLevel.Text);
public int FieldBossLevel = int.Parse(window.fieldBossLevel.Text);
public int DungeonBossLevel = int.Parse(window.dungeonBossLevel.Text);
public int PredatorLevel = int.Parse(window.predatorLevel.Text);
public int LevelCap = int.Parse(window.levelCap.Text);
public int BossAddLevel = int.Parse(window.bossAddLevel.Text);
public bool ForceAddLevel = window.forceAddLevel.IsChecked == true;
Expand All @@ -136,6 +142,7 @@ public FormData() : this(MainPage.Instance) { }
public int DungeonCount = int.Parse(window.dungeonCount.Text);
public int FieldBossCount = int.Parse(window.fieldBossCount.Text);
public int DungeonBossCount = int.Parse(window.dungeonBossCount.Text);
public int PredatorCount = int.Parse(window.predatorCount.Text);
public int CountClampMin = int.Parse(window.countClampMin.Text);
public int CountClampMax = int.Parse(window.countClampMax.Text);
public int CountClampFirstMin = int.Parse(window.countClampFirstMin.Text);
Expand All @@ -144,6 +151,7 @@ public FormData() : this(MainPage.Instance) { }
public bool NightOnlyDungeons = window.nightOnlyDungeons.IsChecked == true;
public bool NightOnlyDungeonBosses = window.nightOnlyDungeonBosses.IsChecked == true;
public bool NightOnlyBosses = window.nightOnlyBosses.IsChecked == true;
public bool NightOnlyPredators = window.nightOnlyPredators.IsChecked == true;

public void RestoreToWindow(MainPage window)
{
Expand Down Expand Up @@ -268,6 +276,7 @@ public MainPage(DispatcherOperation dataOperation)

public void ValidateFormData(int seed = 0)
{
ValidateNumericText(predatorChance, 0, 30, 100);
ValidateNumericText(randomSeed, 0, seed);
ValidateNumericText(groupMin, 1);
ValidateNumericText(groupMax, int.Parse(groupMin.Text));
Expand All @@ -279,13 +288,14 @@ public void ValidateFormData(int seed = 0)
ValidateNumericText(dungeonLevel, 0, 100);
ValidateNumericText(fieldBossLevel, 0, 100);
ValidateNumericText(dungeonBossLevel, 0, 100);
ValidateNumericText(predatorLevel, 0, 100);
ValidateNumericText(levelCap, 1, 60);
ValidateNumericText(bossAddLevel, 0, 85);
ValidateNumericText(randomLevelMin, 1, 1, int.Parse(levelCap.Text));
ValidateNumericText(randomLevelMax, Math.Max(1, int.Parse(randomLevelMin.Text)), int.Parse(levelCap.Text), int.Parse(levelCap.Text));
ValidateNumericText(rarity67MinLevel, 1, Math.Min(18, int.Parse(levelCap.Text)), int.Parse(levelCap.Text));
ValidateNumericText(rarity8UpMinLevel, 1, Math.Min(30, int.Parse(levelCap.Text)), int.Parse(levelCap.Text));
ValidateNumericText(bossesEverywhereChance, 1, 5, 99);
ValidateNumericText(bossesEverywhereChance, 1, 5, 100);
ValidateNumericText(weightUniformMin, 1, 10);
ValidateNumericText(weightUniformMax, int.Parse(weightUniformMin.Text));
ValidateNumericText(weightCustom1, 0, 60);
Expand All @@ -300,6 +310,7 @@ public void ValidateFormData(int seed = 0)
ValidateNumericText(weightCustom10, 0, 1);
ValidateNumericText(weightCustom20, 0, 1);
ValidateNumericText(humanRarity, 1, 4, 20);
ValidateNumericText(humanBossRarity, 1, 5, 20);
ValidateNumericText(humanWeight, 0, 100);
ValidateNumericText(humanWeightAggro, 0, 50);
ValidateNumericText(weightNightOnly, 0m, 10000);
Expand All @@ -309,6 +320,7 @@ public void ValidateFormData(int seed = 0)
ValidateNumericText(dungeonCount, 0, 100);
ValidateNumericText(fieldBossCount, 0, 100);
ValidateNumericText(dungeonBossCount, 0, 100);
ValidateNumericText(predatorCount, 0, 100);
ValidateNumericText(countClampMin, 0, 0);
ValidateNumericText(countClampMax, Math.Max(1, int.Parse(countClampMin.Text)));
ValidateNumericText(countClampFirstMin, 0, 0);
Expand Down Expand Up @@ -482,12 +494,16 @@ private void BossesEverywhereChance_GotFocus(object sender, RoutedEventArgs e)

private void PositiveIntSize2_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.PositiveIntSize2_PreviewTextInput(sender, e);
private void PositiveIntSize2_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.PositiveIntSize2_Pasting(sender, e);
private void PositiveIntPercent_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.PositiveIntPercent_PreviewTextInput(sender, e);
private void PositiveIntPercent_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.PositiveIntPercent_Pasting(sender, e);
private void PositiveIntSize3_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.PositiveIntSize3_PreviewTextInput(sender, e);
private void PositiveIntSize3_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.PositiveIntSize3_Pasting(sender, e);
private void PositiveIntSize4_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.PositiveIntSize4_PreviewTextInput(sender, e);
private void PositiveIntSize4_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.PositiveIntSize4_Pasting(sender, e);
private void NonNegIntSize2_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.NonNegIntSize2_PreviewTextInput(sender, e);
private void NonNegIntSize2_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.NonNegIntSize2_Pasting(sender, e);
private void NonNegIntPercent_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.NonNegIntPercent_PreviewTextInput(sender, e);
private void NonNegIntPercent_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.NonNegIntPercent_Pasting(sender, e);
private void NonNegIntSize3_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.NonNegIntSize3_PreviewTextInput(sender, e);
private void NonNegIntSize3_Pasting(object sender, DataObjectPastingEventArgs e) => SharedWindow.NonNegIntSize3_Pasting(sender, e);
private void NonNegIntSize4_PreviewTextInput(object sender, TextCompositionEventArgs e) => SharedWindow.NonNegIntSize4_PreviewTextInput(sender, e);
Expand Down
6 changes: 3 additions & 3 deletions Window/PalSpawnPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ private void GroupToolBarNew_Click(object sender, RoutedEventArgs e)
(areaData) =>
areaData?.Insert(areaData.Count, new()
{
SpawnList = [new() { Name = "SheepBall" }]
SpawnList = [new() { Name = "RowName" }]
}));
}

Expand Down Expand Up @@ -406,15 +406,15 @@ private void GroupPalDelete_Click(object sender, RoutedEventArgs e)

private void GroupPalNew_Click(object sender, RoutedEventArgs e)
{
GroupAction(sender, e, (index, spawnEntry, spawnList, areaData) => spawnList.Insert(spawnList.Count, new() { Name = "SheepBall" }), true);
GroupAction(sender, e, (index, spawnEntry, spawnList, areaData) => spawnList.Insert(spawnList.Count, new() { Name = "RowName" }), true);
}

private void GroupPalDeleteAll_Click(object sender, RoutedEventArgs e)
{
GroupAction(sender, e, (index, spawnEntry, spawnList, areaData) =>
{
spawnList.Clear();
spawnList.Add(new() { Name = "SheepBall" });
spawnList.Add(new() { Name = "RowName" });
}, true);
}

Expand Down
10 changes: 10 additions & 0 deletions Window/SharedWindowProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public static void PostNotifyInput(object sender, NotifyInputEventArgs e)
public static void PositiveIntSize2_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(positiveIntSize2Regex(), sender, e);
public static void PositiveIntSize2_Pasting(object sender, DataObjectPastingEventArgs e) => TextBox_Pasting(positiveIntSize2Regex(), sender, e);

[GeneratedRegex("^(?:(?!0)[0-9]{0,2}|100)$")]
private static partial Regex positiveIntPercentRegex();
public static void PositiveIntPercent_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(positiveIntPercentRegex(), sender, e);
public static void PositiveIntPercent_Pasting(object sender, DataObjectPastingEventArgs e) => TextBox_Pasting(positiveIntPercentRegex(), sender, e);

[GeneratedRegex("^(?!0)[0-9]{0,3}$")]
private static partial Regex positiveIntSize3Regex();
public static void PositiveIntSize3_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(positiveIntSize3Regex(), sender, e);
Expand All @@ -146,6 +151,11 @@ public static void PostNotifyInput(object sender, NotifyInputEventArgs e)
public static void NonNegIntSize2_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(nonNegIntSize2Regex(), sender, e);
public static void NonNegIntSize2_Pasting(object sender, DataObjectPastingEventArgs e) => TextBox_Pasting(nonNegIntSize2Regex(), sender, e);

[GeneratedRegex("^(?:0|(?!0)[0-9]{0,2}|100)$")]
private static partial Regex nonNegIntPercentRegex();
public static void NonNegIntPercent_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(nonNegIntPercentRegex(), sender, e);
public static void NonNegIntPercent_Pasting(object sender, DataObjectPastingEventArgs e) => TextBox_Pasting(nonNegIntPercentRegex(), sender, e);

[GeneratedRegex("^(?:0|(?!0)[0-9]{0,3})$")]
private static partial Regex nonNegIntSize3Regex();
public static void NonNegIntSize3_PreviewTextInput(object sender, TextCompositionEventArgs e) => TextBox_PreviewTextInput(nonNegIntSize3Regex(), sender, e);
Expand Down

0 comments on commit 2387a83

Please sign in to comment.