Example #1
0
                protected override void OnTarget(Mobile from, object targeted)
                {
                    if (!(targeted is Item targetitem) || Potion.Deleted)
                    {
                        return;
                    }

                    if (!Potion.IsChildOf(from.Backpack) || !targetitem.IsChildOf(from.Backpack))
                    {
                        from.SendLocalizedMessage(1060640); // The item must be in your backpack to use it.
                        return;
                    }

                    var ip = new ItemProps {
                        Item = targetitem, Props = Mannequin.FindMagicalItemProperty(targetitem)
                    };

                    if (IsSource)
                    {
                        Potion.Source = ip;
                    }
                    else
                    {
                        if (Potion.CheckMagicalItem(ip.Props))
                        {
                            from.SendLocalizedMessage(1159504); // The destination item must be free of any magical properties.
                            return;
                        }

                        if (targetitem.HasSocket <Transmogrified>())
                        {
                            from.Send(new AsciiMessage(-1, -1, MessageType.Label, 946, 3, "System", "This item has already been transmogrified."));
                        }
                        else
                        {
                            Potion.Destination = ip;
                        }
                    }

                    int message = 0;

                    if (targetitem.Layer != Potion.ItemLayer)
                    {
                        message = Potion.ValidFailMessage;
                    }
                    else if (Potion.Destination != null && Potion.Destination.Item != null && !Potion.Destination.Item.Deleted &&
                             Potion.Source != null && Potion.Source.Item != null && !Potion.Source.Item.Deleted)
                    {
                        if (Potion.Destination.Item == Potion.Source.Item)
                        {
                            message = 1159518; // You may not set the source and destination objects to the same object!
                        }
                        else if (RaceDefinitions.GetRequiredRace(Potion.Destination.Item) != RaceDefinitions.GetRequiredRace(Potion.Source.Item))
                        {
                            message = 1159560; // You may not set the source and destination objects to objects of different race requirements.
                        }
                        else if (!Potion.CheckRules())
                        {
                            message = Potion.ValidFailMessage;
                        }
                        else if (Potion.Destination.Props.Except(Potion.Source.Props).Any(x => x is MedableArmorProperty))
                        {
                            message = 1159678; // Both source and destination objects must allow the use of the meditation skill (medable) or both block the meditation skill (non-medable).
                        }
                    }

                    if (message == 0)
                    {
                        from.CloseGump(typeof(BaseTransmogrificationPotionGump));
                        from.SendGump(new BaseTransmogrificationPotionGump(Potion));
                    }
                    else
                    {
                        if (IsSource)
                        {
                            Potion.Source = null;
                        }
                        else
                        {
                            Potion.Destination = null;
                        }

                        from.SendLocalizedMessage(message);
                    }
                }