public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            var boneDefinitions = export.GetProperty <ArrayProperty <StructProperty> >(export.ClassName == @"BioLookAtDefinition" ? "BoneDefinitions" : "m_aLookBoneDefs");

            if (boneDefinitions != null)
            {
                //Log.Information($"Randomizing BioLookAtDefinition {export.UIndex}");
                foreach (var item in boneDefinitions)
                {
                    //if (item.GetProp<NameProperty>("m_nBoneName").Value.Name.StartsWith("Eye"))
                    //{
                    //    item.GetProp<FloatProperty>("m_fLimit").Value = ThreadSafeRandom.Next(1, 5);
                    //    item.GetProp<FloatProperty>("m_fUpDownLimit").Value = ThreadSafeRandom.Next(1, 5);
                    //}
                    //else
                    //{
                    item.GetProp <FloatProperty>(@"m_fDelay").Value      = ThreadSafeRandom.NextFloat(0, 5);
                    item.GetProp <FloatProperty>("m_fLimit").Value       = ThreadSafeRandom.NextFloat(1, 170);
                    item.GetProp <FloatProperty>("m_fUpDownLimit").Value = ThreadSafeRandom.NextFloat(70, 170);
                    //}
                }

                export.WriteProperty(boneDefinitions);
                return(true);
            }
            return(false);
        }
Exemple #2
0
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            var properties = export.GetProperties();
            var lightColor = properties.GetProp <StructProperty>("LightColor");

            if (lightColor != null)
            {
                lightColor.GetProp <ByteProperty>("R").Value = (byte)ThreadSafeRandom.Next(256);
                lightColor.GetProp <ByteProperty>("G").Value = (byte)ThreadSafeRandom.Next(256);
                lightColor.GetProp <ByteProperty>("B").Value = (byte)ThreadSafeRandom.Next(256);

                var density = properties.GetProp <FloatProperty>("Density");
                if (density != null)
                {
                    var thicknessRandomizer = ThreadSafeRandom.NextFloat(-density * .03, density * 1.15);
                    density.Value = density + thicknessRandomizer;
                }

                //Debug.WriteLine($"Updating fog {export.InstancedFullPath} in {export.FileRef.FilePath}");
                export.WriteProperties(properties);
                return(true);
            }
            return(false);
        }
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            var location = Location.GetLocation(export);

            if (location != null)
            {
                var locS = location;
                if (ThreadSafeRandom.Next(10) == 0)
                {
                    locS.X = ThreadSafeRandom.NextFloat(-100000, 100000);
                    locS.Y = ThreadSafeRandom.NextFloat(-100000, 100000);
                    locS.Z = ThreadSafeRandom.NextFloat(-100000, 100000);
                }
                else
                {
                    // Fuzz it
                    locS.X *= ThreadSafeRandom.NextFloat(.25, 1.75);
                    locS.Y *= ThreadSafeRandom.NextFloat(.25, 1.75);
                    locS.Z *= ThreadSafeRandom.NextFloat(.25, 1.75);
                }

                Location.SetLocation(export, locS);
                return(true);
            }
            return(false);
        }
