Ejemplo n.º 1
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            Unknown2       = br.ReadBytes(6);
            LightRadius    = br.ReadInt32();
            NumOfColors    = br.ReadInt32(); //
            LightIntensity = br.ReadByte();; //gradient amount 32 00
            UnknownVal     = br.ReadBytes(21);
            // Unknown5 = br.ReadInt32(); //
            // Unknown6 = br.ReadInt16(); //
            ChangeIntensity = br.ReadInt16(); // Color change speed 15
            Color1          = br.ReadColor();
            Color2          = br.ReadColor();

            /*
             * R1 = br.ReadByte();
             * G1 = br.ReadByte(); // Flags2?
             * B1 = br.ReadByte(); // Some flag
             * R2 = br.ReadByte();
             * G2 = br.ReadByte(); // Flags2?
             * B2 = br.ReadByte(); // Some flag
             */


            Unknown3   = br.ReadBytes(74);
            PulseSpeed = br.ReadByte();
            Unknown4   = br.ReadBytes(18);

            /*
             * //ChangeColors = new Color[16];18
             * //for (int i = 0; i < 16; i++) ChangeColors[i] = br.ReadColor();
             * //  Unknown3 = new byte[16];
             * //for (int i = 0; i < 16; i++) ChangeIntensity[i] = br.ReadByte();
             * ChangeRadius = new byte[16];
             * for (int i = 0; i < 16; i++) ChangeRadius[i] = br.ReadByte();
             * ColorChangeIndex = br.ReadInt16();
             * IntensityChangeIndex = br.ReadInt16();
             * RadiusChangeIndex = br.ReadInt16();
             * ObjExtentID = br.ReadInt32();
             * Unknown13 = br.ReadInt16(); // some flags
             * Unknown14 = br.ReadInt16();
             * Unknown15 = br.ReadByte();
             * // Probably type of light (0 = emitter, 1 = absorber?)
             * if (ParsingRule >= 42)
             *  IsAntiLight = br.ReadInt32();
             * else
             *  IsAntiLight = br.ReadByte();
             */
            return(true);
        }
Ejemplo n.º 2
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            // 4 enchantments
            for (int i = 0; i < 4; i++)
            {
                Enchantments[i] = br.ReadString();
            }
            if (ParsingRule > 41)
            {
                if (ParsingRule >= 42)
                {
                    Durability = br.ReadInt16();
                }
                if (ParsingRule == 61)
                {
                    br.ReadByte();
                }
                if (ParsingRule >= 62)
                {
                    Unknown = br.ReadInt32();
                }
            }
            return(true);
        }
Ejemplo n.º 3
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            if (ParsingRule < 42)
            {
                throw new NotSupportedException("Where did you find this map?");
            }
            ScriptActivated = br.ReadInt32();
            // какой-то скриптовый обработчик
            UnknownScriptHandler = br.ReadScriptEventString();
            // координаты места падения
            FallX = br.ReadInt32();
            FallY = br.ReadInt32();
            // таймаут вызова скрипта
            ScriptTime1   = br.ReadInt32();
            ScriptTimeout = br.ReadInt16();
            return(true);
        }
Ejemplo n.º 4
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            // 4 enchantments
            for (int i = 0; i < 4; i++)
            {
                Enchantments[i] = br.ReadString();
            }
            if (ParsingRule > 41)
            {
                // StaffWooden is considered a WAND but without special casting wand structure
                if (thing.HasClassFlag(ThingDb.Thing.ClassFlags.WAND) && !thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.STAFF])
                {
                    WandChargesCurrent = br.ReadByte();
                    WandChargesLimit   = br.ReadByte();
                    if (ParsingRule >= 61)
                    {
                        WandChargePercent = br.ReadInt32();
                    }
                }
                if (ParsingRule >= 42)
                {
                    Durability = br.ReadInt16();
                }
                if (ParsingRule == 63)
                {
                    br.ReadByte();
                }
                if (ParsingRule >= 64)
                {
                    Unknown = br.ReadInt32();
                }
            }
            return(true);
        }
