コード例 #1
0
ファイル: Generic.cs プロジェクト: Hashmi1/IndorilConverter
        protected TES5.Group convert(string file)
        {
            List <OBJ_STRUCT> lst = get_lst(file);

            TES5.Group grup = new TES5.Group(TYPE);

            foreach (OBJ_STRUCT obj in lst)
            {
                TES5.Record r = new TES5.Record(TYPE, obj.editor_id);

                if (obj.editor_id != null)
                {
                    r.addField(new TES5.Field("EDID", Text.editor_id(obj.editor_id)));
                }
                if (obj.game_name != null)
                {
                    r.addField(new TES5.Field("FULL", Text.zstring(obj.game_name)));
                }
                if (obj.model_path != null)
                {
                    r.addField(new TES5.Field("MODL", Text.model_path(obj.model_path)));
                }

                grup.addRecord(r);
            }

            return(grup);
        }
コード例 #2
0
ファイル: FURN.cs プロジェクト: Hashmi1/IndorilConverter
        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);
        }
コード例 #3
0
        public TES5.Group convert(string file, bool ignoreFurniture = false)
        {
            List <OBJ_STRUCT> lst = get_lst(file);

            TES5.Group grup = new TES5.Group(TYPE);

            foreach (OBJ_STRUCT obj in lst)
            {
                TES5.Record r = new TES5.Record(TYPE, obj.editor_id);

                bool isFurn = false;
                if (!ignoreFurniture)
                {
                    isFurn = FURN.consider(obj.model_path, r);
                }

                r.addField(new TES5.Field("EDID", Text.editor_id(obj.editor_id)));
                if (obj.game_name != null && !isFurn)
                {
                    r.addField(new TES5.Field("FULL", Text.zstring(obj.game_name)));
                }
                if (obj.model_path != null)
                {
                    r.addField(new TES5.Field("MODL", Text.model_path(obj.model_path)));
                }

                grup.addRecord(r);
                ModelConverter.convert(obj.model_path, "stat", true);
            }

            return(grup);
        }
コード例 #4
0
ファイル: DOOR.cs プロジェクト: Hashmi1/IndorilConverter
        static TES5.Group make_tes5_doors(List <door_> lst)
        {
            TES5.Group grup = new TES5.Group("DOOR");

            TES5.Record marker = new TES5.Record("DOOR");
            marker.addField(new TES5.Field("EDID", Text.editor_id("teleport_marker")));

            marker_id = marker.id;
            grup.addRecord(marker);

            foreach (door_ d in lst)
            {
                // Make Normal version
                TES5.Record r = new TES5.Record("DOOR", d.id);
                r.addField(new TES5.Field("EDID", Text.editor_id(d.id)));
                r.addField(new TES5.Field("FULL", Text.zstring(d.full_name)));
                r.addField(new TES5.Field("MODL", Text.model_path(d.model_path)));

                // Make Portal version
                TES5.Record r_load = new TES5.Record("DOOR", d.id + "_zload");
                r_load.addField(new TES5.Field("EDID", Text.editor_id(d.id + "_zload")));
                r_load.addField(new TES5.Field("FULL", Text.zstring(d.full_name)));
                r_load.addField(new TES5.Field("MODL", Text.model_path(d.model_path.ToLower().Replace(".nif", "_zload.nif"))));

                grup.addRecord(r);
                grup.addRecord(r_load);

                ModelConverter.convert(d.model_path, "door_load", true);
                ModelConverter.convert(d.model_path, "door_anim", true);
            }

            return(grup);
        }
コード例 #5
0
        public static TES5.Group[] convert(string file)
        {
            List <mw_ltex> mw_textures = get_mw_land_textures(file);

            TES5.Group grup_txst = new TES5.Group("TXST");
            TES5.Group grup_ltex = new TES5.Group("LTEX");

            foreach (mw_ltex t in mw_textures)
            {
                TES5.Record txst = make_txst(t.editor_id, t.texture_path);
                TES5.Record ltex = make_ltex(txst.id, t.editor_id);

                LAND.add_texture(t.index, t.editor_id, t.texture_path, ltex.id);

                grup_txst.addRecord(txst);
                grup_ltex.addRecord(ltex);
            }

            TES5.Group[] grps = new TES5.Group[2];
            grps[0] = grup_txst;
            grps[1] = grup_ltex;

            done = true;

            return(grps);
        }
