예제 #1
0
                public EquipMenu(Mobile from, Mobile m, ItemListEntry[] entries) : base("Equipment", entries)
                {
                    m_Mobile = m;

                    CommandLogging.WriteLine(from, "{0} {1} viewing equipment of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(m));
                }
예제 #2
0
        public static void GetFollowers_OnTarget(Mobile from, object obj)
        {
            if (obj is PlayerMobile)
            {
                PlayerMobile  master = (PlayerMobile)obj;
                List <Mobile> pets   = master.AllFollowers;

                if (pets.Count > 0)
                {
                    CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master));

                    from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : "");

                    for (int i = 0; i < pets.Count; ++i)
                    {
                        Mobile pet = (Mobile)pets[i];

                        if (pet is IMount)
                        {
                            ((IMount)pet).Rider = null; // make sure it's dismounted
                        }
                        pet.MoveToWorld(from.Location, from.Map);
                    }
                }
                else
                {
                    from.SendMessage("There were no pets found for that player.");
                }
            }
            else if (obj is Mobile && ((Mobile)obj).Player)
            {
                Mobile    master = (Mobile)obj;
                ArrayList pets   = new ArrayList();

                foreach (Mobile m in World.Mobiles.Values)
                {
                    if (m is BaseCreature)
                    {
                        BaseCreature bc = (BaseCreature)m;

                        if ((bc.Controlled && bc.ControlMaster == master) || (bc.Summoned && bc.SummonMaster == master))
                        {
                            pets.Add(bc);
                        }
                    }
                }

                if (pets.Count > 0)
                {
                    CommandLogging.WriteLine(from, "{0} {1} getting all followers of {2}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(master));

                    from.SendMessage("That player has {0} pet{1}.", pets.Count, pets.Count != 1 ? "s" : "");

                    for (int i = 0; i < pets.Count; ++i)
                    {
                        Mobile pet = (Mobile)pets[i];

                        if (pet is IMount)
                        {
                            ((IMount)pet).Rider = null; // make sure it's dismounted
                        }
                        pet.MoveToWorld(from.Location, from.Map);
                    }
                }
                else
                {
                    from.SendMessage("There were no pets found for that player.");
                }
            }
            else
            {
                from.BeginTarget(-1, false, TargetFlags.None, new TargetCallback(GetFollowers_OnTarget));
                from.SendMessage("That is not a player. Try again.");
            }
        }
예제 #3
0
        public static void Invoke(Mobile from, Point3D start, Point3D end, string[] args, List <Container> packs = null, bool outline = false, bool mapAvg = false)
        {
            var b = new StringBuilder();

            b.AppendFormat("{0} {1} building ", from.AccessLevel, CommandLogging.Format(from));
            if (start == end)
            {
                b.AppendFormat("at {0} in {1}", start, from.Map);
            }
            else
            {
                b.AppendFormat("from {0} to {1} in {2}", start, end, from.Map);
            }
            b.Append(":");
            for (var i = 0; i < args.Length; ++i)
            {
                b.AppendFormat(" \"{0}\"", args[i]);
            }
            CommandLogging.WriteLine(from, b.ToString());
            var name = args[0];

            FixArgs(ref args);
            string[,] props = null;
            for (var i = 0; i < args.Length; ++i)
            {
                if (Insensitive.Equals(args[i], "set"))
                {
                    var remains = args.Length - i - 1;
                    if (remains >= 2)
                    {
                        props    = new string[remains / 2, 2];
                        remains /= 2;
                        for (var j = 0; j < remains; ++j)
                        {
                            props[j, 0] = args[i + (j * 2) + 1];
                            props[j, 1] = args[i + (j * 2) + 2];
                        }
                        FixSetString(ref args, i);
                    }
                    break;
                }
            }
            var type = ScriptCompiler.FindTypeByName(name);

            if (!IsEntity(type))
            {
                from.SendMessage("No type with that name was found.");
                return;
            }
            var time  = DateTime.UtcNow;
            var built = BuildObjects(from, type, start, end, args, props, packs, outline, mapAvg);

            if (built > 0)
            {
                from.SendMessage("{0} object{1} generated in {2:F1} seconds.", built, built != 1 ? "s" : string.Empty, (DateTime.UtcNow - time).TotalSeconds);
            }
            else
            {
                SendUsage(type, from);
            }
        }
