public uint Flags; // 1 = Playable 2 = Beast Race

            public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                if (format == GameFormat.TES3)
                {
                    for (var i = 0; i < SkillBoosts.Length; i++)
                    {
                        SkillBoosts[i] = new SkillBoost(r, 8, format);
                    }
                    Male.Strength     = (byte)r.ReadInt32(); Female.Strength = (byte)r.ReadInt32();
                    Male.Intelligence = (byte)r.ReadInt32(); Female.Intelligence = (byte)r.ReadInt32();
                    Male.Willpower    = (byte)r.ReadInt32(); Female.Willpower = (byte)r.ReadInt32();
                    Male.Agility      = (byte)r.ReadInt32(); Female.Agility = (byte)r.ReadInt32();
                    Male.Speed        = (byte)r.ReadInt32(); Female.Speed = (byte)r.ReadInt32();
                    Male.Endurance    = (byte)r.ReadInt32(); Female.Endurance = (byte)r.ReadInt32();
                    Male.Personality  = (byte)r.ReadInt32(); Female.Personality = (byte)r.ReadInt32();
                    Male.Luck         = (byte)r.ReadInt32(); Female.Luck = (byte)r.ReadInt32();
                    Male.Height       = r.ReadSingle(); Female.Height = r.ReadSingle();
                    Male.Weight       = r.ReadSingle(); Female.Weight = r.ReadSingle();
                    Flags             = r.ReadUInt32();
                    return;
                }
                for (var i = 0; i < SkillBoosts.Length; i++)
                {
                    SkillBoosts[i] = new SkillBoost(r, 2, format);
                }
                r.ReadInt16(); // padding
                Male.Height = r.ReadSingle(); Female.Height = r.ReadSingle();
                Male.Weight = r.ReadSingle(); Female.Weight = r.ReadSingle();
                Flags       = r.ReadUInt32();
            }
Ejemplo n.º 2
0
 public SPITField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     Type       = r.ReadUInt32();
     SpellCost  = r.ReadInt32();
     SpellLevel = format != GameFormat.TES3 ? r.ReadInt32() : 0;
     Flags      = r.ReadUInt32();
 }
Ejemplo n.º 3
0
 public HEDRField(BinaryFileReader r, int dataSize)
 {
     Version         = r.ReadSingle();
     FileType        = r.ReadUInt32();
     CompanyName     = r.ReadASCIIString(32, ASCIIFormat.ZeroPadded);
     FileDescription = r.ReadASCIIString(256, ASCIIFormat.ZeroPadded);
     NumRecords      = r.ReadUInt32();
 }
Ejemplo n.º 4
0
 public DATAField(BinaryFileReader r, int dataSize)
 {
     Speed  = r.ReadSingle();
     Flags  = r.ReadUInt32();
     Value  = r.ReadUInt32();
     Weight = r.ReadSingle();
     Damage = r.ReadUInt16();
 }
Ejemplo n.º 5
0
 public LNAMField(BinaryFileReader r, int dataSize)
 {
     Direct = new FormId <Record>(r.ReadUInt32());
     //if (dataSize == 0)
     IndirectWorld = new FormId <WRLDRecord>(r.ReadUInt32());
     //if (dataSize == 0)
     IndirectGridX = r.ReadInt16();
     IndirectGridY = r.ReadInt16();
 }
Ejemplo n.º 6
0
        public FormId <Record> Item;      // The ID of the item

        public CNTOField(BinaryFileReader r, int dataSize, GameFormat format)
        {
            if (format == GameFormat.TES3)
            {
                ItemCount = r.ReadUInt32();
                Item      = new FormId <Record>(r.ReadASCIIString(32, ASCIIFormat.ZeroPadded));
                return;
            }
            Item      = new FormId <Record>(r.ReadUInt32());
            ItemCount = r.ReadUInt32();
        }
Ejemplo n.º 7
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Weight  = r.ReadSingle();
         Value   = r.ReadUInt32();
         Unknown = r.ReadUInt32();
         return;
     }
     Value   = r.ReadUInt32();
     Weight  = r.ReadSingle();
     Unknown = 0;
 }
Ejemplo n.º 8
0
 public RDSDField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Sound  = new FormId <SOUNRecord>(r.ReadASCIIString(32, ASCIIFormat.ZeroPadded));
         Flags  = 0;
         Chance = r.ReadByte();
         return;
     }
     Sound  = new FormId <SOUNRecord>(r.ReadUInt32());
     Flags  = r.ReadUInt32();
     Chance = r.ReadUInt32(); //: float with TES5
 }