コード例 #6
0
        public static TES5.Group convert(string file)
        {
            read_templates();
            TES3.ESM.open(file);

            TES5.Group npc_grup = new TES5.Group("NPC_");

            while (TES3.ESM.find("NPC_"))
            {
                TES3.NPC_ npc3 = new TES3.NPC_();
                npc3.read();

                string npc3_head_model = npc3.head.ToLower();

                TES5.NPC.NPC_ npc5 = new TES5.NPC.NPC_();

                if (!body_templates.ContainsKey(npc3_head_model))
                {
                    Log.confirm("No Face-Gen data for " + npc3_head_model + " defined in template: " + Config.Paths.Templates.characters);
                    continue;
                }

                npc5.clone(body_templates[npc3_head_model], npc3.editor_id);

                npc5.editor_id = npc3.editor_id; // redundant?
                npc5.game_name = npc3.game_name;

                npc_grup.addRecord(npc5);
            }

            TES3.ESM.close();

            return(npc_grup);
        }
コード例 #7
0
 private void put(string cell_id, TES5.Group group)
 {
     if (!cell_id.StartsWith(Config.Prefixes.converted_editor_ids))
     {
         Log.error("Given Editor ID is not in skyrim format. Potential Logical Bug");
     }
     cell_id = Text.trim(cell_id);
     dict.Add(cell_id, group);
 }
コード例 #8
0
        private void search_group(TES5.Group grup)
        {
            if (grup.isType(TES5.Group.TYPE.TEMP_REFR))
            {
                UInt32 cell_form_id = Binary.toUInt32(grup.label);

                if (!formid_index.ContainsKey(cell_form_id))
                {
                    Log.error("Cell with formid: " + cell_form_id + " was not encountered");
                }

                Tuple <int, int> cell_grid_info = formid_index[cell_form_id];

                int x = cell_grid_info.Item1;
                int y = cell_grid_info.Item2;

                put(x, y, grup);

                return;
            }

            Queue <TES5.Group>  grps = new Queue <TES5.Group>(grup.subGroups);
            Queue <TES5.Record> recs = new Queue <TES5.Record>(grup.records);

            foreach (int t in grup.turn)
            {
                if (t == 1)
                {
                    TES5.Record r = recs.Dequeue();

                    #region if (r.isType("CELL"))

                    if (r.isType("CELL"))
                    {
                        TES5.Field xclc = r.try_find_field("XCLC");

                        if (xclc != null)
                        {
                            BinaryReader reader = xclc.getData();
                            int          x      = reader.ReadInt32();
                            int          y      = reader.ReadInt32();

                            formid_index.Add(r.id, new Tuple <int, int>(x, y));
                        }
                    }
                    #endregion
                }

                if (t == 2)
                {
                    TES5.Group g = grps.Dequeue();
                    search_group(g);
                }
            }
        }
コード例 #9
0
ファイル: FACT.cs プロジェクト: Hashmi1/IndorilConverter
        public static TES5.Group convert(string file)
        {
            TES5.Group fact = new TES5.Group("FACT");

            TES3.ESM.open(file);

            while (TES3.ESM.find("FACT"))
            {
                TES3.Record f3 = new TES3.Record();
                f3.read();

                string editor_id = f3.find_first("NAME").readString();
                string full_name = f3.find_first("NAME") != null?f3.find_first("NAME").readString() : null;

                TES5.Record f5 = new TES5.Record("FACT", editor_id);

                if (full_name != null)
                {
                    f5.addField(new TES5.Field("FULL", Text.zstring(full_name)));
                }

                List <TES3.SubRecord> ANAMs = f3.find_all("ANAM", true);
                List <TES3.SubRecord> INTVs = f3.find_all("INTV", true);

                foreach (TES3.SubRecord intv in INTVs)
                {
                    int reaction = intv.getData().ReadInt32();
                    if (reaction <= -3) // make hostile
                    {
                        reaction = 1;
                    }
                    else if (reaction > -3 && reaction <= 1)
                    {
                        reaction = 0;
                    }
                    else if (reaction >= 2)
                    {
                        reaction = 2;
                    }
                }

                uint flags = 0;
                flags = BinaryFlag.set(flags, 0x8000);
                f5.addField(new TES5.Field("DATA", Binary.toBin(flags)));
                fact.addRecord(f5);
            }


            TES3.ESM.close();

            return(fact);
        }