예제 #4
0
 public static int Build(Mobile from, Point3D start, Point3D end, ConstructorInfo ctor, object[] values, string[,] props, PropertyInfo[] realProps, List <Container> packs, bool outline = false, bool mapAvg = false)
 {
     try
     {
         var map    = from.Map;
         var width  = end.X - start.X + 1;
         var height = end.Y - start.Y + 1;
         if (outline && (width < 3 || height < 3))
         {
             outline = false;
         }
         var objectCount = packs != null ? packs.Count : outline ? (width + height - 2) * 2 : width * height;
         if (objectCount >= 20)
         {
             from.SendMessage("Constructing {0} objects, please wait.", objectCount);
         }
         var sendError = true;
         var b         = new StringBuilder();
         b.Append("Serials: ");
         if (packs != null)
         {
             for (var i = 0; i < packs.Count; ++i)
             {
                 var built = Build(from, ctor, values, props, realProps, ref sendError);
                 b.AppendFormat("0x{0:X}; ", built.Serial.Value);
                 if (built is Item)
                 {
                     var pack = packs[i];
                     pack.DropItem((Item)built);
                 }
                 else if (built is Mobile m)
                 {
                     m.MoveToWorld(new Point3D(start.X, start.Y, start.Z), map);
                 }
             }
         }
         else
         {
             var z = start.Z;
             for (var x = start.X; x <= end.X; ++x)
             {
                 for (var y = start.Y; y <= end.Y; ++y)
                 {
                     if (outline && x != start.X && x != end.X && y != start.Y && y != end.Y)
                     {
                         continue;
                     }
                     if (mapAvg)
                     {
                         z = map.GetAverageZ(x, y);
                     }
                     var built = Build(from, ctor, values, props, realProps, ref sendError);
                     b.AppendFormat("0x{0:X}; ", built.Serial.Value);
                     if (built is Item item)
                     {
                         item.MoveToWorld(new Point3D(x, y, z), map);
                     }
                     else if (built is Mobile m)
                     {
                         m.MoveToWorld(new Point3D(x, y, z), map);
                     }
                 }
             }
         }
         CommandLogging.WriteLine(from, b.ToString());
         return(objectCount);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
         return(0);
     }
 }
예제 #5
0
            protected override void OnTarget(Mobile from, object targ)
            {
                bool done = false;

                if (!(targ is Item))
                {
                    from.SendMessage("You can only dupe items.");
                    return;
                }

                CommandLogging.WriteLine(from, "{0} {1} duping {2} (inBag={3}; amount={4})", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), m_InBag, m_Amount);

                Item      copy = (Item)targ;
                Container pack;

                if (m_InBag)
                {
                    if (copy.Parent is Container)
                    {
                        pack = (Container)copy.Parent;
                    }
                    else if (copy.Parent is Mobile)
                    {
                        pack = ((Mobile)copy.Parent).Backpack;
                    }
                    else
                    {
                        pack = null;
                    }
                }
                else
                {
                    pack = from.Backpack;
                }

                Type t = copy.GetType();

                //ConstructorInfo[] info = t.GetConstructors();

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

                if (c != null)
                {
                    try
                    {
                        from.SendMessage("Duping {0}...", m_Amount);
                        for (int i = 0; i < m_Amount; i++)
                        {
                            object o = c.Invoke(null);

                            if (o != null && o is Item)
                            {
                                Item newItem = (Item)o;
                                CopyProperties(newItem, copy);//copy.Dupe( item, copy.Amount );
                                copy.OnAfterDuped(newItem);
                                newItem.Parent = null;

                                if (pack != null)
                                {
                                    pack.DropItem(newItem);
                                }
                                else
                                {
                                    newItem.MoveToWorld(from.Location, from.Map);
                                }

                                newItem.InvalidateProperties();

                                CommandLogging.WriteLine(from, "{0} {1} duped {2} creating {3}", from.AccessLevel, CommandLogging.Format(from), CommandLogging.Format(targ), CommandLogging.Format(newItem));
                            }
                        }
                        from.SendMessage("Done");
                        done = true;
                    }
                    catch
                    {
                        from.SendMessage("Error!");
                        return;
                    }
                }

                if (!done)
                {
                    from.SendMessage("Unable to dupe.  Item must have a 0 parameter constructor.");
                }
            }