Exemple #1
0
        // loads the perfection proc info from DB
        public static void LoadSkillPerfectItemTable()
        {
            uint oldMSTime = Time.GetMSTime();

            SkillPerfectItemStorage.Clear(); // reload capability

            //                                                  0               1                      2                  3
            SQLResult result = DB.World.Query("SELECT spellId, requiredSpecialization, perfectCreateChance, perfectItemType FROM skill_perfect_item_template");

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 spell perfection definitions. DB table `skill_perfect_item_template` is empty.");
                return;
            }

            uint count = 0;

            do
            {
                uint spellId = result.Read <uint>(0);
                if (!Global.SpellMgr.HasSpellInfo(spellId, Framework.Constants.Difficulty.None))
                {
                    Log.outError(LogFilter.Sql, "Skill perfection data for spell {0} has non-existent spell id in `skill_perfect_item_template`!", spellId);
                    continue;
                }

                uint requiredSpecialization = result.Read <uint>(1);
                if (!Global.SpellMgr.HasSpellInfo(requiredSpecialization, Framework.Constants.Difficulty.None))
                {
                    Log.outError(LogFilter.Sql, "Skill perfection data for spell {0} has non-existent required specialization spell id {1} in `skill_perfect_item_template`!", spellId, requiredSpecialization);
                    continue;
                }

                float perfectCreateChance = result.Read <float>(2);
                if (perfectCreateChance <= 0.0f)
                {
                    Log.outError(LogFilter.Sql, "Skill perfection data for spell {0} has impossibly low proc chance in `skill_perfect_item_template`!", spellId);
                    continue;
                }

                uint perfectItemType = result.Read <uint>(3);
                if (Global.ObjectMgr.GetItemTemplate(perfectItemType) == null)
                {
                    Log.outError(LogFilter.Sql, "Skill perfection data for spell {0} references non-existent perfect item id {1} in `skill_perfect_item_template`!", spellId, perfectItemType);
                    continue;
                }

                SkillPerfectItemStorage[spellId] = new SkillPerfectItemEntry(requiredSpecialization, perfectCreateChance, perfectItemType);

                ++count;
            }while (result.NextRow());

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} spell perfection definitions in {1} ms", count, Time.GetMSTimeDiffToNow(oldMSTime));
        }
Exemple #2
0
        public static bool CanCreatePerfectItem(Player player, uint spellId, ref float perfectCreateChance, ref uint perfectItemType)
        {
            var entry = SkillPerfectItemStorage.LookupByKey(spellId);

            // no entry in DB means no perfection proc possible
            if (entry == null)
            {
                return(false);
            }

            // if you don't have the spell needed, then no procs for you
            if (!player.HasSpell(entry.requiredSpecialization))
            {
                return(false);
            }

            // set values as appropriate
            perfectCreateChance = entry.perfectCreateChance;
            perfectItemType     = entry.perfectItemType;

            // and tell the caller to start rolling the dice
            return(true);
        }