Example #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            m_PlantType = (PlantType)reader.ReadInt();
            m_PlantHue  = (PlantHue)reader.ReadInt();
            m_ShowType  = reader.ReadBool();

            if (Weight != 1.0)
            {
                Weight = 1.0;
            }

            if (version < 1)
            {
                Stackable = Core.SA;
            }

            if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue))
            {
                m_PlantHue |= PlantHue.Reproduces;
            }
        }
Example #2
0
        private void Update()
        {
            if (m_PlantStatus >= PlantStatus.DeadTwigs)
            {
                ItemID = 0x1B9D;
                Hue    = PlantHueInfo.GetInfo(m_PlantHue).Hue;
            }
            else if (m_PlantStatus >= PlantStatus.FullGrownPlant)
            {
                ItemID = PlantTypeInfo.GetInfo(m_PlantType).ItemID;
                Hue    = PlantHueInfo.GetInfo(m_PlantHue).Hue;
            }
            else if (m_PlantStatus >= PlantStatus.Plant)
            {
                ItemID = 0x1600;
                Hue    = 0;
            }
            else
            {
                ItemID = 0x1602;
                Hue    = 0;
            }

            InvalidateProperties();
        }
Example #3
0
        public int GetSeedLabel(PlantHueInfo hueInfo)
        {
            if (m_SeedLabel != -1)
            {
                return(m_SeedLabel);
            }

            return(hueInfo.IsBright() ? 1061918 : 1061917); // [bright] ~1_COLOR~ ~2_TYPE~ seed
        }
Example #4
0
        public int GetPlantLabelDecorative(PlantHueInfo hueInfo)
        {
            if (m_PlantLabelDecorative != -1)
            {
                return(m_PlantLabelDecorative);
            }

            return(hueInfo.IsBright() ? 1074267 : 1070973); // a decorative [bright] ~1_COLOR~ ~2_TYPE~
        }
Example #5
0
        public int GetSeedLabelPlural(PlantHueInfo hueInfo)
        {
            if (m_SeedLabelPlural != -1)
            {
                return(m_SeedLabelPlural);
            }

            return(hueInfo.IsBright() ? 1113493 : 1113492); // ~1_amount~ [bright] ~2_color~ ~3_type~ seeds
        }
Example #6
0
        public int GetPlantLabelSeed(PlantHueInfo hueInfo)
        {
            if (m_PlantLabelSeed != -1)
            {
                return(m_PlantLabelSeed);
            }

            return(hueInfo.IsBright() ? 1061887 : 1061888); // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
        }
Example #7
0
        public Seed(PlantType plantType, PlantHue plantHue, bool showType) : base(0xDCF)
        {
            Weight    = 1.0;
            Stackable = Core.SA;

            m_PlantType = plantType;
            m_PlantHue  = plantHue;
            m_ShowType  = showType;

            Hue = PlantHueInfo.GetInfo(plantHue).Hue;
        }
Example #8
0
        public static PlantHueInfo GetInfo(PlantHue plantHue)
        {
            PlantHueInfo info = null;

            if (m_Table.TryGetValue(plantHue, out info))
            {
                return(info);
            }
            else
            {
                return(m_Table[PlantHue.Plain]);
            }
        }
        private void AddSeedsState(int x, int y)
        {
            PlantSystem system     = m_Plant.PlantSystem;
            int         totalSeeds = system.AvailableSeeds + system.LeftSeeds;

            if (!m_Plant.Reproduces || totalSeeds == 0)
            {
                AddLabel(x + 5, y, 0x21, "X");
            }
            else
            {
                AddLabel(x, y, PlantHueInfo.GetInfo(system.SeedHue).GumpHue,
                         string.Format("{0}/{1}", system.AvailableSeeds, totalSeeds));
            }
        }
Example #10
0
        private void UpdateMaladies()
        {
            double infestationChance = 0.30 - StrengthPotion * 0.075 + (Water - 2) * 0.10;

            PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_Plant.PlantType);

            if (typeInfo.Flowery)
            {
                infestationChance += 0.10;
            }

            if (PlantHueInfo.IsBright(m_Plant.PlantHue))
            {
                infestationChance += 0.10;
            }

            if (Utility.RandomDouble() < infestationChance)
            {
                Infestation++;
            }


            double fungusChance = 0.15 - StrengthPotion * 0.075 + (Water - 2) * 0.10;

            if (Utility.RandomDouble() < fungusChance)
            {
                Fungus++;
            }

            if (Water > 2 || Utility.RandomDouble() < 0.9)
            {
                Water--;
            }

            if (PoisonPotion > 0)
            {
                Poison      += PoisonPotion;
                PoisonPotion = 0;
            }

            if (CurePotion > 0)
            {
                Disease   += CurePotion;
                CurePotion = 0;
            }

            StrengthPotion = 0;
        }