Ejemplo n.º 5
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            RewardType = (RewardFlags)br.ReadUInt32();
            Unknown1   = br.ReadInt32();
            // spells
            short count = br.ReadInt16();

            Spells = new List <string>(count);
            while (count > 0)
            {
                Spells.Add(br.ReadString());
                count--;
            }
            // abilities
            count     = br.ReadInt16();
            Abilities = new List <string>(count);
            while (count > 0)
            {
                Abilities.Add(br.ReadString());
                count--;
            }
            // monster scrolls
            count    = br.ReadInt16();
            Monsters = new List <string>(count);
            while (count > 0)
            {
                Monsters.Add(br.ReadString());
                count--;
            }
            Unknown2 = br.ReadInt32();
            Unknown3 = br.ReadInt32();
            Unknown4 = br.ReadInt32();
            Unknown5 = br.ReadInt32();
            Unknown6 = br.ReadInt32();
            if (ParsingRule >= 62)
            {
                ActivateChance = br.ReadInt32();
            }
            if (ParsingRule >= 63)
            {
                RareOrSpecial = br.ReadBoolean();
            }

            return(true);
        }
Ejemplo n.º 6
0
        public int IsAntiLight;            // 0xAC Emits light?

        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            UnknownVal     = br.ReadInt32(); // unused?
            Unknown2       = br.ReadBytes(12);
            Unknown3       = br.ReadInt16(); // Color Flags?
            Unknown4       = br.ReadInt16();
            Unknown5       = br.ReadInt32(); // Flags2?
            Unknown6       = br.ReadInt16(); // Some flag
            LightRadius    = br.ReadInt32(); //484290
            NumOfColors    = br.ReadInt32(); // 2 normally
            LightIntensity = br.ReadSingle();


            ChangeColors = new Color[16];
            for (int i = 0; i < 16; i++)
            {
                ChangeColors[i] = br.ReadColor();
            }
            ChangeIntensity = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                ChangeIntensity[i] = br.ReadByte();
            }
            ChangeRadius = new byte[16];
            for (int i = 0; i < 16; i++)
            {
                ChangeRadius[i] = br.ReadByte();
            }
            ColorChangeIndex     = br.ReadInt16();
            IntensityChangeIndex = br.ReadInt16();
            RadiusChangeIndex    = br.ReadInt16();
            ObjExtentID          = br.ReadInt32();
            Unknown13            = br.ReadInt16(); // some flags
            Unknown14            = br.ReadInt16();
            Unknown15            = br.ReadByte();
            // Probably type of light (0 = emitter, 1 = absorber?)
            if (ParsingRule >= 42)
            {
                IsAntiLight = br.ReadInt32();
            }
            else
            {
                IsAntiLight = br.ReadByte();
            }
            return(true);
        }
Ejemplo n.º 7
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            if (ParsingRule < 41)
            {
                br.ReadInt32();
            }
            Angle = br.ReadByte();
            TargX = br.ReadSingle();
            TargY = br.ReadSingle();
            byte spells = br.ReadByte();

            while (spells > 0)
            {
                Spells.Add(br.ReadString());
                spells--;
            }

            return(true);
        }
Ejemplo n.º 8
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            // collisionbox
            SizeX = br.ReadInt32();
            SizeY = br.ReadInt32();
            if (SizeX > 60)
            {
                SizeX = 60;
            }
            if (SizeY > 60)
            {
                SizeY = 60;
            }
            // цвета заливки и граней для PressurePlate
            EdgeColor = br.ReadColor();
            BackColor = br.ReadColor();
            UnkInt1   = br.ReadInt32();
            // обработчики событий
            ScriptOnPressed  = br.ReadScriptEventString();
            ScriptOnReleased = br.ReadScriptEventString();
            ScriptOnCollided = br.ReadScriptEventString();
            // кто может активировать
            AllowedObjClass = br.ReadInt32();
            IgnoredObjClass = br.ReadInt32();
            AllowedTeamID   = br.ReadByte();
            IgnoredTeamID   = br.ReadByte();
            if (ParsingRule >= 61)
            {
                TriggerState = br.ReadByte();
                Unk7         = br.ReadByte();
                UnkInt2      = br.ReadInt32();
            }
            return(true);
        }
