コード例 #1
0
		protected override void OnTarget( Mobile from, object targeted )
		{
			if ( m_Item.Deleted )
				return;

			if ( targeted is ICarvable )
			{
				((ICarvable)targeted).Carve( from, m_Item );
			}
			else
			{
				HarvestSystem system = Lumberjacking.System;
				HarvestDefinition def = Lumberjacking.System.Definition;

				int tileID;
				Map map;
				Point3D loc;

				if ( !system.GetHarvestDetails( from, m_Item, targeted, out tileID, out map, out loc ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else if ( !def.Validate( tileID ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else
				{
					HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

					if ( bank == null )
						return;

					if ( bank.Current < 5 )
					{
						from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
					}
					else
					{
						bank.Consume( 5, from );

						Item item = new Kindling();

						if ( from.PlaceInBackpack( item ) )
						{
							from.SendLocalizedMessage( 500491 ); // You put some kindling into your backpack.
							from.SendLocalizedMessage( 500492 ); // An axe would probably get you more wood.
						}
						else
						{
							from.SendLocalizedMessage( 500490 ); // You can't place any kindling into your backpack!

							item.Delete();
						}
					}
				}
			}
		}
コード例 #2
0
ファイル: BladedItemTarget.cs プロジェクト: nathanvy/runuo
        protected override void OnTarget( Mobile from, object targeted )
        {
            if ( m_Item.Deleted )
                return;

            if ( targeted is ICarvable )
            {
                ((ICarvable)targeted).Carve( from, m_Item );
            }
            else if ( targeted is SwampDragon && ((SwampDragon)targeted).HasBarding )
            {
                SwampDragon pet = (SwampDragon)targeted;

                if ( !pet.Controlled || pet.ControlMaster != from )
                    from.SendLocalizedMessage( 1053022 ); // You cannot remove barding from a swamp dragon you do not own.
                else
                    pet.HasBarding = false;
            }
            else
            {
                if ( targeted is StaticTarget )
                {
                    int itemID = ((StaticTarget)targeted).ItemID;

                    if ( itemID == 0xD15 || itemID == 0xD16 ) // red mushroom
                    {
                        PlayerMobile player = from as PlayerMobile;

                        if ( player != null )
                        {
                            QuestSystem qs = player.Quest;

                            if ( qs is WitchApprenticeQuest )
                            {
                                FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;

                                if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.RedMushrooms )
                                {
                                    player.SendLocalizedMessage( 1055036 ); // You slice a red cap mushroom from its stem.
                                    obj.Complete();
                                    return;
                                }
                            }
                        }
                    }
                }

                HarvestSystem system = Lumberjacking.System;
                HarvestDefinition def = Lumberjacking.System.Definition;

                int tileID;
                Map map;
                Point3D loc;

                if ( !system.GetHarvestDetails( from, m_Item, targeted, out tileID, out map, out loc ) )
                {
                    from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
                }
                else if ( !def.Validate( tileID ) )
                {
                    from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
                }
                else
                {
                    HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

                    if ( bank == null )
                        return;

                    if ( bank.Current < 5 )
                    {
                        from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
                    }
                    else
                    {
                        bank.Consume( 5, from );

                        Item item = new Kindling();

                        if ( from.PlaceInBackpack( item ) )
                        {
                            from.SendLocalizedMessage( 500491 ); // You put some kindling into your backpack.
                            from.SendLocalizedMessage( 500492 ); // An axe would probably get you more wood.
                        }
                        else
                        {
                            from.SendLocalizedMessage( 500490 ); // You can't place any kindling into your backpack!

                            item.Delete();
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: ChristmasItems.cs プロジェクト: Godkong/Origins
        public GiftBag(bool nice)
        {
            Item item = null;

            Hue = Utility.RandomList(32, 77, 2301);

            if (nice)
            {
                Name = "Happy Holidays!";
                DropItem(MakeNewbie(new WristWatch()));
                if (Utility.RandomBool())
                {
                    item = new Cake() { ItemID = 4164 };
                    item.Hue = 432;
                    item.Name = "fruit cake";
                    DropItem(MakeNewbie(item));
                }
                else
                {
                    DropItem(MakeNewbie(new Pizza()));
                }

                if (Utility.RandomBool())
                    DropItem(MakeNewbie(new BeverageBottle(BeverageType.Champagne)));
                else
                    DropItem(MakeNewbie(new BeverageBottle(BeverageType.Eggnog)));

                DropItem(MakeNewbie(new Dates()));

                item = new Goblet();
                item.Name = "a champagne glass";
                item.Hue = Utility.RandomList(77, 34);
                DropItem(MakeNewbie(item));

                /*item = new Goblet();
                item.Name = "a champagne glass";
                item.Hue = 34;
                DropItem(MakeNewbie(item));*/

                DropItem(MakeNewbie(new FireworksWand(100)));

                item = new Item(5359);
                item.Hue = Utility.RandomList(32, 77, 2301);
                item.Name = "Seasons Greetings";
                DropItem(MakeNewbie(item));
            }
            else
            {
                Name = "You were naughty this year!";

                DropItem(MakeNewbie(new Cake() { ItemID = 4164, Name = "spam" })); // spam

                DropItem(MakeNewbie(new Coal()));

                item = new Kindling();
                item.Name = "switches";
                DropItem(item); // not newbied...

                item = new Item(5359);
                item.Hue = Utility.RandomList(32, 77, 2301);
                item.Name = "Maybe next year you will get a nicer gift.";
                DropItem(MakeNewbie(item));
            }
        }
コード例 #4
0
		protected override void OnTarget( Mobile from, object targeted )
		{
			if ( m_Item.Deleted )
				return;

			if ( targeted is ICarvable )
			{
				((ICarvable)targeted).Carve( from, m_Item );
			}
			else if ( targeted is SwampDragon && ((SwampDragon)targeted).HasBarding )
			{
				SwampDragon pet = (SwampDragon)targeted;

				if ( !pet.Controlled || pet.ControlMaster != from )
					from.SendLocalizedMessage( 1053022 ); // You cannot remove barding from a swamp dragon you do not own.
				else
					pet.HasBarding = false;
			}
            else if (targeted is Head)
            {
                Head targ = (Head)targeted;

                if (from.Karma > - 1500)
                {
                    from.SendMessage("Vous n'avez pas le profil d'un dépeceur de crâne...");
                    return;
                }

                if (from.Dex <= Utility.Random(110))
                {
                    from.SendMessage("Vous avez été trop maladroit et avez raté le dépeçage");
                    targ.Delete();
                    return;
                }

                from.SendMessage("Vous achevez d'enlever la chair du crâne.");
                from.AddToBackpack(new Skull());
                targ.Consume();
            }
            else if (targeted is Pumpkin)
            {
                Pumpkin targ = (Pumpkin)targeted;

                if(from.Dex <= Utility.Random(100))
                {
                    from.SendMessage("Vous avez été trop maladroit et avez raté votre tracé");
                    targ.Consume();
                    return;
                }

                int karma= 0;

                if (from.Karma > 100)
                    karma ++;
                else if (from.Karma < -100)
                    karma --;
                
                int chance = Utility.Random(4) + karma;

                if (chance >=2)
                    from.AddToBackpack(new SmileyPumpkin());
                else
                    from.AddToBackpack(new EvilPumpkin());

                from.SendMessage("Vous taillez la citrouille selon votre humeur");
                targ.Consume();
            }
			else
			{
				if ( targeted is StaticTarget )
				{
					int itemID = ((StaticTarget)targeted).ItemID;

					if ( itemID == 0xD15 || itemID == 0xD16 ) // red mushroom
					{
						PlayerMobile player = from as PlayerMobile;

						if ( player != null )
						{
							QuestSystem qs = player.Quest;

							if ( qs is WitchApprenticeQuest )
							{
								FindIngredientObjective obj = qs.FindObjective( typeof( FindIngredientObjective ) ) as FindIngredientObjective;

								if ( obj != null && !obj.Completed && obj.Ingredient == Ingredient.RedMushrooms )
								{
									player.SendLocalizedMessage( 1055036 ); // You slice a red cap mushroom from its stem.
									obj.Complete();
									return;
								}
							}
						}
					}
				}

				HarvestSystem system = Lumberjacking.System;
				HarvestDefinition def = Lumberjacking.System.Definition;

				int tileID;
				Map map;
				Point3D loc;

				if ( !system.GetHarvestDetails( from, m_Item, targeted, out tileID, out map, out loc ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else if ( !def.Validate( tileID ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else
				{
					HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

					if ( bank == null )
						return;

					if ( bank.Current < 5 )
					{
						from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
					}
					else
					{
						bank.Consume( 5, from );

                        if (map.Season == (int)ServerSeasons.Season.Spring && Utility.RandomDouble() < 0.33)
                        {
                            from.PrivateOverheadMessage(Network.MessageType.Regular, 0x3B2, false, "De la sève se met à couler du tronc, souhaitez-vous la recueillir?", from.NetState);
                            from.BeginTarget(2, false, TargetFlags.None, new TargetCallback(OnSelectTarget));
                            return;
                        }

						Item item = new Kindling();

						if ( from.PlaceInBackpack( item ) )
						{
							from.SendLocalizedMessage( 500491 ); // You put some kindling into your backpack.
							from.SendLocalizedMessage( 500492 ); // An axe would probably get you more wood.
						}
						else
						{
							from.SendLocalizedMessage( 500490 ); // You can't place any kindling into your backpack!

							item.Delete();
						}
					}
				}
			}
		}
コード例 #5
0
        protected override void OnTarget( Mobile from, object targeted )
        {
            if ( m_Item.Deleted )
                return;

            if (m_Item is Dagger && targeted is Dagger && m_Item != targeted)
            {
                Dagger m_Hilt = m_Item as Dagger;
                Dagger m_Blade = targeted as Dagger;
                DualDaggers weapon = new DualDaggers();
                weapon.NewCrafting = true;
                weapon.QualityDamage = (int)(m_Hilt.QualityDamage * 0.5 + m_Blade.QualityDamage * 0.5);
                weapon.QualitySpeed = (int)(m_Hilt.QualitySpeed * 0.5 + m_Blade.QualitySpeed * 0.5);
                weapon.QualityAccuracy = (int)(m_Hilt.QualityAccuracy * 0.5 + m_Blade.QualityAccuracy * 0.5);
                weapon.QualityDefense = (int)(m_Hilt.QualityDefense * 0.5 + m_Blade.QualityDefense * 0.5);
                weapon.Resource = m_Hilt.Resource;
                int quality = (int)(m_Blade.MaxHitPoints * 0.5 + m_Hilt.MaxHitPoints * 0.5);
                weapon.MaxHitPoints = quality;
                quality = (int)(m_Blade.HitPoints * 0.5 + m_Hilt.HitPoints * 0.5);
                weapon.HitPoints = quality;
                weapon.Crafter = from;
                weapon.CraftersOriginalName = from.Name;
                quality = (int)(((int)m_Blade.Quality * 50) * 0.5 + ((int)m_Hilt.Quality * 50) * 0.5);
                if (quality == 500)
                    weapon.Quality = WeaponQuality.Legendary;
                if (quality < 500)
                    weapon.Quality = WeaponQuality.Masterwork;
                if (quality < 450)
                    weapon.Quality = WeaponQuality.Illustrious;
                if (quality < 400)
                    weapon.Quality = WeaponQuality.Extraordinary;
                if (quality < 350)
                    weapon.Quality = WeaponQuality.Remarkable;
                if (quality < 300)
                    weapon.Quality = WeaponQuality.Exceptional;
                if (quality < 250)
                    weapon.Quality = WeaponQuality.Superior;
                if (quality < 200)
                    weapon.Quality = WeaponQuality.Regular;
                if (quality < 150)
                    weapon.Quality = WeaponQuality.Inferior;
                if (quality < 100)
                    weapon.Quality = WeaponQuality.Low;
                if (quality < 50)
                    weapon.Quality = WeaponQuality.Poor;
                weapon.BetaNerf = true;
                weapon.InvalidateProperties();
                from.AddToBackpack(weapon);
                weapon.AddItem(m_Blade);
                weapon.AddItem(m_Hilt);
            }

            if (m_Item is HandScythe && targeted is HandScythe && m_Item != targeted)
            {
                HandScythe m_Hilt = m_Item as HandScythe;
                HandScythe m_Blade = targeted as HandScythe;
                DualPicks weapon = new DualPicks();
                weapon.NewCrafting = true;
                weapon.QualityDamage = (int)(m_Hilt.QualityDamage * 0.5 + m_Blade.QualityDamage * 0.5);
                weapon.QualitySpeed = (int)(m_Hilt.QualitySpeed * 0.5 + m_Blade.QualitySpeed * 0.5);
                weapon.QualityAccuracy = (int)(m_Hilt.QualityAccuracy * 0.5 + m_Blade.QualityAccuracy * 0.5);
                weapon.QualityDefense = (int)(m_Hilt.QualityDefense * 0.5 + m_Blade.QualityDefense * 0.5);
                weapon.Resource = m_Hilt.Resource;
                int quality = (int)(m_Blade.MaxHitPoints * 0.5 + m_Hilt.MaxHitPoints * 0.5);
                weapon.MaxHitPoints = quality;
                quality = (int)(m_Blade.HitPoints * 0.5 + m_Hilt.HitPoints * 0.5);
                weapon.HitPoints = quality;
                weapon.Crafter = from;
                weapon.CraftersOriginalName = from.Name;
                quality = (int)(((int)m_Blade.Quality * 50) * 0.5 + ((int)m_Hilt.Quality * 50) * 0.5);
                if (quality == 500)
                    weapon.Quality = WeaponQuality.Legendary;
                if (quality < 500)
                    weapon.Quality = WeaponQuality.Masterwork;
                if (quality < 450)
                    weapon.Quality = WeaponQuality.Illustrious;
                if (quality < 400)
                    weapon.Quality = WeaponQuality.Extraordinary;
                if (quality < 350)
                    weapon.Quality = WeaponQuality.Remarkable;
                if (quality < 300)
                    weapon.Quality = WeaponQuality.Exceptional;
                if (quality < 250)
                    weapon.Quality = WeaponQuality.Superior;
                if (quality < 200)
                    weapon.Quality = WeaponQuality.Regular;
                if (quality < 150)
                    weapon.Quality = WeaponQuality.Inferior;
                if (quality < 100)
                    weapon.Quality = WeaponQuality.Low;
                if (quality < 50)
                    weapon.Quality = WeaponQuality.Poor;
                weapon.BetaNerf = true;
                weapon.InvalidateProperties();
                from.AddToBackpack(weapon);
                weapon.AddItem(m_Blade);
                weapon.AddItem(m_Hilt);
            }

            if (m_Item is Longsword && targeted is Longsword && m_Item != targeted)
            {
                Longsword m_Hilt = m_Item as Longsword;
                Longsword m_Blade = targeted as Longsword;
                DualSwords weapon = new DualSwords();
                weapon.NewCrafting = true;
                weapon.QualityDamage = (int)(m_Hilt.QualityDamage * 0.5 + m_Blade.QualityDamage * 0.5);
                weapon.QualitySpeed = (int)(m_Hilt.QualitySpeed * 0.5 + m_Blade.QualitySpeed * 0.5);
                weapon.QualityAccuracy = (int)(m_Hilt.QualityAccuracy * 0.5 + m_Blade.QualityAccuracy * 0.5);
                weapon.QualityDefense = (int)(m_Hilt.QualityDefense * 0.5 + m_Blade.QualityDefense * 0.5);
                weapon.Resource = m_Hilt.Resource;
                int quality = (int)(m_Blade.MaxHitPoints * 0.5 + m_Hilt.MaxHitPoints * 0.5);
                weapon.MaxHitPoints = quality;
                quality = (int)(m_Blade.HitPoints * 0.5 + m_Hilt.HitPoints * 0.5);
                weapon.HitPoints = quality;
                weapon.Crafter = from;
                weapon.CraftersOriginalName = from.Name;
                quality = (int)(((int)m_Blade.Quality * 50) * 0.5 + ((int)m_Hilt.Quality * 50) * 0.5);
                if (quality == 500)
                    weapon.Quality = WeaponQuality.Legendary;
                if (quality < 500)
                    weapon.Quality = WeaponQuality.Masterwork;
                if (quality < 450)
                    weapon.Quality = WeaponQuality.Illustrious;
                if (quality < 400)
                    weapon.Quality = WeaponQuality.Extraordinary;
                if (quality < 350)
                    weapon.Quality = WeaponQuality.Remarkable;
                if (quality < 300)
                    weapon.Quality = WeaponQuality.Exceptional;
                if (quality < 250)
                    weapon.Quality = WeaponQuality.Superior;
                if (quality < 200)
                    weapon.Quality = WeaponQuality.Regular;
                if (quality < 150)
                    weapon.Quality = WeaponQuality.Inferior;
                if (quality < 100)
                    weapon.Quality = WeaponQuality.Low;
                if (quality < 50)
                    weapon.Quality = WeaponQuality.Poor;
                weapon.BetaNerf = true;
                weapon.InvalidateProperties();
                from.AddToBackpack(weapon);
                weapon.AddItem(m_Blade);
                weapon.AddItem(m_Hilt);
            }

            if ( targeted is ICarvable )
            {
                ((ICarvable)targeted).Carve( from, m_Item );
            }

            else if ( targeted is BaseClothing && ( (Item)targeted ).IsChildOf( from.Backpack ) )
            {
                BaseClothing clothes = targeted as BaseClothing;

                Bandage bandage = new Bandage( 2 );
                bandage.Amount += Math.Max( 0, (int)clothes.Weight );
                bandage.Hue = clothes.Hue;

                Container pack = from.Backpack;

                pack.DropItem( bandage );

                from.SendMessage( "You rip the garment apart and create some bandages out of it" );

                clothes.Delete();
            }

            else
            {
                HarvestSystem system = Lumberjacking.System;
                HarvestDefinition def = Lumberjacking.System.Definition;

                int tileID;
                Map map;
                Point3D loc;

                if ( !system.GetHarvestDetails( from, m_Item, targeted, out tileID, out map, out loc ) )
                {
                    from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
                }
                else if ( !def.Validate( tileID ) )
                {
                    from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
                }
                else
                {
                    HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

                    if ( bank == null )
                        return;

                    if ( bank.Current < 5 )
                    {
                        from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
                    }
                    else
                    {
                        bank.Consume( def, 5 );

                        Item item = new Kindling();

                        if ( from.PlaceInBackpack( item ) )
                        {
                            from.SendLocalizedMessage( 500491 ); // You put some kindling into your backpack.
                            from.SendLocalizedMessage( 500492 ); // An axe would probably get you more wood.
                        }
                        else
                        {
                            from.SendLocalizedMessage( 500490 ); // You can't place any kindling into your backpack!

                            item.Delete();
                        }
                    }
                }
            }
        }
コード例 #6
0
ファイル: CraftItem.cs プロジェクト: Godkong/Origins
        public void CompleteCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CustomCraft customCraft, Point3D p )
        {
            int badCraft = craftSystem.CanCraft( from, tool, m_Type );

            if ( badCraft > 0 )
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    return;
                //from.SendGump( new CraftGump( from, craftSystem, tool, badCraft ) );
                //else
                    //from.SendLocalizedMessage(badCraft);

                return;
            }

            int checkResHue = 0, checkMaxAmount = 0;
            object checkMessage = null;

            // Not enough resource to craft it
            if ( !ConsumeRes( from, typeRes, craftSystem, ref checkResHue, ref checkMaxAmount, ConsumeType.None, ref checkMessage ) )
            {
                if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
                    return;
                    //from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
                /*else if ( checkMessage is int && (int)checkMessage > 0 )
                    from.SendLocalizedMessage( (int)checkMessage );
                else if ( checkMessage is string )
                    from.SendMessage( (string)checkMessage );*/

                return;
            }
            else if ( !ConsumeAttributes( from, ref checkMessage, false ) )
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    return;
                //from.SendGump( new CraftGump( from, craftSystem, tool, checkMessage ) );
                /*else if (checkMessage is int && (int)checkMessage > 0)
                    from.SendLocalizedMessage((int)checkMessage);
                else if (checkMessage is string)
                    from.SendMessage((string)checkMessage);*/

                return;
            }

            bool toolBroken = false;

            int ignored = 1;
            int endquality = 1;

            bool allRequiredSkills = true;

            if ( CheckSkills( from, typeRes, craftSystem, ref ignored, ref allRequiredSkills ) )
            {
                // Resource
                int resHue = 0;
                int maxAmount = 0;

                object message = null;

                // Not enough resource to craft it
                if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, ConsumeType.All, ref message ) )
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                        return;
                    //from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
                    /*else if (message is int && (int)message > 0)
                        from.SendLocalizedMessage((int)message);
                    else if (message is string)
                        from.SendMessage((string)message);*/

                    return;
                }
                else if ( !ConsumeAttributes( from, ref message, true ) )
                {
                    if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
                        return;
                        //from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
                    /*else if ( message is int && (int)message > 0 )
                        from.SendLocalizedMessage( (int)message );
                    else if ( message is string )
                        from.SendMessage( (string)message );*/

                    return;
                }

                if (!((tool.LootType == LootType.Newbied) && (craftSystem is DefBlacksmithy)))
                    tool.UsesRemaining--;

                if ( craftSystem is DefBlacksmithy )
                {
                    AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
                    if ( hammer != null && hammer != tool )
                    {
                        hammer.UsesRemaining--;
                        if ( hammer.UsesRemaining < 1 )
                            hammer.Delete();
                    }
                }

                if ( tool.UsesRemaining < 1 )
                    toolBroken = true;

                if ( toolBroken )
                    tool.Delete();

                int num = 0;

                Item item;
                if ( customCraft != null )
                {
                    item = customCraft.CompleteCraft( out num );
                }
                else if ( typeof( MapItem ).IsAssignableFrom( ItemType ) && from.Map != Map.Trammel && from.Map != Map.Felucca )
                {
                    item = new IndecipherableMap();
                    from.SendLocalizedMessage( 1070800 ); // The map you create becomes mysteriously indecipherable.
                }
                else
                {
                    item = Activator.CreateInstance( ItemType ) as Item;
                }

                if ( item != null )
                {
                    if( item is ICraftable )
                        endquality = ((ICraftable)item).OnCraft( quality, makersMark, from, craftSystem, typeRes, tool, this, resHue );
                    else if ( item.Hue == 0 )
                        item.Hue = resHue;

                    if ( maxAmount > 0 )
                    {
                        if ( !item.Stackable && item is IUsesRemaining )
                            ((IUsesRemaining)item).UsesRemaining *= maxAmount;
                        else
                            item.Amount = maxAmount;
                    }

                    if (craftSystem is DefCarpentry)
                    {
                        Item kindling = new Kindling();

                        kindling.MoveToWorld(p, from.Map);
                        item.MoveToWorld(p, from.Map);
                    }
                    else
                        from.AddToBackpack(item);

                    if( from.AccessLevel > AccessLevel.Player )
                        CommandLogging.WriteLine( from, "Crafting {0} with craft system {1}", CommandLogging.Format( item ), craftSystem.GetType().Name );

                    //from.PlaySound( 0x57 );
                }

                if ( num == 0 )
                    num = craftSystem.PlayEndingEffect( from, false, true, toolBroken, endquality, makersMark, this );

                bool queryFactionImbue = false;
                int availableSilver = 0;
                FactionItemDefinition def = null;
                Faction faction = null;

                if ( item is IFactionItem )
                {
                    def = FactionItemDefinition.Identify( item );

                    if ( def != null )
                    {
                        faction = Faction.Find( from );

                        if ( faction != null )
                        {
                            Town town = Town.FromRegion( from.Region );

                            if ( town != null && town.Owner == faction )
                            {
                                Container pack = from.Backpack;

                                if ( pack != null )
                                {
                                    availableSilver = pack.GetAmount( typeof( Silver ) );

                                    if ( availableSilver >= def.SilverCost )
                                        queryFactionImbue = Faction.IsNearType( from, def.VendorType, 12 );
                                }
                            }
                        }
                    }
                }

                // TODO: Scroll imbuing

                if ( queryFactionImbue )
                    return;
                    //from.SendGump( new FactionImbueGump( quality, item, from, craftSystem, tool, num, availableSilver, faction, def ) );
                else if ( tool != null && !tool.Deleted && tool.UsesRemaining > 0 )
                    return;
                    //from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
                /*else if ( num > 0 )
                    from.SendLocalizedMessage( num );*/
            }
            else if ( !allRequiredSkills )
            {
                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    return;
                //from.SendGump( new CraftGump( from, craftSystem, tool, 1044153 ) );
                else
                    from.SendAsciiMessage("You don't have the required skills to attempt this item.");
                   // from.SendLocalizedMessage(1044153); // You don't have the required skills to attempt this item.
            }
            else
            {
                ConsumeType consumeType = ( UseAllRes ? ConsumeType.Half : ConsumeType.All );
                int resHue = 0;
                int maxAmount = 0;

                object message = null;

                // Not enough resource to craft it
                if ( !ConsumeRes( from, typeRes, craftSystem, ref resHue, ref maxAmount, consumeType, ref message, true ) )
                {
                    if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                        return;
                    //from.SendGump( new CraftGump( from, craftSystem, tool, message ) );
                    /*else if (message is int && (int)message > 0)
                        from.SendLocalizedMessage((int)message);
                    else if (message is string)
                        from.SendMessage((string)message);*/

                    return;
                }

                tool.UsesRemaining--;

                if ( tool.UsesRemaining < 1 )
                    toolBroken = true;

                if ( toolBroken )
                    tool.Delete();

                // SkillCheck failed.
                int num = craftSystem.PlayEndingEffect( from, true, true, toolBroken, endquality, false, this );

                if (tool != null && !tool.Deleted && tool.UsesRemaining > 0)
                    return;
                //from.SendGump( new CraftGump( from, craftSystem, tool, num ) );
                //else if (num > 0)
                    //from.SendLocalizedMessage(num);
            }
        }
コード例 #7
0
		protected override void OnTarget( Mobile from, object targeted )
		{
			if( m_Item.Deleted )
				return;

			if( targeted is ICarvable )
			{
				((ICarvable)targeted).Carve( from, m_Item );
			}
			else if( targeted is ForestWyrm && ((ForestWyrm)targeted).HasBarding )
			{
				ForestWyrm pet = (ForestWyrm)targeted;

				if( !pet.Controlled || pet.ControlMaster != from )
					from.SendLocalizedMessage( 1053022 ); // You cannot remove barding from a swamp dragon you do not own.
				else
					pet.HasBarding = false;
			}
			#region CropSystem
			else if( targeted is Weeds )
			{
				((Weeds)targeted).Delete();

				from.SendMessage( "You slice the roots of the weed and toss them away." );
			}
			else if( targeted is Food && ((Food)targeted).SeedType != null )
			{
				try
				{
					Food food = targeted as Food;
					int amount = (food.Amount * Utility.RandomMinMax( 2, 6 ));
					Item seed = Activator.CreateInstance( food.SeedType, amount ) as Item;

					if( seed != null )
					{
						from.AddToBackpack( seed );
						from.SendMessage( String.Format( "You slice open the plant{0} and remove {1} seeds.",
							(food.Amount > 1 ? "s" : ""), (food.Amount > 1 ? "their" : "its") ) );
					}

					food.Delete();
				}
				catch { }
			}
			else if( targeted is Flax )
			{
				int amount = (((Flax)targeted).Amount * Utility.RandomMinMax( 2, 6 ));

				from.AddToBackpack( new FlaxSeed( amount ) );
				from.SendMessage( "You cut off the stalk of the flax and throw it away, keeping the seeds for later use." );

				((Flax)targeted).Delete();
			}
			else if( targeted is WheatSheaf )
			{
				int amount = (((WheatSheaf)targeted).Amount * Utility.RandomMinMax( 3, 8 ));

				from.AddToBackpack( new WheatSeed( amount ) );
				from.SendMessage( "You split open the wheat and take all the seeds you can find." );

				((WheatSheaf)targeted).Delete();
			}
			else if( targeted is Rose )
			{
				from.AddToBackpack( new RoseBud( Utility.RandomMinMax( 3, 6 ) ) );
				from.SendMessage( "You break away the petals of the flowers and gently remove the buds." );

				((Rose)targeted).Delete();
			}
			#endregion
			else
			{
				HarvestSystem system = Lumberjacking.System;
				HarvestDefinition def = Lumberjacking.System.Definition;

				int tileID;
				Map map;
				Point3D loc;

				if( !system.GetHarvestDetails( from, m_Item, targeted, out tileID, out map, out loc ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else if( !def.Validate( tileID ) )
				{
					from.SendLocalizedMessage( 500494 ); // You can't use a bladed item on that!
				}
				else
				{
					HarvestBank bank = def.GetBank( map, loc.X, loc.Y );

					if( bank == null )
						return;

					if( bank.Current < 5 )
					{
						from.SendLocalizedMessage( 500493 ); // There's not enough wood here to harvest.
					}
					else
					{
						bank.Consume( 5, from );

						Item item = new Kindling();

						if( from.PlaceInBackpack( item ) )
						{
							from.SendLocalizedMessage( 500491 ); // You put some kindling into your backpack.
							from.SendLocalizedMessage( 500492 ); // An axe would probably get you more wood.
						}
						else
						{
							from.SendLocalizedMessage( 500490 ); // You can't place any kindling into your backpack!

							item.Delete();
						}
					}
				}
			}
		}
コード例 #8
0
            protected override void OnTick()
            {
                ++m_Count;
                if (m_Count < m_MaxCount)
                {
                    new SoundTimer(m_From).Start();
                    if (m_From.Mounted)
                        m_From.Animate(26, 5, 2, true, false, 0);
                    else
                        m_From.Animate(9, 5, 2, true, false, 0);
                }
                else
                {
                    m_Bank.Consume(Lumberjacking.System.Definition, 5, m_From);

                    Item item = new Kindling();

                    if (m_From.PlaceInBackpack(item))
                    {
                        m_From.SendLocalizedMessage(500491); // You put some kindling into your backpack.
                        //m_From.SendLocalizedMessage(500492); // An axe would probably get you more wood.
                    }
                    else
                    {
                        m_From.SendLocalizedMessage(500490); // You can't place any kindling into your backpack!

                        item.Delete();
                    }
                }
            }
コード例 #9
0
ファイル: Christmas.cs プロジェクト: FreeReign/Rebirth-Repack
        public GiftBag( bool nice )
        {
            Item item = null;

            Hue = Utility.RandomList( 32, 64, 2301 );

            if ( nice )
            {
                Name = "Happy Holidays!";
                DropItem( MakeNewbie( new WristWatch() ) );
                if ( Utility.RandomBool() )
                {
                    item = new Food( 4164 );
                    item.Hue = 432;
                    item.Name = "fruit cake";
                    DropItem( MakeNewbie( item ) );
                }
                else
                {
                    DropItem( MakeNewbie( new Pizza() ) );
                }

                if ( Utility.RandomBool() )
                    DropItem( MakeNewbie( new BeverageBottle( BeverageType.Champagne ) ) );
                else
                    DropItem( MakeNewbie( new BeverageBottle( BeverageType.EggNog ) ) );

                switch ( Utility.Random( 7 ) )
                {
                    default:
                    case 0:
                        DropItem( MakeNewbie( new Apple() ) );
                        break;
                    case 1:
                        DropItem( MakeNewbie( new Pear() ) );
                        break;
                    case 2:
                        DropItem( MakeNewbie( new Bananas() ) );
                        break;
                    case 3:
                        DropItem( MakeNewbie( new Dates() ) );
                        break;
                    case 4:
                        DropItem( MakeNewbie( new Coconut() ) );
                        break;
                    case 5:
                        DropItem( MakeNewbie( new Peach() ) );
                        break;
                    case 6:
                        DropItem( MakeNewbie( new Grapes() ) );
                        break;
                }

                item = new Goblet();
                item.Name = "a champagne glass";
                item.Hue = 71;
                DropItem( MakeNewbie( item ) );

                item = new Goblet();
                item.Name = "a champagne glass";
                item.Hue = 34;
                DropItem( MakeNewbie( item ) );

                DropItem( MakeNewbie( new FireworksWand( 100 ) ) );

                item = new BaseItem( 5359 );
                item.Hue = Utility.RandomList( 32, 64, 2301 );
                item.Name = "Seasons Greetings";
                DropItem( MakeNewbie( item ) );
            }
            else
            {
                Name = "You were naughty this year!";

                DropItem( MakeNewbie( new Food( 4164 ) ) ); // spam

                DropItem( MakeNewbie( new Coal() ) );

                item = new Kindling();
                item.Name = "switches";
                DropItem( item ); // not newbied...

                item = new BaseItem( 5359 );
                item.Hue = Utility.RandomList( 32, 64, 2301 );
                item.Name = "Maybe next year you will get a nicer gift.";
                DropItem( MakeNewbie( item ) );
            }
        }