コード例 #10
0
ファイル: CELL.cs プロジェクト: Hashmi1/IndorilConverter
        public static TES5.Group convert(string file)
        {
            TES3.ESM.open(file);
            TES5.Group cell_grup = new TES5.Group("CELL");

            while (TES3.ESM.find("CELL"))
            {
                TES3.CELL cell3 = new TES3.CELL();
                cell3.read();

                if (!cell3.interior)
                {
                    continue;
                }

                if (cell3.references.Count == 0)
                {
                    continue;
                }


                Log.info(cell3.cell_name);

                TES5.CELL cell5 = new TES5.CELL(cell3.cell_name);

                cell5.editor_id = cell3.cell_name;
                cell5.full_name = cell3.cell_name;

                cell5.Interior = true;
                if (cell3.HasWater)
                {
                    // Calculate cell bounds
                    foreach (TES3.REFR mw_ref in cell3.references)
                    {
                        cell5.update_bounds(mw_ref.x, mw_ref.y);
                    }
                    // add water planes
                    cell5.addWater(cell3.water_height);
                }

                cell5.add_ambient_light(LGTM.get(CellTYPE.getInstance().get_class(cell3.cell_name)));

                cell5.addToGroup(cell_grup);
                cell5.pack();
            }

            TES3.ESM.close();
            return(cell_grup);
        }
コード例 #11
0
        public static void doit()
        {
            TES3.ESM.open(Config.Paths.mw_esm);
            TES5.Group cell_grup = new TES5.Group("CELL");

            while (TES3.ESM.find("CELL"))
            {
                TES3.CELL morrowind_cell = new TES3.CELL();
                morrowind_cell.read();

                //Utility.Log.info(morrowind_cell.cell_name);
                foreach (TES3.REFR morrowind_reference in morrowind_cell.references)
                {
                }
            }
        }
コード例 #12
0
        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");
        }
コード例 #13
0
ファイル: Generic.cs プロジェクト: Hashmi1/IndorilConverter
        protected List <OBJ_STRUCT> get_lst(string file)
        {
            List <OBJ_STRUCT> lst = new List <OBJ_STRUCT>();

            TES3.ESM.open(file);
            TES5.Group grup = new TES5.Group(TYPE);

            while (TES3.ESM.find(TYPE))
            {
                TES3.Record r3 = new TES3.Record();
                r3.read();

                OBJ_STRUCT obj = new OBJ_STRUCT();

                foreach (TES3.SubRecord srec in r3.subRecords)
                {
                    if (srec.isType("NAME"))
                    {
                        obj.editor_id = Text.trim(new string(srec.getData().ReadChars(srec.size)));
                    }

                    if (srec.isType("FNAM"))
                    {
                        if (srec.size <= 1)
                        {
                            continue; // skip empties
                        }

                        obj.game_name = Text.trim(new string(srec.getData().ReadChars(srec.size)));
                    }

                    if (srec.isType("MODL"))
                    {
                        obj.model_path = Text.trim(new string(srec.getData().ReadChars(srec.size))).ToLower();
                    }
                }

                lst.Add(obj);
            }

            TES3.ESM.close();

            list = lst;
            return(lst);
        }
コード例 #14
0
        public static void make_formID_index(TES5.Group furn)
        {
            chair      = furn.find_record("mw_chair_marker");
            bed        = furn.find_record("mw_bed_marker");
            bench      = furn.find_record("mw_bench_marker");
            bed_double = furn.find_record("mw_doublebed_marker");

            TextWriter f2 = File.CreateText(Config.Paths.Temporary.furn_formid_index);

            f2.WriteLine("# !AUTO-GENERATED! Do NOT edit this file. It contains formid index for FURN markers.");

            f2.WriteLine("mw_chair_marker=" + chair.id);
            f2.WriteLine("mw_bench_marker=" + bench.id);
            f2.WriteLine("mw_bed_marker=" + bed.id);
            f2.WriteLine("mw_doublebed_marker=" + bed_double.id);

            f2.Close();
        }