Example #11
0
        public int GetPlantLabelFullGrown(PlantHueInfo hueInfo)
        {
            if (m_PlantLabelFullGrown != -1)
            {
                return(m_PlantLabelFullGrown);
            }

            if (m_ContainsPlant)
            {
                return(hueInfo.IsBright() ? 1061891 : 1061889); // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~
            }
            else
            {
                return(hueInfo.IsBright() ? 1061892 : 1061890); // a ~1_HEALTH~ [bright] ~2_COLOR~ ~3_NAME~ plant
            }
        }
Example #12
0
        public int GetPlantLabelPlant(PlantHueInfo hueInfo)
        {
            if (m_PlantLabelPlant != -1)
            {
                return(m_PlantLabelPlant);
            }

            if (m_ContainsPlant)
            {
                return(hueInfo.IsBright() ? 1060832 : 1060831); // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~
            }
            else
            {
                return(hueInfo.IsBright() ? 1061887 : 1061888); // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~ ~6_val~
            }
        }
        private void AddResourcesState(int x, int y)
        {
            PlantResourceInfo resInfo = PlantResourceInfo.GetInfo(m_Plant.PlantType, m_Plant.PlantHue);

            PlantSystem system         = m_Plant.PlantSystem;
            int         totalResources = system.AvailableResources + system.LeftResources;

            if (resInfo == null || totalResources == 0)
            {
                AddLabel(x + 5, y, 0x21, "X");
            }
            else
            {
                AddLabel(x, y, PlantHueInfo.GetInfo(m_Plant.PlantHue).GumpHue,
                         string.Format("{0}/{1}", system.AvailableResources, totalResources));
            }
        }
Example #14
0
        public PlantSystem(PlantItem plant, GenericReader reader)
        {
            m_Plant = plant;

            int version = reader.ReadInt();

            m_FertileDirt = reader.ReadBool();

            if (version >= 1)
            {
                m_NextGrowth = reader.ReadDateTime();
            }
            else
            {
                m_NextGrowth = reader.ReadDeltaTime();
            }

            m_GrowthIndicator = (PlantGrowthIndicator)reader.ReadInt();

            m_Water = reader.ReadInt();

            m_Hits           = reader.ReadInt();
            m_Infestation    = reader.ReadInt();
            m_Fungus         = reader.ReadInt();
            m_Poison         = reader.ReadInt();
            m_Disease        = reader.ReadInt();
            m_PoisonPotion   = reader.ReadInt();
            m_CurePotion     = reader.ReadInt();
            m_HealPotion     = reader.ReadInt();
            m_StrengthPotion = reader.ReadInt();

            m_Pollinated     = reader.ReadBool();
            m_SeedType       = (PlantType)reader.ReadInt();
            m_SeedHue        = (PlantHue)reader.ReadInt();
            m_AvailableSeeds = reader.ReadInt();
            m_LeftSeeds      = reader.ReadInt();

            m_AvailableResources = reader.ReadInt();
            m_LeftResources      = reader.ReadInt();

            if (version < 2 && PlantHueInfo.IsCrossable(m_SeedHue))
            {
                m_SeedHue |= PlantHue.Reproduces;
            }
        }
Example #15
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            switch (version)
            {
            case 2:
            case 1:
            {
                m_Level = (SecureLevel)reader.ReadInt();
                goto case 0;
            }

            case 0:
            {
                if (version < 1)
                {
                    m_Level = SecureLevel.CoOwners;
                }

                m_PlantStatus = (PlantStatus)reader.ReadInt();
                m_PlantType   = (PlantType)reader.ReadInt();
                m_PlantHue    = (PlantHue)reader.ReadInt();
                m_ShowType    = reader.ReadBool();

                if (m_PlantStatus < PlantStatus.DecorativePlant)
                {
                    m_PlantSystem = new PlantSystem(this, reader);
                }

                if (version < 2 && PlantHueInfo.IsCrossable(m_PlantHue))
                {
                    m_PlantHue |= PlantHue.Reproduces;
                }

                break;
            }
            }

            m_Instances.Add(this);
        }