Exemple #4
0
        public static bool DetectAndSkipMiniGameSeqRefs(ExportEntry exp, RandomizationOption option)
        {
            if (!CanApplySkip(exp, out var miniGameType))
            {
                return(false);
            }

            if (miniGameType == EMinigameSkipType.SeqRef)
            {
                // Update the credits
                var minigameVarLinks = SeqTools.GetVariableLinksOfNode(exp);
                // Update the Out: Value Remaining to something random.
                var ovrNode = minigameVarLinks.FirstOrDefault(x => x.LinkDesc == "OUT: Value Remaining")?.LinkedNodes.FirstOrDefault();
                if (ovrNode is ExportEntry ovr)
                {
                    ovr.WriteProperty(new IntProperty(ThreadSafeRandom.Next(1, 2400), "IntValue"));
                }
            }
            else if (miniGameType == EMinigameSkipType.SeqAct)
            {
                // Update the credits
                var minigameVarLinks = SeqTools.GetVariableLinksOfNode(exp);
                // Update the Remaining Remaining to something random.
                var ovrNode = minigameVarLinks.FirstOrDefault(x => x.LinkDesc == "Remaining Resources")?.LinkedNodes.FirstOrDefault();
                if (ovrNode is ExportEntry ovr)
                {
                    ovr.WriteProperty(new IntProperty(ThreadSafeRandom.Next(1, 2400), "IntValue"));
                }
            }

            SeqTools.SkipSequenceElement(exp, "Success"); //Success is link 0
            return(true);
        }
        public static bool RandomizeIconicMaleShep(RandomizationOption option)
        {
            var sfxgame = MERFileSystem.GetPackageFile("SFXGame.pcc");

            if (sfxgame != null && File.Exists(sfxgame))
            {
                var sfxgameP = MEPackageHandler.OpenMEPackage(sfxgame);
                var shepMDL  = sfxgameP.GetUExport(42539);
                var objBin   = RSkeletalMesh.FuzzSkeleton(shepMDL, option);

                if (option.HasSubOptionSelected(CharacterCreator.SUBOPTIONKEY_MALESHEP_COLORS))
                {
                    Dictionary <string, CFVector4> vectors = new();
                    Dictionary <string, float>     scalars = new();
                    var materials = objBin.Materials;
                    foreach (var mat in materials.Select(x => sfxgameP.GetUExport(x)))
                    {
                        RMaterialInstance.RandomizeSubMatInst(mat, vectors, scalars);
                    }
                }

                MERFileSystem.SavePackage(sfxgameP);
                return(true);
            }

            return(false);
        }
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            //Log.Information($@"Randomizing light {export.UIndex}");
            var lc = export.GetProperty <StructProperty>("LightColor");

            if (lc == null)
            {
                // create
                var pc = new PropertyCollection();
                pc.Add(new ByteProperty(255, "B"));
                pc.Add(new ByteProperty(255, "G"));
                pc.Add(new ByteProperty(255, "R"));
                pc.Add(new ByteProperty(0, "A"));

                lc = new StructProperty("Color", pc, "LightColor", true);
            }

            RStructs.RandomizeColor(lc, false);
            export.WriteProperty(lc);
            return(true);
        }
        public static bool PerformRandomization(RandomizationOption option)
        {
            var ini = CoalescedHandler.GetIniFile("BioGame.ini");

            var section = ini.GetOrAddSection("SFXGame.SFXVehicleHover");

            section.SetSingleEntry("JumpForce", GenerateRandomVectorStruct(-400, 400, 0, 0, 1200, 4000));
            section.SetSingleEntry("OnGroundJumpMultiplier", ThreadSafeRandom.NextFloat(.5, 2));
            section.SetSingleEntry("MaxThrustJuice", ThreadSafeRandom.NextFloat(0.5, 1));
            section.SetSingleEntry("BoostForce", GenerateRandomVectorStruct(600, 2000, 0, 0, -200, 50));
            section.SetSingleEntry("ThrustRegenerationFactor", ThreadSafeRandom.NextFloat(0.45, 0.7));
            section.SetSingleEntry("SelfRepairRate", ThreadSafeRandom.NextFloat(50, 150));
            section.SetSingleEntry("SelfRepairDelay", ThreadSafeRandom.NextFloat(3, 8));
            section.SetSingleEntry("OffGroundForce", GenerateRandomVectorStruct(0, 0, 0, 0, -2200, -10));
            section.SetSingleEntry("ThrustRegenerationDelay", ThreadSafeRandom.NextFloat(0.2, 1));
            section.SetSingleEntry("VerticalThrustBurnRate", ThreadSafeRandom.NextFloat(0.5, 1.5));
            section.SetSingleEntry("BurnOutPercentage", ThreadSafeRandom.NextFloat(0.1, 0.3));
            section.SetSingleEntry("MaxPitchAngle", ThreadSafeRandom.NextFloat(25, 55));

            ini     = CoalescedHandler.GetIniFile("BioWeapon.ini");
            section = ini.GetOrAddSection("SFXGameContent_Inventory.SFXHeavyWeapon_VehicleMissileLauncher");
            section.SetSingleEntry("Damage", ThreadSafeRandom.NextFloat(200, 500));
            section.SetSingleEntry("RateOfFire", ThreadSafeRandom.NextFloat(100, 300));
            return(true);
        }
        public static bool UwuifyText(RandomizationOption option)
        {
            bool keepCasing   = option.HasSubOptionSelected(RTexts.SUBOPTIONKEY_UWU_KEEPCASING);
            bool addReactions = option.HasSubOptionSelected(RTexts.SUBOPTIONKEY_REACTIONS_ENABLED);

            var existingTLK = TLKHandler.GetBuildingTLK();
            var skipIDs     = existingTLK.StringRefs.Select(x => x.StringID).ToList();
            var MERTlks     = TLKHandler.GetMERTLKs();

            var nonMerTLKs = TLKHandler.GetAllTLKs().Where(x => !MERTlks.Contains(x));

            option.ProgressValue         = 0;
            option.ProgressMax           = nonMerTLKs.Where(x => x.name.EndsWith(@"INT.tlk")).Sum(x => x.StringRefs.Count(y => y.StringID > 0 && !string.IsNullOrWhiteSpace(y.Data)));
            option.ProgressMax          += MERTlks.Where(x => x.name.EndsWith(@"INT.tlk")).Sum(x => x.StringRefs.Count(y => y.StringID > 0 && !string.IsNullOrWhiteSpace(y.Data)));
            option.ProgressIndeterminate = false;


            // UwUify MER TLK first
            foreach (TalkFile tf in MERTlks)
            {
                UwuifyTalkFile(tf, keepCasing, addReactions, skipIDs, true, option);
            }

            // UwUify non MER TLK
            foreach (TalkFile tf in nonMerTLKs)
            {
                UwuifyTalkFile(tf, keepCasing, addReactions, skipIDs, false, option);
            }
            return(true);
        }
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export, out var instancedFullPath))
            {
                return(false);
            }
            // This texture can be randomized.
            // Process:
            // 1. Fetch a random asset that matches the export's fullpath from the TextureAssets path
            //    - Asset binary is as if the texture was stored in the package.
            //    - This allows us to use the binary data without having to do more work on the data
            //    - Mips > 6 are stored externally directly into the TFC stream
            //    - Mip <= 6 are stored locally and are decompressed
            // 2. Is the asset already written somewhere? If it is, we should just write that cached binary out as the binary is not file specific.
            // 3. If asset is not cached yet, we replace the texture binary with the asset's data
            // 4. Read the export in as a UTexture2D
            // 5. Write the higher compressed mips to TFC
            // 6. Setup the properties for texture
            // 7. Commit the props and binary
            // 8. Cache the work that's been done

            // 1. Fetch asset
            var r2d = ActiveBuilder.TextureRandomizations.First(x => x.TextureInstancedFullPath == instancedFullPath);

            InstallTexture(r2d, export);
            return(true);
        }
