Пример #1
0
 public PBDTField(BinaryFileReader r, int dataSize)
 {
     Weight  = r.ReadSingle();
     Value   = r.ReadInt32();
     Quality = r.ReadSingle();
     Uses    = r.ReadInt32();
 }
Пример #2
0
        AAnimationFrame[] LoadAnimation(BinaryFileReader r, int uniqueAnimationIndex, AnimationFrame.SittingTransformation sitting)
        {
            var palette    = GetPalette(r);       // 0x100 * 2 = 0x0200 bytes
            var read_start = (int)r.Position;     // save file position after palette.
            var frameCount = r.ReadInt32();       // 0x04 bytes
            var lookups    = new int[frameCount]; // frameCount * 0x04 bytes

            for (var i = 0; i < frameCount; ++i)
            {
                lookups[i] = r.ReadInt32();
            }
            var frames = new AnimationFrame[frameCount];

            for (var i = 0; i < frameCount; ++i)
            {
                if (lookups[i] < lookups[0])
                {
                    frames[i] = AnimationFrame.NullFrame; // Fix for broken animations, per issue13
                }
                else
                {
                    r.Seek(read_start + lookups[i], SeekOrigin.Begin);
                    frames[i] = new AnimationFrame(uniqueAnimationIndex + (i & 0xff), _graphics, palette, r, sitting);
                }
            }
            return(frames);
        }
Пример #3
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();
 }
Пример #4
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();
 }
Пример #5
0
            public int    Parameter2; // Parameter #2

            public CTDAField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                if (format == GameFormat.TES3)
                {
                    Index           = r.ReadByte();
                    Type            = r.ReadByte();
                    FunctionId      = r.ReadASCIIString(2);
                    CompareOp       = (byte)(r.ReadByte() << 1);
                    Name            = r.ReadASCIIString(dataSize - 5);
                    ComparisonValue = Parameter1 = Parameter2 = 0;
                    return;
                }
                CompareOp = r.ReadByte();
                r.Skip(3); // Unused
                ComparisonValue = r.ReadSingle();
                FunctionId      = r.ReadASCIIString(4);
                Parameter1      = r.ReadInt32();
                Parameter2      = r.ReadInt32();
                if (dataSize != 24)
                {
                    r.Skip(4); // Unused
                }
                Index = Type = 0;
                Name  = null;
            }
Пример #6
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;
            }
 public DATA3Field(BinaryFileReader r, int dataSize)
 {
     Unknown1    = r.ReadInt32();
     Disposition = r.ReadInt32();
     Rank        = r.ReadByte();
     Gender      = r.ReadByte();
     PCRank      = r.ReadByte();
     Unknown2    = r.ReadByte();
 }
Пример #8
0
            public int Flags; //: AutoCalc

            public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                Weight = r.ReadSingle();
                if (format == GameFormat.TES3)
                {
                    Value = r.ReadInt32();
                    Flags = r.ReadInt32();
                }
            }
 public SkillBoost(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         SkillId = (byte)r.ReadInt32();
         Bonus   = (sbyte)r.ReadInt32();
         return;
     }
     SkillId = r.ReadByte();
     Bonus   = r.ReadSByte();
 }
Пример #10
0
 public ENAMField(BinaryFileReader r, int dataSize)
 {
     EffectId    = r.ReadInt16();
     SkillId     = r.ReadByte();
     AttributeId = r.ReadByte();
     Unknown1    = r.ReadInt32();
     Unknown2    = r.ReadInt32();
     Duration    = r.ReadInt32();
     Magnitude   = r.ReadInt32();
     Unknown4    = r.ReadInt32();
 }
Пример #11
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();
                }
            }
Пример #12
0
 public SCHDField(BinaryFileReader r, int dataSize)
 {
     Name           = r.ReadASCIIString(32, ASCIIFormat.ZeroPadded);
     NumShorts      = r.ReadInt32();
     NumLongs       = r.ReadInt32();
     NumFloats      = r.ReadInt32();
     ScriptDataSize = r.ReadInt32();
     LocalVarSize   = r.ReadInt32();
     // SCVRField
     Variables = null;
 }
Пример #13
0
 public MEDTField(BinaryFileReader r, int dataSize)
 {
     SpellSchool = r.ReadInt32();
     BaseCost    = r.ReadSingle();
     Flags       = r.ReadInt32();
     Color       = new ColorRef4 {
         Red = (byte)r.ReadInt32(), Green = (byte)r.ReadInt32(), Blue = (byte)r.ReadInt32(), Null = 255
     };
     SpeedX  = r.ReadSingle();
     SizeX   = r.ReadSingle();
     SizeCap = r.ReadSingle();
 }