Ejemplo n.º 9
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            DirectionId  = (byte)Array.IndexOf(MonsterXfer.NOX_DIRECT_LONG, br.ReadUInt64());
            ScriptEvents = new string[10];
            // Fix for some old maps (null)
            NPCVoiceSet = "";
            BuffList    = new MonsterXfer.BuffEntry[0];
            // Читаем имена обработчиков скриптовых событий
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                {
                    DetectEventTimeout = br.ReadUInt16();
                }

                ScriptEvents[i] = br.ReadScriptEventString();
            }
            // Пропуск (0)
            br.ReadInt32();
            // цвета
            NPCColors = new Color[6];
            byte R, G, B;

            for (int i = 0; i < 6; i++)
            {
                R            = br.ReadByte();
                G            = br.ReadByte();
                B            = br.ReadByte();
                NPCColors[i] = Color.FromArgb(R, G, B);
            }
            // основной блок инфы
            if (ParsingRule >= 32)
            {
                ActionRoamPathFlag = br.ReadByte();
                if (ParsingRule < 49)
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt16();
                }
                else
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt32();
                }

                HealthMultiplier = br.ReadSingle();
                RetreatRatio     = br.ReadSingle();
                ResumeRatio      = br.ReadSingle();
                SightRange       = br.ReadSingle();
                Health           = br.ReadInt16();
                Aggressiveness   = br.ReadSingle();
                if (ParsingRule < 35)
                {
                    DefaultAction = br.ReadInt32();
                }
                EscortObjName = br.ReadString();
                if (ParsingRule >= 34)
                {
                    int spells = br.ReadInt32();
                    KnownSpells = new List <MonsterXfer.SpellEntry>();
                    string spellName  = null;
                    uint   spellFlags = 0;

                    for (int i = 0; i < spells; i++)
                    {
                        spellName  = br.ReadString();
                        spellFlags = br.ReadUInt32();
                        if (ThingDb.Spells.Keys.Contains(spellName))
                        {
                            KnownSpells.Add(new MonsterXfer.SpellEntry(spellName, spellFlags));
                        }
                    }
                }
                else
                {
                    br.BaseStream.Seek(0x224, SeekOrigin.Current);
                }
                // Задержки между заклинаниями
                if (ParsingRule < 47)
                {
                    ReactionCastingDelayMin = (ushort)br.ReadByte();
                    ReactionCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BuffCastingDelayMin = (ushort)br.ReadByte();
                    BuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    DebuffCastingDelayMin = (ushort)br.ReadByte();
                    DebuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    OffensiveCastingDelayMin = (ushort)br.ReadByte();
                    OffensiveCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BlinkCastingDelayMin = (ushort)br.ReadByte();
                    BlinkCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                }
                else
                {
                    ReactionCastingDelayMin  = br.ReadUInt16();
                    ReactionCastingDelayMax  = br.ReadUInt16();
                    BuffCastingDelayMin      = br.ReadUInt16();
                    BuffCastingDelayMax      = br.ReadUInt16();
                    DebuffCastingDelayMin    = br.ReadUInt16();
                    DebuffCastingDelayMax    = br.ReadUInt16();
                    OffensiveCastingDelayMin = br.ReadUInt16();
                    OffensiveCastingDelayMax = br.ReadUInt16();
                    BlinkCastingDelayMin     = br.ReadUInt16();
                    BlinkCastingDelayMax     = br.ReadUInt16();
                }
                if (ParsingRule < 34)
                {
                    MagicNumber = br.ReadUInt32();
                }
                if (ParsingRule >= 33)
                {
                    LockPathDistance = br.ReadSingle();
                }
                if (ParsingRule >= 34)
                {
                    SpellPowerLevel = br.ReadInt32();
                    NPCStrength     = br.ReadByte();
                    NPCSpeed        = br.ReadSingle();
                    AimSkillLevel   = br.ReadSingle();
                    if (ParsingRule < 42)
                    {
                        if (br.ReadInt16() == 0)
                        {
                            Immortal = true;
                        }
                    }
                    TrapSpell1 = br.ReadString();
                    TrapSpell2 = br.ReadString();
                    TrapSpell3 = br.ReadString();
                }
                if (ParsingRule >= 35)
                {
                    string action = br.ReadString();
                    DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action);
                }
                if (ParsingRule >= 41)
                {
                    // here you have to read just a huge amount of information
                    // however it is used very rarely, usually entryType = 4; forced = 0
                    short entryType = br.ReadInt16();
                    if (entryType <= 4)
                    {
                        byte forced = 1;
                        if (entryType >= 2)
                        {
                            forced = br.ReadByte();
                        }
                        if (forced == 1 || entryType < 2)
                        {
                            return(false);
                            // TODO для ПОЛНОЙ совместимости, придётся
                        }
                    }
                }
                if (ParsingRule >= 42)
                {
                    Immortal = br.ReadBoolean();
                }
                if (ParsingRule >= 44)
                {
                    MagicNumber = br.ReadUInt32();
                }
                if (ParsingRule >= 45)
                {
                    MaxHealth = (short)br.ReadInt32();
                }
                if (ParsingRule >= 46)
                {
                    AddedSubclass = br.ReadUInt32();
                }
                if (ParsingRule >= 48)
                {
                    Health = br.ReadInt16();
                }
                if (ParsingRule >= 51)
                {
                    Experience = br.ReadSingle();
                }
                if (ParsingRule >= 52)
                {
                    NPCVoiceSet = br.ReadString();
                }

                if (ParsingRule < 61)
                {
                    return(true);
                }
                // энчанты
                short buffsType = br.ReadInt16();
                if (buffsType > 2 || buffsType <= 0)
                {
                    return(false);
                }

                byte count = br.ReadByte();
                BuffList = new MonsterXfer.BuffEntry[count];
                while (count > 0)
                {
                    MonsterXfer.BuffEntry be = new MonsterXfer.BuffEntry();
                    be.Name     = br.ReadString();
                    be.Power    = br.ReadByte();
                    be.Duration = br.ReadInt32();
                    if (be.Name == ENCHANT_SHIELD && buffsType >= 2)
                    {
                        be.ShieldHealth = br.ReadInt32();
                    }

                    BuffList[count - 1] = be;
                    count--;
                }
                Array.Reverse(BuffList);

                if (ParsingRule >= 62)
                {
                    PoisonLevel = br.ReadByte();
                }
            }
            return(true);
        }