Exemple #10
0
 internal static bool PerformRandomization(RandomizationOption notUsed)
 {
     RandomizeVIPShepDance();
     RandomizeAfterlifeShepDance();
     RandomizeALDancers();
     return(true);
 }
        public static bool RandomizeWeapons(RandomizationOption option)
        {
            var me2rbioweapon = CoalescedHandler.GetIniFile("BIOWeapon.ini");

            // We must manually fetch game files cause MERFS will return the ini from the dlc mod instead.
            ME2Coalesced me2basegamecoalesced = new ME2Coalesced(MERFileSystem.GetSpecificFile(@"BioGame\Config\PC\Cooked\Coalesced.ini"));

            MERLog.Information("Randomizing basegame weapon ini");
            var bioweapon = me2basegamecoalesced.Inis.FirstOrDefault(x => Path.GetFileName(x.Key) == "BIOWeapon.ini").Value;

            RandomizeWeaponIni(bioweapon, me2rbioweapon);

            var weaponInis = Directory.GetFiles(MEDirectories.GetDLCPath(MERFileSystem.Game), "BIOWeapon.ini", SearchOption.AllDirectories).ToList();

            foreach (var wi in weaponInis)
            {
                if (wi.Contains($"DLC_MOD_{MERFileSystem.Game}Randomizer"))
                {
                    continue; // Skip randomizer folders
                }
                MERLog.Information($@"Randomizing weapon ini {wi}");
                //Log.Information("Randomizing weapons in ini: " + wi);
                var dlcWeapIni = DuplicatingIni.LoadIni(wi);
                RandomizeWeaponIni(dlcWeapIni, me2rbioweapon);
                //if (!MERFileSystem.UsingDLCModFS)
                //{
                //    Log.Information("Writing DLC BioWeapon: " + wi);
                //    File.WriteAllText(wi, dlcWeapIni.ToString());
                //}
            }

            return(true);
        }
        public static bool RandomizeExport(ExportEntry exp, RandomizationOption option)
        {
            if (!CanRandomize(exp))
            {
                return(false);
            }
            var props = exp.GetProperties();

            var navs = props.GetProp <ArrayProperty <StructProperty> >("NavList").Select(x => x.Properties.GetProp <ObjectProperty>("Nav")).ToList();

            var destNavs = exp.FileRef.Exports.Where(x => x.IsA("NavigationPoint")).ToList();

            destNavs.Shuffle();
            foreach (var n in navs)
            {
                n.Value = destNavs[0].UIndex;
                destNavs.RemoveAt(0);
            }

            //foreach (var nav in navs)
            //{
            //    var entry = nav.ResolveToEntry(exp.FileRef) as ExportEntry;
            //}

            exp.WriteProperties(props);
            return(true);
        }
