diff --git a/IndustrialPark/Other/IPversion.cs b/IndustrialPark/Other/IPversion.cs index 4d04c7a6..b8dc52c0 100644 --- a/IndustrialPark/Other/IPversion.cs +++ b/IndustrialPark/Other/IPversion.cs @@ -2,7 +2,7 @@ { public class IPversion { - public string version = "preview55"; - public string versionName = "Preview 55"; + public string version = "preview55.1"; + public string versionName = "Preview 55.1"; } } diff --git a/IndustrialPark/Resources/ip_version.json b/IndustrialPark/Resources/ip_version.json index 840f3272..ea02da3e 100644 --- a/IndustrialPark/Resources/ip_version.json +++ b/IndustrialPark/Resources/ip_version.json @@ -1,4 +1,4 @@ { - "version": "preview55", - "versionName": "Preview 55:\n* PIPT rendering: allows rendering of models according to flags set in pipe info table (PIPT) asset. This feature is not perfect as Industrial Park's renderer and the game's are not the same.\n* Updated PIPT editor: allows editing of individual source and destination flags.\n* Updated gizmos: gizmos are sized according to screen position and not model. This keeps their size consistent and much easier to handle. Rotation and scale gizmos allow editing of multiple assets at once (but the transform origin is still local to each object).\n* Update for box triggers: new gizmo allows editing all 6 box coordinates (minimums and maximums) plus trigger pivot point. This allows for more precise placement of box triggers (specially with rotation). Maximums and minimums are also automatically set.\n* Includes BFBBAnimTools.ms under Resources/Scripts.\n* Auto updater on this version might not work for some users. In this case, please download manually from the web page.\n" + "version": "preview55.1", + "versionName": "Preview 55:\n* PIPT rendering: allows rendering of models according to flags set in pipe info table (PIPT) asset. This feature is not perfect as Industrial Park's renderer and the game's are not the same.\n* Updated PIPT editor: allows editing of individual source and destination flags.\n* Updated gizmos: gizmos are sized according to screen position and not model. This keeps their size consistent and much easier to handle. Rotation and scale gizmos allow editing of multiple assets at once (but the transform origin is still local to each object).\n* Update for box triggers: new gizmo allows editing all 6 box coordinates (minimums and maximums) plus trigger pivot point. This allows for more precise placement of box triggers (specially with rotation). Maximums and minimums are also automatically set.\n* Includes BFBBAnimTools.ms under Resources/Scripts.\n* Auto updater on this version might not work for some users. In this case, please download manually from the web page.\n\nPreview 55.1:\n* Randomizer update. Restores Enemies_Allow_Any_Type to an earlier, more stable algorithm.\n" } \ No newline at end of file diff --git a/IndustrialParkRandomizer/Randomizer/RandomizableArchive.cs b/IndustrialParkRandomizer/Randomizer/RandomizableArchive.cs index e87ca52a..f82d7b7a 100644 --- a/IndustrialParkRandomizer/Randomizer/RandomizableArchive.cs +++ b/IndustrialParkRandomizer/Randomizer/RandomizableArchive.cs @@ -97,10 +97,11 @@ public bool Randomize(int seed, RandomizerFlags flags, RandomizerFlags2 flags2, if (LevelName == "kf04") chooseFrom.Remove(VilType.tiki_stone_bind); - - shuffled |= ShuffleVilTypes(new Random(seed), chooseFrom, setTo, + + shuffled |= ShuffleVilTypes(seed, chooseFrom, setTo, flags.HasFlag(RandomizerFlags.Tiki_Models), - flags.HasFlag(RandomizerFlags.Tiki_Allow_Any_Type)); + flags.HasFlag(RandomizerFlags.Tiki_Allow_Any_Type), + false); } if (flags.HasFlag(RandomizerFlags.Enemy_Types) && ContainsAssetWithType(AssetType.VIL)) @@ -133,67 +134,37 @@ public bool Randomize(int seed, RandomizerFlags flags, RandomizerFlags2 flags2, if (settings.ChompBot >= 0) chooseFrom.Add(VilType.robot_0a_chomper_bind); - bool veryRandom = flags.HasFlag(RandomizerFlags.Enemies_Allow_Any_Type); - Random r = new Random(seed); - - List setTo = null; - - if (veryRandom) - { - if (settings.charsOnAnyLevel) - setTo = GetVilTypesInLevel(chooseFrom).ToList(); - else - { - setTo = new List(); - for (int i = 0; i < settings.Fodder; i++) - setTo.Add(VilType.robot_0a_fodder_bind); - for (int i = 0; i < settings.Hammer; i++) - setTo.Add(VilType.ham_bind); - for (int i = 0; i < settings.Tartar; i++) - setTo.Add(VilType.robot_tar_bind); - for (int i = 0; i < settings.GLove; i++) - setTo.Add(VilType.g_love_bind); - for (int i = 0; i < settings.Chuck; i++) - setTo.Add(VilType.robot_chuck_bind); - for (int i = 0; i < settings.Monsoon; i++) - setTo.Add(VilType.robot_4a_monsoon_bind); - for (int i = 0; i < settings.Sleepytime; i++) - setTo.Add(VilType.robot_sleepytime_bind); - for (int i = 0; i < settings.Arf; i++) - setTo.Add(VilType.robot_arf_bind); - for (int i = 0; i < settings.Tubelets; i++) - setTo.Add(VilType.tubelet_bind); - for (int i = 0; i < settings.Slick; i++) - setTo.Add(VilType.robot_9a_bind); - for (int i = 0; i < settings.BombBot; i++) - setTo.Add(VilType.robot_0a_bomb_bind); - for (int i = 0; i < settings.BzztBot; i++) - setTo.Add(VilType.robot_0a_bzzt_bind); - for (int i = 0; i < settings.ChompBot; i++) - setTo.Add(VilType.robot_0a_chomper_bind); - - if (LevelName == "sm01" || LevelName == "gl01") - { - HashSet uniqueSetTo = new HashSet(); - foreach (VilType v in setTo) - uniqueSetTo.Add(v); - foreach (VilType v in GetVilTypesInLevel(setTo)) - uniqueSetTo.Remove(v); - - while (uniqueSetTo.Count > 5) - { - VilType randomRemove = setTo[r.Next(0, setTo.Count)]; - while (uniqueSetTo.Contains(randomRemove) && setTo.Contains(randomRemove)) - setTo.Remove(randomRemove); - uniqueSetTo.Remove(randomRemove); - } - } - } - } - - shuffled |= ShuffleVilTypes(r, chooseFrom, setTo, false, veryRandom && setTo.Count != 0); + List setTo = new List(); + for (int i = 0; i < settings.Fodder; i++) + setTo.Add(VilType.robot_0a_fodder_bind); + for (int i = 0; i < settings.Hammer; i++) + setTo.Add(VilType.ham_bind); + for (int i = 0; i < settings.Tartar; i++) + setTo.Add(VilType.robot_tar_bind); + for (int i = 0; i < settings.GLove; i++) + setTo.Add(VilType.g_love_bind); + for (int i = 0; i < settings.Chuck; i++) + setTo.Add(VilType.robot_chuck_bind); + for (int i = 0; i < settings.Monsoon; i++) + setTo.Add(VilType.robot_4a_monsoon_bind); + for (int i = 0; i < settings.Sleepytime; i++) + setTo.Add(VilType.robot_sleepytime_bind); + for (int i = 0; i < settings.Arf; i++) + setTo.Add(VilType.robot_arf_bind); + for (int i = 0; i < settings.Tubelets; i++) + setTo.Add(VilType.tubelet_bind); + for (int i = 0; i < settings.Slick; i++) + setTo.Add(VilType.robot_9a_bind); + for (int i = 0; i < settings.BombBot; i++) + setTo.Add(VilType.robot_0a_bomb_bind); + for (int i = 0; i < settings.BzztBot; i++) + setTo.Add(VilType.robot_0a_bzzt_bind); + for (int i = 0; i < settings.ChompBot; i++) + setTo.Add(VilType.robot_0a_chomper_bind); + + shuffled |= ShuffleVilTypes(seed, chooseFrom, setTo, false, flags.HasFlag(RandomizerFlags.Enemies_Allow_Any_Type), true); } - + if (flags.HasFlag(RandomizerFlags.Marker_Positions) && ContainsAssetWithType(AssetType.MRKR) && !new string[] { "hb02", "b101", "b201", "b302", "b303" }.Contains(LevelName)) shuffled |= ShuffleMRKRPositions(seed, @@ -786,25 +757,51 @@ public bool RandomizePlayerOnSpawn() return true; } - private bool ShuffleVilTypes(Random r, List chooseFrom, List setTo, bool mixModels, bool veryRandom) + private bool ShuffleVilTypes(int seed, List chooseFrom, List setTo, bool mixModels, bool veryRandom, bool enemies) { + Random r = new Random(seed); + + if (veryRandom && (LevelName == "sm01" || LevelName == "gl01")) + { + HashSet uniqueSetTo = new HashSet(); + foreach (VilType v in setTo) + uniqueSetTo.Add(v); + + while (uniqueSetTo.Count > 5) + { + VilType randomRemove = setTo[r.Next(0, setTo.Count)]; + while (setTo.Contains(randomRemove)) + setTo.Remove(randomRemove); + uniqueSetTo.Remove(randomRemove); + } + } + + if (setTo.Count == 0) + return false; + List assets = (from asset in assetDictionary.Values where asset is AssetVIL vil && chooseFrom.Contains(vil.VilType) select asset).Cast().ToList(); List viltypes = (from asset in assets select asset.VilType).ToList(); - + List models = (from asset in assets select asset.Model_AssetID).ToList(); + foreach (AssetVIL a in assets) { VilType prevVilType = a.VilType; int viltypes_value = r.Next(0, viltypes.Count); + int model_value = mixModels ? r.Next(0, viltypes.Count) : viltypes_value; a.VilType = veryRandom ? setTo[r.Next(0, setTo.Count)] : viltypes[viltypes_value]; - if (mixModels) - a.Model_AssetID = setTo[r.Next(0, setTo.Count)].ToString().Replace("sleepytime", "sleepy-time") + ".MINF"; - else - a.Model_AssetID = a.VilType.ToString().Replace("sleepytime", "sleepy-time") + ".MINF"; + if (enemies && veryRandom) + a.Model_AssetID = + a.VilType == VilType.robot_sleepytime_bind ? + "robot_sleepy-time_bind.MINF" : + a.VilType.ToString() + ".MINF"; + + else a.Model_AssetID = models[model_value]; viltypes.RemoveAt(viltypes_value); + models.RemoveAt(model_value); if (prevVilType == VilType.robot_arf_bind || prevVilType == VilType.tubelet_bind) { @@ -834,14 +831,14 @@ private bool ShuffleVilTypes(Random r, List chooseFrom, List s a.LinksBFBB = links.ToArray(); RemoveAsset(vil.AHDR.assetID); foreach (uint u in assetIDs) - if (ContainsAsset(u) && GetFromAssetID(u).AHDR.assetType == AssetType.MVPT) + if (ContainsAsset(u) && GetFromAssetID(u) is AssetMVPT) RemoveAsset(u); } } return assets.Count != 0; } - + private bool DisableCutscenes() { switch (LevelName) diff --git a/IndustrialParkRandomizer/Randomizer/Randomizer.cs b/IndustrialParkRandomizer/Randomizer/Randomizer.cs index 9885f894..6cfdaa3d 100644 --- a/IndustrialParkRandomizer/Randomizer/Randomizer.cs +++ b/IndustrialParkRandomizer/Randomizer/Randomizer.cs @@ -18,7 +18,7 @@ public enum RandomizerActMode public class Randomizer { - public int version = 54; + public int version = 55; public string rootDir; public bool isDir; public string seedText; @@ -220,42 +220,17 @@ private void PerformDirRandomizer(string backupDir, ProgressBar progressBar) { game = hip.game; scoobyPlatform = hip.platform; - bool disableStuff = false; - if (hip.game != Game.BFBB && (flags.HasFlag(RandomizerFlags.Enemies_Allow_Any_Type) || flags.HasFlag(RandomizerFlags.Shiny_Object_Gates) || flags.HasFlag(RandomizerFlags.Spatula_Gates))) - { - MessageBox.Show("Enemies_Allow_Any_Type, Shiny_Object_Gates and Spatula_Gates are only supported for Battle For Bikini Bottom. They will be disabled."); - disableStuff = true; - } - else if (!Directory.Exists(ArchiveEditorFunctions.editorFilesFolder)) + + if (!Directory.Exists(ArchiveEditorFunctions.editorFilesFolder)) { DialogResult dialogResult = MessageBox.Show("The IndustrialPark-EditorFiles folder has not been found under Resources. You must download it first. Do you wish to download it?", "Note", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) AutomaticUpdater.DownloadEditorFiles(); - else - disableStuff = true; } else AutomaticUpdater.VerifyEditorFiles(); - if (disableStuff) - { - this.flags.Remove(RandomizerFlags.Enemies_Allow_Any_Type); - this.flags.Remove(RandomizerFlags.Shiny_Object_Gates); - this.flags.Remove(RandomizerFlags.Spatula_Gates); - settings.spatReqChum = 75; - - flags = 0; - foreach (RandomizerFlags f in this.flags) - flags |= f; - flags2 = 0; - foreach (RandomizerFlags2 f in this.flags2) - flags2 |= f; - } - - if (settings.restoreRobotLaugh && (hip.game != Game.BFBB || hip.platform != Platform.GameCube)) - settings.restoreRobotLaugh = false; - platformVerified = true; } @@ -401,7 +376,7 @@ private void PerformDirRandomizer(string backupDir, ProgressBar progressBar) { if (enemyVils.Count != 0) { - item1shuffled |= levelPairs[0].Item1.UnimportEnemies(enemyVils); + //item1shuffled |= levelPairs[0].Item1.UnimportEnemies(enemyVils); item2shuffled |= levelPairs[0].Item2.ImportEnemyTypes(enemyVils); }