Ejemplo n.º 1
0
        public static bool ConsumeReeds(Container cont, PlantHue hue, int amount)
        {
            List <DryReeds> reeds = GetReeds(cont, hue);

            if (GetTotalReeds(reeds, hue) >= amount)
            {
                for (int i = 0; i < reeds.Count; i++)
                {
                    DryReeds reed = reeds[i];

                    if (amount >= reed.Amount)
                    {
                        amount -= reed.Amount;
                        reed.Delete();
                    }
                    else
                    {
                        reed.Amount -= amount;
                        break;
                    }
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        public override void OnAfterDuped(Item newItem)
        {
            DryReeds newReeds = newItem as DryReeds;

            if (newReeds != null)
            {
                newReeds.PlantHue = PlantHue;
            }
        }
Ejemplo n.º 3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Clippers.Deleted)
                {
                    return;
                }

                if (targeted is PlantItem)
                {
                    PlantItem plant = (PlantItem)targeted;

                    if (!plant.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(502437);                           // Items you wish to cut must be in your backpack.
                    }
                    if (plant.PlantStatus != PlantStatus.DecorativePlant)
                    {
                        from.SendLocalizedMessage(1112119);                           // You may only use these clippers on decorative plants.
                    }
                    else
                    {
                        // TODO (SA): ¿Se puede podar cualquier tipo de planta?

                        Item item;
                        if (m_Clippers.CutReeds)
                        {
                            item = new DryReeds(plant.PlantHue);
                        }
                        else
                        {
                            item = new PlantClippings(plant.PlantHue);
                        }

                        plant.Delete();

                        if (!from.PlaceInBackpack(item))
                        {
                            item.MoveToWorld(from.Location, from.Map);
                        }

                        from.SendLocalizedMessage(1112120);                           // You cut the plant into small pieces and place them in your backpack.

                        m_Clippers.UsesRemaining--;

                        if (m_Clippers.UsesRemaining <= 0)
                        {
                            m_Clippers.Delete();
                            from.SendLocalizedMessage(1112126);                               // Your clippers break as you use up the last charge.
                        }
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1112119);                       // You may only use these clippers on decorative plants.
                }
            }
Ejemplo n.º 4
0
        public static List <DryReeds> GetReeds(List <DryReeds> reeds, PlantHue hue)
        {
            List <DryReeds> validReeds = new List <DryReeds>();

            for (int i = 0; i < reeds.Count; i++)
            {
                DryReeds reed = reeds[i];

                if (reed.PlantHue == hue)
                {
                    validReeds.Add(reed);
                }
            }

            return(validReeds);
        }
Ejemplo n.º 5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                PlayerMobile pm = from as PlayerMobile;

                if (m_Item.Deleted)
                {
                    return;
                }

                PlantItem plant = targeted as PlantItem;

                if (null == plant || PlantStatus.DecorativePlant != plant.PlantStatus)
                {
                    from.SendLocalizedMessage(1112119); // You may only use these clippers on decorative plants.
                    return;
                }
                if (pm.ToggleCutClippings == true)
                {
                    /*PlantClippings clippings = new PlantClippings();
                     * clippings.PlantHue = plant.PlantHue;
                     * clippings.MoveToWorld(plant.Location, plant.Map);
                     * plant.Delete();*/
                    from.PlaySound(0x248);
                    PlantClippings cl = new PlantClippings();
                    cl.Hue      = ((PlantItem)targeted).Hue;
                    cl.PlantHue = plant.PlantHue;
                    from.AddToBackpack(cl);
                    plant.Delete();
                }


                else if (pm.ToggleCutReeds == true)
                {
                    /*DryReeds reeds = new DryReeds();
                     * reeds.PlantHue = plant.PlantHue;
                     * reeds.MoveToWorld(plant.Location, plant.Map);
                     * plant.Delete();
                     * from.PlaySound(0x248);*/
                    from.PlaySound(0x248);
                    DryReeds dr = new DryReeds();
                    dr.Hue      = ((PlantItem)targeted).Hue;
                    dr.PlantHue = plant.PlantHue;
                    from.AddToBackpack(dr);
                    plant.Delete();
                }
            }
