Ejemplo n.º 1
0
		/// <summary>
		/// Handles dropping of items in given collection.
		/// </summary>
		/// <param name="dataCollection"></param>
		private void DropItems(Creature killer, Random rnd, Position pos, IEnumerable<DropData> dataCollection)
		{
			var dropped = new HashSet<int>();
			foreach (var dropData in dataCollection)
			{
				if (dropData == null || !AuraData.ItemDb.Exists(dropData.ItemId))
				{
					Log.Warning("Creature.Kill: Invalid drop '{0}' from '{1}'.", (dropData == null ? "null" : dropData.ItemId.ToString()), this.RaceId);
					continue;
				}

				var dropRate = dropData.Chance;
				var dropChance = rnd.NextDouble() * 100;
				var month = ErinnTime.Now.Month;

				// Add global bonus
				float itemDropBonus;
				string bonuses;
				if (ChannelServer.Instance.GameEventManager.GlobalBonuses.GetBonusMultiplier(GlobalBonusStat.ItemDropRate, out itemDropBonus, out bonuses))
					dropRate *= itemDropBonus;

				// Tuesday: Increase in dungeon item drop rate.
				// Wednesday: Increase in item drop rate from animals and nature.
				// +50%, bonus is unofficial.
				if ((month == ErinnMonth.Baltane && this.Region.IsDungeon) || (month == ErinnMonth.AlbanHeruin && !this.Region.IsDungeon))
					dropRate *= 1.5f;

				// Add conf
				dropRate *= ChannelServer.Instance.Conf.World.DropRate;

				if (dropChance < dropRate)
				{
					// Only drop any item once
					if (dropped.Contains(dropData.ItemId))
						continue;

					var item = new Item(dropData);
					item.ModifyEquipStats(rnd);
					item.Drop(this.Region, pos, Item.DropRadius, killer, false);

					dropped.Add(dropData.ItemId);
				}
			}
		}