Ejemplo n.º 1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (!BaseCommand.IsAccessible(from, targeted))
                {
                    from.SendMessage("That is not accessible.");
                    return;
                }

                if (targeted is Mobile)
                {
                    from.SendMenu(new EquipMenu(from, (Mobile)targeted, GetEquip((Mobile)targeted)));
                }
            }
		public void OnTarget(Mobile from, Map map, Point3D start, Point3D end, object state)
		{
			try
			{
				object[] states = (object[])state;
				BaseCommand command = (BaseCommand)states[0];
				string[] args = (string[])states[1];

				ObjectConditional cond = ObjectConditional.Parse(from, ref args);

				Rectangle2D rect = new Rectangle2D(start.X, start.Y, end.X - start.X + 1, end.Y - start.Y + 1);

				bool items, mobiles;

				if (!CheckObjectTypes(command, cond, out items, out mobiles))
					return;

				IPooledEnumerable eable;

				if (items && mobiles)
					eable = map.GetObjectsInBounds(rect);
				else if (items)
					eable = map.GetItemsInBounds(rect);
				else if (mobiles)
					eable = map.GetMobilesInBounds(rect);
				else
					return;

				ArrayList objs = new ArrayList();

				foreach (object obj in eable)
				{
					if (mobiles && obj is Mobile && !BaseCommand.IsAccessible(from, obj))
						continue;

					if (cond.CheckCondition(obj))
						objs.Add(obj);
				}

				eable.Free();

				RunCommand(from, objs, command, args);
			}
			catch (Exception ex)
			{
				LogHelper.LogException(ex);
				from.SendMessage(ex.Message);
			}
		}
Ejemplo n.º 3
0
            protected override void OnTarget(Mobile from, object o)
            {
                Mobile       m;
                PlayerMobile mo;
                BaseCreature mx;

                if (!BaseCommand.IsAccessible(from, o))
                {
                    from.SendMessage("That is not accessible.");
                }
                else if (o is BaseCreature)
                {
                    mx = (BaseCreature)o; mx.PlaySound(0x214); mx.FixedEffect(0x376A, 10, 16); mx.ResurrectPet(); mx.Hits = mx.HitsMax; mx.Stam = mx.StamMax; mx.Mana = mx.ManaMax;
                }
                else if (o is Mobile)
                {
                    m = (Mobile)o;
                    if (m.Alive && m is PlayerMobile && m.Account != null && m.NetState.Address.ToString() == "127.0.0.1")
                    {
                        mo = m as PlayerMobile;
                        if (mo.FindItemOnLayer(Layer.Earrings) == null)
                        {
                            var it = new Zearring();
                            it.BlessedBy = mo;
                            mo.AddItem(it);
                        }
                    }
                    if (!m.Alive)
                    {
                        m.PlaySound(0x214);
                        m.FixedEffect(0x376A, 10, 16);
                        m.Resurrect();
                        from.SendMessage("Resurrect it.");
                    }
                    m.Hits   = m.HitsMax;
                    m.Stam   = m.StamMax;
                    m.Mana   = m.ManaMax;
                    m.Thirst = 20;
                    m.Hunger = 20;
                    from.SendMessage("and Recover it.");
                }
                else
                {
                    from.SendMessage("That is not a mobile.");
                }
            }
Ejemplo n.º 4
0
            protected override void OnTarget(Mobile from, object o)
            {
                if (!BaseCommand.IsAccessible(from, o))
                {
                    from.SendMessage("That is not accessible.");
                }
                else if (o is Mobile)
                {
                    var m = (Mobile)o;

                    if (!m.Alive)
                    {
                        m.Resurrect();
                    }

                    m.Hits = m.HitsMax;
                    m.Mana = m.ManaMax;
                    m.Stam = m.StamMax;

                    m.Hunger = 20;
                    m.Thirst = 20;

                    m.Poison = null;
                }
                else if (o is Item)
                {
                    var item = (Item)o;

                    if (item is BaseArmor)
                    {
                        ((BaseArmor)item).HitPoints = ((BaseArmor)item).MaxHitPoints;
                    }

                    if (item is BaseWeapon)
                    {
                        ((BaseWeapon)item).HitPoints = ((BaseWeapon)item).MaxHitPoints;
                    }
                }
            }
Ejemplo n.º 5
0
        private static void Props_OnCommand(CommandEventArgs e)
        {
            if (e.Length == 1)
            {
                IEntity ent = World.FindEntity(e.GetUInt32(0));

                if (ent == null)
                {
                    e.Mobile.SendMessage("No object with that serial was found.");
                }
                else if (!BaseCommand.IsAccessible(e.Mobile, ent))
                {
                    e.Mobile.SendLocalizedMessage(500447); // That is not accessible.
                }
                else
                {
                    e.Mobile.SendGump(new PropertiesGump(e.Mobile, ent));
                }
            }
            else
            {
                e.Mobile.Target = new PropsTarget();
            }
        }
