private static void MakeKensonCool()
        {
            string[] files = new[]
            {
                "BioD_ArvLvl1.pcc",
                "BioD_ArvLvl4_300Entrance.pcc",
            };
            foreach (var f in files)
            {
                var kensonFile = MERFileSystem.GetPackageFile(f, false);
                if (kensonFile != null && File.Exists(kensonFile))
                {
                    var kensonP = MEPackageHandler.OpenMEPackage(kensonFile);
                    var ifp     = kensonP.FindExport("SFXGameContentKenson.Default__SFXPawn_Kenson_01.BioPawnSkeletalMeshComponent");
                    ifp.RemoveProperty("Materials");
                    ifp.RemoveProperty("SkeletalMesh");

                    // Remove materials used in base as they're wrong
                    kensonP.FindExport("SFXGameContentKenson.Default__SFXPawn_Kenson.BioPawnSkeletalMeshComponent").RemoveProperty("Materials");

                    MERFileSystem.SavePackage(kensonP);
                }
                else
                {
                    MERLog.Information($"Kenson file not found: {f}, skipping...");
                }
            }
        }
        private static void RandomizeAudio(IMEPackage package, int topLevelUIndex, bool female)
        {
            var audioToChange = package.Exports.Where(x => x.idxLink == topLevelUIndex && x.ClassName == "WwiseStream").ToList();
            var audioSources  = MERFileSystem.LoadedFiles.Keys.Where(x => x.Contains("_LOC_INT", StringComparison.InvariantCultureIgnoreCase) && x.Contains("Bio")).ToList();

            foreach (var aExp in audioToChange)
            {
                bool installed = false;
                while (!installed)
                {
                    var rAudioSourceF = audioSources.RandomElement();
                    var rAudioSourceP = MEPackageHandler.OpenMEPackage(MERFileSystem.GetPackageFile(rAudioSourceF));
                    var audioOptions  = rAudioSourceP.Exports.Where(x => x.ClassName == "WwiseStream").ToList();
                    if (!audioOptions.Any())
                    {
                        continue;
                    }

                    var audioChoice = audioOptions.RandomElement();

                    // Repoint the TLK to match what's going to be said
                    var nTlk = WwiseTools.ExtractTLKIdFromExportName(audioChoice);
                    var oTlk = WwiseTools.ExtractTLKIdFromExportName(aExp);
                    if (nTlk != -1 && oTlk != -1 && !string.IsNullOrWhiteSpace(TLKHandler.TLKLookupByLang(nTlk, "INT")))
                    {
                        TLKHandler.ReplaceString(oTlk, TLKHandler.TLKLookupByLang(nTlk, "INT"));

                        WwiseTools.RepointWwiseStream(audioChoice, aExp);
                        installed = 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);
        }
Beispiel #4
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 void LoadPowers()
        {
            if (Powers == null)
            {
                string fileContents = MERUtilities.GetEmbeddedStaticFilesTextFile("powerlistme2.json");
                Powers = new List <PowerInfo>();
                var powermanifest = JsonConvert.DeserializeObject <List <PowerInfo> >(fileContents);
                foreach (var powerInfo in powermanifest)
                {
                    var powerFilePath = MERFileSystem.GetPackageFile(powerInfo.PackageFileName, false);
                    if (powerInfo.IsCorrectedPackage || (powerFilePath != null && File.Exists(powerFilePath)))
                    {
                        if (powerInfo.FileDependency != null && MERFileSystem.GetPackageFile(powerInfo.FileDependency, false) == null)
                        {
                            MERLog.Information($@"Dependency file {powerInfo.FileDependency} not found, not adding {powerInfo.PowerName} to power selection pool");
                            continue; // Dependency not met
                        }
                        MERLog.Information($@"Adding {powerInfo.PowerName} to power selection pool");
                        Powers.Add(powerInfo);
                    }

                    if (!powerInfo.IsCorrectedPackage && powerFilePath == null)
                    {
                        MERLog.Information($@"{powerInfo.PowerName} package file not found ({powerInfo.PackageFileName}), weapon not added to weapon pools");
                    }
                }
            }
        }
Beispiel #6
0
        private static void ChangeNormandyPaintings()
        {
            //BioA_Nor_230
            // BioT_NorHenMT Painting01_Diff
            // BioT_NorHenMT Painting02_Diff
            // Both square
            var nor230F = MERFileSystem.GetPackageFile("BioA_Nor_230.pcc");

            if (nor230F != null && File.Exists(nor230F))
            {
                var nor230P = MEPackageHandler.OpenMEPackage(nor230F);

                var painting1 = nor230P.FindExport("BioT_NorHenMT.Painting01_Diff");
                var painting2 = nor230P.FindExport("BioT_NorHenMT.Painting02_Diff");
                if (painting1 != null && painting2 != null)
                {
                    var assets = TFCBuilder.ListTextureAssets("Kasumi.NormandyPaintings").Select(x => $"Kasumi.NormandyPaintings.{x}").ToList();
                    assets.Shuffle();

                    RTexture2D r2d = new RTexture2D()
                    {
                        AllowedTextureAssetNames = assets,
                        LODGroup = new EnumProperty(new NameReference("TEXTUREGROUP_Environment", 1025), "TextureGroup", MEGame.ME2, "LODGroup"), // A bit higher quality
                    };

                    TFCBuilder.InstallTexture(r2d, painting1, assets.PullFirstItem());
                    TFCBuilder.InstallTexture(r2d, painting2, assets.PullFirstItem());

                    MERFileSystem.SavePackage(nor230P);
                }
            }
        }
Beispiel #7
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 void LoadGuns()
        {
            if (AllAvailableWeapons == null)
            {
                string fileContents = MERUtilities.GetEmbeddedStaticFilesTextFile("weaponloadoutrules.json");
                LoadoutSupportsVisibleMapping = JsonConvert.DeserializeObject <ConcurrentDictionary <string, bool> >(fileContents);

                fileContents = MERUtilities.GetEmbeddedStaticFilesTextFile("weaponlistme2.json");
                var allGuns = JsonConvert.DeserializeObject <List <GunInfo> >(fileContents).ToList();
                AllAvailableWeapons     = new List <GunInfo>();
                VisibleAvailableWeapons = new List <GunInfo>();
                foreach (var g in allGuns)
                {
                    var gf = MERFileSystem.GetPackageFile(g.PackageFileName, false);
                    if (g.IsCorrectedPackage || (gf != null && File.Exists(gf)))
                    {
                        MERLog.Information($@"Adding {g.GunName} to weapon selection pools");
                        AllAvailableWeapons.Add(g);
                        if (g.HasGunMesh)
                        {
                            VisibleAvailableWeapons.Add(g);
                        }
                    }

                    if (!g.IsCorrectedPackage && gf == null)
                    {
                        MERLog.Information($@"{g.GunName} package file not found ({g.PackageFileName}), weapon not added to weapon pools");
                    }
                }
                Debug.WriteLine($"Number of available weapons for randomization: {AllAvailableWeapons.Count}");
                Debug.WriteLine($"Number of visible weapons for randomization: {VisibleAvailableWeapons.Count}");
            }
        }
Beispiel #9
0
        private static void InstallBorger()
        {
            var endGame3F = MERFileSystem.GetPackageFile("BioP_EndGm3.pcc");

            if (endGame3F != null && File.Exists(endGame3F))
            {
                var biopEndGm3 = MEPackageHandler.OpenMEPackage(endGame3F);

                var packageBin    = MERUtilities.GetEmbeddedStaticFilesBinaryFile("Delux2go_Edmonton_Burger.pcc");
                var burgerPackage = MEPackageHandler.OpenMEPackageFromStream(new MemoryStream(packageBin));

                // 1. Add the burger package
                var burgerMDL = PackageTools.PortExportIntoPackage(biopEndGm3, burgerPackage.FindExport("Edmonton_Burger_Delux2go.Burger_MDL"));

                // 2. Link up the textures
                TFCBuilder.RandomizeExport(biopEndGm3.FindExport("Edmonton_Burger_Delux2go.Textures.Burger_Diff"), null);
                TFCBuilder.RandomizeExport(biopEndGm3.FindExport("Edmonton_Burger_Delux2go.Textures.Burger_Norm"), null);
                TFCBuilder.RandomizeExport(biopEndGm3.FindExport("Edmonton_Burger_Delux2go.Textures.Burger_Spec"), null);

                // 3. Convert the collector base into lunch or possibly early dinner
                // It's early dinner cause that thing will keep you full all night long
                biopEndGm3.GetUExport(11276).WriteProperty(new ObjectProperty(burgerMDL.UIndex, "SkeletalMesh"));
                biopEndGm3.GetUExport(11282).WriteProperty(new ObjectProperty(burgerMDL.UIndex, "SkeletalMesh"));
                MERFileSystem.SavePackage(biopEndGm3);
            }
        }
        private static void ChangePrisonerNames()
        {
            InstallName(342079);                                        // Prisoner 780
            InstallName(342078);                                        // Prisoner 403
            var didPrisoner = InstallName(BeatPrisonerTLKID) != 0;      // Beat Prisoner
            var didGuard    = InstallName(BeatPrisonerGuardTLKID) != 0; // Beating Guard

            if (didGuard && didPrisoner)
            {
                // Make it so the beating scene shows names
                var cellBLock3F = MERFileSystem.GetPackageFile("BioD_PrsCvA_103CellBlock03.pcc");
                if (cellBLock3F != null)
                {
                    var cellBlock3P = MEPackageHandler.OpenMEPackage(cellBLock3F);

                    // Clone the turianguard pawn type so we can change the name, maybe something else if we want
                    var newGuardBPCST = EntryCloner.CloneTree(cellBlock3P.GetUExport(701), true);
                    newGuardBPCST.ObjectName = "MER_NamedBeatGuard";
                    newGuardBPCST.WriteProperty(new StringRefProperty(BeatPrisonerGuardTLKID, "ActorGameNameStrRef"));
                    cellBlock3P.GetUExport(668).WriteProperty(new ObjectProperty(newGuardBPCST, "ActorType"));

                    // Change shown name for the prisoner
                    cellBlock3P.GetUExport(699).WriteProperty(new StringRefProperty(BeatPrisonerTLKID, "ActorGameNameStrRef"));

                    // Make the two people 'selectable' so they show up with names
                    cellBlock3P.GetUExport(682).RemoveProperty("m_bTargetableOverride"); // guard
                    cellBlock3P.GetUExport(677).RemoveProperty("m_bTargetableOverride"); // prisoner

                    MERFileSystem.SavePackage(cellBlock3P);
                }
            }
        }
Beispiel #11
0
        private static void MakeTubesSectionHarder()
        {
            var preReaperF = MERFileSystem.GetPackageFile("BioD_EndGm2_420CombatZone.pcc");

            if (preReaperF != null && File.Exists(preReaperF))
            {
                var preReaperP = MEPackageHandler.OpenMEPackage(preReaperF);

                // Open tubes on kills to start the attack (post platforms)----------------------
                var seq = preReaperP.GetUExport(15190);

                var attackSw = MERSeqTools.InstallRandomSwitchIntoSequence(seq, 2); //50% chance

                // killed squad member -> squad still exists to 50/50 sw
                KismetHelper.CreateOutputLink(preReaperP.GetUExport(15298), "SquadStillExists", attackSw);

                // 50/50 to just try to do reaper attack
                KismetHelper.CreateOutputLink(attackSw, "Link 1", preReaperP.GetUExport(14262));

                // Automate the platforms one after another
                KismetHelper.RemoveAllLinks(preReaperP.GetUExport(15010)); //B Plat01 Death
                KismetHelper.RemoveAllLinks(preReaperP.GetUExport(15011)); //B Plat02 Death

                // Sub automate - Remove attack completion gate inputs ----
                KismetHelper.RemoveAllLinks(preReaperP.GetUExport(15025)); //Plat03 Attack complete
                KismetHelper.RemoveAllLinks(preReaperP.GetUExport(15029)); //Plat02 Attack complete

                //// Sub automate - Remove activate input into gate
                var cmb2activated = preReaperP.GetUExport(15082);
                var cmb3activated = preReaperP.GetUExport(15087);

                KismetHelper.RemoveAllLinks(cmb2activated);
                KismetHelper.CreateOutputLink(cmb2activated, "Out", preReaperP.GetUExport(2657));

                // Delay the start of platform 3 by 4 seconds to give player a bit more time to handle first two platforms
                // Player will likely have decent weapons by now so they will be better than my testing for sure
                KismetHelper.RemoveAllLinks(cmb3activated);
                var newDelay = EntryCloner.CloneEntry(preReaperP.GetUExport(14307));
                newDelay.WriteProperty(new FloatProperty(4, "Duration"));
                KismetHelper.AddObjectToSequence(newDelay, preReaperP.GetUExport(15183), true);

                KismetHelper.CreateOutputLink(cmb3activated, "Out", newDelay);
                KismetHelper.CreateOutputLink(newDelay, "Finished", preReaperP.GetUExport(2659));
                //                preReaperP.GetUExport(14451).RemoveProperty("bOpen"); // Plat03 gate - forces gate open so when reaper attack fires it passes through
                //              preReaperP.GetUExport(14450).RemoveProperty("bOpen"); // Plat02 gate - forces gate open so when reaper attack fires it passes through


                // There is no end to Plat03 behavior until tubes are dead
                KismetHelper.CreateOutputLink(preReaperP.GetUExport(14469), "Completed", preReaperP.GetUExport(14374)); // Interp completed to Complete in Plat01
                KismetHelper.CreateOutputLink(preReaperP.GetUExport(14470), "Completed", preReaperP.GetUExport(14379)); // Interp completed to Complete in Plat02

                // if possession fails continue the possession loop on plat3 to end of pre-reaper combat
                KismetHelper.CreateOutputLink(preReaperP.GetUExport(16414), "Failed", preReaperP.GetUExport(14307));



                MERFileSystem.SavePackage(preReaperP);
            }
        }
Beispiel #12
0
 private static void ChangeFlyersInFiles(string[] files)
 {
     foreach (var f in files)
     {
         var fPath = MERFileSystem.GetPackageFile(f);
         if (fPath != null && File.Exists(fPath))
         {
             var package = MEPackageHandler.OpenMEPackage(fPath);
             GenericRandomizeFlyerSpawns(package, 3);
             MERFileSystem.SavePackage(package);
         }
     }
 }
Beispiel #13
0
        public static bool RemoveStormCameraShake(RandomizationOption arg)
        {
            var sfxgame = MEPackageHandler.OpenMEPackage(MERFileSystem.GetPackageFile("SFXGame.pcc"));

            // SFXCameraMode_CombatStorm
            var md = sfxgame.GetUExport(25096);

            md.WriteProperty(new BoolProperty(false, "bIsCameraShakeEnabled"));

            //SFXCameraMode_ExporeStorm
            md = sfxgame.GetUExport(25116);
            md.WriteProperty(new BoolProperty(false, "bIsCameraShakeEnabled"));

            MERFileSystem.SavePackage(sfxgame);
            return(true);
        }
Beispiel #14
0
        public static bool SetupFastStartup(RandomizationOption option)
        {
            var entrymenuF = MERFileSystem.GetPackageFile("EntryMenu.pcc");
            var entrymenuP = MEPackageHandler.OpenMEPackage(entrymenuF);
            var skipElem   = entrymenuP.GetUExport(86); // should show splash

            if (!skipElem.ObjectFlags.HasFlag(UnrealFlags.EObjectFlags.DebugPostLoad))
            {
                skipElem.ObjectFlags |= UnrealFlags.EObjectFlags.DebugPostLoad; // mark as modified so subsequent passes don't operate on this
                SeqTools.SkipSequenceElement(skipElem, outboundLinkIdx: 1);
                MERFileSystem.SavePackage(entrymenuP);
            }


            return(true);
        }
Beispiel #15
0
        private static void MakeGarrusDeadly()
        {
            // Relay at the end of the DLC
            var garrusShootSeqFile = MERFileSystem.GetPackageFile(@"BioD_OmgGrA_100Leadup.pcc");

            if (garrusShootSeqFile != null && File.Exists(garrusShootSeqFile))
            {
                var garrusSeqP = MEPackageHandler.OpenMEPackage(garrusShootSeqFile);

                // Chance to shoot Shepard
                RandSeqVarInt(garrusSeqP.GetUExport(1043), 60, 100); //60 to 100 percent chance

                // Make garrus shoot faster so he can actually kill the player
                garrusSeqP.GetUExport(974).WriteProperty(new FloatProperty(3, "PlayRate"));

                // Lower the damage so its not instant kill
                garrusSeqP.GetUExport(34).WriteProperty(new FloatProperty(550, "DamageAmount"));
                garrusSeqP.GetUExport(34).WriteProperty(new FloatProperty(2, "MomentumScale"));

                // Do not reset the chance to shoot shepard again
                SeqTools.ChangeOutlink(garrusSeqP.GetUExport(33), 0, 0, 982);

                // Make garrus damage type very deadly
                var garrusDamageTypeProps = garrusSeqP.GetUExport(8).GetProperties();
                garrusDamageTypeProps.Clear(); // Remove the old props
                garrusDamageTypeProps.AddOrReplaceProp(new BoolProperty(true, "bImmediateDeath"));
                garrusDamageTypeProps.AddOrReplaceProp(new BoolProperty(true, "bIgnoreShieldHitLimit"));
                garrusDamageTypeProps.AddOrReplaceProp(new BoolProperty(true, "bIgnoreShields"));
                garrusDamageTypeProps.AddOrReplaceProp(new BoolProperty(true, "bIgnoresBleedout"));
                garrusSeqP.GetUExport(8).WriteProperties(garrusDamageTypeProps);

                // Make shepard more vulnerable
                garrusSeqP.GetUExport(1005).WriteProperty(new IntProperty(60, "ValueB"));


                // Make garrus stand more often
                garrusSeqP.GetUExport(1039).WriteProperty(new IntProperty(60, "IntValue"));

                // Make shoot extra free bullets
                garrusSeqP.GetUExport(1037).WriteProperty(new IntProperty(75, "IntValue"));
                RandSeqVarInt(garrusSeqP.GetUExport(1042), 1, 4);

                MERFileSystem.SavePackage(garrusSeqP);
            }
        }
Beispiel #16
0
        private static void SetVeetorFootage()
        {
            var moviedata   = RTextureMovie.GetTextureMovieAssetBinary("Veetor.size_mer.bik");
            var veetorFiles = MERFileSystem.LoadedFiles.Keys.Where(x => x.StartsWith("BioD_ProFre_501Veetor")).ToList();

            foreach (var v in veetorFiles)
            {
                MERLog.Information($@"Setting veetor footage in {v}");
                var mpackage     = MERFileSystem.GetPackageFile(v);
                var package      = MEPackageHandler.OpenMEPackage(mpackage);
                var veetorExport = package.FindExport("BioVFX_Env_Hologram.ProFre_501_VeetorFootage");
                if (veetorExport != null)
                {
                    RTextureMovie.RandomizeExportDirect(veetorExport, null, moviedata);
                }
                MERFileSystem.SavePackage(package);
            }
        }
        private static void FixFirstSurvivorNameBchLmL()
        {
            // Make it so the beating scene shows names
            var beachPathF = MERFileSystem.GetPackageFile("BioD_BchLmL_102BeachFight.pcc");

            if (beachPathF != null)
            {
                var beachPathP = MEPackageHandler.OpenMEPackage(beachPathF);

                // Make memory unique
                var tlkId = InstallName();
                if (tlkId != 0)
                {
                    beachPathP.GetUExport(700).WriteProperty(new StringRefProperty(tlkId, "ActorGameNameStrRef"));
                    beachPathP.GetUExport(700).ObjectName = "survivor_female_MER";
                    MERFileSystem.SavePackage(beachPathP);
                }
            }
        }
            public virtual ExportEntry GetAsset(MERPackageCache cache = null)
            {
                IMEPackage package = null;

                if (cache != null)
                {
                    package = cache.GetCachedPackage(PackageFile);
                }
                else
                {
                    var packageF = MERFileSystem.GetPackageFile(PackageFile);
                    if (packageF != null)
                    {
                        package = MEPackageHandler.OpenMEPackage(packageF);
                    }
                }

                return(package?.FindExport(AssetPath));
            }
Beispiel #19
0
        public static bool MakeShepardRagdollable(RandomizationOption option)
        {
            var sfxgame = MEPackageHandler.OpenMEPackage(MERFileSystem.GetPackageFile("SFXGame.pcc"));

            // Add ragdoll power to shep
            var sfxplayercontrollerDefaults = sfxgame.GetUExport(30777);
            var cac = sfxplayercontrollerDefaults.GetProperty <ArrayProperty <ObjectProperty> >("CustomActionClasses");

            cac[5].Value = 25988; //SFXCustomActionRagdoll
            sfxplayercontrollerDefaults.WriteProperty(cac);

            // Update power script design and patch out player physics level
            var sd = sfxgame.GetUExport(14353).Data;

            OneHitKO.NopRange(sd, 0x62, 0x27);
            sfxgame.GetUExport(14353).Data = sd;

            MERFileSystem.SavePackage(sfxgame);
            return(true);
        }
        internal static bool PerformRandomization(RandomizationOption notUsed)
        {
            var uncFiles = MERFileSystem.LoadedFiles.Keys.Where(x => x.Contains("_Unc1", StringComparison.InvariantCultureIgnoreCase)).ToList();

            if (uncFiles.Any())
            {
                // DLC is installed
                foreach (var uncF in uncFiles)
                {
                    var package = MEPackageHandler.OpenMEPackage(MERFileSystem.GetPackageFile(Path.GetFileName(uncF)));
                    RandomizeArcherFaceColor(package);
                    RandomizeCorruptionVFX(package);
                    MakeGethCannonScary(package);
                    ChangeUNC4BaseColors(package);
                    MERFileSystem.SavePackage(package);
                }
            }

            return(true);
        }
Beispiel #21
0
        /// <summary>
        /// Returns a cached package. Ensure this cache is synchronized if across threads or you may end up saving two different instances of files to the same location
        /// </summary>
        /// <param name="packageName"></param>
        /// <returns></returns>
        public override IMEPackage GetCachedPackage(string packageName, bool openIfNotInCache = true)
        {
            // May need way to set maximum size of dictionary so we don't hold onto too much memory.
            packageName = Path.GetFileName(packageName); // Ensure we only use filename
            if (Cache.TryGetValue(packageName, out var package))
            {
                return(package);
            }

            if (openIfNotInCache)
            {
                var file = MERFileSystem.GetPackageFile(packageName, false);
                if (file != null && File.Exists(file))
                {
                    int i = 3;
                    while (i > 0)
                    {
                        try
                        {
                            i--;
                            package = MERFileSystem.OpenMEPackage(file);
                        }
                        catch (IOException e)
                        {
                            // This is a cheap hack around potential multithreading issues
                            Log.Warning($@"I/O Exception opening {file}: {e.Message}. We have {i} attempts remaining to open this package");
                            Thread.Sleep(1000);
                        }
                    }

                    if (package == null)
                    {
                        return(null);
                    }

                    Cache[packageName] = package;
                    return(package);
                }
            }
            return(null); //Package could not be found
        }
Beispiel #22
0
        public static bool RandomizePlayerMovementSpeed(RandomizationOption option)
        {
            var femaleFile    = MERFileSystem.GetPackageFile("BIOG_Female_Player_C.pcc");
            var maleFile      = MERFileSystem.GetPackageFile("BIOG_Male_Player_C.pcc");
            var femalepackage = MEPackageHandler.OpenMEPackage(femaleFile);
            var malepackage   = MEPackageHandler.OpenMEPackage(maleFile);

            SlightlyRandomizeMovementData(femalepackage.GetUExport(2917));
            SlightlyRandomizeMovementData(malepackage.GetUExport(2672));
            MERFileSystem.SavePackage(femalepackage);
            MERFileSystem.SavePackage(malepackage);

            var biogame = CoalescedHandler.GetIniFile("BIOGame.ini");
            var sfxgame = biogame.GetOrAddSection("SFXGame.SFXGame");

            sfxgame.SetSingleEntry("StormStamina", ThreadSafeRandom.NextFloat(1.5f, 12));
            sfxgame.SetSingleEntry("StormRegen", ThreadSafeRandom.NextFloat(0.3f, 1.5f));
            sfxgame.SetSingleEntry("StormStaminaNonCombat", ThreadSafeRandom.NextFloat(1.5f, 8));
            sfxgame.SetSingleEntry("StormRegenNonCombat", ThreadSafeRandom.NextFloat(0.1f, 0.8f));
            return(true);
        }
        public static bool RandomizeSquadmateFaces(RandomizationOption option)
        {
            var henchFiles = MERFileSystem.LoadedFiles.Where(x => x.Key.StartsWith("BioH_") ||
                                                             x.Key.StartsWith("BioP_ProCer") ||
                                                             x.Key.StartsWith("BioD_ProCer") ||
                                                             x.Key == "BioD_EndGm1_110ROMJacob.pcc");

            foreach (var h in henchFiles)
            {
                var hPackage = MERFileSystem.OpenMEPackage(MERFileSystem.GetPackageFile(h.Key));
                foreach (var smhp in SquadmateMorphHeadPaths)
                {
                    var mf = hPackage.FindExport(smhp);
                    if (mf != null)
                    {
                        RandomizeInternal(mf, henchFaceOption);
                    }
                }
                MERFileSystem.SavePackage(hPackage);
            }
            return(true);
        }
Beispiel #24
0
        private static void RandomizeALDancers()
        {
            {
                var denBar = MERFileSystem.GetPackageFile(@"BioD_OmgHub_220DenBar.pcc");
                if (denBar != null)
                {
                    var denBarP = MEPackageHandler.OpenMEPackage(denBar);
                    RandomizeDancer(denBarP.GetUExport(1287));
                    RandomizeDancer(denBarP.GetUExport(1288));
                    RandomizeDancer(denBarP.GetUExport(1289));
                    RandomizeDancer(denBarP.GetUExport(1292));
                    RandomizeDancer(denBarP.GetUExport(1293));
                    MERFileSystem.SavePackage(denBarP);
                }
            }

            var denDance = MERFileSystem.GetPackageFile(@"BioD_OmgHub_230DenDance.pcc");

            if (denDance != null)
            {
                var denDanceP = MEPackageHandler.OpenMEPackage(denDance);
                RandomizeDancer(denDanceP.GetUExport(1257)); //sit
                RandomizeDancer(denDanceP.GetUExport(1250));
                RandomizeDancer(denDanceP.GetUExport(1251));

                // shep sits at dancer. it uses different pawn.
                var entertainerBPSKM = denDanceP.GetUExport(4322);
                var newInfo          = IlliumHub.DancerOptions.RandomElement();
                while (newInfo.Location != null || newInfo.Rotation != null || newInfo.KeepHead == false || (newInfo.BodyAsset != null && !newInfo.BodyAsset.IsAssetFileAvailable()) || (newInfo.HeadAsset != null && !newInfo.HeadAsset.IsAssetFileAvailable()))
                {
                    // I don't want anything that requires specific positioning data, and I want to keep the head.
                    newInfo = IlliumHub.DancerOptions.RandomElement();
                }

                var newDancerMDL = PackageTools.PortExportIntoPackage(denDanceP, newInfo.BodyAsset.GetAsset());
                entertainerBPSKM.WriteProperty(new ObjectProperty(newDancerMDL, "SkeletalMesh"));
                MERFileSystem.SavePackage(denDanceP);
            }
        }
Beispiel #25
0
        private static void RandomizeVIPShepDance()
        {
            var vipLoungeLF = MERFileSystem.GetPackageFile(@"BioD_OmgHub_500DenVIP_LOC_INT.pcc");

            if (vipLoungeLF != null && File.Exists(vipLoungeLF))
            {
                var vipLounge = MEPackageHandler.OpenMEPackage(vipLoungeLF);

                var playerDanceInterpData = vipLounge.GetUExport(547);
                var c = new MERPackageCache();

                InstallShepardDanceGesture(playerDanceInterpData, c);     // Paragon
                InstallShepardDanceGesture(vipLounge.GetUExport(559), c); // Stupid shep lol


                // Make able to dance again and again in convo
                var danceTalk = vipLounge.GetUExport(217);
                var bc        = new ConversationExtended(danceTalk);
                bc.LoadConversation(null);
                bc.StartingList.Clear();
                bc.StartingList.Add(0, 2);
                bc.SerializeNodes();

                MERFileSystem.SavePackage(vipLounge);
            }

            // make able to always talk to dancer
            var vipLoungeF = MERFileSystem.GetPackageFile(@"BioD_OmgHub_500DenVIP.pcc");

            if (vipLoungeF != null && File.Exists(vipLoungeF))
            {
                var vipLounge      = MEPackageHandler.OpenMEPackage(vipLoungeF);
                var selectableBool = vipLounge.GetUExport(8845);
                selectableBool.WriteProperty(new IntProperty(1, "bValue"));
                MERFileSystem.SavePackage(vipLounge);
            }
        }
Beispiel #26
0
        private static void GateTubesAttack()
        {
            // This doesn't actually work like expected, it seems gate doesn't store input value

            // Adds a gate to the tubes attack to ensure it doesn't fire while the previous attack is running still.
            var tubesF = MERFileSystem.GetPackageFile("BioD_EndGm2_425ReaperTubes.pcc");

            if (tubesF != null && File.Exists(tubesF))
            {
                var tubesP = MEPackageHandler.OpenMEPackage(tubesF);

                // Clone a gate
                var gateToClone = tubesP.GetUExport(1316);
                var seq         = tubesP.GetUExport(1496);
                var newGate     = EntryCloner.CloneEntry(gateToClone);
                newGate.RemoveProperty("bOpen"); // Make it open by default.
                KismetHelper.AddObjectToSequence(newGate, seq, true);

                // Hook up the 'START REAPER ATTACK' to the gate, remove it's existing output.
                var sraEvent = tubesP.GetUExport(1455);
                KismetHelper.RemoveOutputLinks(sraEvent);
                KismetHelper.CreateOutputLink(sraEvent, "Out", newGate, 0); // 0 = in, which means fire or queue for fire

                // Hook up the ending of the attack to the gate for 'open' so the gate can be passed through.
                var delay = tubesP.GetUExport(1273);
                KismetHelper.CreateOutputLink(tubesP.GetUExport(103), "Out", delay); // Attack finished (CameraShake_Intimidate) to 2s delay
                KismetHelper.RemoveAllLinks(delay);
                KismetHelper.CreateOutputLink(delay, "Finished", newGate, 1);        //2s Delay to open gate

                // Make the gate automatically close itself on pass through, and configure output of gate to next item.
                KismetHelper.CreateOutputLink(newGate, "Out", newGate, 2);                 // Hook from Out to Close
                KismetHelper.CreateOutputLink(newGate, "Out", tubesP.GetUExport(1340), 0); // Hook from Out to Log (bypass the delay, we are repurposing it)

                MERFileSystem.SavePackage(tubesP);
            }
        }
Beispiel #27
0
        private static void SetupProCer()
        {
            /*
             * PLAYER
             *  Min1Health in BioD_ProCer.pcc, export 1171, sequence TheWorld.PersistentLevel.Main_Sequence, target SeqVar_Player
             *  Min1Health in BioD_ProCer_100RezRoom.pcc, export 3956, sequence TheWorld.PersistentLevel.Main_Sequence.LS0_LevelLoad, target SeqVar_Player
             */
            var DPProCerF = MERFileSystem.GetPackageFile("BioD_ProCer.pcc");

            if (DPProCerF != null && File.Exists(DPProCerF))
            {
                var bpProCerP = MEPackageHandler.OpenMEPackage(DPProCerF);
                bpProCerP.GetUExport(1171).WriteProperty(new IntProperty(0, "bValue"));
                MERFileSystem.SavePackage(bpProCerP);
            }
            var rezRoom = MERFileSystem.GetPackageFile("BioD_ProCer_100RezRoom.pcc");

            if (rezRoom != null && File.Exists(rezRoom))
            {
                var rezRoomP = MEPackageHandler.OpenMEPackage(rezRoom);
                rezRoomP.GetUExport(3956).WriteProperty(new IntProperty(0, "bValue"));
                MERFileSystem.SavePackage(rezRoomP);
            }
        }
        public static bool RandomizeIconicFemShep(RandomizationOption option)
        {
            var femF = MERFileSystem.GetPackageFile("BIOG_Female_Player_C.pcc");

            if (femF != null && File.Exists(femF))
            {
                var femP         = MEPackageHandler.OpenMEPackage(femF);
                var femMorphFace = femP.GetUExport(682);
                RBioMorphFace.RandomizeExportNonHench(femMorphFace, option);
                var matSetup = femP.GetUExport(681);
                RBioMaterialOverride.RandomizeExport(matSetup, option);

                // Copy this data into BioP_Char so you get accurate results
                var biop_charF = MERFileSystem.GetPackageFile(@"BioP_Char.pcc");
                var biop_char  = MEPackageHandler.OpenMEPackage(biop_charF);
                EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.ReplaceSingular, femMorphFace, biop_char, biop_char.GetUExport(3482), true, out IEntry _);
                EntryImporter.ImportAndRelinkEntries(EntryImporter.PortingOption.ReplaceSingular, matSetup, biop_char, biop_char.GetUExport(3472), true, out IEntry _);
                //biop_char.GetUExport(3482).WriteProperties(femMorphFace.GetProperties()); // Copy the morph face
                //biop_char.GetUExport(3472).WriteProperties(matSetup.GetProperties()); // Copy the material setups
                MERFileSystem.SavePackage(biop_char);
                MERFileSystem.SavePackage(femP);
            }
            return(true);
        }
Beispiel #29
0
        private static void RandomizeArtGallery()
        {
            var wideAssets = TFCBuilder.ListTextureAssets("Kasumi.ArtGallery.wide").Select(x => $"Kasumi.ArtGallery.wide.{x}").ToList();
            var tallAssets = TFCBuilder.ListTextureAssets("Kasumi.ArtGallery.tall").Select(x => $"Kasumi.ArtGallery.tall.{x}").ToList();

            wideAssets.Shuffle();
            tallAssets.Shuffle();

            var artyGallery = GetKasumiArtGallerySetup();

            foreach (var kagf in artyGallery)
            {
                var artGalleryF = MERFileSystem.GetPackageFile(kagf.PackageName);
                if (artGalleryF != null && File.Exists(artGalleryF))
                {
                    var artGalleryP = MEPackageHandler.OpenMEPackage(artGalleryF);

                    // Rename instances so they're memory unique so we have a few more paintings
                    if (kagf.RenameMemoryInstances)
                    {
                        if (kagf.TallTextureUIndexes != null)
                        {
                            foreach (var uindex in kagf.TallTextureUIndexes)
                            {
                                if (!artGalleryP.GetUExport(uindex).IsTexture())
                                {
                                    Debugger.Break();
                                }
                                artGalleryP.GetUExport(uindex).ObjectName = $"ME2R_T_KASUMIPAINTING{ThreadSafeRandom.Next(15000)}";
                            }
                        }

                        // Rename mats so they're also unique
                        if (kagf.WideTextureUIndexes != null)
                        {
                            foreach (var uindex in kagf.WideTextureUIndexes)
                            {
                                if (!artGalleryP.GetUExport(uindex).IsTexture())
                                {
                                    Debugger.Break();
                                }
                                artGalleryP.GetUExport(uindex).ObjectName = $"ME2R_W_KASUMIPAINTING{ThreadSafeRandom.Next(15000)}";
                            }
                        }

                        if (kagf.MaterialUIndexes != null)
                        {
                            foreach (var uindex in kagf.MaterialUIndexes)
                            {
                                var exp = artGalleryP.GetUExport(uindex);
                                if (!exp.ClassName.Contains("Material"))
                                {
                                    Debugger.Break();
                                }
                                artGalleryP.GetUExport(uindex).ObjectName = $"ME2R_PAINTMAT_KASUMI{ThreadSafeRandom.Next(15000)}";
                            }
                        }
                    }

                    InstallARArtTextures(kagf.WideTextureUIndexes, wideAssets, artGalleryP, "Wide");
                    InstallARArtTextures(kagf.TallTextureUIndexes, tallAssets, artGalleryP, "Tall");

                    MERFileSystem.SavePackage(artGalleryP);
                }
            }
        }
Beispiel #30
0
        private static void RandomizeTheLongWalk(RandomizationOption option)
        {
            var prelongwalkfile = MERFileSystem.GetPackageFile("BioD_EndGm2_200Factory.pcc");

            if (prelongwalkfile != null)
            {
                // Pre-long walk selection
                var package       = MEPackageHandler.OpenMEPackage(prelongwalkfile);
                var bioticTeamSeq = package.GetUExport(8609);

                var activated = package.GetUExport(8484);
                KismetHelper.RemoveAllLinks(activated);

                // install new logic
                var randSwitch = MERSeqTools.InstallRandomSwitchIntoSequence(bioticTeamSeq, 13); // don't include theif or veteran as dlc might not be installed
                KismetHelper.CreateOutputLink(activated, "Out", randSwitch);

                // Outputs of random choice
                KismetHelper.CreateOutputLink(randSwitch, "Link 1", package.GetUExport(1420));  //thane
                KismetHelper.CreateOutputLink(randSwitch, "Link 2", package.GetUExport(1419));  //jack
                KismetHelper.CreateOutputLink(randSwitch, "Link 3", package.GetUExport(1403));  //garrus
                KismetHelper.CreateOutputLink(randSwitch, "Link 4", package.GetUExport(1399));  //legion
                KismetHelper.CreateOutputLink(randSwitch, "Link 5", package.GetUExport(1417));  //grunt
                KismetHelper.CreateOutputLink(randSwitch, "Link 6", package.GetUExport(1395));  //jacob
                KismetHelper.CreateOutputLink(randSwitch, "Link 7", package.GetUExport(1418));  //samara
                KismetHelper.CreateOutputLink(randSwitch, "Link 8", package.GetUExport(1415));  //mordin
                KismetHelper.CreateOutputLink(randSwitch, "Link 9", package.GetUExport(1405));  //tali
                KismetHelper.CreateOutputLink(randSwitch, "Link 10", package.GetUExport(1401)); //morinth
                KismetHelper.CreateOutputLink(randSwitch, "Link 11", package.GetUExport(1402)); //miranda

                // kasumi
                if (MERFileSystem.GetPackageFile("BioH_Thief_00.pcc") != null)
                {
                    KismetHelper.CreateOutputLink(randSwitch, "Link 12", package.GetUExport(1396)); //kasumi
                }

                // zaeed
                if (MERFileSystem.GetPackageFile("BioH_Veteran_00.pcc") != null)
                {
                    KismetHelper.CreateOutputLink(randSwitch, "Link 13", package.GetUExport(1416)); //zaeed
                }

                MERFileSystem.SavePackage(package);
            }

            var biodEndGm2F = MERFileSystem.GetPackageFile("BioD_EndGm2.pcc");

            if (biodEndGm2F != null)
            {
                var package = MEPackageHandler.OpenMEPackage(biodEndGm2F);
                var ts      = package.GetUExport(7);
                var ss      = ts.GetProperty <ArrayProperty <StructProperty> >("StreamingStates");
                // Make walk4 remain loaded while walk5 is active as enemeis may not yet be cleared out
                var conclusion   = ss[8];
                var visibleNames = conclusion.GetProp <ArrayProperty <NameProperty> >("VisibleChunkNames");
                if (!visibleNames.Any(x => x.Value == "BioD_EndGm2_300Walk04"))
                {
                    // This has pawns as part of the level so we must make sure it doesn't disappear or player will just see enemies disappear
                    visibleNames.Add(new NameProperty("BioD_EndGm2_300Walk04"));
                }

                ts.WriteProperty(ss);
                MERFileSystem.SavePackage(package);
            }

            var longwalkfile = MERFileSystem.GetPackageFile("BioD_EndGm2_300LongWalk.pcc");

            if (longwalkfile != null)
            {
                // automate TLW

                var package     = MEPackageHandler.OpenMEPackage(longwalkfile);
                var seq         = package.GetUExport(1629);
                var stopWalking = package.GetUExport(1569);

                // The auto walk delay on Stop Walking
                var delay = package.GetUExport(806).Clone();
                package.AddExport(delay);
                delay.WriteProperty(new FloatProperty(ThreadSafeRandom.NextFloat(2, 7), "Duration")); // how long to wait until auto walk
                KismetHelper.AddObjectToSequence(delay, seq, true);
                KismetHelper.CreateOutputLink(delay, "Finished", package.GetUExport(156));
                KismetHelper.CreateOutputLink(stopWalking, "Out", delay);

                // Do not allow targeting the escort
                package.GetUExport(1915).WriteProperty(new IntProperty(0, "bValue"));  // stopped walking
                package.GetUExport(1909).WriteProperty(new IntProperty(0, "bValue"));  // loading from save - we will auto start
                KismetHelper.CreateOutputLink(package.GetUExport(1232), "Out", delay); // post loaded from save init

                // Do not enable autosaves, cause it makes it easy to cheese this area. Bypass the 'savegame' item
                KismetHelper.RemoveOutputLinks(package.GetUExport(156));
                KismetHelper.CreateOutputLink(package.GetUExport(156), "Out", package.GetUExport(1106));

                // Pick a random henchman to go on a date with
                //var determineEscortLog = package.GetUExport(1118);
                //var spawnSeq = package.GetUExport(1598);

                //// disconnect old logic
                //KismetHelper.RemoveAllLinks(determineEscortLog);

                // install new logic

                /*var randSwitch = SeqTools.InstallRandomSwitchIntoSequence(spawnSeq, 12); // don't include theif or veteran as dlc might not be installed
                 * KismetHelper.CreateOutputLink(determineEscortLog, "Out", randSwitch);
                 *
                 *
                 * // Outputs of random choice
                 *
                 *
                 *
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 1", package.GetUExport(1599)); //thane
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 2", package.GetUExport(1601)); //jack
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 3", package.GetUExport(1603)); //garrus
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 4", package.GetUExport(1605)); //legion
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 5", package.GetUExport(1607)); //grunt
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 6", package.GetUExport(1609)); //jacob
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 7", package.GetUExport(1611)); //samara
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 8", package.GetUExport(1613)); //mordin
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 9", package.GetUExport(1615)); //tali
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 10", package.GetUExport(1619)); //morinth
                 * KismetHelper.CreateOutputLink(randSwitch, "Link 11", package.GetUExport(1624)); //miranda
                 */



                MERFileSystem.SavePackage(package);
            }

            //randomize long walk lengths.
            var endwalkexportmap = new Dictionary <string, int>()
            {
                { "BioD_EndGm2_300Walk01", 40 },
                { "BioD_EndGm2_300Walk02", 5344 },
                { "BioD_EndGm2_300Walk03", 8884 },
                { "BioD_EndGm2_300Walk04", 6370 },
                { "BioD_EndGm2_300Walk05", 3190 }
            };

            foreach (var map in endwalkexportmap)
            {
                var file = MERFileSystem.GetPackageFile(map.Key + ".pcc");
                if (file != null)
                {
                    var package = MEPackageHandler.OpenMEPackage(file);
                    var export  = package.GetUExport(map.Value);
                    export.WriteProperty(new FloatProperty(ThreadSafeRandom.NextFloat(.5, 2.5), "PlayRate"));
                    MERFileSystem.SavePackage(package);
                }
            }

            /*foreach (var f in files)
             * {
             *  var package = MEPackageHandler.OpenMEPackage(f);
             *  var animExports = package.Exports.Where(x => x.ClassName == "InterpTrackAnimControl");
             *  foreach (var anim in animExports)
             *  {
             *      var animseqs = anim.GetProperty<ArrayProperty<StructProperty>>("AnimSeqs");
             *      if (animseqs != null)
             *      {
             *          foreach (var animseq in animseqs)
             *          {
             *              var seqname = animseq.GetProp<NameProperty>("AnimSeqName").Value.Name;
             *              if (seqname.StartsWith("Walk_"))
             *              {
             *                  var playrate = animseq.GetProp<FloatProperty>("AnimPlayRate");
             *                  var oldrate = playrate.Value;
             *                  if (oldrate != 1) Debugger.Break();
             *                  playrate.Value = ThreadSafeRandom.NextFloat(.2, 6);
             *                  var data = anim.Parent.Parent as ExportEntry;
             *                  var len = data.GetProperty<FloatProperty>("InterpLength");
             *                  len.Value = len.Value * playrate; //this might need to be changed if its not 1
             *                  data.WriteProperty(len);
             *              }
             *          }
             *      }
             *      anim.WriteProperty(animseqs);
             *  }
             *  SavePackage(package);
             * }*/
        }