public static bool PerformRandomization(ExportEntry export, RandomizationOption option) { if (!CanRandomize(export)) { return(false); } MERLog.Information($"{export.FileRef.FilePath}\t{export.FullPath}"); var props = export.GetProperties(); if (export.ClassName == "BioSunFlareComponent" || export.ClassName == "BioSunFlareStreakComponent") { var tint = props.GetProp <StructProperty>("FlareTint"); if (tint != null) { RStructs.RandomizeTint(tint, false); } RProperty.RandFloat(props, "Intensity", 0.0001f, 100f, false); RProperty.RandFloat(props, "BrightPercent", 0.0001f, 0.1f, false); RProperty.RandFloat(props, "Scale", 0.05f, 3f, false); } else if (export.ClassName == "BioSunActor") { var tint = props.GetProp <StructProperty>("SunTint"); if (tint != null) { RStructs.RandomizeTint(tint, false); } } export.WriteProperties(props); return(true); }
public static bool RandomizeExport(ExportEntry material, RandomizationOption option) { if (!CanRandomize(material)) { return(false); } var props = material.GetProperties(); { var vectors = props.GetProp <ArrayProperty <StructProperty> >("VectorParameterValues"); if (vectors != null) { foreach (var vector in vectors) { var pc = vector.GetProp <StructProperty>("ParameterValue"); if (pc != null) { RStructs.RandomizeTint(pc, false); } } } var scalars = props.GetProp <ArrayProperty <StructProperty> >("ScalarParameterValues"); if (scalars != null) { for (int i = 0; i < scalars.Count; i++) { var scalar = scalars[i]; var parameter = scalar.GetProp <NameProperty>("ParameterName"); var currentValue = scalar.GetProp <FloatProperty>("ParameterValue"); if (currentValue > 1) { scalar.GetProp <FloatProperty>("ParameterValue").Value = ThreadSafeRandom.NextFloat(0, currentValue * 1.3); } else { //Debug.WriteLine("Randomizing parameter " + scalar.GetProp<NameProperty>("ParameterName")); scalar.GetProp <FloatProperty>("ParameterValue").Value = ThreadSafeRandom.NextFloat(0, 1); } } //foreach (var scalar in vectors) //{ // var paramValue = vector.GetProp<StructProperty>("ParameterValue"); // RandomizeTint( paramValue, false); //} } } material.WriteProperties(props); return(true); }
public static bool RandomizeExport(ExportEntry export, RandomizationOption option) { if (!CanRandomize(export)) { return(false); } PropertyCollection props = export.GetProperties(); var colorOverrides = props.GetProp <ArrayProperty <StructProperty> >("m_aColorOverrides"); if (colorOverrides != null) { foreach (StructProperty colorParameter in colorOverrides) { //Debug.WriteLine("Randomizing Color Parameter"); RStructs.RandomizeTint(colorParameter.GetProp <StructProperty>("cValue"), false); } } var scalarOverrides = props.GetProp <ArrayProperty <StructProperty> >("m_aScalarOverrides"); if (scalarOverrides != null) { foreach (StructProperty scalarParameter in scalarOverrides) { var name = scalarParameter.GetProp <NameProperty>("nName"); if (name != null) { if (name.Value.Name.Contains("_Frek_") || name.Value.Name.StartsWith("HAIR") || name.Value.Name.StartsWith("HED_Scar")) { var currentValue = scalarParameter.GetProp <FloatProperty>("sValue"); if (currentValue != null) { //Debug.WriteLine("Randomizing FREK HAIR HEDSCAR"); if (currentValue > 1) { scalarParameter.GetProp <FloatProperty>("sValue").Value = ThreadSafeRandom.NextFloat(0, currentValue * 1.3); } else { scalarParameter.GetProp <FloatProperty>("sValue").Value = ThreadSafeRandom.NextFloat(0, 1); } } } } } } export.WriteProperties(props); return(true); }
public static void RandomizeSubMatInst(ExportEntry childMat, Dictionary <string, CFVector4> vectorValues, Dictionary <string, float> scalarValues) { // VECTOR PARAMETERS //Debug.WriteLine($"Randomizing matinst {childMat.InstancedFullPath}"); var vectorParameterValues = VectorParameter.GetVectorParameters(childMat); if (vectorParameterValues != null) { foreach (var vpv in vectorParameterValues) { CFVector4 color; if (!vectorValues.TryGetValue(vpv.ParameterName, out color)) { color = vpv.ParameterValue; RStructs.RandomizeTint(color, false); vectorValues[vpv.ParameterName] = color; } else { vpv.ParameterValue = color; } } //Debug.WriteLine(childMat.InstancedFullPath); VectorParameter.WriteVectorParameters(childMat, vectorParameterValues); } // SCALAR PARAMETERS var scalarParameterValues = ScalarParameter.GetScalarParameters(childMat); if (scalarParameterValues != null) { foreach (var vpv in scalarParameterValues) { if (!scalarValues.TryGetValue(vpv.ParameterName, out float scalarVal)) { // Write new vpv.ParameterValue *= ThreadSafeRandom.NextFloat(0.75, 1.25); scalarValues[vpv.ParameterName] = vpv.ParameterValue; } else { // Write existing vpv.ParameterValue = scalarVal; } } //Debug.WriteLine(childMat.InstancedFullPath); ScalarParameter.WriteScalarParameters(childMat, scalarParameterValues); } }
public static bool RandomizeNPCExport2(ExportEntry export, RandomizationOption randOption) { if (!CanRandomizeNPCExport2(export)) { return(false); } var props = export.GetProperties(); var isIconic = props.GetProp <BoolProperty>("bIconicAppearance"); if (isIconic != null && isIconic) { return(false); // Don't modify an iconic look as it has a bunch fo stuff in it that can totally break it like scalp seams. } Dictionary <string, CFVector4> vectorValues = new(); Dictionary <string, float> scalarValues = new(); if (export.IsA("BioPawn")) { ChangeColorsInSubObjects(export, vectorValues, scalarValues, props); } else { // It's a SFXSkeletalMeshActorMAT, a basic type of NPC. var parms = VectorParameter.GetVectorParameters(export); if (parms != null) { foreach (var parm in parms) { vectorValues[parm.ParameterName] = parm.ParameterValue; RStructs.RandomizeTint(parm.ParameterValue, false); } VectorParameter.WriteVectorParameters(export, parms, "VectorParameters"); // Get submaterials and write out their properties too ChangeColorsInSubObjects(export, vectorValues, scalarValues, props); } // Should we try to randomize things that don't have a skin tone...? if (export.ObjectFlags.Has(UnrealFlags.EObjectFlags.ArchetypeObject) && PackageTools.IsLevelSubfile(Path.GetFileName(export.FileRef.FilePath))) { export.indexValue = ThreadSafeRandom.Next(); } } return(true); }
public static bool RandomizeGalaxyMap(RandomizationOption option) { // Make the ship faster because otherwise it takes ages to do stuff // And can also consume more fuel var sfxgame = MERFileSystem.GetPackageFile("SFXGame.pcc"); if (sfxgame != null && File.Exists(sfxgame)) { var sfxgameP = MEPackageHandler.OpenMEPackage(sfxgame); var galaxyModCamDefaults = sfxgameP.GetUExport(3899); var props = galaxyModCamDefaults.GetProperties(); props.AddOrReplaceProp(new FloatProperty(150, "m_fMovementScalarGalaxy")); // is this used? props.AddOrReplaceProp(new FloatProperty(75, "m_fMovementScalarCluster")); props.AddOrReplaceProp(new FloatProperty(125, "m_fMovementScalarSystem")); galaxyModCamDefaults.WriteProperties(props); // Make it so you can't run out of a gas. if (option.HasSubOptionSelected(SUBOPTIONKEY_INFINITEGAS)) { var BurnFuel = sfxgameP.GetUExport(3877); if (BurnFuel.ObjectName == "BurnFuel") { var bfData = BurnFuel.Data; bfData.OverwriteRange(0x9C, BitConverter.GetBytes(50f)); // Make it so we don't run out of gas BurnFuel.Data = bfData; } } MERFileSystem.SavePackage(sfxgameP); } // Give a bit more starting gas // IDK why it's in Weapon // This doesn't seem to actually do anything. But i'll leave it here anyways var weaponini = CoalescedHandler.GetIniFile("BIOWeapon.ini"); var sfxinvmgr = weaponini.GetOrAddSection("SFXGame.SFXInventoryManager"); sfxinvmgr.SetSingleEntry("FuelEfficiency", 5); // Make faster deceleration cause its hard to stop right var biogameini = CoalescedHandler.GetIniFile("BIOGame.ini"); var camgalaxy = biogameini.GetOrAddSection("SFXGame.BioCameraBehaviorGalaxy"); camgalaxy.SetSingleEntry("m_fShipSystemDeccel", 25); camgalaxy.SetSingleEntry("m_fShipClusterDeccel", .7f); var packageF = MERFileSystem.GetPackageFile(@"BioD_Nor_103aGalaxyMap.pcc"); var package = MEPackageHandler.OpenMEPackage(packageF); foreach (ExportEntry export in package.Exports) { switch (export.ClassName) { case "SFXCluster": { var props = export.GetProperties(); var starColor = props.GetProp <StructProperty>("StarColor"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } starColor = props.GetProp <StructProperty>("StarColor2"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } props.GetProp <IntProperty>("PosX").Value = ThreadSafeRandom.Next(800); props.GetProp <IntProperty>("PosY").Value = ThreadSafeRandom.Next(800); var intensity = props.GetProp <FloatProperty>("SphereIntensity"); if (intensity != null) { intensity.Value = ThreadSafeRandom.NextFloat(0, 6); } intensity = props.GetProp <FloatProperty>("NebularDensity"); if (intensity != null) { intensity.Value = ThreadSafeRandom.NextFloat(0, 6); } intensity = props.GetProp <FloatProperty>("SphereSize"); if (intensity != null) { intensity.Value = ThreadSafeRandom.NextFloat(0, 6); } export.WriteProperties(props); } //RandomizeClustersXY(export); break; case "SFXSystem": { var props = export.GetProperties(); var starColor = props.GetProp <StructProperty>("StarColor"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } starColor = props.GetProp <StructProperty>("FlareTint"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } starColor = props.GetProp <StructProperty>("SunColor"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } props.GetProp <IntProperty>("PosX").Value = ThreadSafeRandom.Next(1000); props.GetProp <IntProperty>("PosY").Value = ThreadSafeRandom.Next(1000); var scale = props.GetProp <FloatProperty>("Scale"); if (scale != null) { scale.Value = ThreadSafeRandom.NextFloat(.1, 2); } export.WriteProperties(props); } break; case "BioPlanet": { var props = export.GetProperties(); var starColor = props.GetProp <StructProperty>("SunColor"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } starColor = props.GetProp <StructProperty>("FlareTint"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } starColor = props.GetProp <StructProperty>("CloudColor"); if (starColor != null) { RStructs.RandomizeTint(starColor, false); } var resourceRichness = props.GetProp <FloatProperty>("ResourceRichness"); if (resourceRichness != null) { resourceRichness.Value = ThreadSafeRandom.NextFloat(0, 1.2); } else { props.AddOrReplaceProp(new FloatProperty(ThreadSafeRandom.NextFloat(0, .6), "ResourceRichness")); } props.GetProp <IntProperty>("PosX").Value = ThreadSafeRandom.Next(1000); props.GetProp <IntProperty>("PosY").Value = ThreadSafeRandom.Next(1000); var scale = props.GetProp <FloatProperty>("Scale"); if (scale != null) { scale.Value = ThreadSafeRandom.NextFloat(.1, 6); } export.WriteProperties(props); } break; case "MaterialInstanceConstant": RMaterialInstance.RandomizeExport(export, null); break; } } MERFileSystem.SavePackage(package); return(true); }
public static bool RandomizeExportSkin(ExportEntry material, RandomizationOption option, ref StructProperty skinColorPV) { if (!CanRandomize(material)) { return(false); } var props = material.GetProperties(); { var vectors = props.GetProp <ArrayProperty <StructProperty> >("VectorParameterValues"); if (vectors != null) { foreach (var vector in vectors) { var pn = vector.GetProp <NameProperty>("ParameterName"); var pv = vector.GetProp <StructProperty>("ParameterValue"); if (pn != null && pn.Value == "SkinTone" && skinColorPV != null && pv != null) { vector.Properties.AddOrReplaceProp(skinColorPV); } else if (pv != null) { RStructs.RandomizeTint(pv, false); if (pn.Value == "SkinTone") { skinColorPV = pv; // Below method will assign data to this structproperty. } } } } var scalars = props.GetProp <ArrayProperty <StructProperty> >("ScalarParameterValues"); if (scalars != null) { for (int i = 0; i < scalars.Count; i++) { var scalar = scalars[i]; var parameter = scalar.GetProp <NameProperty>("ParameterName"); var currentValue = scalar.GetProp <FloatProperty>("ParameterValue"); if (currentValue > 1) { scalar.GetProp <FloatProperty>("ParameterValue").Value = ThreadSafeRandom.NextFloat(.1, currentValue * 1.3); } else { //Debug.WriteLine("Randomizing parameter " + scalar.GetProp<NameProperty>("ParameterName")); scalar.GetProp <FloatProperty>("ParameterValue").Value = ThreadSafeRandom.NextFloat(0, 1); } } //foreach (var scalar in vectors) //{ // var paramValue = vector.GetProp<StructProperty>("ParameterValue"); // RandomizeTint( paramValue, false); //} } } material.WriteProperties(props); return(true); }