Exemple #13
0
        public static bool TurnOnFriendlyFire(RandomizationOption option)
        {
            var sfxgame = MEPackageHandler.OpenMEPackage(MERFileSystem.GetPackageFile("SFXGame.pcc"));
            var md      = sfxgame.GetUExport(21353);
            var patched = md.Data;

            for (int i = 0x0285; i < 0x0317; i++)
            {
                patched[i] = 0x0B; // nop
            }
            md.Data = patched;

            if (option.HasSubOptionSelected(SUBOPTIONKEY_CARELESSFF))
            {
                // Copy a 'return false' over the top of IsFriendlyBlockingSightline
                var fExport = sfxgame.GetUExport(5723);
                var fObjBin = ObjectBinary.From <UFunction>(fExport);

                var friendlyBlockingFunc = sfxgame.GetUExport(1203);
                var fbObjBin             = ObjectBinary.From <UFunction>(friendlyBlockingFunc);

                fbObjBin.ScriptBytecodeSize = fObjBin.ScriptBytecodeSize;
                fbObjBin.ScriptStorageSize  = fObjBin.ScriptStorageSize;
                fbObjBin.ScriptBytes        = fObjBin.ScriptBytes;
                friendlyBlockingFunc.WriteBinary(fbObjBin);
            }
            MERFileSystem.SavePackage(sfxgame);
            return(true);
        }
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            var settings = export.GetProperty <StructProperty>("Settings");

            if (settings != null)
            {
                MERLog.Information($@"Randomizing PostProcessingVolume settings {export.UIndex}");
                // randomize the options
                RProperty.RandBool(settings.Properties, "bEnableDOF", ThreadSafeRandom.Next(3) == 0);
                RProperty.RandBool(settings.Properties, "bEnableFilmic", ThreadSafeRandom.Next(3) == 0);
                RProperty.RandBool(settings.Properties, "bEnableBloom", ThreadSafeRandom.Next(3) == 0);
                RProperty.RandFloat(settings.Properties, "Bloom_Scale", 0, 0.4f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "DOF_BlurKernelSize", 0, 20f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "DOF_MaxNearBlurAmount", 0, 0.2f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "DOF_MaxFarBlurAmount", 0.1f, 0.5f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "DOF_InnerFocusRadius", 0, 2000f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "DOF_FocusDistance", 0, 400f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "Scene_Desaturation", 0, 0.5f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandFloat(settings.Properties, "Scene_InterpolationDuration", 0, 2f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandVector(settings.Properties, "Scene_Highlights", 0, 2, ThreadSafeRandom.Next(8) == 0);
                RProperty.RandVector(settings.Properties, "Scene_Midtones", 0, 6f, ThreadSafeRandom.Next(5) == 0);
                RProperty.RandVector(settings.Properties, "Scene_Shadows", 0, .4f, ThreadSafeRandom.Next(8) == 0);
                export.WriteProperty(settings);
                return(true);
            }
            return(false);
        }
Exemple #15
0
        private static void AutomatePlatforming400(RandomizationOption option)
        {
            var platformControllerF = MERFileSystem.GetPackageFile("BioD_EndGm2_420CombatZone.pcc");

            if (platformControllerF != null)
            {
                var platformController = MEPackageHandler.OpenMEPackage(platformControllerF);
                var delayToClone       = platformController.GetUExport(14314);

                // Remove completion state from squad kills as we won't be using that mechanism
                KismetHelper.RemoveOutputLinks(platformController.GetUExport(14488)); //A Platform 01
                KismetHelper.RemoveOutputLinks(platformController.GetUExport(14496)); //A Platform 02
                KismetHelper.RemoveOutputLinks(platformController.GetUExport(14504)); //A Platform 03
                KismetHelper.RemoveOutputLinks(platformController.GetUExport(14513)); //A Platform 0405 (together)
                                                                                      // there's final platform with the controls on it. we don't touch it

                // Install delays and hook them up to the complection states
                InstallPlatformAutomation(platformController.GetUExport(15057), delayToClone, platformController.GetUExport(14353), 1); //01 to 02
                InstallPlatformAutomation(platformController.GetUExport(15063), delayToClone, platformController.GetUExport(14358), 2); //02 to 03
                InstallPlatformAutomation(platformController.GetUExport(15067), delayToClone, platformController.GetUExport(14363), 3); //03 to 0405
                InstallPlatformAutomation(platformController.GetUExport(15072), delayToClone, platformController.GetUExport(14368), 4); //0405 to 06

                MERFileSystem.SavePackage(platformController);
            }
        }
        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);
        }
