Exemple #1
0
        private const uint LOWEST_TAPER_ID = 63; // This is the lowest id in the SpellComponentTable of a taper (Red Taper)

        /// <summary>
        /// Returns the correct spell formula, which is hashed from a player's account name
        /// </summary>
        public static List <uint> GetSpellFormula(SpellTable spellTable, uint spellId, string accountName)
        {
            SpellBase spell = spellTable.Spells[spellId];

            switch (spell.FormulaVersion)
            {
            case 1:
                return(RandomizeVersion1(spell, accountName));

            case 2:
                return(RandomizeVersion2(spell, accountName));

            case 3:
                return(RandomizeVersion3(spell, accountName));

            default:
                return(spell.Formula);
            }
        }
Exemple #2
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);
            }
        }