Ejemplo n.º 10
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);
            // частота появления монстров
            int spawnRateNum = (int)br.ReadByte();

            MonsterSpawnRate = new byte[spawnRateNum];
            for (int i = 0; i < spawnRateNum; i++)
            {
                MonsterSpawnRate[i] = br.ReadByte();
            }
            // число уже созданных монстров
            SpawnedMonsters = br.ReadByte();
            // заменяется при загрузке на MonsterSpawnLimit
            SavedSpawnLimit = br.ReadByte();
            // должно быть 0 если карта не была сохранена игрой
            LastSpawnFrame = br.ReadUInt32();
            // скриптовые обработчики
            ScriptOnDamage  = br.ReadScriptEventString();
            ScriptOnDestroy = br.ReadScriptEventString();
            ScriptOnCollide = br.ReadScriptEventString();
            ScriptOnSpawn   = br.ReadScriptEventString();
            // монстры
            int           monsters      = (int)br.ReadByte();
            byte          spawnLimitNum = 0;
            List <string> monsterNames  = new List <string>(monsters);

            MonsterData = new byte[monsters][];
            for (int i = 0; i < monsters; i++)
            {
                // именно так
                if (!br.ReadBoolean())
                {
                    monsterNames.Add(null);
                    continue;
                }
                string monsterName = br.ReadString();
                short  unknown     = br.ReadInt16();            // увеличивается для следующего монстра
                // SkipToNextQword
                br.SkipToNextBoundary();
                long entryLenMB = br.ReadInt64();
                MonsterData[i] = br.ReadBytes((int)entryLenMB);

                /*
                 *      MonsterData - типичная инфа об обьекте
                 * short parsingRule1 = br.ReadInt16();
                 * short parsingRule2 = br.ReadInt16();
                 * br.ReadInt32(); // extent
                 * br.ReadInt32(); // globalID
                 * br.ReadSingle(); // X
                 * br.ReadSingle(); // Y
                 * byte term = br.ReadByte();
                 * result.MonsterData[i] = MonsterXfer.FromStream(br.BaseStream, ThingDb.Things[monsterName], parsingRule1);
                 */
                monsterNames.Add(monsterName);
            }
            spawnLimitNum = br.ReadByte();
            MonsterNames  = monsterNames.ToArray();
            // максимальное число создаваемых монстров, берется из gamedata.bin
            MonsterSpawnLimit = new byte[spawnLimitNum];
            for (int i = 0; i < spawnLimitNum; i++)
            {
                MonsterSpawnLimit[i] = br.ReadByte();
            }
            // настройки спавна: 0 - отключен, 1 - рандом позиция, 2 - зависит от игрока
            if (ParsingRule >= 63)
            {
                GenerationFlags = br.ReadInt32();
            }
            return(true);
        }