Exemple #17
0
 public static bool PerformRandomization(RandomizationOption option)
 {
     AddBurgersToCookingQuest();
     RandomizeNormandyHolo();
     RandomizeWrongWashroomSFX();
     return(true);
 }
 public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
 {
     if (!CanRandomize(export, false, out var hairMeshExp))
     {
         return(false);
     }
     return(ForcedRun(hairMeshExp));
 }
Exemple #19
0
 internal static bool PerformRandomization(RandomizationOption notUsed)
 {
     ChangeNormandyPaintings();
     //RandomizeTuxedoMesh();
     //ChangeSecurityTV();
     RandomizeArtGallery();
     return(true);
 }
 public static bool RandomizeExportNonHench(ExportEntry export, RandomizationOption option)
 {
     if (!CanRandomizeNonHench(export))
     {
         return(false);
     }
     RandomizeInternal(export, option);
     return(true);
 }
        //private static bool CanRandomize(ExportEntry export) => !export.IsDefaultObject && export.ClassName == @"TextureMovie" && ExportNameToAssetMapping.ContainsKey(export.ObjectName.Name);
        //public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        //{
        //    if (!CanRandomize(export)) return false;
        //    var assets = ExportNameToAssetMapping[export.ObjectName.Name];
        //    byte[] tmAsset = GetTextureMovieAssetBinary(assets[ThreadSafeRandom.Next(assets.Count)]);
        //    var tm = ObjectBinary.From<TextureMovie>(export);
        //    tm.EmbeddedData = tmAsset;
        //    tm.DataSize = tmAsset.Length;
        //    export.WriteBinary(tm);
        //    return true;
        //}

        // ME2 only has few texture movies so these are used
        public static bool RandomizeExportDirect(ExportEntry export, RandomizationOption option, byte[] tmAsset)
        {
            var tm = ObjectBinary.From <TextureMovie>(export);

            tm.EmbeddedData = tmAsset;
            tm.DataSize     = tmAsset.Length;
            export.WriteBinary(tm);
            return(true);
        }
Exemple #22
0
        public static bool PerformRandomization(RandomizationOption option)
        {
            RandomizeFlyerSpawnPawns();
            AutomatePlatforming400(option);
            MakeTubesSectionHarder();

            RandomizeTheLongWalk(option);
            InstallBorger();
            return(true);
        }
        public static bool RandomizeGameOverText(RandomizationOption arg)
        {
            string   fileContents  = MERUtilities.GetEmbeddedStaticFilesTextFile("gameovertexts.xml");
            XElement rootElement   = XElement.Parse(fileContents);
            var      gameoverTexts = rootElement.Elements("gameovertext").Select(x => x.Value).ToList();
            var      gameOverText  = gameoverTexts[ThreadSafeRandom.Next(gameoverTexts.Count)];

            TLKHandler.ReplaceString(157152, gameOverText);
            return(true);
        }
