コード例 #1
0
ファイル: LootItem.cs プロジェクト: ray2006/WCell
	    /// <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;
		}
コード例 #2
0
ファイル: LootRollProgress.cs プロジェクト: pallmall/WCell
		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>();
		}
コード例 #3
0
ファイル: LootRollProgress.cs プロジェクト: pallmall/WCell
		/// <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;
		}
コード例 #4
0
 /// <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)
 {
 }
コード例 #5
0
ファイル: NPCLoot.cs プロジェクト: KroneckerX/WCell
		public NPCLoot(ILootable looted, uint money, LootItem[] items)
			: base(looted, money, items)
		{
		}
コード例 #6
0
ファイル: LootHandler.cs プロジェクト: remixod/netServer
		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);
					}
				}
			}
		}
コード例 #7
0
ファイル: LootHandler.cs プロジェクト: remixod/netServer
		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);
			}
		}
コード例 #8
0
ファイル: LootHandler.cs プロジェクト: remixod/netServer
		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);
					}
				}
			}
		}
コード例 #9
0
ファイル: Loot.cs プロジェクト: ebakkedahl/WCell
 protected Loot(ILootable looted, uint money, LootItem[] items)
     : this()
 {
     Money = money;
     Items = items;
     Lootable = looted;
 }
コード例 #10
0
ファイル: Loot.cs プロジェクト: ebakkedahl/WCell
        /// <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();
        }
コード例 #11
0
ファイル: Loot.cs プロジェクト: ebakkedahl/WCell
        /// <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);
            }
        }
コード例 #12
0
ファイル: Loot.cs プロジェクト: ebakkedahl/WCell
        /// <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;
        }
コード例 #13
0
ファイル: LootRollProgress.cs プロジェクト: uvbs/Asda2-Server
 /// <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;
 }
コード例 #14
0
ファイル: Loot.cs プロジェクト: NVN/WCell
		/// <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);
			}
		}
コード例 #15
0
 /// <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;
 }
コード例 #16
0
ファイル: NPCLoot.cs プロジェクト: 0xFh/Asda2-Project
 public NPCLoot(ILootable looted, uint money, ItemStackTemplate[] items)
     : base(looted, money, LootItem.Create(items))
 {
 }