/// <summary> /// Creates an array of LootItems from the given array of ItemStackDescriptions /// </summary> /// <param name="descs"></param> /// <returns></returns> public static LootItem[] Create(ItemStackTemplate[] descs) { var items = new LootItem[descs.Length]; for (uint i = 0; i < descs.Length; i++) { var desc = descs[i]; items[i] = new LootItem(desc.Template, desc.Amount, i, desc.Template.RandomPropertiesId); } return items; }
public LootRollProgress(Loot loot, LootItem lootItem, ICollection<LooterEntry> looters) { m_loot = loot; m_lootItem = lootItem; m_RemainingParticipants = new List<LooterEntry>(looters.Count); foreach (var looter in looters) { if (looter.Owner.PassOnLoot) continue; m_RemainingParticipants.Add(looter); } m_rolls = new SortedDictionary<LootRollEntry, LooterEntry>(); }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> public void Dispose() { m_lootItem.RollProgress = null; m_loot = null; m_lootItem = null; }
/// <summary>Hands out the given LootItem to the given Character.</summary> /// <remarks>Adds the given container at the given slot or -if not specified- to the next free slot</remarks> /// <param name="chr"></param> /// <param name="lootItem"></param> /// <param name="targetCont"></param> /// <param name="targetSlot"></param> public void HandoutItem(Character chr, LootItem lootItem, BaseInventory targetCont, int targetSlot) { }
public NPCLoot(ILootable looted, uint money, LootItem[] items) : base(looted, money, items) { }
public static void SendRollWon(Character looter, Loot loot, LootItem item, LootRollEntry entry) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ROLL_WON)) { packet.Write(loot.Lootable.EntityId); packet.Write(item.Index); packet.Write(looter.EntityId); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write((int)(item.Template.RandomSuffixFactor > 0 ? -item.Template.RandomSuffixId : item.Template.RandomPropertiesId)); packet.Write(looter.EntityId); packet.Write(entry.Number); packet.Write((int)entry.Type); foreach (var looterEntry in loot.Looters) { if (looterEntry.Owner != null) { looterEntry.Owner.Client.Send(packet); } } } }
public static void SendAllPassed(Character looter, Loot loot, LootItem item) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ALL_PASSED)) { //packet.Write(item.); looter.Client.Send(packet); } }
public static void SendStartRoll(Loot loot, LootItem item, IEnumerable<LooterEntry> looters, MapId mapid) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_START_ROLL)) { packet.Write(loot.Lootable.EntityId); packet.WriteUInt((uint)mapid); // TODO: actually use this packet.Write(item.Index); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write((int)(item.Template.RandomSuffixFactor > 0 ? -item.Template.RandomSuffixId : item.Template.RandomPropertiesId)); packet.Write(LootMgr.DefaultLootRollTimeout); packet.Write((byte)0x0F); // since 3.3: loot roll mask foreach (var looter in looters) { if (looter.Owner != null) { looter.Owner.Client.Send(packet); } } } }
protected Loot(ILootable looted, uint money, LootItem[] items) : this() { Money = money; Items = items; Lootable = looted; }
/// <summary> /// Marks the given Item as taken and removes it from the list of available Items /// </summary> /// <param name="lootItem"></param> public void RemoveItem(LootItem lootItem) { lootItem.Taken = true; m_takenCount++; // TODO: Have correct collection of all observing Characters foreach (var looter in Looters) { if (looter.Owner != null) { LootHandler.SendLootRemoved(looter.Owner, lootItem.Index); } } CheckFinished(); }
/// <summary> /// Hands out the given LootItem to the given Character. /// </summary> /// <remarks>Adds the given container at the given slot or -if not specified- to the next free slot</remarks> /// <param name="chr"></param> /// <param name="lootItem"></param> /// <param name="targetCont"></param> /// <param name="targetSlot"></param> public void HandoutItem(Character chr, LootItem lootItem, BaseInventory targetCont, int targetSlot) { InventoryError err; var multiLooters = lootItem.MultiLooters; int amount; if (targetCont != null) { // specific slot amount = lootItem.Amount; if (!targetCont.IsValidSlot(targetSlot) || targetCont.Items[targetSlot] != null) { // slot is not valid or occupied err = targetCont.TryAdd(lootItem.Template, ref amount, ItemReceptionType.Loot); } else { err = targetCont.TryAdd(lootItem.Template, ref amount, targetSlot, ItemReceptionType.Loot); } } else { // auto loot amount = lootItem.Amount; //err = chr.Inventory.TryAdd(lootItem.Template, ref amount); err = chr.Inventory.TryAdd(lootItem.Template, ref amount, ItemReceptionType.Loot); } if (err == InventoryError.OK) { if (amount < lootItem.Amount && multiLooters == null) { // Only a part of the item stack was added, a part remains // TODO: Amount changed, but amount displayed to looters is still the same (SMSG_LOOT_ITEM_NOTIFY?) lootItem.Amount = amount; } if (multiLooters != null) { multiLooters.Remove(chr.LooterEntry); } if (multiLooters == null || multiLooters.Count == 0) { RemoveItem(lootItem); } chr.Achievements.CheckPossibleAchievementUpdates(Constants.Achievements.AchievementCriteriaType.LootItem, (uint)lootItem.Template.ItemId, (uint)lootItem.Amount); } else { ItemHandler.SendInventoryError(chr.Client, null, null, err); } }
/// <summary> /// Returns whether the given looter may loot the given Item. /// Make sure the Looter is logged in before calling this Method. /// /// TODO: Find the right error messages /// TODO: Only give every MultiLoot item to everyone once! Also check for quest-dependencies etc. /// </summary> public InventoryError CheckTakeItemConditions(LooterEntry looter, LootItem item) { if (item.Taken) { return InventoryError.ALREADY_LOOTED; } if (item.RollProgress != null) { // TODO: Still being rolled for return InventoryError.DONT_OWN_THAT_ITEM; } if (!looter.MayLoot(this)) { return InventoryError.DontReport; } var multiLooters = item.MultiLooters; if (multiLooters != null) { if (!multiLooters.Contains(looter)) { if (looter.Owner != null) { // make sure, Item cannot be seen by client anymore LootHandler.SendLootRemoved(looter.Owner, item.Index); } return InventoryError.DONT_OWN_THAT_ITEM; } return InventoryError.OK; } if (!item.Template.CheckLootConstraints(looter.Owner)) { return InventoryError.DONT_OWN_THAT_ITEM; } if (Method != LootMethod.FreeForAll) { // definitely Group-Loot if ((item.Template.Quality > Group.LootThreshold && !item.Passed) || (Group.MasterLooter != null && Group.MasterLooter != looter.Owner.GroupMember)) { return InventoryError.DONT_OWN_THAT_ITEM; } } return InventoryError.OK; }
/// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. /// </summary> /// <filterpriority>2</filterpriority> public void Dispose() { this.m_lootItem.RollProgress = (LootRollProgress)null; this.m_loot = (Loot)null; this.m_lootItem = (LootItem)null; }
/// <summary> /// Hands out the given LootItem to the given Character. /// </summary> /// <remarks>Adds the given container at the given slot or -if not specified- to the next free slot</remarks> /// <param name="chr"></param> /// <param name="lootItem"></param> /// <param name="targetCont"></param> /// <param name="targetSlot"></param> public void HandoutItem(Character chr, LootItem lootItem, BaseInventory targetCont, int targetSlot) { InventoryError err; var multiLooters = lootItem.MultiLooters; int amount; if (targetCont != null) { // specific slot amount = lootItem.Amount; if (!targetCont.IsValidSlot(targetSlot)) { err = targetCont.TryAdd(lootItem.Template, ref amount, true); } else { err = targetCont.TryAdd(lootItem.Template, ref amount, targetSlot, true); } } else { // auto loot amount = lootItem.Amount; //err = chr.Inventory.TryAdd(lootItem.Template, ref amount); err = chr.Inventory.TryAdd(lootItem.Template, ref amount); } if (err == InventoryError.OK) { if (amount < lootItem.Amount && multiLooters == null) { // Only a part of the item stack was added, a part remains // TODO: Amount changed, but amount displayed to looters is still the same (SMSG_LOOT_ITEM_NOTIFY?) lootItem.Amount = amount; } if (multiLooters != null) { multiLooters.Remove(chr.LooterEntry); } if (multiLooters == null || multiLooters.Count == 0) { RemoveItem(lootItem); } } else { ItemHandler.SendInventoryError(chr.Client, null, null, err); } }
public NPCLoot(ILootable looted, uint money, ItemStackTemplate[] items) : base(looted, money, LootItem.Create(items)) { }