コード例 #15
0
ファイル: REFR.cs プロジェクト: Hashmi1/IndorilConverter
        private static void add_exterior_references(TES5.REFR refr)
        {
            int cell_x = (int)(refr.loc.x / 4096f);
            int cell_y = (int)(refr.loc.y / 4096f);

            if (refr.loc.x < 0f)
            {
                cell_x--;
            }

            if (refr.loc.y < 0f)
            {
                cell_y--;
            }


            TES5.Group reference_group = ext_index.get_reference_group(cell_x, cell_y);

            reference_group.addRecord(refr);
        }
コード例 #16
0
        public static TES5.Group convert()
        {
            if (!has_read)
            {
                read_templates();
            }

            TES5.Group g = new TES5.Group("LGTM");

            g.addRecord(tomb);
            g.addRecord(cave);
            g.addRecord(dwemer);
            g.addRecord(daedric);
            g.addRecord(redoran);
            g.addRecord(telvanni);
            g.addRecord(imperial);
            g.addRecord(hlaalu);
            g.addRecord(fort);
            g.addRecord(default_);

            return(g);
        }
コード例 #17
0
        static void search_group(TES5.Group group)
        {
            Queue <TES5.Record> q_rec  = new Queue <TES5.Record>(group.records);
            Queue <TES5.Group>  q_sgrp = new Queue <TES5.Group>(group.subGroups);

            foreach (int t in group.turn)
            {
                if (t == 2)
                {
                    search_group(q_sgrp.Dequeue());
                }

                if (t == 1)
                {
                    TES5.Record r = q_rec.Dequeue();
                    if (r.isType("CELL"))
                    {
                        foreach (TES5.Field fld in r.fields)
                        {
                            if (fld.isType("XCLC"))
                            {
                                BinaryReader br = fld.getData();
                                x = br.ReadInt32();
                                y = br.ReadInt32();
                                Log.info(x + "," + y);
                            }
                        }
                    }

                    if (r.isType("LAND"))
                    {
                        search_record(r);
                        x = 0;
                        y = 0;
                    }
                }
            }
        }
コード例 #18
0
        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");
        }
コード例 #19
0
        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
コード例 #20
0
 private void put(int x, int y, TES5.Group group)
 {
     dict.Add(new Tuple <int, int>(x, y), group);
 }
コード例 #21
0
        private void search_group(TES5.Group grup)
        {
            if (grup.isType(TES5.Group.TYPE.TEMP_REFR))
            {
                UInt32 cell_form_id = Binary.toUInt32(grup.label);

                if (!formid_index.ContainsKey(cell_form_id))
                {
                    Log.error("Cell with formid: " + cell_form_id + " was not encountered");
                }

                string cell_id = formid_index[cell_form_id];

                put(cell_id, grup);

                return;
            }

            Queue <TES5.Group>  grps = new Queue <TES5.Group>(grup.subGroups);
            Queue <TES5.Record> recs = new Queue <TES5.Record>(grup.records);

            foreach (int t in grup.turn)
            {
                if (t == 1)
                {
                    TES5.Record r = recs.Dequeue();

                    #region if (r.isType("CELL"))

                    if (r.isType("CELL"))
                    {
                        TES5.Field DATA = r.try_find_field("DATA");

                        if (DATA == null)
                        {
                            continue;
                        }

                        if (DATA.data_size() < 2)
                        {
                            continue;
                        }

                        UInt16 flags = DATA.getData().ReadUInt16();

                        if (!BinaryFlag.isSet((UInt16)flags, (UInt16)0x0001))
                        {
                            continue;
                        }

                        TES5.Field EDID = r.try_find_field("EDID");

                        if (EDID != null)
                        {
                            BinaryReader reader  = EDID.getData();
                            string       cell_id = Text.trim(new string (reader.ReadChars(EDID.data_size())));
                            formid_index.Add(r.id, cell_id);
                        }
                    }
                    #endregion
                }

                if (t == 2)
                {
                    TES5.Group g = grps.Dequeue();
                    search_group(g);
                }
            }
        }
