예제 #1
0
        public static Dictionary <short, Npc> ReadNpcSection(BinaryReader reader, QbnHeader header)
        {
            var npcs = new Dictionary <short, Npc>();

            reader.BaseStream.Seek(header.NpcsSectionOffset, 0);
            for (var i = 0; i < header.NpcsSectionCount; i++)
            {
                var index = reader.ReadInt16();

                Npc npc = new Npc
                {
                    Index            = index,
                    Gender           = (Gender)reader.ReadByte(),
                    FacePictureIndex = reader.ReadByte(),
                    NpcTypeRaw       = reader.ReadUInt16(),
                    FactionRaw       = reader.ReadUInt16(),
                    Variable         = "n_" + VariableNames.LookUp(reader.ReadUInt32()),
                    Null1            = reader.ReadUInt32(),
                    TextRecordId1    = reader.ReadUInt16(),
                    TextRecordId2    = reader.ReadUInt16()
                };
                npc.NpcType = (NpcType)npc.NpcTypeRaw;
                npc.Faction = (FactionId)npc.FactionRaw;
                npcs[index] = npc;
            }

            return(npcs);
        }
예제 #2
0
        public static Dictionary <short, Location> ReadLocationSection(BinaryReader reader, QbnHeader header)
        {
            var locations = new Dictionary <short, Location>();

            reader.BaseStream.Seek(header.LocationsSectionOffset, 0);
            for (var i = 0; i < header.LocationsSectionCount; i++)
            {
                var index = reader.ReadInt16();

                Location location = new Location
                {
                    Index           = index,
                    Flags           = reader.ReadByte(),
                    GeneralLocation = (GeneralLocation)reader.ReadByte(),
                    FineLocation    = reader.ReadUInt16(),
                    LocationTypeRaw = reader.ReadInt16(),
                    DoorSelector    = reader.ReadInt16(),
                    Unknown1        = reader.ReadUInt16(),
                    Variable        = "l_" + VariableNames.LookUp(reader.ReadUInt32()),
                    ObjPtr          = reader.ReadUInt32(),
                    TextRecordId1   = reader.ReadUInt16(),
                    TextRecordId2   = reader.ReadUInt16()
                };

                if (location.GeneralLocation == GeneralLocation.Specific)
                {
                    location.LocationType  = LocationType.SpecificLocation;
                    location.KnownLocation = (NamedPlace)location.FineLocation;
                }
                else
                {
                    location.KnownLocation = NamedPlace.None;
                    if (location.FineLocation == 0)
                    {
                        location.LocationType = (LocationType)location.LocationTypeRaw;
                    }
                    else
                    {
                        location.LocationType = (LocationType)location.LocationTypeRaw + 500;
                    }
                }

                locations[index] = location;
            }

            return(locations);
        }
예제 #3
0
        public static Dictionary <short, State> ReadStateSection(BinaryReader reader, QbnHeader header)
        {
            var states = new Dictionary <short, State>();

            reader.BaseStream.Seek(header.StatesSectionOffset, 0);
            for (int i = 0; i < header.StatesSectionCount; i++)
            {
                short index = reader.ReadInt16();

                states[index] = new State
                {
                    Index       = index,
                    IsGlobal    = reader.ReadBoolean(),
                    GlobalIndex = reader.ReadByte(),
                    Variable    = "s_" + VariableNames.LookUp(reader.ReadUInt32())
                };
            }

            return(states);
        }
예제 #4
0
        public static Dictionary <short, Mob> ReadMobSection(BinaryReader reader, QbnHeader header)
        {
            var mobs = new Dictionary <short, Mob>();

            reader.BaseStream.Seek(header.MobsSectionOffset, 0);
            for (var i = 0; i < header.MobsSectionCount; i++)
            {
                short index = reader.ReadByte();

                mobs[index] = new Mob
                {
                    Index    = index,
                    Null1    = reader.ReadUInt16(),
                    Type     = (MobType)reader.ReadByte(),
                    Count    = reader.ReadUInt16(),
                    Variable = "m_" + VariableNames.LookUp(reader.ReadUInt32()),
                    Null2    = reader.ReadUInt32()
                };
            }

            return(mobs);
        }
예제 #5
0
        public static Dictionary <short, Timer> ReadTimerSection(BinaryReader reader, QbnHeader header)
        {
            var timers = new Dictionary <short, Timer>();

            reader.BaseStream.Seek(header.TimersSectionOffset, 0);
            for (var i = 0; i < header.TimersSectionCount; i++)
            {
                var index = reader.ReadInt16();

                Timer timer = new Timer
                {
                    Index    = index,
                    Flags1   = reader.ReadByte(),
                    Flags2   = reader.ReadByte(),
                    TypeRaw  = reader.ReadByte(),
                    Minimum  = reader.ReadInt32(),
                    Maximum  = reader.ReadInt32(),
                    Started  = reader.ReadUInt32(),
                    Duration = reader.ReadUInt32(),
                    Link1    = reader.ReadInt32(),
                    Link2    = reader.ReadInt32(),
                    Variable = "t_" + VariableNames.LookUp(reader.ReadUInt32())
                };
                timer.Type      = (TimerType)timer.TypeRaw;
                timer.Link1Type = ((timer.Flags2 & 0x1) == 0) ? RecordType.Location : RecordType.Npc;
                timer.Link2Type = ((timer.Flags2 & 0x2) == 0) ? RecordType.Location : RecordType.Npc;

                timers[index] = timer;

//                TimeSpan minimum = TimeSpan.FromMinutes(timer.Minimum);
//                TimeSpan maximum = TimeSpan.FromMinutes(timer.Maximum);

//                string binary1 = Convert.ToString(timer.Flags1, 2).PadLeft(8, '0');
//                Console.WriteLine($"{Program.Quest.Name} {Program.Quest.Locations.Count} {Program.Quest.Npcs.Count} {timer.Type} '{binary1}' {timer.Link1Type} {timer.Link1} {timer.Link2Type} {timer.Link2} {minimum} {maximum}");
            }

            return(timers);
        }
예제 #6
0
        public static Dictionary <short, Item> ReadItemSection(BinaryReader reader, QbnHeader header)
        {
            var items = new Dictionary <short, Item>();

            reader.BaseStream.Seek(header.ItemsSectionOffset, 0);
            for (var i = 0; i < header.ItemsSectionCount; i++)
            {
                var index = reader.ReadInt16();

                items[index] = new Item
                {
                    Index         = index,
                    RewardType    = (RewardType)reader.ReadByte(),
                    Category      = (ItemCategory)reader.ReadUInt16(),
                    ItemId        = reader.ReadUInt16(),
                    Variable      = "i_" + VariableNames.LookUp(reader.ReadUInt32()),
                    Unknown1      = reader.ReadUInt32(),
                    TextRecordId1 = reader.ReadUInt16(),
                    TextRecordId2 = reader.ReadUInt16()
                };
            }

            return(items);
        }