Пример #14
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;
 }
Пример #15
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format != GameFormat.TES3)
     {
         X          = Y = Granularity = 0;
         PointCount = r.ReadInt16();
         return;
     }
     X           = r.ReadInt32();
     Y           = r.ReadInt32();
     Granularity = r.ReadInt16();
     PointCount  = r.ReadInt16();
 }
Пример #16
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Weight          = r.ReadSingle();
         Value           = r.ReadInt32();
         Time            = r.ReadInt32();
         Radius          = r.ReadInt32();
         LightColor      = r.ReadT <ColorRef4>(4);
         Flags           = r.ReadInt32();
         FalloffExponent = 1;
         FOV             = 90;
         return;
     }
     Time       = r.ReadInt32();
     Radius     = r.ReadInt32();
     LightColor = r.ReadT <ColorRef4>(4);
     Flags      = r.ReadInt32();
     if (dataSize == 32)
     {
         FalloffExponent = r.ReadSingle();
         FOV             = r.ReadSingle();
     }
     else
     {
         FalloffExponent = 1;
         FOV             = 90;
     }
     Value  = r.ReadInt32();
     Weight = r.ReadSingle();
 }
Пример #17
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Type    = (byte)r.ReadInt32();
         Quality = r.ReadSingle();
         Weight  = r.ReadSingle();
         Value   = r.ReadInt32();
         return;
     }
     Type    = r.ReadByte();
     Value   = r.ReadInt32();
     Weight  = r.ReadSingle();
     Quality = r.ReadSingle();
 }
Пример #18
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Type       = r.ReadInt32();
         Weight     = r.ReadSingle();
         Value      = r.ReadInt16();
         EnchantPts = r.ReadInt16();
         return;
     }
     Value      = r.ReadInt32();
     Weight     = r.ReadSingle();
     Type       = 0;
     EnchantPts = 0;
 }
Пример #19
0
 internal static Texture2DInfo LoadRawTexture(Stream inputStream)
 {
     using (var r = new BinaryFileReader(inputStream))
     {
         var width         = r.ReadInt32();
         var height        = r.ReadInt32();
         var frameLength   = r.BaseStream.Length;
         var sizeOfFrame   = 20;
         var frameDataSize = height * width;
         var bitsPerPixel  = (int)((frameLength - sizeOfFrame) / frameDataSize);
         r.Position = frameLength - (width * height * bitsPerPixel);
         var rawData = r.ReadBytes(width * height * bitsPerPixel);
         return(bitsPerPixel == 1
             ? new Texture2DInfo(width, height, UnityEngine.TextureFormat.RGBA32, false, rawData).From8BitPallet(GetGlobal8BitPallet(), UnityEngine.TextureFormat.RGBA32)
             : new Texture2DInfo(width, height, UnityEngine.TextureFormat.RGBA32, false, rawData).FromABGR555());
     }
 }
 public TRDTField(BinaryFileReader r, int dataSize)
 {
     EmotionType  = r.ReadUInt32();
     EmotionValue = r.ReadInt32();
     r.Skip(4); // Unused
     ResponseNumber = r.ReadByte();
     r.Skip(3); // Unused
 }
Пример #21
0
 public DATAField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         Weight     = r.ReadSingle();
         Value      = r.ReadInt32();
         Flags      = (byte)r.ReadInt32();
         Teaches    = (byte)r.ReadInt32();
         EnchantPts = r.ReadInt32();
         return;
     }
     Flags      = r.ReadByte();
     Teaches    = r.ReadByte();
     Value      = r.ReadInt32();
     Weight     = r.ReadSingle();
     EnchantPts = 0;
 }
Пример #22
0
 public PSDTField(BinaryFileReader r, int dataSize)
 {
     Month     = r.ReadByte();
     DayOfWeek = r.ReadByte();
     Date      = r.ReadByte();
     Time      = (sbyte)r.ReadByte();
     Duration  = r.ReadInt32();
 }
Пример #23
0
 public SNAMField(BinaryFileReader r, int dataSize)
 {
     Values = new int[dataSize >> 2];
     for (var i = 0; i < Values.Length; i++)
     {
         Values[i] = r.ReadInt32();
     }
 }