コード例 #22
0
        public static TES5.Group convert(string file)
        {
            TES5.Group LIGH_GRP = new TES5.Group("LIGH");
            TES3.ESM.open(file);

            while (TES3.ESM.find("LIGH"))
            {
                TES3.LIGH l3 = new TES3.LIGH();
                l3.read();

                TES5.LIGH l        = new TES5.LIGH(l3.editor_id);
                TES5.LIGH l_shadow = new TES5.LIGH(l3.editor_id + "_shadow");

                TES5.LIGH[] ls = new TES5.LIGH[2] {
                    l, l_shadow
                };

                for (int i = 0; i < 2; i++)
                {
                    TES5.LIGH l5 = ls[i];

                    l5.model = l3.model;

                    l5.Radius = l3.radius; // TODO: Better Replacement?

                    l5.Time   = (int)l3.time;
                    l5.Value  = l3.value;
                    l5.r      = l3.red;
                    l5.g      = l3.green;
                    l5.b      = l3.blue;
                    l5.Weight = l3.weight;

                    // l5.Dynamic = l3.Dynamic; // Not in CK?
                    l5.carried = l3.Can_Carry;

                    l5.Flicker = l3.Flicker;
                    //l5.FlickerSlow = l3.Flicker_Slow; // FlickerSlow not in CK
                    l5.Pulse = l3.Pulse;

                    if (l3.model == null)
                    {
                        // if no model then make it shadow-less
                    }
                    else
                    {
                        //l5.Omnidirectional = true; // if model present make it shadow casting omni-directinal

                        if (i == 1)
                        {
                            l5.Omnidirectional = true;
                        }

                        ModelConverter.convert(l3.model, "stat", true); // and convert model
                    }

                    l5.pack();
                    LIGH_GRP.addRecord(l5);
                    TypeIndex.getInstance().put(l5.editor_id, TypeIndex.TYPE.LIGH); // Mark self as LIGH
                }
            }

            TES3.ESM.close();
            return(LIGH_GRP);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
ファイル: REFR.cs プロジェクト: Hashmi1/IndorilConverter
 private static void add_interior_references(TES5.REFR refr, string cell_id)
 {
     TES5.Group reference_group = int_index.get_reference_group(cell_id);
     reference_group.addRecord(refr);
 }
コード例 #25
0
        public static TES5.Group convert(string file_path, bool ignoreFurniture = false)
        {
            TES3.ESM.open(file_path);

            List <STRUCT_STAT> list_stat = new List <STRUCT_STAT>();

            while (TES3.ESM.find("STAT"))
            {
                TES3.Record stat = new TES3.Record();
                stat.read();

                STRUCT_STAT stat_ = new STRUCT_STAT();

                foreach (TES3.SubRecord srec in stat.subRecords)
                {
                    if (srec.isType("MODL"))
                    {
                        stat_.model_path = Text.trim(new string(srec.getData().ReadChars(srec.size)));
                        //stat_.model_path = stat_.model_path.Split('\\')[stat_.model_path.Split('\\').Length - 1];
                        //stat_.model_path = "morrowind\\" + stat_.model_path;
                        Log.info(stat_.model_path);
                    }

                    if (srec.isType("NAME"))
                    {
                        stat_.editor_id = Text.trim(new string(srec.getData().ReadChars(srec.size)));
                    }
                }



                list_stat.Add(stat_);
            }

            TES3.ESM.close();

            // Make TES5


            TES5.Group stat_grup = new TES5.Group("STAT");

            foreach (STRUCT_STAT stat in list_stat)
            {
                TES5.Record stat_tes5 = new TES5.Record("STAT", stat.editor_id, 0);
                stat_tes5.addField(new TES5.Field("EDID", Text.editor_id(stat.editor_id)));
                //stat_tes5.addField(new TES5.Field("OBND", new byte[12]));
                stat_tes5.addField(new TES5.Field("MODL", Text.model_path(stat.model_path)));

                MemoryStream mstream = new MemoryStream();
                BinaryWriter bw      = new BinaryWriter(mstream);
                bw.Write(90f);
                bw.Write(0);

                stat_tes5.addField(new TES5.Field("DNAM", mstream.ToArray()));

                if (!ignoreFurniture)
                {
                    Convert.FURN.consider(stat.model_path, stat_tes5);
                }
                stat_grup.addRecord(stat_tes5);


                ModelConverter.convert(stat.model_path, "stat", true);
            }


            return(stat_grup);
        }