static void Main(string[] args) { TES5.ESM esm = new TES5.ESM("final.esp"); esm.add_masters("Skyrim.esm"); TES5.Group[] ltex = Convert.LTEX.convert(Config.Paths.mw_esm); //TES5.Group door = Convert.DOOR.convert(ConfigNew.Paths.mw_esm); TES5.Group furn = Convert.FURN.convert(); TES5.Group acti = Convert.ACTI.getInstance().convert(Config.Paths.mw_esm); //TES5.Group npc_ = Convert.NPC_.convert(ConfigNew.Paths.mw_esm); TES5.Group stat = Convert.STAT.convert(Config.Paths.mw_esm); TES5.Group lgtm = Convert.LGTM.convert(); acti.addRecord(TES5.ACTI.get_water_instance()); TES5.Group light = Convert.LIGH.convert(Config.Paths.mw_esm); TES5.Group cell = Convert.CELL.convert(Config.Paths.mw_esm); //List<TES5.Group> wrld = Convert.LAND.convert(ConfigNew.Paths.mw_esm); List <TES5.Group> cell_grp = new List <TES5.Group>(); cell_grp.Add(cell); Convert.REFERENCE.REFR.add_references(Config.Paths.mw_esm, cell_grp, null); esm.add_group(ltex[0]); esm.add_group(ltex[1]); esm.add_group(stat); //esm.add_group(npc_); esm.add_group(furn); esm.add_group(lgtm); esm.add_group(acti); esm.add_group(light); //esm.add_group(door); esm.add_group(cell); //esm.add_group(wrld); esm.write_to_file(Config.Paths.skyrim_path + "final.esp"); Log.exit("DONE"); }
public static void presets() { string[] races = { "Breton", "Dark Elf", "High Elf", "Imperial", "Redguard", "Wood Elf", "Nord", "Khajiit", "Argonian", "Orc" }; string[] sexes = { "Female", "Male" }; Dictionary <string, Dictionary <string, Queue <string> > > dict = new Dictionary <string, Dictionary <string, Queue <string> > >(); foreach (string r in races) { Dictionary <string, Queue <string> > d = new Dictionary <string, Queue <string> >(); dict.Add(r.Replace(" ", ""), d); foreach (string s in sexes) { d.Add(s, new Queue <string>()); } } TextReader fin = File.OpenText("tmp\\faces.csv"); while (fin.Peek() != -1) { string line = fin.ReadLine(); string[] parsed = line.Split(','); string race = parsed[0]; string sex = parsed[1]; string model = parsed[2].ToLower(); dict[race.Replace(" ", "")][sex].Enqueue(model); } BinaryReader bw = new BinaryReader(new FileStream("tmp\\Skyrim.esm", FileMode.Open)); TES5.Record head = new TES5.Record("TES4"); head.read(bw); TES5.Group g = new TES5.Group(); g.read(bw); while (!g.hasLabel("NPC_")) { Log.info("Reading: "); g.read(bw); } TES5.ESM esm = new TES5.ESM("faces.esp"); esm.add_masters("Skyrim.esm"); TES5.Group g_out = new TES5.Group("NPC_"); foreach (TES5.Record r in g.records) { if (!r.isType("NPC_")) { continue; } TES5.Field f = r.find_field_OR_FAIL("ACBS", "ACBS not found"); UInt32 flagers = f.getData().ReadUInt32(); if (BinaryFlag.isSet(flagers, 0x04)) { string edid = r.find_field_OR_FAIL("EDID", "").readString(); string sex = ""; if (edid.Contains("Female")) { sex = "Female"; } else if (edid.Contains("Male")) { sex = "Male"; } else { Log.error("Can't be"); } string race = edid.Split(new string[] { sex }, StringSplitOptions.None).First(); if (dict[race][sex].Count == 0) { continue; } string model = dict[race][sex].Dequeue(); Log.info(race); Log.info(sex); Log.info(r.find_field_OR_FAIL("EDID", "").readString()); TES5.Field full = r.try_find_field("FULL"); if (full == null) { full = new TES5.Field("FULL", Text.zstring(model)); r.fields.Insert(11, full); } else { full.replaceData(Text.zstring(model)); } r.find_field_OR_FAIL("EDID", "").replaceData(Text.zstring(model)); TES5.Record new_rec = new TES5.Record("NPC_"); new_rec.clone(r, model); new_rec.find_field_OR_FAIL("EDID", "").replaceData(Text.zstring(model)); g_out.addRecord(new_rec); } } esm.add_group(g_out); esm.write_to_file(Config.Paths.Templates.characters); }