Exemple #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                Item target = ((Item)targeted);

                Container pack = from.Backpack;

                if (pack == null)
                {
                    from.SendMessage("Please ensure you have a pack.");
                    return;
                }

                if (target == null || target.Deleted || !(target is Runebook) || ((Runebook)target).Entries.Count > 0)
                {
                    from.SendMessage("You can only copy to an empty runebook.");
                    return;
                }

                if (target.RootParent != from)
                {
                    from.SendMessage("The runebook you wish to write to must be in your backpack.");
                    return;
                }

                if (ConsumeTotal(pack, ((Runebook)m_Source).Entries.Count, true) > -1)
                {
                    from.SendMessage("This operation requires unmarked recall runes and mark scrolls.");
                    from.SendMessage("Total of each needed: {0}.", ((Runebook)m_Source).Entries.Count);
                    return;
                }

                Type t = typeof(Runebook);

                ConstructorInfo c = t.GetConstructor(Type.EmptyTypes);

                if (c != null)
                {
                    try
                    {
                        from.SendMessage("Writing Copy...");

                        object o = c.Invoke(null);

                        if (o != null && o is Item)
                        {
                            Item newItem = (Item)o;
                            Dupe.CopyProperties(newItem, m_Source);
                            m_Source.OnAfterDuped(newItem);
                            newItem.Parent = null;
                            pack.DropItem(newItem);

                            newItem.InvalidateProperties();
                            from.SendMessage("Done");
                            m_Pen.UsesRemaining -= 1;
                            m_Pen.InvalidateProperties();
                            target.Delete();
                        }
                    }
                    catch
                    {
                        from.SendMessage("Error, please notify a GM!");
                    }
                }
            }