Example #1
0
        public void PlantSeed(Mobile from, Seed seed)
        {
            if (m_PlantStatus >= PlantStatus.FullGrownPlant)
            {
                LabelTo(from, 1061919);                   // You must use a seed on a bowl of dirt!
            }
            else if (!IsUsableBy(from))
            {
                LabelTo(from, 1061921);                   // The bowl of dirt must be in your pack, or you must lock it down.
            }
            else if (m_PlantStatus != PlantStatus.BowlOfDirt)
            {
                from.SendLocalizedMessage(1080389, "#" + GetLocalizedPlantStatus().ToString());                   // This bowl of dirt already has a ~1_val~ in it!
            }
            else if (m_PlantSystem.Water < 2)
            {
                LabelTo(from, 1061920);                   // The dirt in this bowl needs to be softened first.
            }
            else
            {
                m_PlantType = seed.PlantType;
                m_PlantHue  = seed.PlantHue;
                m_ShowType  = seed.ShowType;

                seed.Delete();

                PlantStatus = PlantStatus.Seed;

                m_PlantSystem.Reset(false);

                LabelTo(from, 1061922);                   // You plant the seed in the bowl of dirt.
            }
        }
Example #2
0
        public void PlantSeed(Mobile from, Seed seed)
        {
            if (m_PlantStatus >= PlantStatus.FullGrownPlant)
            {
                LabelTo(from, 1061919);                 // You must use a seed on a bowl of dirt!
            }
            else if (!IsUsableBy(from))
            {
                LabelTo(from, 1061921);                 // The bowl of dirt must be in your pack, or you must lock it down.
            }
            else if (m_PlantStatus != PlantStatus.BowlOfDirt)
            {
                if (m_PlantStatus >= PlantStatus.Plant)
                {
                    LabelTo(from, "This bowl of dirt already has a plant in it!");
                }
                else if (m_PlantStatus >= PlantStatus.Sapling)
                {
                    LabelTo(from, "This bowl of dirt already has a sapling in it!");
                }
                else
                {
                    LabelTo(from, "This bowl of dirt already has a seed in it!");
                }
            }
            else if (m_PlantSystem.Water < 2)
            {
                LabelTo(from, 1061920);                 // The dirt in this bowl needs to be softened first.
            }
            else
            {
                m_PlantType = seed.PlantType;
                m_PlantHue  = seed.PlantHue;
                m_ShowType  = seed.ShowType;

                seed.Delete();

                PlantStatus = PlantStatus.Seed;

                m_PlantSystem.Reset(false);

                LabelTo(from, 1061922);                 // You plant the seed in the bowl of dirt.
            }
        }
Example #3
0
        public override void OnResponse( NetState sender, RelayInfo info )
        {
            Mobile from = sender.Mobile;

            if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
                return;

            if ( !m_Plant.IsUsableBy( from ) )
            {
                m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
                return;
            }

            switch ( info.ButtonID )
            {
                case 1: // Cancel
                {
                    from.SendGump( new MainPlantGump( m_Plant ) );

                    break;
                }
                case 2: // Help
                {
                    from.Send( new DisplayHelpTopic( 71, true ) ); // EMPTYING THE BOWL

                    from.SendGump( new EmptyTheBowlGump( m_Plant ) );

                    break;
                }
                case 3: // Ok
                {
                    PlantBowl bowl = new PlantBowl();

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

                        m_Plant.LabelTo( from, 1053047 ); // You cannot empty a bowl with a full pack!
                        from.SendGump( new MainPlantGump( m_Plant ) );

                        break;
                    }

                    if ( m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant )
                    {
                        Seed seed = new Seed( m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType );

                        if ( !from.PlaceInBackpack( seed ) )
                        {
                            bowl.Delete();
                            seed.Delete();

                            m_Plant.LabelTo( from, 1053047 ); // You cannot empty a bowl with a full pack!
                            from.SendGump( new MainPlantGump( m_Plant ) );

                            break;
                        }
                    }

                    m_Plant.Delete();

                    break;
                }
            }
        }