Exemple #24
0
 public static bool RandomizeExport(ExportEntry exp, RandomizationOption option)
 {
     if (!CanRandomize(exp))
     {
         return(false);
     }
     //Log.Information("Randomizing eye color");
     RMaterialInstance.RandomizeExport(exp, null);
     return(true);
 }
        /// <summary>
        /// Hack to force power lists to load with only a single check
        /// </summary>
        /// <param name="option"></param>
        /// <returns></returns>
        public static bool Init(RandomizationOption option)
        {
            MERLog.Information(@"Preloading weapon data");
            LoadGuns();
            WeaponAnimsPackage        = MERFileSystem.GetStartupPackage();
            WeaponAnimationsArrayProp = WeaponAnimsPackage.FindExport("WeaponAnimData").GetProperty <ArrayProperty <StructProperty> >("WeaponAnimSpecs");

            MERLog.Information(@"Installing weapon animations startup package");
            MERFileSystem.InstallStartupPackage(); // Contains weapon animations
            return(true);
        }
 public static bool RandomizeExport(ExportEntry arg1, RandomizationOption arg2)
 {
     // Write debug code here
     //var hi = arg1.InstancedFullPath;
     if (arg1.ClassName == "Function")
     {
         var         unFunc = UE3FunctionReader.ReadFunction(arg1);
         TextBuilder tb     = new TextBuilder();
         unFunc.Decompile(tb, false, false);
     }
     return(true);
 }
        public static bool RandomizeIntroText(RandomizationOption arg)
        {
            string   fileContents  = MERUtilities.GetEmbeddedStaticFilesTextFile("openingcrawls.xml");
            XElement rootElement   = XElement.Parse(fileContents);
            var      gameoverTexts = rootElement.Elements("CrawlText").Select(x => x.Value).ToList();

            // The trim calls here will remove first and last lines that are blank. The TrimForIntro() will remove whitespace per line.
            TLKHandler.ReplaceString(331765, TrimForIntro(gameoverTexts.RandomElement().Trim()));
            TLKHandler.ReplaceString(263408, TrimForIntro(gameoverTexts.RandomElement().Trim()));
            TLKHandler.ReplaceString(348756, TrimForIntro(gameoverTexts.RandomElement().Trim()));
            TLKHandler.ReplaceString(391285, TrimForIntro(gameoverTexts.RandomElement().Trim())); // Genesis DLC uses this extra string for some reason
            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);
        }
Exemple #29
0
        public static bool RandomizeExport(ExportEntry export, RandomizationOption option)
        {
            if (!CanRandomize(export))
            {
                return(false);
            }
            var seqLinks = SeqTools.GetVariableLinksOfNode(export);

            // Make a new list of sequence vars based on the originals. We will null out items in this list to prevent randomization of them
            // before we merge back in.
            var randomizationMask = new List <SeqTools.VarLinkInfo>(seqLinks);

            for (int i = 0; i < randomizationMask.Count; i++)
            {
                var info = randomizationMask[i];
                if (!info.LinkedNodes.Any() || !CanLinkBeRandomized(info))
                {
                    // blacklisted or no nodes
                    randomizationMask[i] = null; // Null this object
                    continue;
                }
            }

            // Get total amount of nodes that can be randomized.
            var allNodes = randomizationMask.Where(x => x != null).SelectMany(x => x.LinkedNodes).ToList();

            if (allNodes.Count() < 2)
            {
                return(false); // Can't do anything as there is not enough nodes to randomize.
            }

            // Shuffle the list of nodes that will be installed
            allNodes.Shuffle();

            // Iterate over the randomization mask and use it to determine which varlinks to update
            for (int i = 0; i < randomizationMask.Count; i++)
            {
                var info = randomizationMask[i];
                if (info != null)
                {
                    // Can be changed. As they are just references we can update this list directly
                    info.LinkedNodes.Clear();
                    info.LinkedNodes.Add(allNodes.PullFirstItem());
                }
            }

            // Write the updated links out.
            SeqTools.WriteVariableLinksToNode(export, seqLinks);

            return(true);
        }
        private static bool shouldRandomizeBone(string boneName, RandomizationOption option)
        {
            if (boneName.Contains("base", StringComparison.InvariantCultureIgnoreCase))
            {
                return(false);
            }

            if (boneName.Contains("finger", StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (boneName.Contains("eye", StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (boneName.Contains("mouth", StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (boneName.Contains("sneer", StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }
            if (boneName.Contains("brow", StringComparison.InvariantCultureIgnoreCase))
            {
                return(true);
            }

            if (option.SliderValue >= MODERATE_RANDOM)
            {
                if (ThreadSafeRandom.Next(4) != 0)
                {
                    return(false);
                }

                if (boneName.Contains("spine", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
                if (boneName.Contains("chest", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
                if (boneName.Contains("butt", StringComparison.InvariantCultureIgnoreCase))
                {
                    return(true);
                }
            }
            return(false);
        }