Ejemplo n.º 9
0
            public uint Type; // 0x000 = Object, 0x001 = Quest, 0x100 = Magic Effect

            public SCHRField(BinaryFileReader r, int dataSize)
            {
                r.Skip(4); // Unused
                RefCount      = r.ReadUInt32();
                CompiledSize  = r.ReadUInt32();
                VariableCount = r.ReadUInt32();
                Type          = r.ReadUInt32();
                if (dataSize == 20)
                {
                    return;
                }
                r.Skip(dataSize - 20);
            }
Ejemplo n.º 10
0
 public DATAField(BinaryFileReader r, int dataSize)
 {
     Flags     = r.ReadUInt32();
     BaseCost  = r.ReadSingle();
     AssocItem = r.ReadInt32();
     //wbUnion('Assoc. Item', wbMGEFFAssocItemDecider, [
     //  wbFormIDCk('Unused', [NULL]),
     //  wbFormIDCk('Assoc. Weapon', [WEAP]),
     //  wbFormIDCk('Assoc. Armor', [ARMO, NULL{?}]),
     //  wbFormIDCk('Assoc. Creature', [CREA, LVLC, NPC_]),
     //  wbInteger('Assoc. Actor Value', itS32, wbActorValueEnum)
     MagicSchool        = r.ReadInt32();
     ResistValue        = r.ReadInt32();
     CounterEffectCount = r.ReadUInt16();
     r.Skip(2); // Unused
     Light           = new FormId <LIGHRecord>(r.ReadUInt32());
     ProjectileSpeed = r.ReadSingle();
     EffectShader    = new FormId <EFSHRecord>(r.ReadUInt32());
     if (dataSize == 36)
     {
         return;
     }
     EnchantEffect = new FormId <EFSHRecord>(r.ReadUInt32());
     CastingSound  = new FormId <SOUNRecord>(r.ReadUInt32());
     BoltSound     = new FormId <SOUNRecord>(r.ReadUInt32());
     HitSound      = new FormId <SOUNRecord>(r.ReadUInt32());
     AreaSound     = new FormId <SOUNRecord>(r.ReadUInt32());
     ConstantEffectEnchantmentFactor = r.ReadSingle();
     ConstantEffectBarterFactor      = r.ReadSingle();
 }
Ejemplo n.º 11
0
        private void ReadHeader(BinaryFileReader reader)
        {
            // Check map for validity
            // Note: disabled, causes decompression of the entire file ( = SLOW)
            //if(inputStream->getSize() < 50)
            //{
            //	throw std::runtime_error("Corrupted map file.");
            //}

            // Map version
            UInt32 byte1 = reader.ReadUInt32();

            Console.WriteLine("Map version:" + byte1);
            mapObject.Header.Version = (EMapFormat)byte1;


            mapObject.Header.AreAnyPlayers = reader.ReadBool();
            Console.WriteLine("AreAnyPlayers:" + mapObject.Header.AreAnyPlayers);

            mapObject.Header.Height = reader.ReadUInt32();
            mapObject.Header.Width  = mapObject.Header.Height;
            Console.WriteLine("Map Height and Width:" + mapObject.Header.Height);

            mapObject.Header.IsTwoLevel = reader.ReadBool();
            Console.WriteLine("twoLevel:" + mapObject.Header.IsTwoLevel);


            mapObject.Header.Name = reader.ReadString();
            Console.WriteLine("Name:" + mapObject.Header.Name);

            mapObject.Header.Description = reader.ReadString();
            Console.WriteLine("Description:" + mapObject.Header.Description);

            mapObject.Header.Difficulty = reader.ReadUInt8();
            Console.WriteLine("Difficulty:" + mapObject.Header.Difficulty);

            int heroLevelLimit = reader.ReadUInt8();

            Console.WriteLine("HeroLevelLimit:" + heroLevelLimit);


            ReadPlayerInfo(reader);

            ReadVictoryLossConditions(reader);

            ReadTeamInfo(reader);

            ReadAllowedHeroes(reader);
        }
Ejemplo n.º 12
0
 public RDATField(BinaryFileReader r, int dataSize)
 {
     Type     = r.ReadUInt32();
     Flags    = (REGNType)r.ReadByte();
     Priority = r.ReadByte();
     r.Skip(2); // Unused
 }