Ejemplo n.º 6
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                PlayerMobile pm = from as PlayerMobile;

                if (this.m_Item.Deleted)
                    return;

                PlantItem plant = targeted as PlantItem;

                if (null == plant || PlantStatus.DecorativePlant != plant.PlantStatus)
                {
                    from.SendLocalizedMessage(1112119); // You may only use these clippers on decorative plants.
                    return;
                }
                if (pm.ToggleCutClippings == true)
                {
                    /*PlantClippings clippings = new PlantClippings();
                    clippings.PlantHue = plant.PlantHue;
                    clippings.MoveToWorld(plant.Location, plant.Map);
                    plant.Delete();*/
                    from.PlaySound(0x248);
                    PlantClippings cl = new PlantClippings();
                    cl.Hue = ((PlantItem)targeted).Hue;
                    cl.PlantHue = plant.PlantHue;
                    from.AddToBackpack(cl);
                    plant.Delete();
                }
                else if (pm.ToggleCutReeds == true)
                {
                    /*DryReeds reeds = new DryReeds();
                    reeds.PlantHue = plant.PlantHue;
                    reeds.MoveToWorld(plant.Location, plant.Map);
                    plant.Delete();
                    from.PlaySound(0x248);*/
                    from.PlaySound(0x248);
                    DryReeds dr = new DryReeds();
                    dr.Hue = ((PlantItem)targeted).Hue;
                    dr.PlantHue = plant.PlantHue;
                    from.AddToBackpack(dr);
                    plant.Delete();
                }
                //TODO: Add in clipping hedges (short and tall) and juniperbushes for topiaries
            }
Ejemplo n.º 7
0
        public void OnTarget(Mobile from, object targeted)
        {
            if (targeted is Item)
            {
                var item = (Item)targeted;

                if (item.Parent is Mobile)
                {
                    from.SendLocalizedMessage(1112350); // You cannot scour items that are being worn!
                }
                else if (item.IsLockedDown || item.IsSecure)
                {
                    from.SendLocalizedMessage(1112351); // You may not scour items which are locked down.
                }
                else if (item.QuestItem)
                {
                    from.SendLocalizedMessage(1151837); // You may not scour toggled quest items.
                }
                else if (item is DryReeds)
                {
                    if (!(from is PlayerMobile) || !((PlayerMobile)from).BasketWeaving)
                    {
                        from.SendLocalizedMessage(1112253); //You haven't learned basket weaving. Perhaps studying a book would help!
                    }
                    else
                    {
                        DryReeds  reed1 = (DryReeds)targeted;
                        Container cont  = from.Backpack;

                        Server.Engines.Plants.PlantHue hue = reed1.PlantHue;

                        if (!reed1.IsChildOf(from.Backpack))
                        {
                            from.SendLocalizedMessage(1116249); //That must be in your backpack for you to use it.
                        }
                        else if (cont != null)
                        {
                            Item[]      items = cont.FindItemsByType(typeof(DryReeds));
                            List <Item> list  = new List <Item>();
                            int         total = 0;

                            foreach (Item it in items)
                            {
                                if (it is DryReeds)
                                {
                                    DryReeds check = (DryReeds)it;

                                    if (reed1.PlantHue == check.PlantHue)
                                    {
                                        total += it.Amount;
                                        list.Add(it);
                                    }
                                }
                            }

                            int toConsume = 2;

                            if (list.Count > 0 && total > 1)
                            {
                                foreach (Item it in list)
                                {
                                    if (it.Amount >= toConsume)
                                    {
                                        it.Consume(toConsume);
                                        toConsume = 0;
                                    }
                                    else if (it.Amount < toConsume)
                                    {
                                        it.Delete();
                                        toConsume -= it.Amount;
                                    }

                                    if (toConsume <= 0)
                                    {
                                        break;
                                    }
                                }

                                SoftenedReeds sReed = new SoftenedReeds(hue);

                                if (!from.Backpack.TryDropItem(from, sReed, false))
                                {
                                    sReed.MoveToWorld(from.Location, from.Map);
                                }

                                m_UsesRemaining--;

                                if (m_UsesRemaining <= 0)
                                {
                                    Delete();
                                }
                                else
                                {
                                    InvalidateProperties();
                                }

                                from.PlaySound(0x23E);
                            }
                            else
                            {
                                from.SendLocalizedMessage(1112250); //You don't have enough of this type of dry reeds to make that.
                            }
                        }
                    }
                }
                else if (BasePigmentsOfTokuno.IsValidItem(item))
                {
                    from.PlaySound(0x23E);

                    ((Item)targeted).Hue = 0;

                    m_UsesRemaining--;

                    if (m_UsesRemaining <= 0)
                    {
                        Delete();
                    }
                    else
                    {
                        InvalidateProperties();
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1112349); // You cannot scour that!
                }
            }
            else
            {
                from.SendLocalizedMessage(1112349); // You cannot scour that!
            }
        }