Ejemplo n.º 11
0
        public static MonsterGeneratorXfer FromStream(Stream mstream, short ParsingRule)
        {
            MonsterGeneratorXfer result = new MonsterGeneratorXfer();

            NoxBinaryReader br = new NoxBinaryReader(mstream);
            // частота появления монстров
            int spawnRateNum = (int) br.ReadByte();
            result.MonsterSpawnRate = new byte[spawnRateNum];
            for (int i = 0; i < spawnRateNum; i++)
                result.MonsterSpawnRate[i] = br.ReadByte();
            // число уже созданных монстров
            result.SpawnedMonsters = br.ReadByte();
            // заменяется при загрузке на MonsterSpawnLimit
            result.SavedSpawnLimit = br.ReadByte();
            // должно быть 0 если карта не была сохранена игрой
            result.LastSpawnFrame = br.ReadUInt32();
            // скриптовые обработчики
            result.ScriptOnDamage = br.ReadScriptEventString();
            result.ScriptOnDestroy = br.ReadScriptEventString();
            result.ScriptOnCollide = br.ReadScriptEventString();
            result.ScriptOnSpawn = br.ReadScriptEventString();
            // монстры
            int monsters = (int) br.ReadByte();
            byte spawnLimitNum = 0;
            List<string> monsterNames = new List<string>(monsters);
            result.MonsterData = new byte[monsters][];
            for (int i = 0; i < monsters; i++)
            {
                // именно так
                if (!br.ReadBoolean())
                {
                    monsterNames.Add(null);
                    continue;
                }
                string monsterName = br.ReadString();
                short unknown = br.ReadInt16(); // увеличивается для следующего монстра
                // SkipToNextQword
                br.SkipToNextBoundary();
                long entryLenMB = br.ReadInt64();
                result.MonsterData[i] = br.ReadBytes((int) entryLenMB);
                /*
              					MonsterData - типичная инфа об обьекте
                short parsingRule1 = br.ReadInt16();
                short parsingRule2 = br.ReadInt16();
                br.ReadInt32(); // extent
                br.ReadInt32(); // globalID
                br.ReadSingle(); // X
                br.ReadSingle(); // Y
                byte term = br.ReadByte();
                result.MonsterData[i] = MonsterXfer.FromStream(br.BaseStream, ThingDb.Things[monsterName], parsingRule1);
                */
                monsterNames.Add(monsterName);
            }
            spawnLimitNum = br.ReadByte();
            result.MonsterNames = monsterNames.ToArray();
            // максимальное число создаваемых монстров, берется из gamedata.bin
            result.MonsterSpawnLimit = new byte[spawnLimitNum];
            for (int i = 0; i < spawnLimitNum; i++)
                result.MonsterSpawnLimit[i] = br.ReadByte();
            // настройки спавна: 0 - отключен, 1 - рандом позиция, 2 - зависит от игрока
            if (ParsingRule >= 63)
                result.GenerationFlags = br.ReadInt32();
            return result;
        }
