예제 #1
0
        public static void analyze(string record)
        {
            ESM.open(Config.Paths.mw_esm);
            Log lg = new Log("explore.txt");

            while (ESM.find(record))
            {
                TES3.Record rec = new TES3.Record();
                rec.read();

                lg.log(new string(rec.Name));

                foreach (SubRecord sr in rec.subRecords)
                {
                    lg.log("    " + new string(sr.name) + "       " + sr.size);

                    if (sr.isType("BYDT"))
                    {
                        byte[] flgs = sr.getData().ReadBytes(4);
                        lg.log(Text.toHex(flgs[2]));
                    }

                    else
                    {
                        lg.log(sr.readString());
                    }
                }
            }

            lg.show();
        }
예제 #2
0
        public static void analyze2(string record)
        {
            ESM.open(Config.Paths.mw_esm);
            Log lg = new Log("explore.txt");

            while (ESM.find(record))
            {
                TES3.Record rec = new TES3.Record();
                rec.read();

                byte[] flgs = rec.find_first("BYDT").getData().ReadBytes(4);

                if (flgs[0] == 0 && flgs[3] == 0)
                {
                    string edid = rec.find_first("NAME").readString();
                    string rnam = rec.find_first("FNAM").readString();
                    string sex  = "";

                    if (BinaryFlag.isSet((int)flgs[2], (int)0x01))
                    {
                        sex = "Female";
                    }
                    else
                    {
                        sex = "Male";
                    }



                    lg.log(rnam + "," + sex + "," + edid);
                }
            }

            lg.show();
        }
예제 #3
0
        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);
        }
예제 #4
0
        static List <door_> get_tes3_doors(string file)
        {
            TES3.ESM.open(file);

            List <door_> door_list = new List <door_>();

            while (TES3.ESM.find("DOOR"))
            {
                TES3.Record door = new TES3.Record();
                door.read();

                if (!new string(door.Name).Equals("DOOR"))
                {
                    Log.error("Read non-door record");
                }

                door_ d = new door_();

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

                    if (srec.isType("FNAM"))
                    {
                        d.full_name = Text.trim(new string(srec.getData().ReadChars(srec.size)));
                    }

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

                if (String.IsNullOrEmpty(d.full_name))
                {
                    d.full_name = "Door";
                }

                door_list.Add(d);
            }

            TES3.ESM.close();
            return(door_list);
        }
예제 #5
0
        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);
        }
예제 #6
0
        private static List <mw_ltex> get_mw_land_textures(string file)
        {
            List <mw_ltex> lst = new List <mw_ltex>();

            TES3.ESM.open(file);

            while (TES3.ESM.find("LTEX"))
            {
                TES3.Record ltex = new TES3.Record();
                ltex.read();

                mw_ltex mw_ltex_ = new mw_ltex();


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

                    else if (sr.isType("DATA"))
                    {
                        mw_ltex_.texture_path = Text.trim(new string (sr.getData().ReadChars(sr.size)));
                    }

                    else if (sr.isType("INTV"))
                    {
                        mw_ltex_.index = sr.getData().ReadInt32();
                    }
                }

                lst.Add(mw_ltex_);
            }

            TES3.ESM.close();
            return(lst);
        }
예제 #7
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);
        }