public override void OnResponse( NetState sender, RelayInfo info )
		{
			Mobile from = sender.Mobile;

			if ( info.ButtonID == 0 || m_hive.Deleted || !from.InRange( m_hive.GetWorldLocation(), 3 ) )
				return;

			if( !m_hive.IsAccessibleTo( from ) )
			{
				m_hive.LabelTo( from, "You cannot use that." );
				return;
			}

			switch ( info.ButtonID )
			{
				case (int)Buttons.butExit: //Exit back to main gump
				{
					from.SendGump( new BeehiveMainGump(from,m_hive) );
					break;
				}
				case (int)Buttons.butHoney: //Honey
				{
					//ToDo: get hurt or poisoned when harvesting

					Item hivetool = GetHiveTool( from );

					if( NeedHiveTool )
					{
						if( hivetool == null || !(hivetool is HiveTool) )
						{
							m_hive.LabelTo( from, "You need a hive tool to extract the excess honey!" );
							from.SendGump( new BeehiveProductionGump( from, m_hive ) );
							return;
						}
					}

					if( m_hive.Honey < 3 )
					{
						m_hive.LabelTo( from, "There isn't enough honey in the hive to fill a bottle!" );
						from.SendGump( new BeehiveProductionGump( from, m_hive ) );
						break;
					}

					Container pack = from.Backpack;

					if ( pack != null && pack.ConsumeTotal( typeof( Bottle ), 1 ) )
					{
						JarHoney honey = new JarHoney();

						if ( !from.PlaceInBackpack( honey ) )
						{
							honey.Delete();
							from.PlaceInBackpack( new Bottle() ); //add the consumed bottle
							m_hive.LabelTo( from, "There is not enough room in your backpack for the honey!" );
							from.SendGump( new BeehiveProductionGump( from, m_hive ) );
							break;
						}

						if( NeedHiveTool )
						{
							((HiveTool)hivetool).UsesRemaining--;
							if( ((HiveTool)hivetool).UsesRemaining < 1 )
							{
								from.SendMessage("You wear out the hive tool.");
								hivetool.Delete();
							}
						}

						m_hive.Honey -= 3;
						m_hive.LabelTo( from, "You fill a bottle with golden honey and place it in your pack." );
						from.SendGump( new BeehiveProductionGump(from,m_hive) );
						break;
					}
					else
					{
						m_hive.LabelTo( from, "You need a bottle to fill with honey!" );
						from.SendGump( new BeehiveProductionGump( from, m_hive ) );
						break;
					}
				}
				case (int)Buttons.butWax: //Wax
				{
					//ToDo: get hurt or poisoned when harvesting

					Item hivetool = GetHiveTool( from );

					if( NeedHiveTool )
					{
						if( hivetool == null || !(hivetool is HiveTool) )
						{
							m_hive.LabelTo( from, "You need a hive tool to scrape the excess beeswax!" );
							from.SendGump( new BeehiveProductionGump( from, m_hive ) );
							return;
						}
					}

					if( m_hive.Wax < 1 )
					{
						m_hive.LabelTo( from, "There isn't enough excess wax in the hive to harvest!" );
						return;
					}

					Item wax;

					if( PureWax )
					{
						wax = new Beeswax(m_hive.Wax);
					}
					else
					{
						wax = new RawBeeswax(m_hive.Wax);
					}

					if ( !from.PlaceInBackpack( wax ) )
					{
						wax.Delete();

						m_hive.LabelTo( from, "There is not enough room in your backpack for the wax!" );
						from.SendGump( new BeehiveProductionGump( from, m_hive ) );
						break;
					}

					if( NeedHiveTool )
					{
						((HiveTool)hivetool).UsesRemaining--;
						if( ((HiveTool)hivetool).UsesRemaining < 1 )
						{
							from.SendMessage("You wear out the hive tool.");
							hivetool.Delete();
						}
					}

					m_hive.Wax = 0;
					m_hive.LabelTo( from, "You collect the excess beeswax and place it in your pack." );
					from.SendGump( new BeehiveProductionGump(from,m_hive) );
					break;
				}
			}
		}
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (info.ButtonID == 0 || m_pot.Deleted || !from.InRange(m_pot.GetWorldLocation(), 3))
            {
                return;
            }

            if (!m_pot.IsAccessibleTo(from))
            {
                from.PrivateOverheadMessage(0, 1154, false, "I cannot use that.", from.NetState);
                return;
            }

            switch (info.ButtonID)
            {
            case (int)Buttons.cmdHelp:
            {
                from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                from.SendGump(new apiBeeHiveHelpGump(from, 1));
                break;
            }

            case (int)Buttons.cmdAddRaw:                     //Add Raw Honey
            {
                from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));

                if (m_pot.PureBeeswax > 0)
                {
                    from.PrivateOverheadMessage(0, 1154, false, "You cannot mix raw beeswax with rendered wax.  Please empty the pot first.", from.NetState);
                    return;
                }

                from.PrivateOverheadMessage(0, 1154, false, "Choose the raw beeswax you wish to add to the pot.", from.NetState);
                m_pot.BeginAdd(from);

                break;
            }

            case (int)Buttons.cmdEmptyPot:                     //Empty the pot
            {
                if (m_pot.PureBeeswax < 1 && m_pot.RawBeeswax < 1)
                {
                    from.PrivateOverheadMessage(0, 1154, false, "There is no wax in the pot.", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    return;
                }

                Item wax;

                if (m_pot.PureBeeswax > 0)
                {
                    wax = new Beeswax(m_pot.PureBeeswax);
                }
                else
                {
                    wax = new RawBeeswax(m_pot.RawBeeswax);
                }

                if (!from.PlaceInBackpack(wax))
                {
                    wax.Delete();
                    from.PrivateOverheadMessage(0, 1154, false, "There is not enough room in your backpack for the wax!", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    break;
                }

                m_pot.RawBeeswax  = 0;
                m_pot.PureBeeswax = 0;

                m_pot.ItemID = 2532;                         //empty pot

                from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                from.PrivateOverheadMessage(0, 1154, false, "You place the beeswax in your pack.", from.NetState);

                break;
            }

            case (int)Buttons.cmdRenderWax:                     //render the wax
            {
                if (m_pot.UsesRemaining < 1)
                {                        //no uses remaining
                    from.PrivateOverheadMessage(0, 1154, false, "The pot is too damamged to render beeswax.", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    return;
                }
                else if (m_pot.PureBeeswax > 1)
                {                        //already rendered
                    from.PrivateOverheadMessage(0, 1154, false, "The pot is already full of rendered beeswax.", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    return;
                }
                else if (m_pot.RawBeeswax < 10)
                {                        //not enough raw beeswax
                    from.PrivateOverheadMessage(0, 1154, false, "There is not enough raw beeswax in the pot.", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    return;
                }
                else if (!BeeHiveHelper.Find(from, BeeHiveHelper.m_HeatSources))
                {                        //need a heat source to melt the wax
                    from.PrivateOverheadMessage(0, 1154, false, "You must be near a heat source to render beeswax.", from.NetState);
                    from.SendGump(new apiBeeHiveSmallPotGump(from, m_pot));
                    return;
                }

                m_pot.ItemID = 0x142b;                         //pot overflowing with wax

                m_pot.UsesRemaining--;
                if (m_pot.UsesRemaining < 0)
                {
                    m_pot.UsesRemaining = 0;
                }

                int waste = Utility.RandomMinMax(1, m_pot.RawBeeswax / 5);

                if (GiveSlumgum)
                {                        //give slumgum
                    Item gum = new Slumgum(Math.Max(1, waste));

                    if (!from.PlaceInBackpack(gum))
                    {
                        gum.Delete();
                    }
                }

                from.PlaySound(0x21);
                from.PrivateOverheadMessage(0, 1154, false, "You slowly melt the raw beeswax and remove the impurities.", from.NetState);

                m_pot.PureBeeswax = m_pot.RawBeeswax - waste;
                m_pot.RawBeeswax  = 0;

                break;
            }
            }
        }
Exemple #3
0
        public void EndAdd(Mobile from, object o)
        {
            if (o is Item && ((Item)o).IsChildOf(from.Backpack))
            {
                if (o is Beeswax)
                {
                    //error checking
                    if (UsesRemaining < 1)
                    {
                        from.PrivateOverheadMessage(0, 1154, false, "The pot is too damaged to melt any more wax.", from.NetState);
                        return;
                    }
                    else if (m_Beeswax >= MaxWax)
                    {
                        from.PrivateOverheadMessage(0, 1154, false, "The pot cannot hold any more wax.", from.NetState);
                        return;
                    }
                    else if (!BeehiveHelper.HasHeatSource(from))
                    {
                        from.PrivateOverheadMessage(0, 1154, false, "You must be near a heat source to melt beeswax.", from.NetState);
                        return;
                    }

                    Beeswax wax = (Beeswax)o;

                    if ((wax.Amount + MeltedBeeswax) > MaxWax)
                    {
                        wax.Amount   -= (MaxWax - MeltedBeeswax);
                        MeltedBeeswax = MaxWax;
                    }
                    else
                    {
                        MeltedBeeswax += wax.Amount;
                        wax.Delete();
                    }

                    from.PrivateOverheadMessage(0, 1154, false, "You slowly melt the beeswax and mix it in the pot.", from.NetState);

                    this.ItemID = 5162;                     //change the graphic

                    from.PlaySound(43);                     //bellow sound
                    //from.PlaySound( 0x21 ); //bubbling sound

                    UsesRemaining--;

                    if (MeltedBeeswax < MaxWax)
                    {
                        BeginAdd(from);
                    }
                }
                else if (o == this)
                {
                    //empty the pot
                    if (MeltedBeeswax < 1)
                    {
                        from.PrivateOverheadMessage(0, 1154, false, "There is no wax in the pot.", from.NetState);
                    }
                    else
                    {
                        Item wax = new Beeswax(MeltedBeeswax);

                        if (!from.PlaceInBackpack(wax))
                        {
                            wax.Delete();
                            from.PrivateOverheadMessage(0, 1154, false, "There is not enough room in your backpack for the wax!", from.NetState);
                            return;
                        }

                        MeltedBeeswax = 0;

                        ItemID = 2541;                         //empty pot

                        from.PrivateOverheadMessage(0, 1154, false, "You empty the pot and place the beeswax in your pack.", from.NetState);
                    }
                }
                else
                {
                    from.PrivateOverheadMessage(0, 1154, false, "You can only melt pure beeswax in the pot.", from.NetState);
                }
            }
            else
            {
                from.PrivateOverheadMessage(0, 1154, false, "The wax must be in your pack to target it.", from.NetState);
            }
        }
		public override void OnResponse( NetState sender, RelayInfo info )
		{
			Mobile from = sender.Mobile;

			if ( info.ButtonID == 0 || m_Pot.Deleted || !from.InRange( m_Pot.GetWorldLocation(), 3 ) )
				return;

			if( !m_Pot.IsAccessibleTo( from ) )
			{
				from.PrivateOverheadMessage( 0, 1154, false, "I cannot use that.", from.NetState );
				return;
			}

			switch ( info.ButtonID )
			{
				case (int)Buttons.cmdHelp:
				{
					from.SendGump( new BeehiveSmallPotGump(from,m_Pot) );
					from.SendGump( new BeehiveHelpGump(from, 1) );
					break;
				}
				case (int)Buttons.cmdAddRaw: //Add Raw Honey
				{
					from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );

					if ( m_Pot.PureBeeswax > 0 )
					{
						from.PrivateOverheadMessage( 0, 1154, false,  "You cannot mix raw beeswax with rendered wax.  Please empty the pot first.", from.NetState );
						return;
					}

					from.PrivateOverheadMessage( 0, 1154, false,  "Choose the raw beeswax you wish to add to the pot.", from.NetState );
					m_Pot.BeginAdd( from );

					break;
				}
				case (int)Buttons.cmdEmptyPot: //Empty the pot
				{
					if( m_Pot.PureBeeswax < 1 && m_Pot.RawBeeswax < 1 )
					{
						from.PrivateOverheadMessage( 0, 1154, false, "There is no wax in the pot.", from.NetState );
						from.SendGump( new BeehiveSmallPotGump(from,m_Pot) );
						return;
					}

					Item wax;

					if( m_Pot.PureBeeswax > 0 )
					{
						wax = new Beeswax(m_Pot.PureBeeswax);
					}
					else
					{
						wax = new RawBeeswax(m_Pot.RawBeeswax);
					}

					if ( !from.PlaceInBackpack( wax ) )
					{
						wax.Delete();
						from.PrivateOverheadMessage( 0, 1154, false,  "There is not enough room in your backpack for the wax!", from.NetState );
						from.SendGump( new BeehiveSmallPotGump( from, m_Pot ) );
						break;
					}

					m_Pot.RawBeeswax = 0;
					m_Pot.PureBeeswax = 0;

					m_Pot.ItemID = 2532; //empty pot

					from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );
					from.PrivateOverheadMessage( 0, 1154, false,  "You place the beeswax in your pack.", from.NetState );

					break;
				}
				case (int)Buttons.cmdRenderWax: //render the wax
				{
					if( m_Pot.UsesRemaining < 1 )
					{//no uses remaining
						from.PrivateOverheadMessage( 0, 1154, false,  "The pot is too damamged to render beeswax.", from.NetState );
						from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );
						return;
					}
					else if( m_Pot.PureBeeswax > 1 )
					{//already rendered
						from.PrivateOverheadMessage( 0, 1154, false,  "The pot is already full of rendered beeswax.", from.NetState );
						from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );
						return;
					}
					else if( m_Pot.RawBeeswax < 10 )
					{//not enough raw beeswax
						from.PrivateOverheadMessage( 0, 1154, false,  "There is not enough raw beeswax in the pot.", from.NetState );
						from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );
						return;
					}
					else if( !BeehiveHelper.HasHeatSource( from ) )
					{//need a heat source to melt the wax
						from.PrivateOverheadMessage( 0, 1154, false,  "You must be near a heat source to render beeswax.", from.NetState );
						from.SendGump( new BeehiveSmallPotGump(from, m_Pot) );
						return;
					}

					m_Pot.ItemID = 0x142b; //pot overflowing with wax

					m_Pot.UsesRemaining--;
					if( m_Pot.UsesRemaining < 0 )
						m_Pot.UsesRemaining = 0;

					int waste = Utility.RandomMinMax( 1, m_Pot.RawBeeswax / 5 );

					if( GiveSlumgum )
					{//give slumgum
						Item gum = new Slumgum( Math.Max( 1, waste ) );

						if ( !from.PlaceInBackpack( gum ) )
							gum.Delete();
					}

					from.PlaySound( 0x21 );
					from.PrivateOverheadMessage( 0, 1154, false,  "You slowly melt the raw beeswax and remove the impurities.", from.NetState );

					m_Pot.PureBeeswax = m_Pot.RawBeeswax - waste;
					m_Pot.RawBeeswax = 0;

					break;
				}
			}
		}
		public void EndAdd( Mobile from, object o )
		{
			if ( o is Item && ((Item)o).IsChildOf( from.Backpack ) )
			{
				if( o is Beeswax )
				{
					//error checking
					if ( UsesRemaining < 1 )
					{
						from.PrivateOverheadMessage( 0, 1154, false,  "The pot is too damaged to melt any more wax.", from.NetState );
						return;
					}
					else if ( m_Beeswax >= MaxWax )
					{
						from.PrivateOverheadMessage( 0, 1154, false,  "The pot cannot hold any more wax.", from.NetState );
						return;
					}
					else if( !BeehiveHelper.HasHeatSource( from ) )
					{
						from.PrivateOverheadMessage( 0, 1154, false,  "You must be near a heat source to melt beeswax.", from.NetState );
						return;
					}

					Beeswax wax = (Beeswax)o;

					if( (wax.Amount + MeltedBeeswax) > MaxWax )
					{
						wax.Amount -= (MaxWax - MeltedBeeswax);
						MeltedBeeswax = MaxWax;
					}
					else
					{
						MeltedBeeswax += wax.Amount;
						wax.Delete();
					}

					from.PrivateOverheadMessage( 0, 1154, false,  "You slowly melt the beeswax and mix it in the pot.", from.NetState );

					this.ItemID = 5162; //change the graphic

					from.PlaySound( 43 ); //bellow sound
					//from.PlaySound( 0x21 ); //bubbling sound

					UsesRemaining--;

					if ( MeltedBeeswax < MaxWax )
						BeginAdd( from );
				}
				else if ( o == this )
				{
					//empty the pot
					if( MeltedBeeswax < 1 )
						from.PrivateOverheadMessage( 0, 1154, false, "There is no wax in the pot.", from.NetState );
					else
					{
						Item wax = new Beeswax( MeltedBeeswax );

						if ( !from.PlaceInBackpack( wax ) )
						{
							wax.Delete();
							from.PrivateOverheadMessage( 0, 1154, false,  "There is not enough room in your backpack for the wax!", from.NetState );
							return;
						}

						MeltedBeeswax = 0;

						ItemID = 2541; //empty pot

						from.PrivateOverheadMessage( 0, 1154, false,  "You empty the pot and place the beeswax in your pack.", from.NetState );
					}
				}
				else
					from.PrivateOverheadMessage( 0, 1154, false,  "You can only melt pure beeswax in the pot.", from.NetState );
			}
			else
			{
				from.PrivateOverheadMessage( 0, 1154, false,  "The wax must be in your pack to target it.", from.NetState );
			}
		}
        public override void OnDoubleClick(Mobile from )
        {
            if (! from.InRange( this.GetWorldLocation(), 1 ))
            {
                from.LocalOverheadMessage( MessageType.Regular, 906, 1019045 ); // I can't reach that.
            }
            else
            {
                if ( m_wax == 0 && m_honey == 0 )
                    from.SendMessage( "The hive is empty." );
                else
                {
                    bool givehoney = false, givewax = false;

                    if ( m_wax > 0 )
                    {
                        Beeswax wax = new Beeswax( m_wax );

                        if ( !from.AddToBackpack( wax ) )
                        {
                            wax.Delete();
                        }
                        else
                            givewax = true;
                    }

                    if ( m_honey > 0 )
                    {
                        JarHoney honey = new JarHoney( m_honey );

                        if ( !from.AddToBackpack( honey ) )
                        {
                            honey.Delete();
                        }
                        else
                            givehoney = true;
                    }

                    if ( givehoney && givewax )
                    {
                        from.SendMessage( String.Format( "You gather {0} honey and {1} wax.", m_honey, m_wax ) );
                        m_wax = 0; m_honey = 0;
                    }
                    else if ( givehoney )
                    {
                        from.SendMessage( String.Format( "You gather {0} honey.", m_honey ) );
                        m_honey = 0;
                    }
                    else if ( givewax )
                    {
                        from.SendMessage( String.Format( "You gather {0} wax.", m_wax ) );
                        m_wax = 0;
                    }
                    else
                        from.SendMessage( "You do not manage to gather anything from the hive." );
                }

                if ( m_timer == null )
                {
                    m_timer = new CommunityBeeHiveTimer( this );
                    m_timer.Start();
                }
                else if ( m_timer != null && !m_timer.Running )
                {
                    m_timer.Stop();
                    m_timer = new CommunityBeeHiveTimer( this );
                    m_timer.Start();
                }
            }
        }