Пример #1
0
        // Calls processor of corresponding LootTemplate (which handles everything including references)
        public bool FillLoot(uint lootId, LootStore store, Player lootOwner, bool personal, bool noEmptyError = false, LootModes lootMode = LootModes.Default)
        {
            // Must be provided
            if (lootOwner == null)
            {
                return(false);
            }

            LootTemplate tab = store.GetLootFor(lootId);

            if (tab == null)
            {
                if (!noEmptyError)
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' loot id #{1} used but it doesn't have records.", store.GetName(), lootId);
                }
                return(false);
            }

            _itemContext = lootOwner.GetMap().GetDifficultyLootItemContext();

            tab.Process(this, store.IsRatesAllowed(), (byte)lootMode);          // Processing is done there, callback via Loot.AddItem()

            // Setting access rights for group loot case
            Group group = lootOwner.GetGroup();

            if (!personal && group != null)
            {
                roundRobinPlayer = lootOwner.GetGUID();

                for (GroupReference refe = group.GetFirstMember(); refe != null; refe = refe.next())
                {
                    Player player = refe.GetSource();
                    if (player)   // should actually be looted object instead of lootOwner but looter has to be really close so doesnt really matter
                    {
                        FillNotNormalLootFor(player, player.IsAtGroupRewardDistance(lootOwner));
                    }
                }

                for (byte i = 0; i < items.Count; ++i)
                {
                    ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(items[i].itemid);
                    if (proto != null)
                    {
                        if (proto.GetQuality() < group.GetLootThreshold())
                        {
                            items[i].is_underthreshold = true;
                        }
                    }
                }
            }
            // ... for personal loot
            else
            {
                FillNotNormalLootFor(lootOwner, true);
            }

            return(true);
        }
Пример #2
0
        public void Verify(LootStore lootstore, uint id)
        {
            // Checking group chances
            foreach (var group in Groups)
                    group.Value.Verify(lootstore, id, (byte)(group.Key + 1));

            // @todo References validity checks
        }
Пример #3
0
            public void Verify(LootStore lootstore, uint id, byte group_id = 0)
            {
                float chance = RawTotalChance();
                if (chance > 101.0f)                                    // @todo replace with 100% when DBs will be ready
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} group {2} has total chance > 100% ({3})", lootstore.GetName(), id, group_id, chance);

                if (chance >= 100.0f && !EqualChanced.Empty())
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} group {2} has items with chance=0% but group total chance >= 100% ({3})", lootstore.GetName(), id, group_id, chance);

            }
Пример #4
0
        public bool IsValid(LootStore store, uint entry)
        {
            if (mincount == 0)
            {
                Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: wrong mincount ({3}) - skipped", store.GetName(), entry, itemid, reference);
                return(false);
            }

            if (reference == 0)                                  // item (quest or non-quest) entry, maybe grouped
            {
                ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(itemid);
                if (proto == null)
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: item does not exist - skipped", store.GetName(), entry, itemid);
                    return(false);
                }

                if (chance == 0 && groupid == 0)                      // Zero chance is allowed for grouped entries only
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: equal-chanced grouped entry, but group not defined - skipped", store.GetName(), entry, itemid);
                    return(false);
                }

                if (chance != 0 && chance < 0.000001f)             // loot with low chance
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: low chance ({3}) - skipped",
                                 store.GetName(), entry, itemid, chance);
                    return(false);
                }

                if (maxcount < mincount)                       // wrong max count
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: max count ({3}) less that min count ({4}) - skipped", store.GetName(), entry, itemid, maxcount, reference);
                    return(false);
                }
            }
            else                                                    // mincountOrRef < 0
            {
                if (needs_quest)
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: quest chance will be treated as non-quest chance", store.GetName(), entry, itemid);
                }
                else if (chance == 0)                              // no chance for the reference
                {
                    Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: zero chance is specified for a reference, skipped", store.GetName(), entry, itemid);
                    return(false);
                }
            }
            return(true);                                            // Referenced template existence is checked at whole store level
        }
Пример #5
0
 static void Initialize()
 {
     Creature = new LootStore("creature_loot_template", "creature entry");
     Disenchant = new LootStore("disenchant_loot_template", "item disenchant id");
     Fishing = new LootStore("fishing_loot_template", "area id");
     Gameobject = new LootStore("gameobject_loot_template", "gameobject entry");
     Items = new LootStore("item_loot_template", "item entry");
     Mail = new LootStore("mail_loot_template", "mail template id", false);
     Milling = new LootStore("milling_loot_template", "item entry (herb)");
     Pickpocketing = new LootStore("pickpocketing_loot_template", "creature pickpocket lootid");
     Prospecting = new LootStore("prospecting_loot_template", "item entry (ore)");
     Reference = new LootStore("reference_loot_template", "reference id", false);
     Skinning = new LootStore("skinning_loot_template", "creature skinning id");
     Spell = new LootStore("spell_loot_template", "spell id (random item creating)", false);
 }