Example #16
0
        private int GetLabel(out string args)
        {
            PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_PlantType);
            PlantHueInfo  hueInfo  = PlantHueInfo.GetInfo(m_PlantHue);

            int title;

            if (m_ShowType || typeInfo.PlantCategory == PlantCategory.Default)
            {
                title = hueInfo.Name;
            }
            else
            {
                title = (int)typeInfo.PlantCategory;
            }

            if (Amount == 1)
            {
                if (m_ShowType)
                {
                    args = String.Format("#{0}\t#{1}", title, typeInfo.Name);
                    return(typeInfo.GetSeedLabel(hueInfo));
                }
                else
                {
                    args = String.Format("#{0}", title);
                    return(hueInfo.IsBright() ? 1060839 : 1060838); // [bright] ~1_val~ seed
                }
            }
            else
            {
                if (m_ShowType)
                {
                    args = String.Format("{0}\t#{1}\t#{2}", Amount, title, typeInfo.Name);
                    return(typeInfo.GetSeedLabelPlural(hueInfo));
                }
                else
                {
                    args = String.Format("{0}\t#{1}", Amount, title);
                    return(hueInfo.IsBright() ? 1113491 : 1113490); // ~1_amount~ [bright] ~2_val~ seeds
                }
            }
        }
Example #17
0
        public override void AddNameProperty(ObjectPropertyList list)
        {
            if (m_PlantStatus >= PlantStatus.DeadTwigs)
            {
                base.AddNameProperty(list);
            }
            else if (m_PlantStatus < PlantStatus.Seed)
            {
                string args;

                if (ShowContainerType)
                {
                    args = String.Format("#{0}\t#{1}", GetLocalizedContainerType(), m_PlantSystem.GetLocalizedDirtStatus());
                }
                else
                {
                    args = String.Format("#{0}", m_PlantSystem.GetLocalizedDirtStatus());
                }

                list.Add(1060830, args); // a ~1_val~ of ~2_val~ dirt
            }
            else
            {
                PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_PlantType);
                PlantHueInfo  hueInfo  = PlantHueInfo.GetInfo(m_PlantHue);

                if (m_PlantStatus >= PlantStatus.DecorativePlant)
                {
                    list.Add(typeInfo.GetPlantLabelDecorative(hueInfo), String.Format("#{0}\t#{1}", hueInfo.Name, typeInfo.Name));
                }
                else if (m_PlantStatus >= PlantStatus.FullGrownPlant)
                {
                    list.Add(typeInfo.GetPlantLabelFullGrown(hueInfo), String.Format("#{0}\t#{1}\t#{2}", m_PlantSystem.GetLocalizedHealth(), hueInfo.Name, typeInfo.Name));
                }
                else
                {
                    string args;

                    if (ShowContainerType)
                    {
                        args = String.Format("#{0}\t#{1}\t#{2}", GetLocalizedContainerType(), m_PlantSystem.GetLocalizedDirtStatus(), m_PlantSystem.GetLocalizedHealth());
                    }
                    else
                    {
                        args = String.Format("#{0}\t#{1}", m_PlantSystem.GetLocalizedDirtStatus(), m_PlantSystem.GetLocalizedHealth());
                    }

                    if (m_ShowType)
                    {
                        args += String.Format("\t#{0}\t#{1}\t#{2}", hueInfo.Name, typeInfo.Name, GetLocalizedPlantStatus());

                        if (m_PlantStatus == PlantStatus.Plant)
                        {
                            list.Add(typeInfo.GetPlantLabelPlant(hueInfo), args);
                        }
                        else
                        {
                            list.Add(typeInfo.GetPlantLabelSeed(hueInfo), args);
                        }
                    }
                    else
                    {
                        args += String.Format("\t#{0}\t#{1}", (typeInfo.PlantCategory == PlantCategory.Default) ? hueInfo.Name : (int)typeInfo.PlantCategory, GetLocalizedPlantStatus());

                        list.Add(hueInfo.IsBright() ? 1060832 : 1060831, args); // a ~1_val~ of ~2_val~ dirt with a ~3_val~ [bright] ~4_val~ ~5_val~
                    }
                }
            }
        }
Example #18
0
 public Seed() : this(PlantTypeInfo.RandomFirstGeneration(), PlantHueInfo.RandomFirstGeneration(), false)
 {
 }
