Skip to content

Commit

Permalink
preview 55.1
Browse files Browse the repository at this point in the history
  • Loading branch information
igorseabra4 committed Dec 22, 2019
1 parent cc39742 commit 793b178
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 104 deletions.
4 changes: 2 additions & 2 deletions IndustrialPark/Other/IPversion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
4 changes: 2 additions & 2 deletions IndustrialPark/Resources/ip_version.json
Original file line number Diff line number Diff line change
@@ -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"
}
139 changes: 68 additions & 71 deletions IndustrialParkRandomizer/Randomizer/RandomizableArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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<VilType> setTo = null;

if (veryRandom)
{
if (settings.charsOnAnyLevel)
setTo = GetVilTypesInLevel(chooseFrom).ToList();
else
{
setTo = new List<VilType>();
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<VilType> uniqueSetTo = new HashSet<VilType>();
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<VilType> setTo = new List<VilType>();
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,
Expand Down Expand Up @@ -786,25 +757,51 @@ public bool RandomizePlayerOnSpawn()
return true;
}

private bool ShuffleVilTypes(Random r, List<VilType> chooseFrom, List<VilType> setTo, bool mixModels, bool veryRandom)
private bool ShuffleVilTypes(int seed, List<VilType> chooseFrom, List<VilType> setTo, bool mixModels, bool veryRandom, bool enemies)
{
Random r = new Random(seed);

if (veryRandom && (LevelName == "sm01" || LevelName == "gl01"))
{
HashSet<VilType> uniqueSetTo = new HashSet<VilType>();
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<AssetVIL> assets = (from asset in assetDictionary.Values where asset is AssetVIL vil && chooseFrom.Contains(vil.VilType) select asset).Cast<AssetVIL>().ToList();
List<VilType> viltypes = (from asset in assets select asset.VilType).ToList();

List<AssetID> 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)
{
Expand Down Expand Up @@ -834,14 +831,14 @@ private bool ShuffleVilTypes(Random r, List<VilType> chooseFrom, List<VilType> 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)
Expand Down
33 changes: 4 additions & 29 deletions IndustrialParkRandomizer/Randomizer/Randomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 793b178

Please sign in to comment.