Ejemplo n.º 13
0
            public int    Flags; // 0 = ?, 1 = Ignore Normal Weapon Resistance?

            public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                if (format == GameFormat.TES3)
                {
                    Weight    = r.ReadSingle();
                    Value     = r.ReadInt32();
                    Type      = r.ReadUInt16();
                    Health    = r.ReadInt16();
                    Speed     = r.ReadSingle();
                    Reach     = r.ReadSingle();
                    Damage    = r.ReadInt16();
                    ChopMin   = r.ReadByte();
                    ChopMax   = r.ReadByte();
                    SlashMin  = r.ReadByte();
                    SlashMax  = r.ReadByte();
                    ThrustMin = r.ReadByte();
                    ThrustMax = r.ReadByte();
                    Flags     = r.ReadInt32();
                    return;
                }
                Type    = (ushort)r.ReadUInt32();
                Speed   = r.ReadSingle();
                Reach   = r.ReadSingle();
                Flags   = r.ReadInt32();
                Value   = r.ReadInt32();
                Health  = (short)r.ReadInt32();
                Weight  = r.ReadSingle();
                Damage  = r.ReadInt16();
                ChopMin = ChopMax = SlashMin = SlashMax = ThrustMin = ThrustMax = 0;
            }
Ejemplo n.º 14
0
        public List <FMIDField <Record> > SCROs = new List <FMIDField <Record> >(); // Global variable reference

        public override bool CreateField(BinaryFileReader r, GameFormat format, string type, int dataSize)
        {
            switch (type)
            {
            case "EDID": EDID = r.ReadSTRV(dataSize); return(true);

            case "SCHD": SCHD = new SCHDField(r, dataSize); return(true);

            case "SCVR": if (format != GameFormat.TES3)
                {
                    SLSDs.Last().SCVRField(r, dataSize);
                }
                else
                {
                    SCHD.SCVRField(r, dataSize);
                } return(true);

            case "SCDA":
            case "SCDT": SCDA = r.ReadBYTV(dataSize); return(true);

            case "SCTX": SCTX = r.ReadSTRV(dataSize); return(true);

            // TES4
            case "SCHR": SCHR = new SCHRField(r, dataSize); return(true);

            case "SLSD": SLSDs.Add(new SLSDField(r, dataSize)); return(true);

            case "SCRO": SCROs.Add(new FMIDField <Record>(r, dataSize)); return(true);

            case "SCRV": var idx = r.ReadUInt32(); SCRVs.Add(SLSDs.Single(x => x.Idx == idx)); return(true);

            default: return(false);
            }
        }
 public TRDTField(BinaryFileReader r, int dataSize)
 {
     EmotionType  = r.ReadUInt32();
     EmotionValue = r.ReadInt32();
     r.Skip(4); // Unused
     ResponseNumber = r.ReadByte();
     r.Skip(3); // Unused
 }
Ejemplo n.º 16
0
 public PGRLField(BinaryFileReader r, int dataSize)
 {
     Reference = new FormId <REFRRecord>(r.ReadUInt32());
     PointIds  = new short[(dataSize - 4) >> 2];
     for (var i = 0; i < PointIds.Length; i++)
     {
         PointIds[i] = r.ReadInt16();
         r.Skip(2); // Unused (can merge back)
     }
 }
Ejemplo n.º 17
0
            public RNAMField(BinaryFileReader r, int dataSize)
            {
                GridX = r.ReadInt16();
                GridY = r.ReadInt16();
                var referenceCount = r.ReadUInt32();
                var referenceSize  = dataSize - 8;

                Assert(referenceSize >> 3 == referenceCount);
                GridReferences = r.ReadTArray <Reference>(referenceSize, referenceSize >> 3);
            }
Ejemplo n.º 18
0
            public float[] UseValue;       // The use types for each skill are hard-coded.

            public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                Action         = format == GameFormat.TES3 ? 0 : r.ReadInt32();
                Attribute      = r.ReadInt32();
                Specialization = r.ReadUInt32();
                UseValue       = new float[format == GameFormat.TES3 ? 4 : 2];
                for (var i = 0; i < UseValue.Length; i++)
                {
                    UseValue[i] = r.ReadSingle();
                }
            }