Ejemplo n.º 6
0
        private static void Go_OnCommand(CommandEventArgs e)
        {
            Mobile from = e.Mobile;

            if (e.Length == 0)
            {
                GoGump.DisplayTo(from);
                return;
            }

            if (e.Length == 1)
            {
                try
                {
                    int ser = e.GetInt32(0);

                    IEntity ent = World.FindEntity(ser);

                    if (ent is Item)
                    {
                        Item item = (Item)ent;

                        Map     map = item.Map;
                        Point3D loc = item.GetWorldLocation();

                        Mobile owner = item.RootParent as Mobile;

                        if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible(from, owner) /* !from.CanSee( owner )*/)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (!FixMap(ref map, ref loc, item))
                        {
                            from.SendMessage("That is an internal item and you cannot go to it.");
                            return;
                        }

                        from.MoveToWorld(loc, map);

                        return;
                    }
                    else if (ent is Mobile)
                    {
                        Mobile m = (Mobile)ent;

                        Map     map = m.Map;
                        Point3D loc = m.Location;

                        Mobile owner = m;

                        if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !BaseCommand.IsAccessible(from, owner) /* !from.CanSee( owner )*/)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= from.AccessLevel)
                        {
                            from.SendMessage("You can not go to what you can not see.");
                            return;
                        }
                        else if (!FixMap(ref map, ref loc, m))
                        {
                            from.SendMessage("That is an internal mobile and you cannot go to it.");
                            return;
                        }

                        from.MoveToWorld(loc, map);

                        return;
                    }
                    else
                    {
                        string name = e.GetString(0);
                        Map    map;

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            map = Map.AllMaps[i];

                            if (map.MapIndex == 0x7F || map.MapIndex == 0xFF)
                            {
                                continue;
                            }

                            if (Insensitive.Equals(name, map.Name))
                            {
                                from.Map = map;
                                return;
                            }
                        }

                        Dictionary <string, Region> list = from.Map.Regions;

                        foreach (KeyValuePair <string, Region> kvp in list)
                        {
                            Region r = kvp.Value;

                            if (Insensitive.Equals(r.Name, name))
                            {
                                from.Location = new Point3D(r.GoLocation);
                                return;
                            }
                        }

                        for (int i = 0; i < Map.AllMaps.Count; ++i)
                        {
                            Map m = Map.AllMaps[i];

                            if (m.MapIndex == 0x7F || m.MapIndex == 0xFF || from.Map == m)
                            {
                                continue;
                            }

                            foreach (Region r in m.Regions.Values)
                            {
                                if (Insensitive.Equals(r.Name, name))
                                {
                                    from.MoveToWorld(r.GoLocation, m);
                                    return;
                                }
                            }
                        }

                        if (ser != 0)
                        {
                            from.SendMessage("No object with that serial was found.");
                        }
                        else
                        {
                            from.SendMessage("No region with that name was found.");
                        }

                        return;
                    }
                }
                catch
                {
                }

                from.SendMessage("Region name not found");
            }
            else if (e.Length == 2 || e.Length == 3)
            {
                Map map = from.Map;

                if (map != null)
                {
                    try
                    {
                        /*
                         * This to avoid being teleported to (0,0) if trying to teleport
                         * to a region with spaces in its name.
                         */
                        int x = int.Parse(e.GetString(0));
                        int y = int.Parse(e.GetString(1));
                        int z = (e.Length == 3) ? int.Parse(e.GetString(2)) : map.GetAverageZ(x, y);

                        from.Location = new Point3D(x, y, z);
                    }
                    catch
                    {
                        from.SendMessage("Region name not found.");
                    }
                }
            }
            else if (e.Length == 6)
            {
                Map map = from.Map;

                if (map != null)
                {
                    Point3D p = Sextant.ReverseLookup(map, e.GetInt32(3), e.GetInt32(0), e.GetInt32(4), e.GetInt32(1), Insensitive.Equals(e.GetString(5), "E"), Insensitive.Equals(e.GetString(2), "S"));

                    if (p != Point3D.Zero)
                    {
                        from.Location = p;
                    }
                    else
                    {
                        from.SendMessage("Sextant reverse lookup failed.");
                    }
                }
            }
            else
            {
                from.SendMessage("Format: Go [name | serial | (x y [z]) | (deg min (N | S) deg min (E | W)]");
            }
        }
