public static void read_templates() { if (doOnce) { return; } doOnce = true; TES5.ESM esm = TES5.ESM.read_from_file(Config.Paths.Templates.characters); foreach (TES5.Record r in esm.find_TOP_group_OR_FAIL("NPC_").records) { TES5.Field FULL = r.try_find_field("FULL"); TES5.Field EDID = r.find_field_OR_FAIL("EDID", "NPC encountered with no editor id, FORMID=" + Text.toHex(r.id)); if (FULL == null) { Log.confirm(EDID.readString() + " : FaceGen Template NPC does not have a NAME. Un-named NPCs are ignored and not used as facegen templates."); continue; } string name_full = FULL.readString().ToLower(); body_templates.Add(name_full, r); } }
public static TES5.Group convert() { if (furn != null) { return(furn); } furn = new TES5.Group("FURN"); TES5.ESM esm = TES5.ESM.read_from_file(Config.Paths.Templates.furniture); TES5.Group furn_g = esm.find_TOP_group_OR_FAIL("FURN"); chair = furn_g.find_record("mw_chair_marker"); bed = furn_g.find_record("mw_bed_marker"); bench = furn_g.find_record("mw_bench_marker"); bed_double = furn_g.find_record("mw_doublebed_marker"); if (chair == null || bed == null || bench == null || bed_double == null) { Log.error("FURN some Furniture marker were not assigned. Possibly bad furn.esp template"); } chair.reset_formid("mw_chair_marker"); bed.reset_formid("mw_bed_marker"); bench.reset_formid("mw_bench_marker"); bed_double.reset_formid("mw_doublebed_marker"); furn.addRecord(chair); furn.addRecord(bed); furn.addRecord(bench); furn.addRecord(bed_double); return(furn); }
public void make(TES5.ESM esm) { Log.info_colored("Indexing ESM file. This can take a while. Please Wait", ConsoleColor.Green); foreach (Group g in esm.getGroups()) { parse(g); } Log.info_colored("Parsing successful. Index has been made.", ConsoleColor.Green); available_formid = dict_formid.Keys.ToArray().Max() + 1; if (dict_formid.ContainsKey(available_formid)) { Log.error("ESM_Index, formids are not continous"); } }
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"); }
private static void read_templates() { has_read = true; TES5.ESM esm = TES5.ESM.read_from_file(Config.Paths.light_templates); TES5.Group LGTM_GRUP = esm.find_TOP_group_OR_FAIL("LGTM", "No LGTM Group in Template File"); default_ = LGTM_GRUP.find_record("mw_ltmp_default"); daedric = LGTM_GRUP.find_record("mw_ltmp_daedric"); fort = LGTM_GRUP.find_record("mw_ltmp_fort"); dwemer = LGTM_GRUP.find_record("mw_ltmp_dwemer"); tomb = velothi = LGTM_GRUP.find_record("mw_ltmp_tomb"); hlaalu = LGTM_GRUP.find_record("mw_ltmp_hlaalu"); redoran = LGTM_GRUP.find_record("mw_ltmp_redoran"); telvanni = LGTM_GRUP.find_record("mw_ltmp_telvanni"); cave = mine = LGTM_GRUP.find_record("mw_ltmp_mine"); imperial = LGTM_GRUP.find_record("mw_ltmp_imperial"); if (default_ == null || hlaalu == null || fort == null || imperial == null || redoran == null || telvanni == null || dwemer == null || daedric == null || cave == null || tomb == null) { Log.error("TES5:LTMP Not all Lighting templates were assigned"); } default_.reset_formid("mw_ltmp_default"); daedric.reset_formid("mw_ltmp_daedric"); fort.reset_formid("mw_ltmp_fort"); dwemer.reset_formid("mw_ltmp_dwemer"); tomb.reset_formid("mw_ltmp_tomb"); hlaalu.reset_formid("mw_ltmp_hlaalu"); redoran.reset_formid("mw_ltmp_redoran"); telvanni.reset_formid("mw_ltmp_telvanni"); cave.reset_formid("mw_ltmp_mine"); imperial.reset_formid("mw_ltmp_imperial"); }
public static void make_marker_config() { TES5.ESM esm = new TES5.ESM(Config.Paths.Temporary.furn_placement_esp); esm.add_masters("Skyrim.esm"); TextWriter file_01 = File.CreateText(Config.Paths.Temporary.furn_linker); file_01.WriteLine("# !AUTO-GENERATED! Do NOT modify this file by hand. Contains linking data for FURN markers."); TES5.Group furn = Convert.FURN.convert(); make_formID_index(furn); TES5.Group stats = Convert.STAT.convert(Config.Paths.mw_esm, true); TES5.Group acti = Convert.ACTI.getInstance().convert(Config.Paths.mw_esm, true); TES5.Group lgtm = Convert.LGTM.convert(); TES5.CELL cell = new TES5.CELL("mw_furnitureworkshop"); file_01.WriteLine("cell=" + cell.id); cell.full_name = "Furniture Workshop"; cell.add_ambient_light(Convert.LGTM.get(Convert.CellTYPE.TYPE.DEFAULT)); cell.pack(); TES5.Group cell_grp = new TES5.Group("CELL"); cell.addToGroup(cell_grp); List <TES5.Record> grps = new List <TES5.Record>(stats.records); foreach (TES5.Record r in acti.records) { grps.Add(r); } # region
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); }