Пример #1
0
        public static bool ConsumeReeds(Container cont, PlantHue hue, int amount)
        {
            List <SoftenedReeds> reeds = GetReeds(cont, hue);

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

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

                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #2
0
        public override void OnAfterDuped(Item newItem)
        {
            SoftenedReeds newReeds = newItem as SoftenedReeds;

            if (newReeds != null)
            {
                newReeds.PlantHue = PlantHue;
            }
        }
Пример #3
0
        public static List <SoftenedReeds> GetReeds(List <SoftenedReeds> reeds, PlantHue hue)
        {
            List <SoftenedReeds> validReeds = new List <SoftenedReeds>();

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

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

            return(validReeds);
        }
Пример #4
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!
            }
        }
Пример #5
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!(targeted is SoftenedReeds) || !((SoftenedReeds)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));

                    SoftenedReeds reeds = targeted as SoftenedReeds;

                    WeavableBasket basket = (WeavableBasket)Activator.CreateInstance(m_CraftItem.ItemType);
                    bool           delete = true;

                    if (!reeds.IsChildOf(from.Backpack))
                    {
                        // You don't have enough wooden shafts to make that.
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112246));
                    }
                    if (from.Backpack == null || from.Backpack.GetAmount(typeof(Shaft)) < basket.NeededShafts)
                    {
                        // You don't have enough wooden shafts to make that.
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112246));
                    }
                    else if (SoftenedReeds.GetTotalReeds(from.Backpack, reeds.PlantHue) < basket.NeededReeds)
                    {
                        // You don't have enough of this type of softened reeds to make that.
                        from.SendGump(new CraftGump(from, m_CraftSystem, m_Tool, 1112251));
                    }
                    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())
                            {
                                SoftenedReeds.ConsumeReeds(from.Backpack, reeds.PlantHue, basket.NeededReeds / 2);

                                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(Shaft), basket.NeededShafts);
                                SoftenedReeds.ConsumeReeds(from.Backpack, reeds.PlantHue, basket.NeededReeds);

                                basket.Hue = reeds.Hue;
                                from.AddToBackpack(basket);
                                delete = false;

                                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));
                        }
                    }

                    if (delete)
                    {
                        basket.Delete();
                    }
                }
            }
Пример #6
0
        public void OnTarget(Mobile from, object targeted)
        {
            if (!(from is PlayerMobile) || !((PlayerMobile)from).BasketWeaving)
                from.SendLocalizedMessage(1112253); //You haven't learned basket weaving. Perhaps studying a book would help!
            else if (targeted is DryReeds)
            {
                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 item in items)
                    {
                        if (item is DryReeds)
                        {
                            DryReeds check = (DryReeds)item;

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

                    int toConsume = 2;

                    if (list.Count > 0 && total > 1)
                    {
                        foreach (Item item in list)
                        {
                            if (item.Amount >= toConsume)
                            {
                                item.Consume(toConsume);
                                toConsume = 0;
                            }
                            else if (item.Amount < toConsume)
                            {
                                item.Delete();
                                toConsume -= item.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.
                }

                return;
            }

            if (targeted is Item && BasePigmentsOfTokuno.IsValidItem((Item)targeted))
            {
                from.PlaySound(0x23E);
                from.SendMessage("You scour any color from the item.");

                ((Item)targeted).Hue = 0;
                this.Consume();
            }
            else
                from.SendMessage("You cannot scour that!");
        }