Esempio n. 1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);
            int version = reader.ReadInt();

            //Version 0
            if (version >= 0)
            {
                m_PlantSeed        = (PlantSeed)reader.ReadItem();
                m_ReadyForHarvest  = reader.ReadBool();
                m_GrowthValue      = reader.ReadDouble();
                m_WaterValue       = reader.ReadDouble();
                m_SoilQualityValue = reader.ReadDouble();
                m_HeatValue        = reader.ReadDouble();
            }

            //-----

            PlantPersistance.m_Instances.Add(this);
        }
Esempio n. 2
0
        public bool Harvest(Mobile from)
        {
            if (!SpecialAbilities.Exists(from))
            {
                return(false);
            }

            if (from.Backpack.TotalItems >= from.Backpack.MaxItems)
            {
                from.SendMessage("Your backpack does not have enough space for that.");
                return(false);
            }

            if (m_PlantSeed != null && from.Backpack != null)
            {
                Item item = (Item)Activator.CreateInstance(m_PlantSeed.PlantType);

                if (item == null)
                {
                    return(false);
                }

                if (item.Stackable && m_PlantSeed.PlantCount > 1)
                {
                    item.Amount = m_PlantSeed.PlantCount;
                    from.Backpack.DropItem(item);
                }

                else
                {
                    if (from.Backpack.TotalItems + m_PlantSeed.PlantCount > from.Backpack.MaxItems)
                    {
                        from.SendMessage("Your backpack does not have enough space for that.");
                        return(false);
                    }

                    item.Delete();

                    for (int a = 0; a < m_PlantSeed.PlantCount; a++)
                    {
                        item = (Item)Activator.CreateInstance(m_PlantSeed.PlantType);
                        from.Backpack.DropItem(item);
                    }
                }

                m_PlantSeed.Delete();
                m_PlantSeed = null;

                m_ReadyForHarvest  = false;
                m_GrowthValue      = 0;
                m_WaterValue       = 0;
                m_SoilQualityValue = 0;
                m_HeatValue        = 0;

                from.PlaySound(0x5AE);
                from.SendMessage("You harvest the plant.");

                TimedStatic dirt = new TimedStatic(Utility.RandomList(7681, 7682), 3);
                dirt.Name = "dirt";
                dirt.MoveToWorld(from.Location, from.Map);

                int dirtCount = Utility.RandomMinMax(2, 3);
                for (int a = 0; a < dirtCount; a++)
                {
                    Point3D newLocation = SpecialAbilities.GetRandomAdjustedLocation(from.Location, from.Map, true, 1, false);

                    dirt      = new TimedStatic(Utility.RandomList(7681, 7682), 3);
                    dirt.Name = "dirt";
                    dirt.MoveToWorld(newLocation, from.Map);
                }

                return(true);
            }

            return(false);
        }
Esempio n. 3
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (!SpecialAbilities.Exists(from))
                {
                    return;
                }
                if (m_PlantBowl == null)
                {
                    return;
                }
                if (m_PlantBowl.Deleted)
                {
                    return;
                }

                IPoint3D location = target as IPoint3D;

                if (location == null)
                {
                    return;
                }

                Point3D targetLocation = new Point3D(location.X, location.Y, location.Z);

                if (target is Item)
                {
                    Item item = target as Item;

                    targetLocation = item.GetWorldLocation();
                }

                if (Utility.GetDistance(from.Location, targetLocation) > 2)
                {
                    from.SendMessage("That target is too far away.");
                    return;
                }

                if (!from.Map.InLOS(from.Location, targetLocation))
                {
                    from.SendMessage("That target is out of sight.");
                    return;
                }

                if (!from.InRange(m_PlantBowl.GetWorldLocation(), 2))
                {
                    from.SendMessage("You are too far away from your plant bowl to target that.");

                    from.CloseGump(typeof(PlantGump));
                    from.SendGump(new PlantGump(from, m_PlantBowl));

                    return;
                }

                //Need Seed
                if (m_PlantBowl.PlantSeed == null)
                {
                    if (target is PlantSeed)
                    {
                        PlantSeed plantSeed = target as PlantSeed;

                        m_PlantBowl.PlantSeed = plantSeed;
                        m_PlantBowl.PlantSeed.Internalize();

                        from.PlaySound(0x059);
                        from.SendMessage("You plant the seed into the plant bowl.");
                    }

                    else
                    {
                        from.SendMessage("That is not a plant seed.");
                    }

                    from.CloseGump(typeof(PlantGump));
                    from.SendGump(new PlantGump(from, m_PlantBowl));

                    return;
                }

                //Add Ingredients
                else
                {
                    //Water Container
                    if (IsWaterContainer(target))
                    {
                        if (m_PlantBowl.WaterValue == PlantPersistance.MaxWater)
                        {
                            from.SendMessage("That plant bowl is already at full water capacity.");
                        }

                        else if (m_PlantBowl.GetWaterFromContainer(from, target))
                        {
                            m_PlantBowl.WaterValue += PlantPersistance.WaterAddedPerUse;

                            if (m_PlantBowl.WaterValue > PlantPersistance.MaxWater)
                            {
                                m_PlantBowl.WaterValue = PlantPersistance.MaxWater;
                            }

                            from.PlaySound(0x4E);
                            from.SendMessage("You fill the plant bowl with some water.");
                        }

                        else
                        {
                            from.SendMessage("There is not enough water available to fill this plant bowl.");
                        }

                        from.CloseGump(typeof(PlantGump));
                        from.SendGump(new PlantGump(from, m_PlantBowl));

                        return;
                    }

                    //Soil Item
                    else if (target is SoilEnhancer)
                    {
                        SoilEnhancer soilEnhancer = target as SoilEnhancer;

                        if (m_PlantBowl.SoilQualityValue == PlantPersistance.MaxSoilQuality)
                        {
                            from.SendMessage("That plant bowl is at maximum soil richness.");
                        }

                        else if (m_PlantBowl.SoilQualityValue >= soilEnhancer.MaxSoilQuality)
                        {
                            from.SendMessage("That plant requires a higher quality soil enhancer to increase its soil richness further.");
                        }

                        else
                        {
                            m_PlantBowl.SoilQualityValue += soilEnhancer.SoilQualityIncrease;

                            if (m_PlantBowl.SoilQualityValue > soilEnhancer.MaxSoilQuality)
                            {
                                m_PlantBowl.SoilQualityValue = soilEnhancer.MaxSoilQuality;
                            }

                            from.PlaySound(Utility.RandomList(0x134, 0x133, 0x132, 0x131));
                            from.SendMessage("You increase the plant's soil richness.");

                            soilEnhancer.Charges--;

                            if (soilEnhancer.Charges == 0)
                            {
                                soilEnhancer.Delete();
                            }
                        }

                        from.CloseGump(typeof(PlantGump));
                        from.SendGump(new PlantGump(from, m_PlantBowl));

                        return;
                    }

                    else
                    {
                        from.SendMessage("You cannot add that as an ingredient to this plant bowl.");

                        from.CloseGump(typeof(PlantGump));
                        from.SendGump(new PlantGump(from, m_PlantBowl));

                        return;
                    }
                }
            }