Example #4
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;

            if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant)
            {
                return;
            }

            if (info.ButtonID == 3 && !from.InRange(m_Plant.GetWorldLocation(), 3))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446);                   // That is too far away.
                return;
            }

            if (!m_Plant.IsUsableBy(from))
            {
                m_Plant.LabelTo(from, 1061856);                   // You must have the item in your backpack or locked down in order to use it.
                return;
            }

            switch (info.ButtonID)
            {
            case 1:                     // Cancel
            {
                from.SendGump(new MainPlantGump(m_Plant));

                break;
            }

            case 2:                                        // Help
            {
                from.Send(new DisplayHelpTopic(71, true)); // EMPTYING THE BOWL

                from.SendGump(new EmptyTheBowlGump(m_Plant));

                break;
            }

            case 3:                     // Ok
            {
                PlantBowl bowl = new PlantBowl();

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

                    m_Plant.LabelTo(from, 1053047);                                       // You cannot empty a bowl with a full pack!
                    from.SendGump(new MainPlantGump(m_Plant));

                    break;
                }

                if (m_Plant.PlantStatus != PlantStatus.BowlOfDirt && m_Plant.PlantStatus < PlantStatus.Plant)
                {
                    Seed seed = new Seed(m_Plant.PlantType, m_Plant.PlantHue, m_Plant.ShowType);

                    if (!from.PlaceInBackpack(seed))
                    {
                        bowl.Delete();
                        seed.Delete();

                        m_Plant.LabelTo(from, 1053047);                                           // You cannot empty a bowl with a full pack!
                        from.SendGump(new MainPlantGump(m_Plant));

                        break;
                    }
                }

                m_Plant.Delete();

                break;
            }
            }
        }
Example #5
0
        public bool TryAddSeed(Mobile from, Seed seed, int index = -1)
        {
            if (!from.Backpack.CheckHold(from, seed, true, true) || seed.Amount <= 0)
            {
                return(false);
            }
            else if (!from.InRange(this.GetWorldLocation(), 3) || from.Map != this.Map)
            {
                return(false);
            }
            else if (TotalCount + seed.Amount <= MaxSeeds)
            {
                SeedEntry entry    = GetExisting(seed);
                int       oldcount = UniqueCount;

                if (entry != null)
                {
                    entry.Seed.Amount += seed.Amount;
                    seed.Delete();
                }
                else if (UniqueCount < MaxUnique)
                {
                    entry = new SeedEntry(seed);
                    DropItem(seed);

                    seed.Movable = false;
                }
                else
                {
                    from.SendLocalizedMessage(1151839); // There is not enough room in the box.
                }

                if (entry != null)
                {
                    if (Entries.Contains(entry))
                    {
                        if (index > -1 && index < Entries.Count - 1)
                        {
                            Entries.Remove(entry);
                            AddEntry(entry, index);
                        }
                    }
                    else
                    {
                        if (index > -1 && index < Entries.Count)
                        {
                            AddEntry(entry, index);
                        }
                        else
                        {
                            AddEntry(entry);
                        }
                    }

                    from.SendLocalizedMessage(1151846); // You put the seed in the seedbox.

                    if (from is PlayerMobile)
                    {
                        var gump = new SeedBoxGump((PlayerMobile)from, this);
                        gump.CheckPage(entry);

                        BaseGump.SendGump(gump);
                    }

                    InvalidateProperties();
                    return(true);
                }
            }
            else
            {
                from.SendLocalizedMessage(1151839); // There is not enough room in the box.
            }

            return(false);
        }