Ejemplo n.º 12
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            DirectionId  = (byte)Array.IndexOf(NOX_DIRECT_LONG, br.ReadUInt64());
            ScriptEvents = new string[10];
            // Read script event handler names
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                {
                    DetectEventTimeout = br.ReadUInt16();
                }

                ScriptEvents[i] = br.ReadScriptEventString();
            }
            // Skip (0)
            if (ParsingRule >= 11)
            {
                br.ReadInt32();
            }
            if (ParsingRule >= 31)
            {
                ActionRoamPathFlag = br.ReadByte();
                if (ParsingRule < 51)
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt16();
                }
                else
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt32();
                }

                HealthMultiplier = br.ReadSingle();
                RetreatRatio     = br.ReadSingle();
                ResumeRatio      = br.ReadSingle();
                SightRange       = br.ReadSingle();
                if (ParsingRule < 33)
                {
                    br.BaseStream.Seek(2, SeekOrigin.Current);
                }
                Aggressiveness = br.ReadSingle();
                if (ParsingRule < 34)
                {
                    DefaultAction = br.ReadInt32();
                }
                EscortObjName = br.ReadString();
                if (ParsingRule >= 34)
                {
                    int spells = br.ReadInt32();
                    KnownSpells = new List <SpellEntry>();
                    string spellName  = null;
                    uint   spellFlags = 0;

                    for (int i = 0; i < spells; i++)
                    {
                        spellName  = br.ReadString();
                        spellFlags = br.ReadUInt32();
                        if (ThingDb.Spells.Keys.Contains(spellName))
                        {
                            KnownSpells.Add(new SpellEntry(spellName, spellFlags));
                        }
                    }
                }
                else
                {
                    br.BaseStream.Seek(0x224, SeekOrigin.Current);
                }
                // Spell usage delay values
                if (ParsingRule < 46)
                {
                    ReactionCastingDelayMin = (ushort)br.ReadByte();
                    ReactionCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BuffCastingDelayMin = (ushort)br.ReadByte();
                    BuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    DebuffCastingDelayMin = (ushort)br.ReadByte();
                    DebuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    OffensiveCastingDelayMin = (ushort)br.ReadByte();
                    OffensiveCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BlinkCastingDelayMin = (ushort)br.ReadByte();
                    BlinkCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                }
                else
                {
                    ReactionCastingDelayMin  = br.ReadUInt16();
                    ReactionCastingDelayMax  = br.ReadUInt16();
                    BuffCastingDelayMin      = br.ReadUInt16();
                    BuffCastingDelayMax      = br.ReadUInt16();
                    DebuffCastingDelayMin    = br.ReadUInt16();
                    DebuffCastingDelayMax    = br.ReadUInt16();
                    OffensiveCastingDelayMin = br.ReadUInt16();
                    OffensiveCastingDelayMax = br.ReadUInt16();
                    BlinkCastingDelayMin     = br.ReadUInt16();
                    BlinkCastingDelayMax     = br.ReadUInt16();
                }
                if (ParsingRule > 32)
                {
                    LockPathDistance = br.ReadSingle();
                }

                if (ParsingRule >= 33)
                {
                    SpellPowerLevel = br.ReadInt32();
                    AimSkillLevel   = br.ReadSingle();
                    if (ParsingRule < 42)
                    {
                        if (br.ReadInt16() == 0)
                        {
                            Immortal = true;
                        }
                    }
                    if (ParsingRule < 53)
                    {
                        int spellIndex = br.ReadInt32();
                        TrapSpell1 = ThingDb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        TrapSpell2 = ThingDb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        TrapSpell3 = ThingDb.Spells.Values[spellIndex].Name;
                    }
                    else
                    {
                        TrapSpell1 = br.ReadString();
                        TrapSpell2 = br.ReadString();
                        TrapSpell3 = br.ReadString();
                    }
                }
                if (ParsingRule >= 34)
                {
                    string action = br.ReadString();
                    DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action);
                }
                if (ParsingRule >= 41)
                {
                    // large, complex structure dealing with AI-specific data
                    // it is only used on saved games, normally entryType = 4; forced = 0
                    short entryType = br.ReadInt16();
                    if (entryType <= 4)
                    {
                        byte forced = 1;
                        if (entryType >= 2)
                        {
                            forced = br.ReadByte();
                        }
                        if (forced == 1 || entryType < 2)
                        {
                            return(false);
                            // TODO implement for full compatibility
                        }
                    }
                }
                if (ParsingRule >= 42)
                {
                    Immortal = br.ReadBoolean();
                }
                if (ParsingRule >= 43 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.SHOPKEEPER])
                {
                    // Shop contents
                    ShopkeeperInfoStruct si = new ShopkeeperInfoStruct();
                    if (ParsingRule >= 50)
                    {
                        si.BuyValueMultiplier = br.ReadSingle();
                    }
                    if (ParsingRule >= 61)
                    {
                        si.SellValueMultiplier = br.ReadSingle();
                    }
                    if (ParsingRule >= 48)
                    {
                        si.ShopkeeperGreetingText = br.ReadString();
                    }
                    byte items = br.ReadByte();
                    si.ShopItems = new ShopItemInfo[items];
                    for (int i = 0; i < items; i++)
                    {
                        ShopItemInfo item = new ShopItemInfo();
                        if (ParsingRule < 50)
                        {
                            br.ReadInt32();
                        }
                        item.Count = br.ReadByte();
                        item.Name  = br.ReadString();
                        if (ParsingRule >= 47)
                        {
                            item.SpellID = br.ReadString();
                            item.Ench1   = br.ReadString();
                            item.Ench2   = br.ReadString();
                            item.Ench3   = br.ReadString();
                            item.Ench4   = br.ReadString();
                        }
                        si.ShopItems[i] = item;
                    }
                    ShopkeeperInfo = si;
                }
                if (ParsingRule >= 44)
                {
                    MagicNumber = br.ReadUInt32();
                }
                if (ParsingRule >= 45)
                {
                    AddedSubclass = br.ReadUInt32();
                }
                if (ParsingRule >= 49)
                {
                    Health = br.ReadInt16();
                }
                if (ParsingRule >= 51)
                {
                    SetDefaultResumeRatio   = br.ReadBoolean();
                    SetDefaultRetreatRatio  = br.ReadBoolean();
                    SetDefaultMonsterStatus = br.ReadBoolean();
                    LearnDefaultSpells      = br.ReadBoolean();
                }
                if (ParsingRule >= 54 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.FEMALE_NPC])
                {
                    MaidenBodyColors = new Color[6];
                    byte R, G, B;
                    for (int i = 0; i < 6; i++)
                    {
                        R = br.ReadByte();
                        G = br.ReadByte();
                        B = br.ReadByte();
                        MaidenBodyColors[i] = Color.FromArgb(R, G, B);
                    }
                    if (ParsingRule >= 55)
                    {
                        MaidenVoiceSet = br.ReadString();
                    }
                }
                if (ParsingRule >= 62)
                {
                    short entryType = br.ReadInt16();
                    if (entryType > 2 || entryType <= 0)
                    {
                        return(false);
                    }

                    byte count = br.ReadByte();
                    BuffList = new BuffEntry[count];
                    while (count > 0)
                    {
                        BuffEntry be = new BuffEntry();
                        be.Name     = br.ReadString();
                        be.Power    = br.ReadByte();
                        be.Duration = br.ReadInt32();
                        if (be.Name == ENCHANT_SHIELD && entryType >= 2)
                        {
                            be.ShieldHealth = br.ReadInt32();
                        }

                        BuffList[count] = be;
                        count--;
                    }
                    Array.Reverse(BuffList);
                }
                if (ParsingRule >= 63 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC])
                {
                    WoundedNPCVoiceSet = br.ReadString();
                }
                if (ParsingRule >= 64)
                {
                    PoisonLevel = br.ReadByte();
                }
            }
            return(true);
        }