Example #19
0
        protected override void OnTarget(Mobile from, object targeted)
        {
            if (!m_Plant.Deleted && m_Plant.PlantStatus < PlantStatus.DecorativePlant && from.InRange(m_Plant.GetWorldLocation(), 3))
            {
                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.
                }
                else 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
                {
                    PlantItem targ = targeted as PlantItem;

                    if (targ == null || targ.PlantStatus >= PlantStatus.DecorativePlant || targ.PlantStatus <= PlantStatus.BowlOfDirt)
                    {
                        m_Plant.LabelTo(from, 1053070); // You can only pollinate other specially grown plants!
                    }
                    else if (!targ.IsUsableBy(from))
                    {
                        targ.LabelTo(from, 1061856); // You must have the item in your backpack or locked down in order to use it.
                    }
                    else if (!targ.IsCrossable)
                    {
                        targ.LabelTo(from, 1053073); // You cannot cross-pollinate with a mutated plant!
                    }
                    else if (!targ.PlantSystem.PollenProducing)
                    {
                        targ.LabelTo(from, 1053074); // This plant is not in the flowering stage. You cannot pollinate it!
                    }
                    else if (targ.PlantSystem.Health < PlantHealth.Healthy)
                    {
                        targ.LabelTo(from, 1053075); // You cannot pollinate an unhealthy plant!
                    }
                    else if (targ.PlantSystem.Pollinated)
                    {
                        targ.LabelTo(from, 1053072); // This plant has already been pollinated!
                    }
                    else if (targ == m_Plant)
                    {
                        targ.PlantSystem.Pollinated = true;
                        targ.PlantSystem.SeedType   = m_Plant.PlantType;
                        targ.PlantSystem.SeedHue    = m_Plant.PlantHue;

                        targ.LabelTo(from, 1053071); // You pollinate the plant with its own pollen.
                    }
                    else
                    {
                        targ.PlantSystem.Pollinated = true;
                        targ.PlantSystem.SeedType   = PlantTypeInfo.Cross(m_Plant.PlantType, targ.PlantType);
                        targ.PlantSystem.SeedHue    = PlantHueInfo.Cross(m_Plant.PlantHue, targ.PlantHue);

                        targ.LabelTo(from, 1053076); // You successfully cross-pollinate the plant.
                    }
                }
            }
        }
        private void DrawPlant()
        {
            PlantStatus status = m_Plant.PlantStatus;

            if (status < PlantStatus.FullGrownPlant)
            {
                AddImage(110, 85, 0x589);

                AddItem(122, 94, 0x914);
                AddItem(135, 94, 0x914);
                AddItem(120, 112, 0x914);
                AddItem(135, 112, 0x914);

                if (status >= PlantStatus.Stage2)
                {
                    AddItem(127, 112, 0xC62);
                }
                if (status == PlantStatus.Stage3 || status == PlantStatus.Stage4)
                {
                    AddItem(129, 85, 0xC7E);
                }
                if (status >= PlantStatus.Stage4)
                {
                    AddItem(121, 117, 0xC62);
                    AddItem(133, 117, 0xC62);
                }
                if (status >= PlantStatus.Stage5)
                {
                    AddItem(110, 100, 0xC62);
                    AddItem(140, 100, 0xC62);
                    AddItem(110, 130, 0xC62);
                    AddItem(140, 130, 0xC62);
                }
                if (status >= PlantStatus.Stage6)
                {
                    AddItem(105, 115, 0xC62);
                    AddItem(145, 115, 0xC62);
                    AddItem(125, 90, 0xC62);
                    AddItem(125, 135, 0xC62);
                }
            }
            else
            {
                PlantTypeInfo typeInfo = PlantTypeInfo.GetInfo(m_Plant.PlantType);
                PlantHueInfo  hueInfo  = PlantHueInfo.GetInfo(m_Plant.PlantHue);

                // The large images for these trees trigger a client crash, so use a smaller, generic tree.
                if (m_Plant.PlantType == PlantType.CypressTwisted || m_Plant.PlantType == PlantType.CypressStraight)
                {
                    AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, 0x0CCA, hueInfo.Hue);
                }
                else
                {
                    AddItem(130 + typeInfo.OffsetX, 96 + typeInfo.OffsetY, typeInfo.ItemID, hueInfo.Hue);
                }
            }

            if (status != PlantStatus.BowlOfDirt)
            {
                int message = m_Plant.PlantSystem.GetLocalizedHealth();

                switch (m_Plant.PlantSystem.Health)
                {
                case PlantHealth.Dying:
                {
                    AddItem(92, 167, 0x1B9D);
                    AddItem(161, 167, 0x1B9D);

                    AddHtmlLocalized(136, 167, 42, 20, message, 0x00FC00, false, false);

                    break;
                }

                case PlantHealth.Wilted:
                {
                    AddItem(91, 164, 0x18E6);
                    AddItem(161, 164, 0x18E6);

                    AddHtmlLocalized(132, 167, 42, 20, message, 0x00C207, false, false);

                    break;
                }

                case PlantHealth.Healthy:
                {
                    AddItem(96, 168, 0xC61);
                    AddItem(162, 168, 0xC61);

                    AddHtmlLocalized(129, 167, 42, 20, message, 0x008200, false, false);

                    break;
                }

                case PlantHealth.Vibrant:
                {
                    AddItem(93, 162, 0x1A99);
                    AddItem(162, 162, 0x1A99);

                    AddHtmlLocalized(129, 167, 42, 20, message, 0x0083E0, false, false);

                    break;
                }
                }
            }
        }