public void BuildLootResponse(LootResponse packet, Player viewer, PermissionTypes permission) { if (permission == PermissionTypes.None) { return; } packet.Coins = gold; switch (permission) { case PermissionTypes.Group: case PermissionTypes.Master: case PermissionTypes.Restricted: { // if you are not the round-robin group looter, you can only see // blocked rolled items and quest items, and !ffa items for (byte i = 0; i < items.Count; ++i) { if (!items[i].is_looted && !items[i].freeforall && items[i].conditions.Empty() && items[i].AllowedForPlayer(viewer)) { LootSlotType slot_type; if (items[i].is_blocked) // for ML & restricted is_blocked = !is_underthreshold { switch (permission) { case PermissionTypes.Group: slot_type = LootSlotType.RollOngoing; break; case PermissionTypes.Master: { if (viewer.GetGroup() && viewer.GetGroup().GetMasterLooterGuid() == viewer.GetGUID()) { slot_type = LootSlotType.Master; } else { slot_type = LootSlotType.Locked; } break; } case PermissionTypes.Restricted: slot_type = LootSlotType.Locked; break; default: continue; } } else if (roundRobinPlayer.IsEmpty() || viewer.GetGUID() == roundRobinPlayer || !items[i].is_underthreshold) { // no round robin owner or he has released the loot // or it IS the round robin group owner // => item is lootable slot_type = LootSlotType.AllowLoot; } else { // item shall not be displayed. continue; } LootItemData lootItem = new LootItemData(); lootItem.LootListID = (byte)(i + 1); lootItem.UIType = slot_type; lootItem.Quantity = items[i].count; lootItem.Loot = new ItemInstance(items[i]); packet.Items.Add(lootItem); } } break; } case PermissionTypes.All: case PermissionTypes.Owner: { for (byte i = 0; i < items.Count; ++i) { if (!items[i].is_looted && !items[i].freeforall && items[i].conditions.Empty() && items[i].AllowedForPlayer(viewer)) { LootItemData lootItem = new LootItemData(); lootItem.LootListID = (byte)(i + 1); lootItem.UIType = (permission == PermissionTypes.Owner ? LootSlotType.Owner : LootSlotType.AllowLoot); lootItem.Quantity = items[i].count; lootItem.Loot = new ItemInstance(items[i]); packet.Items.Add(lootItem); } } break; } default: return; } LootSlotType slotType = permission == PermissionTypes.Owner ? LootSlotType.Owner : LootSlotType.AllowLoot; var lootPlayerQuestItems = GetPlayerQuestItems(); var q_list = lootPlayerQuestItems.LookupByKey(viewer.GetGUID()); if (!q_list.Empty()) { for (var i = 0; i < q_list.Count; ++i) { QuestItem qi = q_list[i]; LootItem item = quest_items[qi.index]; if (!qi.is_looted && !item.is_looted) { LootItemData lootItem = new LootItemData(); lootItem.LootListID = (byte)(items.Count + i + 1); lootItem.Quantity = item.count; lootItem.Loot = new ItemInstance(item); if (item.follow_loot_rules) { switch (permission) { case PermissionTypes.Master: lootItem.UIType = LootSlotType.Master; break; case PermissionTypes.Restricted: lootItem.UIType = item.is_blocked ? LootSlotType.Locked : LootSlotType.AllowLoot; break; case PermissionTypes.Group: if (!item.is_blocked) { lootItem.UIType = LootSlotType.AllowLoot; } else { lootItem.UIType = LootSlotType.RollOngoing; } break; default: lootItem.UIType = slotType; break; } } else { lootItem.UIType = slotType; } packet.Items.Add(lootItem); } } } var lootPlayerFFAItems = GetPlayerFFAItems(); var ffa_list = lootPlayerFFAItems.LookupByKey(viewer.GetGUID()); if (!ffa_list.Empty()) { foreach (var fi in ffa_list) { LootItem item = items[fi.index]; if (!fi.is_looted && !item.is_looted) { LootItemData lootItem = new LootItemData(); lootItem.LootListID = (byte)(fi.index + 1); lootItem.UIType = slotType; lootItem.Quantity = item.count; lootItem.Loot = new ItemInstance(item); packet.Items.Add(lootItem); } } } var lootPlayerNonQuestNonFFAConditionalItems = GetPlayerNonQuestNonFFAConditionalItems(); var conditional_list = lootPlayerNonQuestNonFFAConditionalItems.LookupByKey(viewer.GetGUID()); if (!conditional_list.Empty()) { foreach (var ci in conditional_list) { LootItem item = items[ci.index]; if (!ci.is_looted && !item.is_looted) { LootItemData lootItem = new LootItemData(); lootItem.LootListID = (byte)(ci.index + 1); lootItem.Quantity = item.count; lootItem.Loot = new ItemInstance(item); if (item.follow_loot_rules) { switch (permission) { case PermissionTypes.Master: lootItem.UIType = LootSlotType.Master; break; case PermissionTypes.Restricted: lootItem.UIType = item.is_blocked ? LootSlotType.Locked : LootSlotType.AllowLoot; break; case PermissionTypes.Group: if (!item.is_blocked) { lootItem.UIType = LootSlotType.AllowLoot; } else { lootItem.UIType = LootSlotType.RollOngoing; } break; default: lootItem.UIType = slotType; break; } } else { lootItem.UIType = slotType; } packet.Items.Add(lootItem); } } } }
public LootItem LootItemInSlot(uint lootSlot, Player player, out QuestItem qitem, out QuestItem ffaitem, out QuestItem conditem) { qitem = null; ffaitem = null; conditem = null; LootItem item = null; bool is_looted = true; if (lootSlot >= items.Count) { uint questSlot = (uint)(lootSlot - items.Count); var questItems = PlayerQuestItems.LookupByKey(player.GetGUID()); if (!questItems.Empty()) { QuestItem qitem2 = questItems.Find(p => p.index == questSlot); if (qitem2 != null) { qitem = qitem2; item = quest_items[qitem2.index]; is_looted = qitem2.is_looted; } } } else { item = items[(int)lootSlot]; is_looted = item.is_looted; if (item.freeforall) { var questItemList = PlayerFFAItems.LookupByKey(player.GetGUID()); if (!questItemList.Empty()) { foreach (var c in questItemList) { if (c.index == lootSlot) { QuestItem ffaitem2 = c; ffaitem = ffaitem2; is_looted = ffaitem2.is_looted; break; } } } } else if (!item.conditions.Empty()) { var questItemList = PlayerNonQuestNonFFAConditionalItems.LookupByKey(player.GetGUID()); if (!questItemList.Empty()) { foreach (var iter in questItemList) { if (iter.index == lootSlot) { QuestItem conditem2 = iter; conditem = conditem2; is_looted = conditem2.is_looted; break; } } } } } if (is_looted) { return(null); } return(item); }