GiveItem() public method

Adds item to creature's inventory.
public GiveItem ( Item item ) : bool
item Item
return bool
Exemplo n.º 1
0
		public override void Reward(Creature creature, Quest quest)
		{
			creature.GiveItem(this.ItemId, this.Amount);
			Send.AcquireItemInfo(creature, this.ItemId, this.Amount);
		}
Exemplo n.º 2
0
		/// <summary>
		/// Applies random fountain effect to creature.
		/// </summary>
		/// <param name="creature"></param>
		protected virtual void Touch(Creature creature)
		{
			var rnd = RandomProvider.Get();

			// All notices are unofficial

			switch (rnd.Next(15))
			{
				case 0: // Full Life
					{
						creature.FullLifeHeal();
						Send.Notice(creature, Localization.Get("Full Life"));
						break;
					}

				case 1: // 0 Injuries
					{
						creature.Injuries = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Injuries"));
						break;
					}

				case 2: // Full Stamina
					{
						creature.Stamina = creature.StaminaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Full Stamina"));
						break;
					}

				case 3: // Full Mana
					{
						creature.Mana = creature.ManaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Full Mana"));
						break;
					}

				case 4: // No Hunger
					{
						creature.Hunger = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Hunger"));
						break;
					}

				case 5: // Gold
					{
						creature.GiveItem(Item.CreateGold(rnd.Next(100, 200 + 1)));
						Send.Notice(creature, Localization.Get("Gold"));
						break;
					}

				case 6: // Exp
					{
						creature.GiveExp(1000);
						Send.Notice(creature, Localization.Get("Exp"));
						break;
					}

				case 7: // Bless All
					{
						var items = creature.Inventory.GetEquipment(a => a.IsBlessable);
						creature.Bless(items);
						Send.Notice(creature, Localization.Get("Blessed All"));
						break;
					}

				case 8: // Bless One
					{
						var equip = creature.Inventory.GetEquipment(a => !a.IsBlessed && a.IsBlessable);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						creature.Bless(item);

						Send.Notice(creature, Localization.Get("Blessed {0}"), item.Data.Name);
						break;
					}

				case 9: // Repair One
					{
						var equip = creature.Inventory.GetEquipment(a => a.OptionInfo.Durability != a.OptionInfo.DurabilityMax);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						item.OptionInfo.Durability = item.OptionInfo.DurabilityMax;
						Send.ItemDurabilityUpdate(creature, item);

						Send.Notice(creature, Localization.Get("Repaired {0}"), item.Data.Name);
						break;
					}

				case 10: // No Stamina and Hungry
					{
						creature.Stamina = 0;
						creature.Hunger = creature.StaminaMax;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Stamina and Hungry"));
						break;
					}

				case 11: // Lose one blessing
					{
						var equip = creature.Inventory.GetEquipment(a => a.IsBlessed);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.ElementAt(rnd.Next(count));
						item.OptionInfo.Flags &= ~ItemFlags.Blessed;
						Send.ItemBlessed(creature, item);

						Send.Notice(creature, Localization.Get("Lost blessing on {0}"), item.Data.Name);
						break;
					}

				case 12: // No Stamina
					{
						creature.Stamina = 0;
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("No Stamina"));
						break;
					}

				case 13: // Random Injuries
					{
						creature.Injuries = rnd.Next((int)(creature.Life * 0.9f) + 1);
						Send.StatUpdateDefault(creature);
						Send.Notice(creature, Localization.Get("Random Injuries"));
						break;
					}

				case 14: // Lose one durability on random equip
					{
						var equip = creature.Inventory.GetEquipment(a => a.OptionInfo.Durability >= 1000);
						var count = equip.Count();

						if (count == 0)
							break;

						var item = equip.Random();
						creature.Inventory.ReduceDurability(item, 1000);

						Send.Notice(creature, Localization.Get("Repaired {0}"), item.Data.Name);
						break;
					}
			}
		}