Ejemplo n.º 1
0
		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>();
		}
Ejemplo n.º 2
0
		/// <summary>
		/// Returns whether this Looter is entitled to loot anything from the given loot
		/// </summary>
		public bool MayLoot(Loot loot)
		{
			if (m_owner == null)
			{
				return false;
			}

			if (((loot.Looters.Count == 0 || loot.Looters.Contains(this))) ||							// we are one of the initial looters OR:
				 m_owner.GodMode ||
				 (loot.Group != null && m_owner.Group == loot.Group && (								// we are part of the group AND:
					 (loot.FreelyAvailableCount > 0) ||													//	there are freely available items or
					 m_owner.GroupMember == loot.Group.MasterLooter)))									//	this is the MasterLooter
			{
				return true;
			}
			return false;
		}
Ejemplo n.º 3
0
		/// <summary>
		/// Releases the current loot and (maybe) makes it available to everyone else.
		/// </summary>
		public void Release()
		{
			if (m_loot != null)
			{
				if (m_owner != null)
				{
					LootHandler.SendLootReleaseResponse(m_owner, m_loot);
				}

				m_loot.RemoveLooter(this);
				if (m_loot.Looters.Count == 0)
				{
					// last looter released
					m_loot.IsReleased = true;
				}
				Loot = null;
			}
		}
Ejemplo n.º 4
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;
		}
Ejemplo n.º 5
0
		public static void SendMasterList(Character looter, Loot loot)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_MASTER_LIST))
			{
				looter.Client.Send(packet);
			}
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Requires loot to already be generated
		/// </summary>
		/// <param name="lootable"></param>
		public void TryLoot(ILootable lootable)
		{
			Release(); // make sure that the Character is not still looting something else

			var loot = lootable.Loot;
			if (loot == null)
			{
				LootHandler.SendLootFail(m_owner, lootable);
				// TODO: Kneel and unkneel?
			}
			else if (MayLoot(loot))
			{
				// we are either already a looter or become a new one
				m_owner.CancelAllActions();
				Loot = loot;

				LootHandler.SendLootResponse(m_owner, loot);
			}
			else
			{
				LootHandler.SendLootFail(m_owner, lootable);
			}
		}
Ejemplo n.º 7
0
		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);
			}
		}
Ejemplo n.º 8
0
		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);
					}
				}
			}
		}
Ejemplo n.º 9
0
		// TODO: Still unimplemented packets
		public static void SendItemNotify(Character looter, Loot loot)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ITEM_NOTIFY))
			{
				// guid, byte, byte, int, string
				looter.Client.Send(packet);
			}
		}
Ejemplo n.º 10
0
		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);
					}
				}
			}
		}
Ejemplo n.º 11
0
		public static void SendClearMoney(Loot loot)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_CLEAR_MONEY))
			{
				foreach (var looterEntry in loot.Looters)
				{
					if (looterEntry.Owner != null)
					{
						looterEntry.Owner.Client.Send(packet);
					}
				}
			}
		}
Ejemplo n.º 12
0
		public static void SendLootReleaseResponse(Character looter, Loot loot)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_RELEASE_RESPONSE))
			{
				packet.Write(looter.EntityId);
				packet.WriteByte(1);
				looter.Client.Send(packet);
			}
		}
Ejemplo n.º 13
0
		public static void SendLootResponse(Character looter, Loot loot)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_RESPONSE, 14 + (loot.RemainingCount * 22)))
			{
				var looterEntry = looter.LooterEntry;

				packet.Write(loot.Lootable.EntityId);
				packet.Write((byte)loot.ResponseType);
				packet.Write(loot.IsMoneyLooted ? 0 : loot.Money);

				var countPos = packet.Position;
				var count = 0;
				packet.Position++;
				for (var i = 0; i < loot.Items.Length; i++)
				{
					var item = loot.Items[i];
					var templ = item.Template;
					var looters = item.MultiLooters;
					if (!item.Taken &&
						((looters == null && templ.CheckLootConstraints(looter)) ||
						(looters != null && looters.Contains(looterEntry))))
					{
						packet.Write((byte)i);
						packet.Write(templ.Id);
						packet.Write(item.Amount);
						packet.Write(templ.DisplayId);
						packet.Write(templ.RandomSuffixFactor);
						packet.Write(templ.RandomSuffixFactor > 0 ? -(int)templ.RandomSuffixId : (int)templ.RandomPropertiesId);
						packet.Write((byte)item.Decision);
						count++;
					}
				}

				packet.Position = countPos;
				packet.Write((byte)count);

				looter.Client.Send(packet);
			}
		}