Ejemplo n.º 8
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!(targeted is DryReeds) || !((DryReeds)targeted).IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1046439);                       // That is not a valid target.
                    from.SendLocalizedMessage(1074794);                       // Target the material to use:

                    from.Target = new ReedsTarget(m_CraftSystem, m_TypeRes, m_Tool, m_CraftItem);
                }
                else
                {
                    from.EndAction(typeof(CraftSystem));

                    DryReeds reeds = targeted as DryReeds;

                    if (!reeds.IsChildOf(from.Backpack))
                    {
                        // You do not have enough scouring toxins to make that!
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112326));
                    }
                    if (from.Backpack == null || from.Backpack.GetAmount(typeof(ScouringToxin)) < 1)
                    {
                        // You do not have enough scouring toxins to make that!
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112326));
                    }
                    else if (DryReeds.GetTotalReeds(from.Backpack, reeds.PlantHue) < 2)
                    {
                        // You don't have enough of this type of dry reeds to make that.
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112250));
                    }
                    else
                    {
                        bool allRequiredSkills = true;

                        double chance = m_CraftItem.GetSuccessChance(from, m_TypeRes, m_CraftSystem, true, ref allRequiredSkills);

                        if (chance > 0.0)
                        {
                            chance += m_CraftItem.GetTalismanBonus(from, m_CraftSystem);
                        }

                        if (allRequiredSkills)
                        {
                            if (chance < Utility.RandomDouble())
                            {
                                DryReeds.ConsumeReeds(from.Backpack, reeds.PlantHue, 1);

                                from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1044043));                                     // You failed to create the item, and some of your materials are lost.
                            }
                            else
                            {
                                from.Backpack.ConsumeTotal(typeof(ScouringToxin), 1);
                                DryReeds.ConsumeReeds(from.Backpack, reeds.PlantHue, 2);

                                from.AddToBackpack(new SoftenedReeds(reeds.PlantHue));

                                bool toolBroken = false;

                                m_Tool.UsesRemaining--;

                                if (m_Tool.UsesRemaining < 1)
                                {
                                    toolBroken = true;
                                }

                                if (toolBroken)
                                {
                                    m_Tool.Delete();

                                    from.SendLocalizedMessage(1044038);                                       // You have worn out your tool!
                                    from.SendLocalizedMessage(1044154);                                       // You create the item.
                                }

                                if (!toolBroken)
                                {
                                    // You create the item.
                                    from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1044154));
                                }
                            }
                        }
                        else
                        {
                            // You don't have the required skills to attempt this item.
                            from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1044153));
                        }
                    }
                }
            }
Ejemplo n.º 9
0
        protected void Target(Mobile from, object targeted)
        {
            if (from.Backpack == null)
            {
                return;
            }

            if (!IsChildOf(from.Backpack))
            {
                // This must be in your backpack to use it.
                from.SendLocalizedMessage(1080063);
            }
            else if (targeted is Item)
            {
                Item item = targeted as Item;

                if (item.Parent is Mobile)
                {
                    // You cannot scour items that are being worn!
                    from.SendLocalizedMessage(1112350);
                }
                else if (!item.IsChildOf(from.Backpack))
                {
                    // That must be in your pack for you to use it.
                    from.SendLocalizedMessage(1042001);
                }
                else if (!item.Movable)
                {
                    // You may not scour items which are locked down.
                    from.SendLocalizedMessage(1112351);
                }
                else if (item is DryReeds)
                {
                    if (!(from is PlayerMobile) || !((PlayerMobile)from).BasketWeaving)
                    {
                        // You haven't learned basket weaving. Perhaps studying a book would help!
                        from.SendLocalizedMessage(1112253);
                    }
                    else
                    {
                        PlantHue hue = ((DryReeds)item).PlantHue;

                        if (DryReeds.ConsumeReeds(from.Backpack, hue, 2))
                        {
                            Consume();
                            from.AddToBackpack(new SoftenedReeds(hue));
                        }
                        else
                        {
                            // You don't have enough of this type of dry reeds to make that.
                            from.SendLocalizedMessage(1112250);
                        }
                    }
                }
                else if (NaturalDye.IsValidItem(item))
                {
                    Consume();

                    item.Hue = 0;
                    from.PlaySound(0x23E);
                }
                else
                {
                    // You cannot scour that!
                    from.SendLocalizedMessage(1112349);
                }
            }
            else
            {
                // You cannot scour that!
                from.SendLocalizedMessage(1112349);
            }
        }