コード例 #1
0
ファイル: SpellBase.cs プロジェクト: paroxysmal/ACE
        private const uint HIGHEST_COMP_ID = 198; // "Essence of Kemeroi", for Void Spells -- not actually ever in game!

        /// <summary>
        /// Does the math based on the crypto keys (name and description) for the spell formula.
        /// </summary>
        private static List <uint> DecryptFormula(List <uint> rawComps, string name, string desc)
        {
            List <uint> comps = new List <uint>();

            // uint testDescHash = ComputeHash(" – 200");
            uint nameHash = SpellTable.ComputeHash(name);
            uint descHash = SpellTable.ComputeHash(desc);

            uint key = (nameHash % 0x12107680) + (descHash % 0xBEADCF45);

            for (int i = 0; i < rawComps.Count; i++)
            {
                uint comp = (rawComps[i] - key);

                // This seems to correct issues with certain spells with extended characters.
                if (comp > HIGHEST_COMP_ID) // highest comp ID is 198 - "Essence of Kemeroi", for Void Spells
                {
                    comp = comp & 0xFF;
                }

                comps.Add(comp);
            }

            return(comps);
        }
コード例 #2
0
        public string GetTitle(CharacterTitle title)
        {
            var titleEnums = DatManager.PortalDat.ReadFromDat <EnumMapper>(EnumMapper_CharacterTitle_FileID);

            if (!titleEnums.IdToStringMap.TryGetValue((uint)title, out var titleEnum))
            {
                return(null);
            }

            var hash = SpellTable.ComputeHash(titleEnum);

            var entry = DatManager.LanguageDat.CharacterTitles.StringTableData.FirstOrDefault(i => i.Id == hash);

            if (entry == null)
            {
                return(null);
            }

            return(entry.Strings.FirstOrDefault());
        }