Ejemplo n.º 19
0
 public AIDTField(BinaryFileReader r, int dataSize)
 {
     Hello    = r.ReadByte();
     Unknown1 = r.ReadByte();
     Fight    = r.ReadByte();
     Flee     = r.ReadByte();
     Alarm    = r.ReadByte();
     Unknown2 = r.ReadByte();
     Unknown3 = r.ReadByte();
     Unknown4 = r.ReadByte();
     Flags    = r.ReadUInt32();
 }
Ejemplo n.º 20
0
 public SCITField(BinaryFileReader r, int dataSize)
 {
     Name         = "Script Effect";
     ScriptFormId = r.ReadInt32();
     if (dataSize == 4)
     {
         return;
     }
     School       = r.ReadInt32();
     VisualEffect = r.ReadASCIIString(4);
     Flags        = dataSize > 12 ? r.ReadUInt32() : 0;
 }
 public XLOCField(BinaryFileReader r, int dataSize)
 {
     LockLevel = r.ReadByte();
     r.Skip(3); // Unused
     Key = new FormId <KEYMRecord>(r.ReadUInt32());
     if (dataSize == 16)
     {
         r.Skip(4); // Unused
     }
     Flags = r.ReadByte();
     r.Skip(3); // Unused
 }
Ejemplo n.º 22
0
        private void ReadRumors(BinaryFileReader reader)
        {
            uint rumNr = reader.ReadUInt32();

            Console.WriteLine("Rumor count: " + rumNr);

            for (int it = 0; it < rumNr; it++)
            {
                string name = reader.ReadString();
                string text = reader.ReadString();
                Console.WriteLine(string.Format("Rumor: name={0} text={1}", name, text));
            }
        }
Ejemplo n.º 23
0
        private void ReadObjectTemplates(BinaryFileReader reader)
        {
            uint defAmount = reader.ReadUInt32();

            Console.WriteLine("ReadObjectTemplates totally:" + defAmount);

            // Read custom defs
            for (int idd = 0; idd < defAmount; ++idd)
            {
                string animationFile = reader.ReadString();
                Console.WriteLine("Object Animation File:" + animationFile);

                int[] blockMask = new int[6];
                int[] visitMask = new int[6];

                foreach (int val in blockMask)
                {
                    int r = reader.ReadUInt8();
                    //Console.WriteLine("BlockMask: " + r);
                }

                foreach (int val in visitMask)
                {
                    int r = reader.ReadUInt8();
                    //Console.WriteLine("VisitMask: " + r);
                }

                reader.ReadUInt16();
                int terrMask = reader.ReadUInt16();

                uint objectId      = reader.ReadUInt32();
                uint objectSubId   = reader.ReadUInt32();
                int  type          = reader.ReadUInt8();
                int  printPriority = reader.ReadUInt8() * 100;

                reader.Skip(16);
            }
        }
Ejemplo n.º 24
0
        public static void ReadNonfixed(BinaryFileReader r, Header header, RecordGroup group)
        {
            var world = int.Parse(header.Label);

            // header
            r.Skip(4 * 5);
            var width  = r.ReadUInt32();
            var height = r.ReadUInt32();

            r.Skip(4);
            var indexSize = (int)(width * height);
            var indices   = r.ReadTArray <uint>(indexSize * 4, indexSize);

            r.Skip(4);
            // pages
            var page     = r.ReadT <Page>(28); r.Skip(4 * 7);
            var entities = new Entity[page.EntityCount];

            for (var i = 0; i < entities.Length; i++)
            {
                entities[i] = r.ReadT <Entity>(64);
            }
        }
Ejemplo n.º 25
0
 public Header(RecordGroup group, BinaryFileReader r, GameFormat format)
 {
     Group          = group;
     HeaderPosition = r.Position;
     Type           = r.ReadASCIIString(4);
     if (Type == "GRUP")
     {
         DataSize  = (uint)(r.ReadUInt32() - (format == GameFormat.TES4 ? 20 : 24));
         Label     = RecordGroup.ToLabel(Group.Depth == 0, r.ReadBytes(4));
         GroupType = (HeaderGroupType)r.ReadInt32();
         r.ReadUInt32(); // stamp | stamp + uknown
         if (format != GameFormat.TES4)
         {
             r.ReadUInt32(); // version + uknown
         }
         Position = r.Position;
         return;
     }
     DataSize = r.ReadUInt32();
     if (format == GameFormat.TES3)
     {
         r.ReadUInt32(); // unknown
     }
     Flags = (HeaderFlags)r.ReadUInt32();
     if (format == GameFormat.TES3)
     {
         Position = r.Position;
         return;
     }
     // tes4
     FormId = r.ReadUInt32();
     r.ReadUInt32();
     if (format == GameFormat.TES4)
     {
         Position = r.Position;
         return;
     }
     // tes5
     r.ReadUInt32();
     Position = r.Position;
 }
