public PARAMDEF GetParamdefForParam(string paramType) { PARAMDEF pd = PARAMDEF.XmlDeserialize($@"{GetParamdefDir()}\{paramType}.xml"); MsbEditor.ParamMetaData meta = MsbEditor.ParamMetaData.XmlDeserialize($@"{GetParammetaDir()}\{paramType}.xml", pd); return(pd); }
private ParamMetaData(XmlDocument xml, PARAMDEF def) { XmlNode root = xml.SelectSingleNode("PARAMMETA"); int xmlVersion = int.Parse(root.Attributes["XmlVersion"].InnerText); if (xmlVersion != XML_VERSION) { throw new InvalidDataException($"Mismatched XML version; current version: {XML_VERSION}, file version: {xmlVersion}"); } Add(def, this); foreach (XmlNode node in root.SelectNodes("Enums/Enum")) { ParamEnum en = new ParamEnum(node); enums.Add(en.name, en); } foreach (PARAMDEF.Field f in def.Fields) { try { XmlNode pairedNode = root.SelectSingleNode($"Field/{Regex.Replace(f.InternalName, @"[^a-zA-Z0-9_]", "")}"); if (pairedNode == null) { new FieldMetaData(f); continue; } new FieldMetaData(this, pairedNode, f); } catch { new FieldMetaData(f); } } }
public PARAM Read(string name, PARAMDEF def) { var param = Params[name]; param.ApplyParamdef(def); return(param); }
private ParamMetaData(PARAMDEF def) { Add(def, this); foreach (PARAMDEF.Field f in def.Fields) { new FieldMetaData(this, f); } // Blank Metadata }
public static void LoadParams(SQLiteConnection con, string paramdefFilepath, IList <string> paramDirs) { // The metadata tables should be created ahead of time. CreateBndMetadataTables(con); CreateBndTableOfContentsTable(con); CreateParamMetadataTables(con); // Reading an original paramdefbnd var paramdefs = new Dictionary <string, PARAMDEF>(); var paramdefbnd = BND3.Read(paramdefFilepath); foreach (BinderFile file in paramdefbnd.Files) { var paramdef = PARAMDEF.Read(file.Bytes); paramdefs[paramdef.ParamType] = paramdef; } ReadParamdefsIntoDatabase(con, paramdefs.Values.ToList()); // Loading parambnd List <string> paramFilepaths = new List <string>(); foreach (var paramDir in paramDirs) { // DeS has both a gameparam.parambnd.dcx and a gameparamna.parambnd.dcx. // Only grab gameparamna.parambnd.dcx if we have it. string filterPattern = "*.parambnd.dcx"; if (Directory.GetFiles(paramDir, "*gameparamna.parambnd.dcx").Length > 0) { Console.WriteLine("Skipping gameparam.parambnd.dcx"); filterPattern = "*gameparamna.parambnd.dcx"; } paramFilepaths.AddRange(Directory.GetFiles(paramDir, filterPattern)); } foreach (var paramFilepath in paramFilepaths) { // Have to construct Table of Contents as we go through, since the info isn't all at BND level, but is needed when reconstructing var bndContents = new List <BndContentsEntry>(); Console.WriteLine("Loading file: " + paramFilepath); var parambnd = BND3.Read(paramFilepath); foreach (BinderFile file in parambnd.Files) { PARAM param = PARAM.Read(file.Bytes); // DSR doesn't seem to like applying carefully, specifically SP_EFFECT_PARAM_ST in Gameparam. At minimum. param.ApplyParamdef(paramdefs[param.ParamType]); var entry = new BndContentsEntry(paramFilepath, file.ID, file.Name, file.Flags, file.CompressionType, param.ParamType); bndContents.Add(entry); ReadParamIntoDatabase(con, Path.GetFileNameWithoutExtension(file.Name), param); } // Create the metadata tables ReadBndMetadataIntoDatabase(con, paramFilepath, parambnd); ReadBndTableOfContentsIntoDatabase(con, Path.GetFileName(paramFilepath), bndContents); } }
static void translateParamDefs(string a) { string paramDefDir = a.EndsWith("\\") ? a.Substring(a.Length - 1, 1) : a; string[] paramDefFileList = Directory.GetFiles(paramDefDir); List <string> paramDefFileNameList = new List <string>(); List <PARAMDEF> paramDefs = new List <PARAMDEF>(); Console.WriteLine("### " + paramDefDir); for (int i = 0; i < paramDefFileList.Length; i++) { string fn = paramDefFileList[i].Substring(paramDefDir.Length + 1, paramDefFileList[i].Length - (paramDefDir.Length + 1)); paramDefFileNameList.Add(fn); paramDefs.Add(PARAMDEF.Read(File.ReadAllBytes(paramDefFileList[i]))); } TranslationClient client = TranslationClient.Create(GoogleCredential.FromFile("C:\\Users\\dmtin\\google-translate-api-key.txt")); for (int i = 0; i < paramDefs.Count; i++) { PARAMDEF pd = paramDefs[i]; Console.WriteLine("\n\n\n\n==================" + pd.ParamType + "=================="); for (int j = 0; j < pd.Fields.Count; j++) { PARAMDEF.Field field = pd.Fields[j]; try { TranslationResult responseA = client.TranslateText(field.DisplayName, LanguageCodes.English, LanguageCodes.Japanese); // Translate request if (responseA != null && responseA.TranslatedText != null && responseA.TranslatedText.Trim().Length > 0) { field.DisplayName = responseA.TranslatedText; } TranslationResult responseB = client.TranslateText(field.Description, LanguageCodes.English, LanguageCodes.Japanese); // Translate request if (responseB != null && responseB.TranslatedText != null && responseB.TranslatedText.Trim().Length > 0) { field.Description = responseB.TranslatedText; } } catch (Exception ex) { Console.WriteLine("EXCEPTION :: " + ex.Message); } Console.WriteLine(field.DisplayName + ":: " + field.Description); } } Directory.CreateDirectory(paramDefDir + "\\translated\\"); for (int i = 0; i < paramDefs.Count; i++) { string outPath = paramDefDir + "\\translated\\" + paramDefFileNameList[i]; byte[] outData = paramDefs[i].Write(); File.WriteAllBytes(outPath, outData); } }
private static void LoadParamdefs() { _paramdefs = new Dictionary <string, PARAMDEF>(); var dir = AssetLocator.GetParamdefDir(); var files = Directory.GetFiles(dir, "*.xml"); foreach (var f in files) { var pdef = PARAMDEF.XmlDeserialize(f); _paramdefs.Add(pdef.ParamType, pdef); } }
public static void Run(Game game, FileInfo paramdexPath, Regex typeFilter) { var paramdefPaths = Directory.GetFiles($"{paramdexPath.FullName}/{game}/Defs", "*.xml"); foreach (var paramdefPath in paramdefPaths) { var paramdef = PARAMDEF.XmlDeserialize(paramdefPath); if (!typeFilter.IsMatch(paramdef.ParamType)) { continue; } Console.WriteLine($"struct {paramdef.ParamType} {{"); foreach (var field in paramdef.Fields) { var ctype = field.DisplayType switch { PARAMDEF.DefType _ when field.BitSize == 1 => "bool", PARAMDEF.DefType.s8 => "char", PARAMDEF.DefType.u8 => "unsigned char", PARAMDEF.DefType.s16 => "short", PARAMDEF.DefType.u16 => "unsigned short", PARAMDEF.DefType.s32 => "int", PARAMDEF.DefType.u32 => "unsigned int", PARAMDEF.DefType.f32 => "float", PARAMDEF.DefType.dummy8 => "char", PARAMDEF.DefType.fixstr => "char*", PARAMDEF.DefType.fixstrW => "wchar_t*", _ => throw new ArgumentOutOfRangeException() }; Console.Write($" {ctype} {field.DisplayName}"); if (field.BitSize != -1 && field.BitSize % 8 != 0) { Console.Write($" : {field.BitSize}"); } else if (field.ArrayLength > 1) { Console.Write($"[{field.ArrayLength}]"); } Console.WriteLine(";"); } Console.WriteLine("};"); } } }
public GameParamHandler(Dictionary <string, PARAMDEF> paramdefs, TextHandler text, byte[] paramBNDData) { ParamDefs = paramdefs; ParamBnd = BND3.Read(paramBNDData); foreach (BinderFile file in ParamBnd.Files) { string name = Path.GetFileNameWithoutExtension(file.Name); PARAM param = PARAM.Read(file.Bytes); PARAMDEF p = ParamDefs[param.ParamType]; param.ApplyParamdef(p); Params[name] = param; } AI = new ParamDict <NPCThought>("NpcThinkParam", this, text); Armor = new ParamDict <Armor>("EquipParamProtector", this, text); ArmorUpgrades = new ParamDict <ArmorUpgrade>("ReinforceParamProtector", this, text); AttacksPC = new ParamDict <Attack>("AtkParam_Pc", this, text); AttacksNPC = new ParamDict <Attack>("AtkParam_Npc", this, text); BehaviorsPC = new ParamDict <Behavior>("BehaviorParam_PC", this, text); BehaviorsNPC = new ParamDict <Behavior>("BehaviorParam", this, text); Bullets = new ParamDict <Bullet>("Bullet", this, text); CalcCorrects = new ParamDict <CalcCorrect>("CalcCorrectGraph", this, text); ChrInits = new ParamDict <ChrInit>("CharaInitParam", this, text); CoolTimes = new ParamDict <CoolTime>("CoolTimeParam", this, text); UpgradeMaterials = new ParamDict <EquipMtrlSet>("EquipMtrlSetParam", this, text); FaceGens = new ParamDict <FaceGen>("FaceGenParam", this, text); GameAreas = new ParamDict <GameArea>("GameAreaParam", this, text); Goods = new ParamDict <Good>("EquipParamGoods", this, text); HitMtrls = new ParamDict <HitMtrl>("HitMtrlParam", this, text); ItemLots = new ParamDict <ItemLot>("ItemLotParam", this, text); Knockbacks = new ParamDict <Knockback>("KnockBackParam", this, text); LockCams = new ParamDict <LockCam>("LockCamParam", this, text); Magic = new ParamDict <Magic>("Magic", this, text); Movement = new ParamDict <Move>("MoveParam", this, text); MenuColorTables = new ParamDict <MenuColorTable>("MenuColorTableParam", this, text); NPCs = new ParamDict <NPC>("NpcParam", this, text); ObjActs = new ParamDict <ObjAct>("ObjActParam", this, text); Objects = new ParamDict <GameObject>("ObjectParam", this, text); Rings = new ParamDict <Accessory>("EquipParamAccessory", this, text); ShopLineups = new ParamDict <ShopLineup>("ShopLineupParam", this, text); Skeletons = new ParamDict <Skeleton>("SkeletonParam", this, text); SpEffects = new ParamDict <SpEffect>("SpEffectParam", this, text); SpEffectVFXs = new ParamDict <SpEffectVFX>("SpEffectVfxParam", this, text); Talks = new ParamDict <Talk>("TalkParam", this, text); Throws = new ParamDict <Throw>("ThrowParam", this, text); Weapons = new ParamDict <Weapon>("EquipParamWeapon", this, text); WeaponUpgrades = new ParamDict <WeaponUpgrade>("ReinforceParamWeapon", this, text); WhiteCoolTimes = new ParamDict <WhiteCoolTime>("WhiteCoolTimeParam", this, text); }
private static List <(string, PARAMDEF)> LoadParamdefs() { _paramdefs = new Dictionary <string, PARAMDEF>(); var dir = AssetLocator.GetParamdefDir(); var files = Directory.GetFiles(dir, "*.xml"); List <(string, PARAMDEF)> defPairs = new List <(string, PARAMDEF)>(); foreach (var f in files) { var pdef = PARAMDEF.XmlDeserialize(f); _paramdefs.Add(pdef.ParamType, pdef); defPairs.Add((f, pdef)); } return(defPairs); }
private static void LoadParamdefs() { _paramdefs = new Dictionary <string, PARAMDEF>(); var dir = AssetLocator.GetParamdefDir(); var files = Directory.GetFiles(dir, "*.xml"); var mdir = AssetLocator.GetParammetaDir(); foreach (var f in files) { var pdef = PARAMDEF.XmlDeserialize(f); var fName = f.Substring(f.LastIndexOf('\\') + 1); ParamMetaData.XmlDeserialize($@"{mdir}\{fName}", pdef); _paramdefs.Add(pdef.ParamType, pdef); } }
public ParamWrapper(string name, PARAM param, PARAM.Layout layout, string description) { if (layout == null || layout.Size != param.DetectedSize) { layout = new PARAM.Layout { new PARAM.Layout.Entry(PARAM.CellType.dummy8, "Unknown", (int)param.DetectedSize, null) }; Error = true; } Name = name; Param = param; Layout = layout; Paramdef = Layout.ToParamdef(name, out Paramtdfs); Param.ApplyParamdef(Paramdef); Description = description; }
public static ParamMetaData XmlDeserialize(string path, PARAMDEF def) { if (!File.Exists(path)) { return(new ParamMetaData(def)); } var mxml = new XmlDocument(); try { mxml.Load(path); return(new ParamMetaData(mxml, path, def)); } catch { return(new ParamMetaData(def)); } }
public PARAMDEF GetParamdefForParam(string paramType) { string game; switch (Type) { case GameType.DemonsSouls: game = "DES"; break; case GameType.DarkSoulsPTDE: game = "DS1"; break; case GameType.DarkSoulsRemastered: game = "DS1R"; break; case GameType.DarkSoulsIISOTFS: game = "DS2S"; break; case GameType.Bloodborne: game = "BB"; break; case GameType.DarkSoulsIII: game = "DS3"; break; case GameType.Sekiro: game = "SDT"; break; default: throw new Exception("Game type not set"); } return(PARAMDEF.XmlDeserialize($@"Assets\Paramdex\{game}\Defs\{paramType}.xml")); }
public PARAM Read(string name, PARAMDEF def) { var worksheet = Spreadsheet.Workbook.Worksheets.First(sheet => sheet.Name.Equals(name)); var rowCount = worksheet.Dimension.Rows; var param = new PARAM(); param.ParamType = def.ParamType; param.Rows = new List <PARAM.Row>(rowCount - 2); param.ApplyParamdef(def); for (var rowIndex = 3; rowIndex <= rowCount; rowIndex++) { var id = int.Parse(worksheet.Cells[rowIndex, 1].Value.ToString()); var rowName = worksheet.Cells[rowIndex, 2].Value ?? string.Empty; var row = new PARAM.Row(id, (string?)rowName, def); for (var cellIndex = 0; cellIndex < def.Fields.Count; cellIndex++) { var value = worksheet.Cells[rowIndex, 3 + cellIndex].Value; if (value is string v && v == "-") { // padding, we don't store this in excel files continue; } if (value is null) { Console.WriteLine($"Row ID {id} and field ${def.Fields[cellIndex].DisplayName} has null value, assuming default"); continue; } row.Cells[cellIndex].Value = value; } param.Rows.Add(row); } return(param); }
private void UnpackGameBNDFile() { // Reading an original paramdefbnd paramDefs = new Dictionary <string, PARAMDEF>(); paramDefBnd = BND3.Read(pathToParamDef); foreach (BinderFile file in paramDefBnd.Files) { var paramdef = PARAMDEF.Read(file.Bytes); paramDefs[paramdef.ParamType] = paramdef; } parms = new Dictionary <string, PARAM>(); paramBnd = BND3.Read(pathToParamDataFile); foreach (BinderFile file in paramBnd.Files) { string name = Path.GetFileNameWithoutExtension(file.Name); var param = PARAM.Read(file.Bytes); param.ApplyParamdef(paramDefs[param.ParamType]); parms[name] = param; } }
public static void WriteParams(SQLiteConnection con, string outputPath, bool overwriteOutputFiles) { // Writing a parambnd // Need to construct our BND3 files based on what's in our DB. // This is a kludge to create a mapping (filename -> (source_path, BND)). var bnds = new Dictionary <string, KeyValuePair <string, BND3> >(); // First thing to do is get our basic BND file setup. using (var cmd = new SQLiteCommand(@"SELECT * FROM 'bnd_metadata'", con)) { var reader = cmd.ExecuteReader(); while (reader.Read()) { var bnd = new BND3 { BigEndian = reader.GetBoolean(reader.GetOrdinal(@"big_endian")), BitBigEndian = reader.GetBoolean(reader.GetOrdinal(@"bit_big_endian")), Compression = (DCX.Type)Enum.Parse(typeof(DCX.Type), reader.GetString(reader.GetOrdinal(@"compression"))), Format = (Binder.Format)reader.GetInt64(reader.GetOrdinal(@"format")), Unk18 = reader.GetInt32(reader.GetOrdinal(@"unk18")), Version = reader.GetString(reader.GetOrdinal(@"version")), Files = new List <BinderFile>() }; var filename = reader.GetString(reader.GetOrdinal(@"filename")); bnds.Add(Path.GetFileName(filename), new KeyValuePair <string, BND3>(filename, bnd)); } } // Get our list of files. We'll grab the contents afterwards. // Note that it's a List because there can be multiple files associated with a given ParamType. var files = new Dictionary <string, KeyValuePair <string, List <BinderFile> > >(); using (var cmd = new SQLiteCommand(@"SELECT * FROM 'bnd_contents'", con)) { var reader = cmd.ExecuteReader(); while (reader.Read()) { var source_file = reader.GetString(reader.GetOrdinal(@"source_file")); var file = new BinderFile { ID = reader.GetInt32(reader.GetOrdinal(@"file_id")), Name = reader.GetString(reader.GetOrdinal(@"name")), Flags = (Binder.FileFlags)reader.GetInt64(reader.GetOrdinal(@"flags")), CompressionType = (DCX.Type)System.Enum.Parse(typeof(DCX.Type), reader.GetString(reader.GetOrdinal(@"compression_type"))) }; var paramType = reader.GetString(reader.GetOrdinal("param_type")); // Add the file to both our list of files in the appropriate BND and also to our dictionary // so that we can continue building it out. bnds[source_file].Value.Files.Add(file); if (files.ContainsKey(Path.GetFileNameWithoutExtension(file.Name))) { var dictValue = files.TryGetValue(Path.GetFileNameWithoutExtension(file.Name), out KeyValuePair <string, List <BinderFile> > value) ? value : new KeyValuePair <string, List <BinderFile> >(paramType, new List <BinderFile>()); dictValue.Value.Add(file); } else { var dictValue = new KeyValuePair <string, List <BinderFile> >(paramType, new List <BinderFile>() { file }); files.Add(Path.GetFileNameWithoutExtension(file.Name), dictValue); } } } // Get all of our PARAMDEFs Dictionary <string, PARAMDEF> paramTypeToParamDef = new Dictionary <string, PARAMDEF>(); using (var cmd = new SQLiteCommand(@"SELECT * FROM 'paramdef_metadata';", con)) using (var fieldsCmd = new SQLiteCommand(@"SELECT * FROM 'paramdef_fields' WHERE param_type=$param_type;", con)) { var reader = cmd.ExecuteReader(); while (reader.Read()) { PARAMDEF paramdef = new PARAMDEF { BigEndian = reader.GetBoolean(reader.GetOrdinal(@"big_endian")), Compression = (DCX.Type)Enum.Parse(typeof(DCX.Type), reader.GetString(reader.GetOrdinal(@"compression"))), ParamType = reader.GetString(reader.GetOrdinal(@"param_type")), Unicode = reader.GetBoolean(reader.GetOrdinal(@"unicode")), DataVersion = reader.GetInt16(reader.GetOrdinal(@"data_version")), FormatVersion = reader.GetInt16(reader.GetOrdinal(@"format_version")) }; paramTypeToParamDef.Add(paramdef.ParamType, paramdef); } } using (var cmd = new SQLiteCommand(@"SELECT * FROM 'paramdef_fields' WHERE param_type=$param_type;", con)) { foreach (KeyValuePair <string, PARAMDEF> keyValue in paramTypeToParamDef) { // Get all the fields for our paramdef AddParamToCommand(cmd, @"$param_type", keyValue.Key); var fieldReader = cmd.ExecuteReader(); var fields = new List <Field>(); while (fieldReader.Read()) { var descOrdinal = fieldReader.GetOrdinal(@"description"); var field = new Field { ArrayLength = fieldReader.GetInt32(fieldReader.GetOrdinal(@"array_length")), BitSize = fieldReader.GetInt32(fieldReader.GetOrdinal(@"bit_size")), Default = fieldReader.GetFloat(fieldReader.GetOrdinal(@"default")), // Description can be NULL. Need to check. Sigh. Description = fieldReader.IsDBNull(descOrdinal) ? null : fieldReader.GetFieldValue <string>(descOrdinal), DisplayFormat = fieldReader.GetString(fieldReader.GetOrdinal(@"display_format")), DisplayName = fieldReader.GetString(fieldReader.GetOrdinal(@"display_name")), DisplayType = (DefType)System.Enum.Parse(typeof(DefType), fieldReader.GetString(fieldReader.GetOrdinal(@"display_type"))), EditFlags = (EditFlags)fieldReader.GetInt64(fieldReader.GetOrdinal(@"edit_flags")), Increment = fieldReader.GetFloat(fieldReader.GetOrdinal(@"increment")), InternalName = fieldReader.GetString(fieldReader.GetOrdinal(@"internal_name")), InternalType = fieldReader.GetString(fieldReader.GetOrdinal(@"internal_type")), Maximum = fieldReader.GetFloat(fieldReader.GetOrdinal(@"maximum")), Minimum = fieldReader.GetFloat(fieldReader.GetOrdinal(@"minimum")), SortID = fieldReader.GetInt32(fieldReader.GetOrdinal(@"sort_id")) }; fields.Add(field); } keyValue.Value.Fields = fields; var exc = new Exception(); if (!keyValue.Value.Validate(out exc)) { throw exc; } fieldReader.Close(); } } // Now we need to grab our contents for each file. foreach (KeyValuePair <string, KeyValuePair <string, List <BinderFile> > > entry in files) { // Want to iterate through each file. Keep in mind multiple tables can have same ParamType, so we can't loop via ParamType. // e.g. DeS AtkParam_Npc and AtkParam_Pc foreach (BinderFile file in entry.Value.Value) { //var tableName = Path.GetFileNameWithoutExtension(file.Name); var tableName = entry.Key; Console.WriteLine("Reading from: " + tableName); using (var cmd = new SQLiteCommand(@"SELECT * FROM '" + tableName + "';", con)) using (var metadataCmd = new SQLiteCommand(@"SELECT * FROM param_metadata WHERE param_type = $param_type", con)) { var paramDef = paramTypeToParamDef[entry.Value.Key]; var paramFile = new PARAM(); paramFile.ParamType = entry.Value.Key; AddParamToCommand(metadataCmd, @"$param_type", entry.Value.Key); var metadataReader = metadataCmd.ExecuteReader(); while (metadataReader.Read()) { paramFile.BigEndian = metadataReader.GetBoolean(metadataReader.GetOrdinal(@"big_endian")); paramFile.Compression = (DCX.Type)Enum.Parse(typeof(DCX.Type), metadataReader.GetString(metadataReader.GetOrdinal(@"compression"))); paramFile.Format2D = (PARAM.FormatFlags1)Enum.Parse(typeof(PARAM.FormatFlags1), metadataReader.GetString(metadataReader.GetOrdinal(@"format2d"))); paramFile.Format2E = (PARAM.FormatFlags2)Enum.Parse(typeof(PARAM.FormatFlags2), metadataReader.GetString(metadataReader.GetOrdinal(@"format2e"))); byte[] buf = new byte[1]; metadataReader.GetBytes(metadataReader.GetOrdinal("paramdef_format_version"), 0, buf, 0, 1); paramFile.ParamdefFormatVersion = buf[0]; paramFile.Unk06 = metadataReader.GetInt16(metadataReader.GetOrdinal(@"unk06")); paramFile.ParamdefDataVersion = metadataReader.GetInt16(metadataReader.GetOrdinal(@"paramdef_data_version")); } var reader = cmd.ExecuteReader(); paramFile.Rows = new List <PARAM.Row>(); while (reader.Read()) { var id = reader.GetInt32(reader.GetOrdinal(@"id")); // Description can be NULL var descOrdinal = reader.GetOrdinal(@"description"); var description = reader.IsDBNull(descOrdinal) ? null : reader.GetFieldValue <string>(descOrdinal); var row = new PARAM.Row(id, description, paramDef); foreach (Field field in paramDef.Fields) { var name = field.InternalName; // Not using InternalType. I don't know the complete set of raw strings across all games. // It would be better to use not be tied to a display field. For some value of "better". var type = field.DisplayType; switch (type) { // Padding case case DefType.dummy8: int length = field.ArrayLength; if (field.BitSize == -1) { row[name].Value = Enumerable.Repeat((byte)0, length).ToArray(); } else { row[name].Value = 0; } break; // All the integer cases case DefType.s8: case DefType.s16: case DefType.s32: case DefType.u8: case DefType.u16: case DefType.u32: row[name].Value = reader.GetInt32(reader.GetOrdinal(name)); break; // Float cases case DefType.f32: row[name].Value = reader.GetFloat(reader.GetOrdinal(name)); break; // String case case DefType.fixstr: case DefType.fixstrW: row[name].Value = reader.GetString(reader.GetOrdinal(name)); break; } } paramFile.Rows.Add(row); } // Don't apply carefully. We don't have the ability to set the DetectedSize. It only occurs on Read paramFile.ApplyParamdef(paramDef); var exc = new Exception(); if (!paramFile.Validate(out exc)) { Console.WriteLine("Failed with exception: " + exc); } file.Bytes = paramFile.Write(); } } } foreach (KeyValuePair <string, KeyValuePair <string, BND3> > entry in bnds) { // Default to writing the original file. // If output path is defined, put everything there. var outputFile = entry.Value.Key; if (outputPath != null) { outputFile = outputPath + Path.DirectorySeparatorChar + entry.Key; Console.WriteLine("Output current parambnd.dcx: " + outputFile); } if (!File.Exists(outputFile) || overwriteOutputFiles) { entry.Value.Value.Write(outputFile); } else { // Backup the eisting file before writing. // Just append the unix time and ".bak" to avoid managing whole sets of backup nonsense. var unixTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); string backupFile = outputFile + "." + unixTime + ".bak"; Console.WriteLine("Collision found. Not overwriting. Moving original file to backup at: " + backupFile); File.Move(outputFile, backupFile); entry.Value.Value.Write(outputFile); } } }
public static ParamMetaData Get(PARAMDEF def) { return(_ParamMetas[def]); }
static void Main(string[] args) { //Load list of params into memory List <PARAMDEF> ParamDefs = new List <PARAMDEF>(); List <PARAM> AllParams = new List <PARAM>(); var gameFolder = @"D:\Program Files (x86)\Steam\steamapps\common\Dark Souls Prepare to Die Edition\DATA\"; var gameparamBnds = Directory.GetFiles(gameFolder + "param\\GameParam\\", "*.parambnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))); var drawparamBnds = Directory.GetFiles(gameFolder + "param\\DrawParam\\", "*.parambnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))); List <BND> PARAMBNDs = gameparamBnds.Concat(drawparamBnds).ToList(); var paramdefBnds = Directory.GetFiles(gameFolder + "paramdef\\", "*.paramdefbnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))).ToList(); for (int i = 0; i < paramdefBnds.Count(); i++) { foreach (var paramdef in paramdefBnds[i]) { PARAMDEF newParamDef = paramdef.ReadDataAs <PARAMDEF>(new Progress <(int, int)> ((r) => { })); ParamDefs.Add(newParamDef); } } for (int i = 0; i < PARAMBNDs.Count(); i++) { foreach (var param in PARAMBNDs[i]) { PARAM newParam = param.ReadDataAs <PARAM>(new Progress <(int, int)> ((p) => { })); newParam.ApplyPARAMDEFTemplate(ParamDefs.Where(x => x.ID == newParam.ID).First()); AllParams.Add(newParam); } } //loading complete //change all the things foreach (PARAM paramFile in AllParams) { if (paramFile.VirtualUri.EndsWith("AtkParam_Npc.param")) { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { //max guard break //do everything to make enemies as difficult to fight as possible if (cell.Def.Name == "guardAtkRate") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, cell.Def.Max, null); } //every hit knocks you down btw else if (cell.Def.Name == "dmgLevel") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 7, null); } //double hitbox radius? else if (cell.Def.Name == "hit0_Radius") { PropertyInfo prop = cell.GetType().GetProperty("Value"); prop.SetValue(cell, (float)(prop.GetValue(cell, null)) * 1.5, null); } } } } else if (paramFile.ID == "NPC_THINK_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { //max these //once enemies see you, they'll chase you like no tomorrow string[] attrsToMax = { "farDist", "outDist", "maxBackhomeDist", "backhomeDist", "backhomeBattleDist", "BackHome_LookTargetTime", "BackHome_LookTargetDist", "BattleStartDist", "ear_angX", "ear_angY", "ear_dist" }; if (attrsToMax.Contains(cell.Def.Name)) { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, cell.Def.Max, null); } //add nose dist? string[] attrsToMin = { "nearDist", "midDist", "nose_dist" }; if (attrsToMin.Contains(cell.Def.Name)) { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, cell.Def.Min, null); } //specific values if (cell.Def.Name == "eye_angX") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 70, null); } else if (cell.Def.Name == "eye_angY") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 70, null); } else if (cell.Def.Name == "eye_dist") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 7, null); } else if (cell.Def.Name == "CallHelp_ReplyBehaviorType") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 1, null); } else if (cell.Def.Name == "CallHelp_ActionAnimId") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, -1, null); } else if (cell.Def.Name == "CallHelp_ForgetTimeByArrival") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 20, null); } else if (cell.Def.Name == "CallHelp_CallValidRange") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 50, null); } else if (cell.Def.Name == "CallHelp_MinWaitTime") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 0, null); } else if (cell.Def.Name == "CallHelp_MaxWaitTime") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 10, null); } } } } else if (paramFile.ID == "NPC_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "turnVellocity") { //something relatively slow, but not so slow you can backstep fish super easily Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 80, null); } } } } else if (paramFile.ID == "CHARACTER_INIT_PARAM") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { //change one id entry only (theif) if (paramRow.ID == 2003) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { //light crossbow if (cell.Def.Name == "equip_Subwep_Right") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 1250000, null); } //sorc catalyst else if (cell.Def.Name == "equip_Subwep_Left") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 1300000, null); } //light bolts else if (cell.Def.Name == "equip_Bolt") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 2100000, null); } //heavy bolts else if (cell.Def.Name == "equip_SubBolt") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 2101000, null); } //light bolt quantity else if (cell.Def.Name == "boltNum") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 999, null); } //heavy bolt quantity else if (cell.Def.Name == "subBoltNum") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 200, null); } //start with black firebombs else if (cell.Def.Name == "item_01") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 297, null); } //99 black firebombs else if (cell.Def.Name == "itemNum_01") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 99, null); } //alluring skulls else if (cell.Def.Name == "item_02") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 294, null); } //alluring skulls quantity else if (cell.Def.Name == "itemNum_02") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 99, null); } //slumbering ring else if (cell.Def.Name == "equip_Accessory01") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 123, null); } //chameleon else if (cell.Def.Name == "equip_Spell_01") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 3550, null); } //enough int to use chameleon else if (cell.Def.Name == "baseMag") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 14, null); } } } } } else if (paramFile.ID == "BULLET_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { //Light(standard?) bolt if (paramRow.ID == 600) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "GravityOutRange") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 0, null); } else if (cell.Def.Name == "initVellocity") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 100, null); } else if (cell.Def.Name == "maxVellocity") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 100, null); } else if (cell.Def.Name == "HitBulletID") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 121, null); } } } //Heavy bolt = shotgun if (paramRow.ID == 601) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "GravityOutRange") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 10, null); } /*else if (cell.Def.Name == "initVellocity") * { * Type type = cell.GetType(); * PropertyInfo prop = type.GetProperty("Value"); * prop.SetValue(cell, 100, null); * } * else if (cell.Def.Name == "maxVellocity") * { * Type type = cell.GetType(); * PropertyInfo prop = type.GetProperty("Value"); * prop.SetValue(cell, 100, null); * } * else if (cell.Def.Name == "HitBulletID") * { * Type type = cell.GetType(); * PropertyInfo prop = type.GetProperty("Value"); * prop.SetValue(cell, 121, null); * }*/ else if (cell.Def.Name == "NumShoot") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 12, null); } /*else if (cell.Def.Name == "ShootAngle") * { * Type type = cell.GetType(); * PropertyInfo prop = type.GetProperty("Value"); * prop.SetValue(cell, -10, null); * }*/ else if (cell.Def.Name == "ShootAngleInterval") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 6, null); } else if (cell.Def.Name == "ShootAngleXZ") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 24, null); } else if (cell.Def.Name == "ShootAngleXInterval") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 10, null); } } } } } else if (paramFile.ID == "EQUIP_PARAM_WEAPON_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { if (paramRow.ID == 1250000) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "bowDistRate") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 10, null); } } } //bandit knife else if (paramRow.ID == 100000) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "throwAtkRate") { //backstabbu Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 65, null); } } } } } else if (paramFile.ID == "THROW_INFO_BANK") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { //add only for PC? if (cell.Def.Name == "Dist") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 3, null); } else if (cell.Def.Name == "diffAngMax") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 75, null); } else if (cell.Def.Name == "upperYRange") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 0.75, null); } else if (cell.Def.Name == "lowerYRange") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 0.75, null); } } } } else if (paramFile.ID == "SP_EFFECT_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { if (paramRow.ID == 3130 || paramRow.ID == 3140) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { //add only for PC? if (cell.Def.Name == "effectEndurance") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 1, null); } } } } } } //Resave params as BNDs foreach (var paramBnd in PARAMBNDs) { foreach (var param in paramBnd) { var filteredParamName = param.Name.Substring(param.Name.LastIndexOf("\\") + 1).Replace(".param", ""); var matchingParam = AllParams.Where(x => x.VirtualUri == param.Name).First(); param.ReplaceData(matchingParam, new Progress <(int, int)> ((p) => { })); } DataFile.Resave(paramBnd, new Progress <(int, int)> ((p) => { })); } }
static void Main(string[] args) { List <PARAMDEF> ParamDefs = new List <PARAMDEF>(); List <PARAM> AllParams = new List <PARAM>(); //var gameFolder = @"D:\Program Files (x86)\Steam\steamapps\common\Dark Souls Prepare to Die Edition\DATA\"; var gameFolder = @"C:\Users\mcouture\Desktop\DS-Modding\Dark Souls Prepare to Die Edition\DATA\"; var gameparamBnds = Directory.GetFiles(gameFolder + "param\\GameParam\\", "*.parambnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))); List <BND> PARAMBNDs = gameparamBnds.ToList(); List <BND> allMsgBnds = Directory.GetFiles(gameFolder + "msg\\ENGLISH\\", "*.msgbnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))).ToList(); var paramdefBnds = Directory.GetFiles(gameFolder + "paramdef\\", "*.paramdefbnd") .Select(p => DataFile.LoadFromFile <BND>(p, new Progress <(int, int)> ((pr) => { }))).ToList(); for (int i = 0; i < paramdefBnds.Count(); i++) { foreach (var paramdef in paramdefBnds[i]) { PARAMDEF newParamDef = paramdef.ReadDataAs <PARAMDEF>(new Progress <(int, int)> ((r) => { })); ParamDefs.Add(newParamDef); } } for (int i = 0; i < PARAMBNDs.Count(); i++) { foreach (var param in PARAMBNDs[i]) { PARAM newParam = param.ReadDataAs <PARAM>(new Progress <(int, int)> ((p) => { })); newParam.ApplyPARAMDEFTemplate(ParamDefs.Where(x => x.ID == newParam.ID).First()); AllParams.Add(newParam); } } foreach (PARAM paramFile in AllParams) { if (paramFile.ID == "NPC_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "moveType") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 6, null); } } } } else if (paramFile.VirtualUri.EndsWith("AtkParam_Pc.param")) { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "knockbackDist") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 5, null); } string[] attackAttrs = { "atkPhys", "atkMag", "atkFire", "atkThun", "atkPhysCorrection", "atkMagCorrection", "atkFireCorrection", "atkThunCorrection" }; if (attackAttrs.Contains(cell.Def.Name)) { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, 0, null); } } } } else if (paramFile.ID == "NPC_THINK_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { string[] attrsToMax = { "outDist", "maxBackhomeDist", "backhomeDist", "backhomeBattleDist", "BackHome_LookTargetTime", "BackHome_LookTargetDist", "SightTargetForgetTime", "SoundTargetForgetTime" }; if (attrsToMax.Contains(cell.Def.Name)) { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, cell.Def.Max, null); } else if (cell.Def.Name == "TeamAttackEffectivity") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, cell.Def.Max, null); } } } } else if (paramFile.ID == "BULLET_PARAM_ST") { foreach (MeowDSIO.DataTypes.PARAM.ParamRow paramRow in paramFile.Entries) { foreach (MeowDSIO.DataTypes.PARAM.ParamCellValueRef cell in paramRow.Cells) { if (cell.Def.Name == "isHitBothTeam:1") { Type type = cell.GetType(); PropertyInfo prop = type.GetProperty("Value"); prop.SetValue(cell, true, null); } //else if (cell.Def.Name == "isPenetrate") //{ // Type type = cell.GetType(); // PropertyInfo prop = type.GetProperty("Value"); // prop.SetValue(cell, 1, null); //} } } } } //Resave BNDs foreach (var paramBnd in PARAMBNDs) { foreach (var param in paramBnd) { var filteredParamName = param.Name.Substring(param.Name.LastIndexOf("\\") + 1).Replace(".param", ""); var matchingParam = AllParams.Where(x => x.VirtualUri == param.Name).First(); param.ReplaceData(matchingParam, new Progress <(int, int)> ((p) => { })); } DataFile.Resave(paramBnd, new Progress <(int, int)> ((p) => { })); } }
public PARAMDEFRef(string Key, PARAMDEF Value) { this.Key = Key; this.Value = Value; }
private ParamMetaData(XmlDocument xml, string path, PARAMDEF def) { _xml = xml; _path = path; XmlNode root = xml.SelectSingleNode("PARAMMETA"); int xmlVersion = int.Parse(root.Attributes["XmlVersion"].InnerText); if (xmlVersion != XML_VERSION) { throw new InvalidDataException($"Mismatched XML version; current version: {XML_VERSION}, file version: {xmlVersion}"); } Add(def, this); XmlNode self = root.SelectSingleNode("Self"); if (self != null) { XmlAttribute Off = self.Attributes["OffsetSize"]; if (Off != null) { OffsetSize = int.Parse(Off.InnerText); } XmlAttribute FixOff = self.Attributes["FixedOffset"]; if (FixOff != null) { FixedOffset = int.Parse(FixOff.InnerText); } XmlAttribute R0 = self.Attributes["Row0Dummy"]; if (R0 != null) { Row0Dummy = true; } XmlAttribute AltOrd = self.Attributes["AlternativeOrder"]; if (AltOrd != null) { AlternateOrder = new List <string>(AltOrd.InnerText.Replace("\n", "").Split(',', StringSplitOptions.RemoveEmptyEntries)); for (int i = 0; i < AlternateOrder.Count; i++) { AlternateOrder[i] = AlternateOrder[i].Trim(); } } } foreach (XmlNode node in root.SelectNodes("Enums/Enum")) { ParamEnum en = new ParamEnum(node); enums.Add(en.name, en); } Dictionary <string, int> nameCount = new Dictionary <string, int>(); foreach (PARAMDEF.Field f in def.Fields) { try { string name = FixName(f.InternalName); int c = nameCount.GetValueOrDefault(name, 0); XmlNodeList nodes = root.SelectNodes($"Field/{name}"); //XmlNode pairedNode = root.SelectSingleNode($"Field/{}"); XmlNode pairedNode = nodes[c]; nameCount[name] = c + 1; if (pairedNode == null) { new FieldMetaData(this, f); continue; } new FieldMetaData(this, pairedNode, f); } catch { new FieldMetaData(this, f); } } }
public ExcelParamSheet(PARAM Param, PARAMDEF ParamDef) : base() { this.Param = Param; this.ParamDef = ParamDef; }
public static void Run( Game game, ParamFormat inputFormat, FileInfo inputPath, ParamFormat outputFormat, FileInfo outputPath, FileInfo paramdexPath, Regex typeFilter) { using var reader = inputFormat.CreateReader(game, inputPath); using var writer = outputFormat.CreateWriter(game, outputPath); foreach (var paramRef in reader.List()) { var paramName = paramRef.Name; var paramType = paramRef.Type; if (!typeFilter.IsMatch(paramName) && !typeFilter.IsMatch(paramType)) { continue; } Console.WriteLine($"Reading {paramName} with type {paramType}"); var paramDefPath = $"{paramdexPath.FullName}/{game}/Defs/{paramType}.xml"; if (!File.Exists(paramDefPath)) { Console.WriteLine($"No paramdef for {paramName}, {paramType}. Skipping."); continue; } var paramDef = PARAMDEF.XmlDeserialize(paramDefPath); var param = reader.Read(paramName, paramDef); /* the same names.txt parsing code from yapped */ var paramRowNames = new Dictionary <long, string>(); var paramNamesPath = $@"{paramdexPath.FullName}/{game}/Names/{paramName}.txt"; if (File.Exists(paramNamesPath)) { var paramNamesText = File.ReadAllText(paramNamesPath); foreach (var line in Regex.Split(paramNamesText, @"\s*[\r\n]+\s*")) { if (line.Length <= 0) { continue; } var match = Regex.Match(line, @"^(\d+) (.+)$"); var id = long.Parse(match.Groups[1].Value); var name = match.Groups[2].Value; paramRowNames[id] = name; } } foreach (var row in param.Rows.Where(row => paramRowNames.ContainsKey(row.ID))) { row.Name = paramRowNames[row.ID]; } writer.Write(paramName, param); } }
private static void LoadParamsDS2() { var dir = AssetLocator.GameRootDirectory; var mod = AssetLocator.GameModDirectory; if (!File.Exists($@"{dir}\enc_regulation.bnd.dcx")) { MessageBox.Show("Could not find DS2 regulation file. Functionality will be limited.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!BND4.Is($@"{dir}\enc_regulation.bnd.dcx")) { MessageBox.Show("Use yapped to decrypt your DS2 regulation file. Functionality will be limited.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Keep track of loaded params as we load loose and regulation params HashSet <string> loadedParams = new HashSet <string>(); // Load params List <string> scandir = new List <string>(); if (mod != null && Directory.Exists($@"{mod}\Param")) { scandir.Add($@"{mod}\Param"); } scandir.Add($@"{dir}\Param"); foreach (var d in scandir) { var paramfiles = Directory.GetFileSystemEntries(d, @"*.param"); foreach (var p in paramfiles) { bool blacklisted = false; var name = Path.GetFileNameWithoutExtension(p); foreach (var bl in _ds2ParamBlacklist) { if (name.StartsWith(bl)) { blacklisted = true; } } if (blacklisted) { continue; } var lp = PARAM.Read(p); var fname = lp.ParamType; PARAMDEF def = AssetLocator.GetParamdefForParam(fname); lp.ApplyParamdef(def); if (!_params.ContainsKey(name)) { _params.Add(name, lp); } } } // Load params var param = $@"{mod}\enc_regulation.bnd.dcx"; if (!File.Exists(param)) { param = $@"{dir}\enc_regulation.bnd.dcx"; } BND4 paramBnd = BND4.Read(param); EnemyParam = GetParam(paramBnd, "EnemyParam.param"); if (EnemyParam != null) { PARAMDEF def = AssetLocator.GetParamdefForParam(EnemyParam.ParamType); EnemyParam.ApplyParamdef(def); } LoadParamFromBinder(paramBnd); }
static void translateParams(string a, string b) { string paramDir = a.EndsWith("\\") ? a.Substring(a.Length - 1, 1) : a; string paramDefDir = b.EndsWith("\\") ? b.Substring(b.Length - 1, 1) : b; string[] paramFileList = Directory.GetFiles(paramDir); string[] paramDefFileList = Directory.GetFiles(paramDefDir); List <string> paramFileNameList = new List <string>(); List <PARAMDEF> paramDefs = new List <PARAMDEF>(); List <PARAM> paramaroos = new List <PARAM>(); Console.WriteLine("### " + paramDir); Console.WriteLine("### " + paramDefDir + "\n"); for (int i = 0; i < paramFileList.Length; i++) { string fn = paramFileList[i].Substring(paramDir.Length + 1, paramFileList[i].Length - (paramDir.Length + 1)); paramFileNameList.Add(fn); paramaroos.Add(PARAM.Read(File.ReadAllBytes(paramFileList[i]))); } for (int i = 0; i < paramDefFileList.Length; i++) { paramDefs.Add(PARAMDEF.Read(File.ReadAllBytes(paramDefFileList[i]))); } for (int i = 0; i < paramaroos.Count; i++) { PARAM p = paramaroos[i]; for (int j = 0; j < paramDefs.Count; j++) { PARAMDEF pd = paramDefs[j]; if (p.ParamType.Equals(pd.ParamType)) { p.ApplyParamdef(pd); } } } TranslationClient client = TranslationClient.Create(GoogleCredential.FromFile("C:\\Users\\dmtin\\google-translate-api-key.txt")); for (int i = 0; i < paramaroos.Count; i++) { Console.WriteLine("\n\n\n\n==================" + paramaroos[i].ParamType + "=================="); for (int j = 0; j < paramaroos[i].Rows.Count; j++) { PARAM.Row row = paramaroos[i].Rows[j]; try { if (row.Name != null && !row.Name.Trim().Equals("") && !row.Name.Trim().Equals("0")) { TranslationResult response = client.TranslateText(row.Name, LanguageCodes.English, LanguageCodes.Japanese); // Translate request if (response != null && response.TranslatedText != null && response.TranslatedText.Trim().Length > 0) { row.Name = response.TranslatedText; } } } catch (Exception ex) { Console.WriteLine("EXCEPTION :: " + ex.Message); } Console.WriteLine(row.ID + ":: " + row.Name); } } Directory.CreateDirectory(paramDir + "\\translated\\"); for (int i = 0; i < paramaroos.Count; i++) { string outPath = paramDir + "\\translated\\" + paramFileNameList[i]; byte[] outData = paramaroos[i].Write(); File.WriteAllBytes(outPath, outData); } Console.WriteLine("\n\n Done!"); }
private static void Add(PARAMDEF key, ParamMetaData meta) { _ParamMetas.Add(key, meta); }
public SoulsMod(string gameDir, string backupExt = ".smbak", byte[] paramBNDData = null, byte[] paramdefBNDData = null, byte[] itemMSGBNDData = null, byte[] menuMSGBNDData = null) { if (!gameDir.EndsWith(@"\")) { gameDir += @"\"; } GameDir = gameDir; BackupExt = backupExt; // RestoreBackups(); // No need to restore backups automatically, as all files are loaded directly FROM the backups anyway. // Text is loaded first so it can be passed to `GameParamHandler`. #if DEBUG Console.Write("Loading Text... "); #endif if (itemMSGBNDData == null) { itemMSGBNDData = File.ReadAllBytes(GameDir + @"msg/ENGLISH/item.msgbnd.dcx"); } if (menuMSGBNDData == null) { menuMSGBNDData = File.ReadAllBytes(GameDir + @"msg/ENGLISH/menu.msgbnd.dcx"); } Text = new TextHandler(itemMSGBNDData, menuMSGBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading Text (vanilla copy)... "); #endif VanillaText = new TextHandler(itemMSGBNDData, menuMSGBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading ParamDefs... "); #endif if (paramdefBNDData == null) { paramdefBNDData = File.ReadAllBytes(GameDir + @"paramdef\paramdef.paramdefbnd.dcx"); } BND3 paramdefBnd = BND3.Read(paramdefBNDData); foreach (BinderFile file in paramdefBnd.Files) { PARAMDEF paramdef = PARAMDEF.Read(file.Bytes); ParamDefs[paramdef.ParamType] = paramdef; } #if DEBUG Console.Write("Done.\n"); Console.Write("Loading GameParams... "); #endif if (paramBNDData == null) { paramBNDData = File.ReadAllBytes(GameDir + @"param\GameParam\GameParam.parambnd.dcx"); } GPARAM = new GameParamHandler(ParamDefs, Text, paramBNDData); #if DEBUG Console.Write("Done.\n"); Console.Write("Loading GameParams (vanilla copy)... "); #endif if (paramBNDData != null) { VanillaGPARAM = new GameParamHandler(ParamDefs, VanillaText, paramBNDData); } else { VanillaGPARAM = new GameParamHandler(ParamDefs, VanillaText, GameDir + @"param\GameParam\GameParam.parambnd.dcx"); } #if DEBUG Console.Write("Done.\n"); #endif }
public PARAM Read(string name, PARAMDEF def) { throw new System.NotImplementedException(); }