Example #6
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            var from = sender.Mobile;

            if (info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus is >= PlantStatus.DecorativePlant or PlantStatus.BowlOfDirt)
            {
                return;
            }

            if (info.ButtonID >= 6 && info.ButtonID <= 8 && !from.InRange(m_Plant.GetWorldLocation(), 3))
            {
                from.LocalOverheadMessage(MessageType.Regular, 0x3E9, 500446); // That is too far away.
                return;
            }

            if (!m_Plant.IsUsableBy(from))
            {
                m_Plant.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
                return;
            }

            switch (info.ButtonID)
            {
            case 1:     // Main menu
            {
                from.SendGump(new MainPlantGump(m_Plant));

                break;
            }

            case 2:     // Set to decorative
            {
                if (m_Plant.PlantStatus == PlantStatus.Stage9)
                {
                    from.SendGump(new SetToDecorativeGump(m_Plant));
                }

                break;
            }

            case 3:     // Pollination
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.PollinationState);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 4:     // Resources
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.ResourceProduction);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 5:     // Seeds
            {
                from.NetState.SendDisplayHelpTopic(HelpTopic.SeedProduction);

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 6:     // Gather pollen
            {
                if (!m_Plant.IsCrossable)
                {
                    m_Plant.LabelTo(from, 1053050);         // You cannot gather pollen from a mutated plant!
                }
                else if (!m_Plant.PlantSystem.PollenProducing)
                {
                    // You cannot gather pollen from a plant in this stage of development!
                    m_Plant.LabelTo(from, 1053051);
                }
                else if (m_Plant.PlantSystem.Health < PlantHealth.Healthy)
                {
                    m_Plant.LabelTo(from, 1053052);         // You cannot gather pollen from an unhealthy plant!
                }
                else
                {
                    from.Target = new PollinateTarget(m_Plant);
                    from.SendLocalizedMessage(1053054);         // Target the plant you wish to cross-pollinate to.

                    break;
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 7:     // Gather resources
            {
                var resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);
                var system  = m_Plant.PlantSystem;

                if (resInfo == null)
                {
                    if (m_Plant.IsCrossable)
                    {
                        m_Plant.LabelTo(from, 1053056);         // This plant has no resources to gather!
                    }
                    else
                    {
                        m_Plant.LabelTo(from, 1053055);         // Mutated plants do not produce resources!
                    }
                }
                else if (system.AvailableResources == 0)
                {
                    m_Plant.LabelTo(from, 1053056);         // This plant has no resources to gather!
                }
                else
                {
                    var resource = resInfo.CreateResource();

                    if (from.PlaceInBackpack(resource))
                    {
                        system.AvailableResources--;
                        m_Plant.LabelTo(from, 1053059);         // You gather resources from the plant.
                    }
                    else
                    {
                        resource.Delete();
                        // You attempt to gather as many resources as you can hold, but your backpack is full.
                        m_Plant.LabelTo(from, 1053058);
                    }
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }

            case 8:     // Gather seeds
            {
                var system = m_Plant.PlantSystem;

                if (!m_Plant.Reproduces)
                {
                    m_Plant.LabelTo(from, 1053060);         // Mutated plants do not produce seeds!
                }
                else if (system.AvailableSeeds == 0)
                {
                    m_Plant.LabelTo(from, 1053061);         // This plant has no seeds to gather!
                }
                else
                {
                    var seed = new Seed(system.SeedType, system.SeedHue, true);

                    if (from.PlaceInBackpack(seed))
                    {
                        system.AvailableSeeds--;
                        m_Plant.LabelTo(from, 1053063);         // You gather seeds from the plant.
                    }
                    else
                    {
                        seed.Delete();
                        // You attempt to gather as many seeds as you can hold, but your backpack is full.
                        m_Plant.LabelTo(from, 1053062);
                    }
                }

                from.SendGump(new ReproductionGump(m_Plant));

                break;
            }
            }
        }
Example #7
0
        public bool TryAddSeed(Mobile from, Seed seed, int index = -1)
        {
            if (!CheckAccessible(from, this))
            {
                PrivateOverheadMessage(MessageType.Regular, 946, 1010563, from.NetState); // This container is secure.
                return(false);
            }

            if (!from.Backpack.CheckHold(from, seed, true, true) || seed.Amount <= 0)
            {
                return(false);
            }

            if (!from.InRange(GetWorldLocation(), 3) || from.Map != Map)
            {
                return(false);
            }

            if (TotalCount + seed.Amount <= MaxSeeds)
            {
                SeedEntry entry = GetExisting(seed);

                if (entry != null)
                {
                    entry.Seed.Amount += seed.Amount;
                    seed.Delete();
                }
                else if (UniqueCount < MaxUnique)
                {
                    entry = new SeedEntry(seed);
                    DropItem(seed);

                    seed.Movable = false;
                }
                else
                {
                    from.SendLocalizedMessage(1151839); // There is not enough room in the box.
                }

                if (entry != null)
                {
                    InvalidateProperties();

                    if (Entries.Contains(entry))
                    {
                        if (index > -1 && index < Entries.Count - 1)
                        {
                            Entries.Remove(entry);
                            AddEntry(entry, index);
                        }
                    }
                    else
                    {
                        if (index > -1 && index < Entries.Count)
                        {
                            AddEntry(entry, index);
                        }
                        else
                        {
                            AddEntry(entry);
                        }
                    }

                    from.SendLocalizedMessage(1151846); // You put the seed in the seedbox.

                    if (from is PlayerMobile mobile)
                    {
                        var gump = mobile.FindGump <SeedBoxGump>();

                        if (gump != null)
                        {
                            gump.CheckPage(entry);
                            gump.Refresh();
                        }
                        else
                        {
                            gump = new SeedBoxGump(mobile, this);
                            gump.CheckPage(entry);

                            BaseGump.SendGump(gump);
                        }
                    }

                    return(true);
                }
            }
            else
            {
                from.SendLocalizedMessage(1151839); // There is not enough room in the box.
            }

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

            if ( info.ButtonID == 0 || m_Plant.Deleted || m_Plant.PlantStatus >= PlantStatus.DecorativePlant || m_Plant.PlantStatus == PlantStatus.BowlOfDirt || !from.InRange( m_Plant.GetWorldLocation(), 3 ) )
                return;

            if ( !m_Plant.IsUsableBy( from ) )
            {
                m_Plant.LabelTo( from, 1061856 ); // You must have the item in your backpack or locked down in order to use it.
                return;
            }

            switch ( info.ButtonID )
            {
                case 1: // Main menu
                {
                    from.SendGump( new MainPlantGump( m_Plant ) );

                    break;
                }
                case 2: // Set to decorative
                {
                    if ( m_Plant.PlantStatus == PlantStatus.Stage9 )
                    {
                        from.SendGump( new SetToDecorativeGump( m_Plant ) );
                    }

                    break;
                }
                case 3: // Pollination
                {
                    from.Send( new DisplayHelpTopic( 67, true ) ); // POLLINATION STATE

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
                case 4: // Resources
                {
                    from.Send( new DisplayHelpTopic( 69, true ) ); // RESOURCE PRODUCTION

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
                case 5: // Seeds
                {
                    from.Send( new DisplayHelpTopic( 68, true ) ); // SEED PRODUCTION

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
                case 6: // Gather pollen
                {
                    if ( !m_Plant.IsCrossable )
                    {
                        m_Plant.LabelTo( from, 1053050 ); // You cannot gather pollen from a mutated plant!
                    }
                    else if ( !m_Plant.PlantSystem.PollenProducing )
                    {
                        m_Plant.LabelTo( from, 1053051 ); // You cannot gather pollen from a plant in this stage of development!
                    }
                    else if ( m_Plant.PlantSystem.Health < PlantHealth.Healthy )
                    {
                        m_Plant.LabelTo( from, 1053052 ); // You cannot gather pollen from an unhealthy plant!
                    }
                    else
                    {
                        from.Target = new PollinateTarget( m_Plant );
                        from.SendLocalizedMessage( 1053054 ); // Target the plant you wish to cross-pollinate to.

                        break;
                    }

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
                case 7: // Gather resources
                {
                    PlantResourceInfo resInfo = PlantResourceInfo.GetInfo( m_Plant.PlantType, m_Plant.PlantHue );
                    PlantSystem system = m_Plant.PlantSystem;

                    if ( resInfo == null )
                    {
                        if ( m_Plant.IsCrossable )
                            m_Plant.LabelTo( from, 1053056 ); // This plant has no resources to gather!
                        else
                            m_Plant.LabelTo( from, 1053055 ); // Mutated plants do not produce resources!
                    }
                    else if ( system.AvailableResources == 0 )
                    {
                        m_Plant.LabelTo( from, 1053056 ); // This plant has no resources to gather!
                    }
                    else
                    {
                        Item resource = resInfo.CreateResource();

                        if ( from.PlaceInBackpack( resource ) )
                        {
                            system.AvailableResources--;
                            m_Plant.LabelTo( from, 1053059 ); // You gather resources from the plant.
                        }
                        else
                        {
                            resource.Delete();
                            m_Plant.LabelTo( from, 1053058 ); // You attempt to gather as many resources as you can hold, but your backpack is full.
                        }
                    }

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
                case 8: // Gather seeds
                {
                    PlantSystem system = m_Plant.PlantSystem;

                    if ( !m_Plant.IsCrossable )
                    {
                        m_Plant.LabelTo( from, 1053060 ); // Mutated plants do not produce seeds!
                    }
                    else if ( system.AvailableSeeds == 0 )
                    {
                        m_Plant.LabelTo( from, 1053061 ); // This plant has no seeds to gather!
                    }
                    else
                    {
                        Seed seed = new Seed( system.SeedType, system.SeedHue, true );

                        if ( from.PlaceInBackpack( seed ) )
                        {
                            system.AvailableSeeds--;
                            m_Plant.LabelTo( from, 1053063 ); // You gather seeds from the plant.
                        }
                        else
                        {
                            seed.Delete();
                            m_Plant.LabelTo( from, 1053062 ); // You attempt to gather as many seeds as you can hold, but your backpack is full.
                        }
                    }

                    from.SendGump( new ReproductionGump( m_Plant ) );

                    break;
                }
            }
        }