Ejemplo n.º 7
0
        public void OnTarget(Mobile from, object targeted, object state)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendMessage("That is not accessible.");
                return;
            }

            object[]    states  = (object[])state;
            BaseCommand command = (BaseCommand)states[0];

            string[] args = (string[])states[1];

            if (command.ObjectTypes == ObjectTypes.Mobiles)
            {
                return;                 // sanity check
            }
            if (!(targeted is Container))
            {
                from.SendMessage("That is not a container.");
            }
            else
            {
                try
                {
                    ObjectConditional cond = ObjectConditional.Parse(from, ref args);

                    bool items, mobiles;

                    if (!CheckObjectTypes(command, cond, out items, out mobiles))
                    {
                        return;
                    }

                    if (!items)
                    {
                        from.SendMessage("This command only works on items.");
                        return;
                    }

                    Container cont = (Container)targeted;

                    Item[] found;

                    if (cond.Type == null)
                    {
                        found = cont.FindItemsByType(typeof(Item), true);
                    }
                    else
                    {
                        found = cont.FindItemsByType(cond.Type, true);
                    }

                    ArrayList list = new ArrayList();

                    for (int i = 0; i < found.Length; ++i)
                    {
                        if (cond.CheckCondition(found[i]))
                        {
                            list.Add(found[i]);
                        }
                    }

                    RunCommand(from, list, command, args);
                }
                catch (Exception e)
                {
                    LogHelper.LogException(e);
                    from.SendMessage(e.Message);
                }
            }
        }
Ejemplo n.º 8
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Mobile.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Mobile))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.SendGump(new PropertiesGump(m_From, m_Mobile));
                break;
            }

            case 3:                     // Delete
            {
                if (!m_Mobile.Player)
                {
                    CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Mobile));
                    m_Mobile.Delete();
                    m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                }

                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                InvokeCommand(String.Format("Go {0}", m_Mobile.Serial.Value));
                break;
            }

            case 5:                     // Bring them here
            {
                if (m_From.Map == null || m_From.Map == Map.Internal)
                {
                    m_From.SendMessage("You cannot bring that person here.");
                }
                else
                {
                    m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                    m_Mobile.MoveToWorld(m_From.Location, m_From.Map);
                }

                break;
            }

            case 6:                     // Move to target
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));
                m_From.Target = new MoveTarget(m_Mobile);
                break;
            }

            case 7:                     // Kill
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.Kill();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 8:                     // Res
            {
                if (m_From == m_Mobile || m_From.AccessLevel > m_Mobile.AccessLevel)
                {
                    m_Mobile.PlaySound(0x214);
                    m_Mobile.FixedEffect(0x376A, 10, 16);

                    m_Mobile.Resurrect();
                }

                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                break;
            }

            case 9:                     // Client
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_List, m_Page, m_Mobile));

                if (m_Mobile.NetState != null)
                {
                    m_From.SendGump(new ClientGump(m_From, m_Mobile.NetState));
                }

                break;
            }
            }
        }
Ejemplo n.º 9
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }
            else if (!BaseCommand.IsAccessible(m_From, m_Item))
            {
                m_From.SendMessage("That is no longer accessible.");
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                return;
            }

            switch (info.ButtonID)
            {
            case 0:
            case 1:
            {
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.SendGump(new PropertiesGump(m_From, m_Item));
                break;
            }

            case 3:                     // Delete
            {
                CommandLogging.WriteLine(m_From, "{0} {1} deleting {2}", m_From.AccessLevel, CommandLogging.Format(m_From), CommandLogging.Format(m_Item));
                m_Item.Delete();
                m_From.SendGump(new InterfaceGump(m_From, m_List, m_Page));
                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                InvokeCommand(String.Format("Go {0}", m_Item.Serial.Value));
                break;
            }

            case 5:                     // Move to target
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                m_From.Target = new MoveTarget(m_Item);
                break;
            }

            case 6:                     // Bring to pack
            {
                Mobile owner = m_Item.RootParent as Mobile;

                if (owner != null && (owner.Map != null && owner.Map != Map.Internal) && !m_From.CanSee(owner))
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else if (owner != null && (owner.Map == null || owner.Map == Map.Internal) && owner.Hidden && owner.AccessLevel >= m_From.AccessLevel)
                {
                    m_From.SendMessage("You can not get what you can not see.");
                }
                else
                {
                    m_From.SendGump(new InterfaceItemGump(m_From, m_List, m_Page, m_Item));
                    m_From.AddToBackpack(m_Item);
                }

                break;
            }
            }
        }