Exemplo n.º 1
0
        public static SpellComponentsTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E00000F))
            {
                return((SpellComponentsTable)DatManager.PortalDat.FileCache[0x0E00000F]);
            }
            else
            {
                // Create the datReader for the proper file
                DatReader            datReader = DatManager.PortalDat.GetReaderForFile(0x0E00000F);
                SpellComponentsTable comps     = new SpellComponentsTable();

                comps.FileId = datReader.ReadUInt32();
                uint numComps = datReader.ReadUInt16(); // Should be 163 or 0xA3
                datReader.AlignBoundary();
                // loop through the entire file...
                for (uint i = 0; i < numComps; i++)
                {
                    SpellComponentBase newComp = new SpellComponentBase();
                    uint compId = datReader.ReadUInt32();
                    newComp.Name = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newComp.Category = datReader.ReadUInt32();
                    newComp.Icon     = datReader.ReadUInt32();
                    newComp.Type     = datReader.ReadUInt32();
                    newComp.Gesture  = datReader.ReadUInt32();
                    newComp.Time     = datReader.ReadSingle();
                    newComp.Text     = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newComp.CDM = datReader.ReadSingle();
                    comps.SpellComponents.Add(compId, newComp);
                }

                DatManager.PortalDat.FileCache[0x0E00000F] = comps;
                return(comps);
            }
        }
Exemplo n.º 2
0
        public Generator GetNextGenerator(DatReader datReader)
        {
            Name = datReader.ReadObfuscatedString();
            datReader.AlignBoundary();
            Id    = datReader.ReadInt32();
            Count = datReader.ReadInt32();

            // Console.WriteLine($"{Id:X8} {Count:X8} {Name}");

            for (var i = 0; i < Count; i++)
            {
                var child = new Generator();
                child = child.GetNextGenerator(datReader);
                Items.Add(child);
            }
            return(this);
        }
Exemplo n.º 3
0
        public static SpellTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E00000E))
            {
                return((SpellTable)DatManager.PortalDat.FileCache[0x0E00000E]);
            }
            else
            {
                // Create the datReader for the proper file
                DatReader  datReader = DatManager.PortalDat.GetReaderForFile(0x0E00000E);
                SpellTable spells    = new SpellTable();

                spells.FileId = datReader.ReadUInt32();
                uint spellCount = datReader.ReadUInt16();
                spells.SpellBaseHash = datReader.ReadUInt16();

                for (uint i = 0; i < spellCount; i++)
                {
                    SpellBase newSpell = new SpellBase();
                    uint      spellId  = datReader.ReadUInt32();
                    newSpell.Name = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newSpell.Desc = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newSpell.School            = (MagicSchool)datReader.ReadUInt32();
                    newSpell.Icon              = datReader.ReadUInt32();
                    newSpell.Category          = datReader.ReadUInt32();
                    newSpell.Bitfield          = datReader.ReadUInt32();
                    newSpell.BaseMana          = datReader.ReadUInt32();
                    newSpell.BaseRangeConstant = datReader.ReadSingle();
                    newSpell.BaseRangeMod      = datReader.ReadSingle();
                    newSpell.Power             = datReader.ReadUInt32();
                    newSpell.SpellEconomyMod   = datReader.ReadSingle();
                    newSpell.FormulaVersion    = datReader.ReadUInt32();
                    newSpell.ComponentLoss     = datReader.ReadUInt32();
                    newSpell.MetaSpellType     = (SpellType)datReader.ReadUInt32();
                    newSpell.MetaSpellId       = datReader.ReadUInt32();

                    switch (newSpell.MetaSpellType)
                    {
                    case SpellType.Enchantment:
                    case SpellType.FellowEnchantment:
                    {
                        newSpell.Duration        = datReader.ReadDouble();
                        newSpell.DegradeModifier = datReader.ReadSingle();
                        newSpell.DegradeLimit    = datReader.ReadSingle();
                        break;
                    }

                    case SpellType.PortalSummon:
                    {
                        newSpell.PortalLifetime = datReader.ReadDouble();
                        break;
                    }
                    }

                    // Components : Load them first, then decrypt them. More efficient to hash all at once.
                    List <uint> rawComps = new List <uint>();
                    for (uint j = 0; j < 8; j++)
                    {
                        uint comp = datReader.ReadUInt32();
                        // We will only add the comp if it is valid
                        if (comp > 0)
                        {
                            rawComps.Add(comp);
                        }
                    }
                    // Get the decryped component values
                    newSpell.Formula = DecryptFormula(rawComps, newSpell.Name, newSpell.Desc);

                    newSpell.CasterEffect           = datReader.ReadUInt32();
                    newSpell.TargetEffect           = datReader.ReadUInt32();
                    newSpell.FizzleEffect           = datReader.ReadUInt32();
                    newSpell.RecoveryInterval       = datReader.ReadDouble();
                    newSpell.RecoveryAmount         = datReader.ReadSingle();
                    newSpell.DisplayOrder           = datReader.ReadUInt32();
                    newSpell.NonComponentTargetType = datReader.ReadUInt32();
                    newSpell.ManaMod = datReader.ReadUInt32();

                    spells.Spells.Add(spellId, newSpell);
                }

                DatManager.PortalDat.FileCache[0x0E00000E] = spells;
                return(spells);
            }
        }