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 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); }
private static void RandomizeVowelsInternal(TalkFile tf, List <int> skipIDs, Dictionary <char, char> translationMap, bool isMERTlk, RandomizationOption option) { var tfName = Path.GetFileNameWithoutExtension(tf.path); var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1); foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data)).ToList()) { option.IncrementProgressValue(); if (sref.Data.Contains("DLC_")) { continue; // Don't modify } if (!isMERTlk && skipIDs.Contains(sref.StringID)) { continue; // Do not randomize this version of the string as it's in the DLC version specifically } // See if strref has CUSTOMTOKEN or a control symbol List <int> skipRanges = new List <int>(); FindSkipRanges(sref, skipRanges); var newStr = sref.Data.ToArray(); for (int i = 0; i < sref.Data.Length; i++) // For every letter { // Skip any items we should not skip. if (skipRanges.Any() && skipRanges[0] == i) { i = skipRanges[1] - 1; // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character skipRanges.RemoveAt(0); // remove first 2 skipRanges.RemoveAt(0); // remove first 2 if (i >= sref.Data.Length - 1) { break; } continue; } if (translationMap.ContainsKey(newStr[i])) { // Remap the letter newStr[i] = translationMap[newStr[i]]; } else { // Do not change the letter. It might be something like <. } TLKHandler.ReplaceString(sref.StringID, new string(newStr), langCode); } } }
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); }
private static void RandomizeFlyerSpawnPawns() { string[] files = { "BioD_EndGm2_420CombatZone.pcc", "BioD_EndGm2_430ReaperCombat.pcc" }; ChangeFlyersInFiles(files); // Install names TLKHandler.ReplaceString(7892160, "Indoctrinated Krogan"); //Garm update TLKHandler.ReplaceString(7892161, "Enthralled Batarian"); //Batarian Commando update //TLKHandler.ReplaceString(7892162, "Collected Human"); //Batarian Commando update }
private static int InstallName(int stringId = 0) { count++; if (PawnNameListInstanced.Any()) { var newPawnName = PawnNameListInstanced.PullFirstItem(); if (stringId == 0) { stringId = TLKHandler.GetNewTLKID(); } TLKHandler.ReplaceString(stringId, newPawnName); return(stringId); } return(0); // Not changed }
public static bool RandomizePsychProfiles(RandomizationOption option) { //Psych Profiles string fileContents = MERUtilities.GetEmbeddedStaticFilesTextFile("psychprofiles.xml"); XElement rootElement = XElement.Parse(fileContents); var childhoods = rootElement.Descendants("childhood").Where(x => x.Value != "").Select(x => (x.Attribute("name").Value, string.Join("\n", x.Value.Split('\n').Select(s => s.Trim())))).ToList(); var reputations = rootElement.Descendants("reputation").Where(x => x.Value != "").Select(x => (x.Attribute("name").Value, string.Join("\n", x.Value.Split('\n').Select(s => s.Trim())))).ToList(); childhoods.Shuffle(); reputations.Shuffle(); var backgroundTlkPairs = new List <(int nameId, int descriptionId)>(); backgroundTlkPairs.Add((45477, 34931)); //Spacer backgroundTlkPairs.Add((45508, 34940)); //Earthborn backgroundTlkPairs.Add((45478, 34971)); //Colonist foreach (var pair in backgroundTlkPairs) { var childHood = childhoods.PullFirstItem(); TLKHandler.ReplaceString(pair.nameId, childHood.Value); TLKHandler.ReplaceString(pair.descriptionId, childHood.Item2.Trim()); } backgroundTlkPairs.Clear(); backgroundTlkPairs.Add((45482, 34934)); //Sole Survivor backgroundTlkPairs.Add((45483, 34936)); //War Hero backgroundTlkPairs.Add((45484, 34938)); //Ruthless foreach (var pair in backgroundTlkPairs) { var reputation = reputations.PullFirstItem(); TLKHandler.ReplaceString(pair.nameId, reputation.Value); TLKHandler.ReplaceString(pair.descriptionId, reputation.Item2.Trim()); } return(true); }
private static void UwuifyTalkFile(TalkFile tf, bool keepCasing, bool addReactions, List <int> skipIDs, bool isMERTlk, RandomizationOption option) { var tfName = Path.GetFileNameWithoutExtension(tf.path); var langCode = tfName.Substring(tfName.LastIndexOf("_", StringComparison.InvariantCultureIgnoreCase) + 1); if (langCode != "INT") { return; } foreach (var sref in tf.StringRefs.Where(x => x.StringID > 0 && !string.IsNullOrWhiteSpace(x.Data))) { option.IncrementProgressValue(); var strData = sref.Data; //strData = "New Game"; if (strData.Contains("DLC_")) { continue; // Don't modify } if (!isMERTlk && skipIDs.Contains(sref.StringID)) { continue; // Do not randomize this version of the string as it's in the DLC version specifically } //if (sref.StringID != 325648) // continue; // See if strref has CUSTOMTOKEN or a control symbol List <int> skipRanges = new List <int>(); FindSkipRanges(sref, skipRanges); // uwuify it StringBuilder sb = new StringBuilder(); char previousChar = (char)0x00; char currentChar; for (int i = 0; i < strData.Length; i++) { if (skipRanges.Any() && skipRanges[0] == i) { sb.Append(strData.Substring(skipRanges[0], skipRanges[1] - skipRanges[0])); previousChar = (char)0x00; i = skipRanges[1] - 1; // We subtract one as the next iteration of the loop will +1 it again, which then will make it read the 'next' character skipRanges.RemoveAt(0); // remove first 2 skipRanges.RemoveAt(0); // remove first 2 if (i >= strData.Length - 1) { break; } continue; } currentChar = strData[i]; if (currentChar == 'L' || currentChar == 'R') { sb.Append(keepCasing ? 'W' : 'w'); } else if (currentChar == 'l' || currentChar == 'r') { sb.Append('w'); if (ThreadSafeRandom.Next(5) == 0) { sb.Append('w'); // append another w 20% of the time if (ThreadSafeRandom.Next(8) == 0) { sb.Append('w'); // append another w 20% of the time } } } else if (currentChar == 'N' && (previousChar == 0x00 || previousChar == ' ')) { sb.Append(keepCasing ? "Nyaa" : "nyaa"); } else if (currentChar == 'O' || currentChar == 'o') { if (previousChar == 'N' || previousChar == 'n' || previousChar == 'M' || previousChar == 'm') { sb.Append("yo"); } else { sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i])); } } else if (currentChar == '!' && !addReactions) { sb.Append(currentChar); if (ThreadSafeRandom.Next(2) == 0) { sb.Append(currentChar); // append another ! 50% of the time } } else { sb.Append(keepCasing ? strData[i] : char.ToLower(strData[i])); } previousChar = currentChar; } var str = sb.ToString(); if (addReactions) { str = AddReactionToLine(strData, str, keepCasing); } else { str = str.Replace("f**k", keepCasing ? "UwU" : "uwu", StringComparison.InvariantCultureIgnoreCase); } TLKHandler.ReplaceString(sref.StringID, str, langCode); } }