public void AddEntry(LootStoreItem item) { if (item.chance != 0) ExplicitlyChanced.Add(item); else EqualChanced.Add(item); }
public void Process(Loot loot, ushort lootMode) { LootStoreItem item = Roll(loot, lootMode); if (item != null) { loot.AddItem(item); } }
uint LoadLootTable() { // Clearing store (for reloading case) Clear(); // 0 1 2 3 4 5 6 7 8 SQLResult result = DB.World.Query("SELECT Entry, Item, Reference, Chance, QuestRequired, LootMode, GroupId, MinCount, MaxCount FROM {0}", GetName()); if (result.IsEmpty()) { return(0); } uint count = 0; do { uint entry = result.Read <uint>(0); uint item = result.Read <uint>(1); uint reference = result.Read <uint>(2); float chance = result.Read <float>(3); bool needsquest = result.Read <bool>(4); ushort lootmode = result.Read <ushort>(5); byte groupid = result.Read <byte>(6); byte mincount = result.Read <byte>(7); byte maxcount = result.Read <byte>(8); if (groupid >= 1 << 7) // it stored in 7 bit field { Log.outError(LogFilter.Sql, "Table '{0}' entry {1} item {2}: group ({3}) must be less {4} - skipped", GetName(), entry, item, groupid, 1 << 7); return(0); } LootStoreItem storeitem = new LootStoreItem(item, reference, chance, needsquest, lootmode, groupid, mincount, maxcount); if (!storeitem.IsValid(this, entry)) // Validity checks { continue; } // Looking for the template of the entry // often entries are put together if (m_LootTemplates.Empty() || !m_LootTemplates.ContainsKey(entry)) { m_LootTemplates.Add(entry, new LootTemplate()); } // Adds current row to the template m_LootTemplates[entry].AddEntry(storeitem); ++count; }while (result.NextRow()); Verify(); // Checks validity of the loot store return(count); }
public void AddEntry(LootStoreItem item) { if (item.groupid > 0 && item.reference == 0) // Group { if (!Groups.ContainsKey(item.groupid - 1)) Groups[item.groupid - 1] = new LootGroup(); Groups[item.groupid - 1].AddEntry(item); // Adds new entry to the group } else // Non-grouped entries and references are stored together Entries.Add(item); }
public bool Check(LootStoreItem item) { if (!Convert.ToBoolean(item.lootmode & _lootMode)) return true; byte foundDuplicates = 0; foreach (var lootItem in _loot.items) if (lootItem.itemid == item.itemid) if (++foundDuplicates == _loot.maxDuplicates) return true; return false; }
public LootItem(LootStoreItem li) { itemid = li.itemid; conditions = li.conditions; ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(itemid); freeforall = proto != null && proto.GetFlags().HasAnyFlag(ItemFlags.MultiDrop); follow_loot_rules = proto != null && proto.FlagsCu.HasAnyFlag(ItemFlagsCustom.FollowLootRules); needs_quest = li.needs_quest; randomBonusListId = ItemEnchantmentManager.GenerateItemRandomBonusListId(itemid); }
public LootItem(LootStoreItem li) { itemid = li.itemid; conditions = li.conditions; ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(itemid); freeforall = proto != null && proto.GetFlags().HasAnyFlag(ItemFlags.MultiDrop); follow_loot_rules = proto != null && proto.FlagsCu.HasAnyFlag(ItemFlagsCustom.FollowLootRules); needs_quest = li.needs_quest; randomSuffix = ItemEnchantment.GenerateEnchSuffixFactor(itemid); randomPropertyId = ItemEnchantment.GenerateItemRandomPropertyId(itemid); upgradeId = Global.DB2Mgr.GetRulesetItemUpgrade(itemid); canSave = true; }
public bool Check(LootStoreItem item) { if (!Convert.ToBoolean(item.lootmode & _lootMode)) { return(true); } byte foundDuplicates = 0; foreach (var lootItem in _loot.items) { if (lootItem.itemid == item.itemid) { if (++foundDuplicates == _loot.maxDuplicates) { return(true); } } } return(false); }
// Inserts the item into the loot (called by LootTemplate processors) public void AddItem(LootStoreItem item) { ItemTemplate proto = Global.ObjectMgr.GetItemTemplate(item.itemid); if (proto == null) { return; } uint count = RandomHelper.URand(item.mincount, item.maxcount); uint stacks = (uint)(count / proto.GetMaxStackSize() + (Convert.ToBoolean(count % proto.GetMaxStackSize()) ? 1 : 0)); List <LootItem> lootItems = item.needs_quest ? quest_items : items; uint limit = (uint)(item.needs_quest ? SharedConst.MaxNRQuestItems : SharedConst.MaxNRLootItems); for (uint i = 0; i < stacks && lootItems.Count < limit; ++i) { LootItem generatedLoot = new LootItem(item); generatedLoot.context = _itemContext; generatedLoot.count = (byte)Math.Min(count, proto.GetMaxStackSize()); if (_itemContext != 0) { List <uint> bonusListIDs = Global.DB2Mgr.GetItemBonusTree(generatedLoot.itemid, _itemContext); generatedLoot.BonusListIDs.AddRange(bonusListIDs); } lootItems.Add(generatedLoot); count -= proto.GetMaxStackSize(); // non-conditional one-player only items are counted here, // free for all items are counted in FillFFALoot(), // non-ffa conditionals are counted in FillNonQuestNonFFAConditionalLoot() if (!item.needs_quest && item.conditions.Empty() && !proto.GetFlags().HasAnyFlag(ItemFlags.MultiDrop)) { ++unlootedCount; } } }