Пример #24
0
            public int[] AttributeId; // only for Attribute related effects, 0 or -1 otherwise

            public IRDTField(BinaryFileReader r, int dataSize)
            {
                Weight   = r.ReadSingle();
                Value    = r.ReadInt32();
                EffectId = new int[4];
                for (var i = 0; i < EffectId.Length; i++)
                {
                    EffectId[i] = r.ReadInt32();
                }
                SkillId = new int[4];
                for (var i = 0; i < SkillId.Length; i++)
                {
                    SkillId[i] = r.ReadInt32();
                }
                AttributeId = new int[4];
                for (var i = 0; i < AttributeId.Length; i++)
                {
                    AttributeId[i] = r.ReadInt32();
                }
            }
Пример #25
0
 public CNAMField(BinaryFileReader r, int dataSize)
 {
     LeafCurvature      = r.ReadSingle();
     MinimumLeafAngle   = r.ReadSingle();
     MaximumLeafAngle   = r.ReadSingle();
     BranchDimmingValue = r.ReadSingle();
     LeafDimmingValue   = r.ReadSingle();
     ShadowRadius       = r.ReadInt32();
     RockSpeed          = r.ReadSingle();
     RustleSpeed        = r.ReadSingle();
 }
Пример #26
0
 public EFITField(BinaryFileReader r, int dataSize, GameFormat format)
 {
     if (format == GameFormat.TES3)
     {
         EffectId     = r.ReadASCIIString(2);
         SkillId      = r.ReadByte();
         AttributeId  = r.ReadByte();
         Type         = r.ReadInt32();
         Area         = r.ReadInt32();
         Duration     = r.ReadInt32();
         MagnitudeMin = r.ReadInt32();
         MagnitudeMax = r.ReadInt32();
         return;
     }
     EffectId     = r.ReadASCIIString(4);
     MagnitudeMin = r.ReadInt32();
     Area         = r.ReadInt32();
     Duration     = r.ReadInt32();
     Type         = r.ReadInt32();
     ActorValue   = r.ReadInt32();
 }
Пример #27
0
        public static DATVField ReadDATV(this BinaryFileReader r, int length, char type)
        {
            switch (type)
            {
            case 'b': return(new DATVField {
                    B = r.ReadInt32() != 0
                });

            case 'i': return(new DATVField {
                    I = r.ReadInt32()
                });

            case 'f': return(new DATVField {
                    F = r.ReadSingle()
                });

            case 's': return(new DATVField {
                    S = r.ReadASCIIString(length, ASCIIFormat.PossiblyNullTerminated)
                });

            default: throw new InvalidOperationException($"{type}");
            }
        }
            //public int Gold;

            public NPDTField(BinaryFileReader r, int dataSize)
            {
                if (dataSize == 52)
                {
                    Level        = r.ReadInt16();
                    Strength     = r.ReadByte();
                    Intelligence = r.ReadByte();
                    Willpower    = r.ReadByte();
                    Agility      = r.ReadByte();
                    Speed        = r.ReadByte();
                    Endurance    = r.ReadByte();
                    Personality  = r.ReadByte();
                    Luck         = r.ReadByte();
                    Skills       = r.ReadBytes(27);
                    Reputation   = r.ReadByte();
                    Health       = r.ReadInt16();
                    SpellPts     = r.ReadInt16();
                    Fatigue      = r.ReadInt16();
                    Disposition  = r.ReadByte();
                    FactionId    = r.ReadByte();
                    Rank         = r.ReadByte();
                    Unknown1     = r.ReadByte();
                    Gold         = r.ReadInt32();
                }
                else
                {
                    Level       = r.ReadInt16();
                    Disposition = r.ReadByte();
                    FactionId   = r.ReadByte();
                    Rank        = r.ReadByte();
                    Unknown1    = r.ReadByte();
                    Unknown2    = r.ReadByte();
                    Unknown3    = r.ReadByte();
                    Gold        = r.ReadInt32();
                }
            }
Пример #29
0
            public int Flags;        //: AutoCalc

            public ENITField(BinaryFileReader r, int dataSize, GameFormat format)
            {
                Type = r.ReadInt32();
                if (format == GameFormat.TES3)
                {
                    EnchantCost  = r.ReadInt32();
                    ChargeAmount = r.ReadInt32();
                }
                else
                {
                    ChargeAmount = r.ReadInt32();
                    EnchantCost  = r.ReadInt32();
                }
                Flags = r.ReadInt32();
            }
Пример #30
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;
 }