Ejemplo n.º 26
0
 public LVLOField(BinaryFileReader r, int dataSize)
 {
     Level = r.ReadInt16();
     r.Skip(2); // Unused
     ItemFormId = new FormId <Record>(r.ReadUInt32());
     if (dataSize == 12)
     {
         Count = r.ReadInt16();
         r.Skip(2); // Unused
     }
     else
     {
         Count = 0;
     }
 }
Ejemplo n.º 27
0
 public DATAField(BinaryFileReader r, int dataSize)
 {
     Density  = r.ReadByte();
     MinSlope = r.ReadByte();
     MaxSlope = r.ReadByte();
     r.ReadByte();
     UnitFromWaterAmount = r.ReadUInt16();
     r.Skip(2);
     UnitFromWaterType = r.ReadUInt32();
     PositionRange     = r.ReadSingle();
     HeightRange       = r.ReadSingle();
     ColorRange        = r.ReadSingle();
     WavePeriod        = r.ReadSingle();
     Flags             = r.ReadByte();
     r.Skip(3);
 }
Ejemplo n.º 28
0
 public SLSDField(BinaryFileReader r, int dataSize)
 {
     Idx = r.ReadUInt32();
     r.ReadUInt32(); // Unknown
     r.ReadUInt32(); // Unknown
     r.ReadUInt32(); // Unknown
     Type = r.ReadUInt32();
     r.ReadUInt32(); // Unknown
     // SCVRField
     VariableName = null;
 }
Ejemplo n.º 29
0
        public void Read(BinaryFileReader r, string filePath, GameFormat format)
        {
            var startPosition = r.Position;
            var endPosition   = startPosition + Header.DataSize;

            while (r.Position < endPosition)
            {
                var fieldHeader = new FieldHeader(r, format);
                if (fieldHeader.Type == "XXXX")
                {
                    if (fieldHeader.DataSize != 4)
                    {
                        throw new InvalidOperationException();
                    }
                    fieldHeader.DataSize = (int)r.ReadUInt32();
                    continue;
                }
                else if (fieldHeader.Type == "OFST" && Header.Type == "WRLD")
                {
                    r.Position = endPosition;
                    continue;
                }
                var position = r.Position;
                if (!CreateField(r, format, fieldHeader.Type, fieldHeader.DataSize))
                {
                    Log($"Unsupported ESM record type: {Header.Type}:{fieldHeader.Type}");
                    r.Position += fieldHeader.DataSize;
                    continue;
                }
                // check full read
                if (r.Position != position + fieldHeader.DataSize)
                {
                    throw new FormatException($"Failed reading {Header.Type}:{fieldHeader.Type} field data at offset {position} in {filePath} of {r.Position - position - fieldHeader.DataSize}");
                }
            }
            // check full read
            if (r.Position != endPosition)
            {
                throw new FormatException($"Failed reading {Header.Type} record data at offset {startPosition} in {filePath}");
            }
        }
Ejemplo n.º 30
0
            public ColorRef4       VertexShading; // RGB + Shading radius (0 - 200) %

            public RDOTField(BinaryFileReader r, int dataSize)
            {
                Object    = new FormId <Record>(r.ReadUInt32());
                ParentIdx = r.ReadUInt16();
                r.Skip(2); // Unused
                Density         = r.ReadSingle();
                Clustering      = r.ReadByte();
                MinSlope        = r.ReadByte();
                MaxSlope        = r.ReadByte();
                Flags           = r.ReadByte();
                RadiusWrtParent = r.ReadUInt16();
                Radius          = r.ReadUInt16();
                MinHeight       = r.ReadSingle();
                MaxHeight       = r.ReadSingle();
                Sink            = r.ReadSingle();
                SinkVariance    = r.ReadSingle();
                SizeVariance    = r.ReadSingle();
                AngleVariance   = new Vector3Int(r.ReadUInt16(), r.ReadUInt16(), r.ReadUInt16());
                r.Skip(2); // Unused
                VertexShading = r.ReadT <ColorRef4>(dataSize);
            }