Ejemplo n.º 13
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            Unknown2       = br.ReadBytes(6);
            Unknown7       = br.ReadByte();
            Unknown8       = br.ReadByte();
            LightRadius    = br.ReadInt16();
            NumOfColors    = br.ReadInt32();   //
            LightIntensity = br.ReadInt16();;; //gradient amount 32 00
            R  = br.ReadByte();
            R2 = br.ReadByte();

            UnknownR  = br.ReadByte();
            UnknownR2 = br.ReadByte();

            G         = br.ReadByte();
            G2        = br.ReadByte();
            UnknownG  = br.ReadByte();
            UnknownG2 = br.ReadByte();

            B         = br.ReadByte();
            B2        = br.ReadByte();
            UnknownB  = br.ReadByte();
            UnknownB2 = br.ReadByte();

            UnknownVal = br.ReadBytes(8);

            ChangeIntensity = br.ReadInt16(); // Color change speed 15
            Color1          = br.ReadColor();
            Color2          = br.ReadColor();
            Color3          = br.ReadColor();
            Color4          = br.ReadColor();
            Color5          = br.ReadColor();
            Color6          = br.ReadColor();
            Color7          = br.ReadColor();
            Color8          = br.ReadColor();
            Color9          = br.ReadColor();
            Color10         = br.ReadColor();

            Unknown3 = br.ReadBytes(18);           //-21//39
            ChangeIntensitySingle = br.ReadByte(); //max radius
            Unknown10             = br.ReadByte(); //min radius

            MaxRadius2 = br.ReadByte();
            MinRadius2 = br.ReadByte();

            MaxRadius3 = br.ReadByte();
            MinRadius3 = br.ReadByte();

            MaxRadius4 = br.ReadByte();
            MinRadius4 = br.ReadByte();

            MaxRadius5 = br.ReadByte();
            MinRadius5 = br.ReadByte();

            MaxRadius6 = br.ReadByte();
            MinRadius6 = br.ReadByte();

            MaxRadius7 = br.ReadByte();
            MinRadius7 = br.ReadByte();

            MaxRadius8 = br.ReadByte();
            MinRadius8 = br.ReadByte();

            MaxRadius9 = br.ReadByte();
            MinRadius9 = br.ReadByte();

            MaxRadius10 = br.ReadByte();
            MinRadius10 = br.ReadByte();

            Unknown30        = br.ReadBytes(12);//30
            PulseSpeed       = br.ReadByte();
            Unknown11        = br.ReadByte();
            PulseSpeedSingle = br.ReadByte();
            Unknown4         = br.ReadBytes(11);//13


            Unknown80 = br.ReadByte();
            type      = br.ReadByte();
            Unknown9  = br.ReadBytes(3);
            return(true);
        }