public override void Register( BaseCommand command )
		{
			base.Register( command );

			for ( int i = 0; i < command.Commands.Length; ++i )
				CommandSystem.Register( command.Commands[i], command.AccessLevel, new CommandEventHandler( Redirect ) );
		}
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			if ( command.ObjectTypes == ObjectTypes.Items )
				return; // sanity check

			obj = from;
		}
		public override void Process( Mobile from, BaseCommand command, string[] args )
		{
			RangeCommandImplementor impl = RangeCommandImplementor.Instance;

			if ( impl == null )
				return;

			impl.Process( 18, from, command, args );
		}
Exemple #4
0
		public static void Register( BaseCommand command )
		{
			m_AllCommands.Add( command );

			List<BaseCommandImplementor> impls = BaseCommandImplementor.Implementors;

			for ( int i = 0; i < impls.Count; ++i )
			{
				BaseCommandImplementor impl = impls[i];

				if ( (command.Supports & impl.SupportRequirement) != 0 )
					impl.Register( command );
			}
		}
        public override void Process(Mobile from, BaseCommand command, string[] args)
        {
            AreaCommandImplementor impl = AreaCommandImplementor.Instance;

            if (impl == null)
                return;

            Map map = from.Map;

            if (map == null || map == Map.Internal)
                return;

            impl.OnTarget(from, map, Point3D.Zero, new Point3D(map.Width - 1, map.Height - 1, 0), new object[] { command, args });
        }
		public void Process( int range, Mobile from, BaseCommand command, string[] args )
		{
			AreaCommandImplementor impl = AreaCommandImplementor.Instance;

			if ( impl == null )
				return;

			Map map = from.Map;

			if ( map == null || map == Map.Internal )
				return;

			Point3D start = new Point3D( from.X - range, from.Y - range, from.Z );
			Point3D end = new Point3D( from.X + range, from.Y + range, from.Z );

			impl.OnTarget( from, map, start, end, new object[] { command, args } );
		}
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;

                if (!this.CheckObjectTypes(from, command, ext, out items, out mobiles))
                    return;

                if (!mobiles) // sanity check
                {
                    command.LogFailure("This command does not support items.");
                    return;
                }

                ArrayList list = new ArrayList();

                List<NetState> states = NetState.Instances;

                for (int i = 0; i < states.Count; ++i)
                {
                    NetState ns = states[i];
                    Mobile mob = ns.Mobile;

                    if (mob == null)
                        continue;

                    if (!BaseCommand.IsAccessible(from, mob))
                        continue;

                    if (ext.IsValid(mob))
                        list.Add(mob);
                }

                ext.Filter(list);

                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				if (LoggingCustom.CommandDebug)
					LoggingCustom.LogCommandDebug("Global...compiling\t");
                Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "1\t");
				if ( !CheckObjectTypes( from, command, ext, out items, out mobiles ) )
					return;

				ArrayList list = new ArrayList();

				if ( items )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "2\t");
                    foreach ( Item item in World.Items.Values )
					{
						if ( ext.IsValid( item ) )
							list.Add( item );
					}
				}

				if ( mobiles )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "3\t");
                    foreach ( Mobile mob in World.Mobiles.Values )
					{
						if ( ext.IsValid( mob ) )
							list.Add( mob );
					}
				}
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "startfilter:list with " + list.Count+ " in it\t");
				ext.Filter( list );
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "4\t");
				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

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

				if ( !mobiles ) // sanity check
				{
					command.LogFailure( "This command does not support items." );
					return;
				}

				ArrayList list = new ArrayList();
				ArrayList addresses = new ArrayList();

				System.Collections.Generic.List<NetState> states = NetState.Instances;

				for ( int i = 0; i < states.Count; ++i )
				{
					NetState ns = (NetState)states[i];
					Mobile mob = ns.Mobile;

					if ( mob != null && !addresses.Contains( ns.Address ) && ext.IsValid( mob ) )
					{
						list.Add( mob );
						addresses.Add( ns.Address );
					}
				}

				ext.Filter( list );

				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

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

				Region reg = from.Region;

				ArrayList list = new ArrayList();

				if ( mobiles )
				{
					foreach ( Mobile mob in reg.GetMobiles() )
					{
						if( !BaseCommand.IsAccessible( from, mob ) )
							continue;

						if ( ext.IsValid( mob ) )
							list.Add( mob );
					}
				}
				else
				{
					command.LogFailure( "This command does not support items." );
					return;
				}

				ext.Filter( list );

				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public override void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			try
			{
				Extensions ext = Extensions.Parse( from, ref args );

				bool items, mobiles;

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

				ArrayList list = new ArrayList();

				if ( items )
				{
					foreach ( Item item in World.Items.Values )
					{
						if ( ext.IsValid( item ) )
							list.Add( item );
					}
				}

				if ( mobiles )
				{
					foreach ( Mobile mob in World.Mobiles.Values )
					{
						if ( ext.IsValid( mob ) )
							list.Add( mob );
					}
				}

				ext.Filter( list );

				obj = list;
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
		public override void Process( Mobile from, BaseCommand command, string[] args )
		{
			BoundingBoxPicker.Begin( from, new BoundingBoxCallback( OnTarget ), new object[]{ command, args } );
		}
		public void RunCommand( Mobile from, object obj, BaseCommand command, string[] args )
		{
			try
			{
                if (command is GetCommand && obj is ArrayList && ((ArrayList)obj).Count > 20000)
                {
                    throw new Exception("Get command has too many potential target: " + ((ArrayList)obj).Count);
                }
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "RunCommand\t" + command.Commands[0] + "\t");
                CommandEventArgs e = new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args );
                
				if ( !command.ValidateArgs( this, e ) )
					return;

				bool flushToLog = false;

				if ( obj is ArrayList )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "objArrayList\t");
					ArrayList list = (ArrayList)obj;

					if ( list.Count > 20 )
						CommandLogging.Enabled = false;
					else if ( list.Count == 0 )
						command.LogFailure( "Nothing was found to use this command on." );

					command.ExecuteList( e, list );

					if ( list.Count > 20 )
					{
						flushToLog = true;
						CommandLogging.Enabled = true;
					}
				}
				else if ( obj != null )
				{
                    if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "obj\t");
                    if ( command.ListOptimized )
					{
						ArrayList list = new ArrayList();
						list.Add( obj );
						command.ExecuteList( e, list );
					}
					else
					{
						command.Execute( e, obj );
					}
				}
                if (LoggingCustom.CommandDebug) LoggingCustom.LogCommandDebug( "flush\t"); 
				command.Flush( from, flushToLog );
			}
			catch ( Exception ex )
			{
				if (from != null) from.SendMessage( ex.Message );
			}
		}
Exemple #14
0
        public override void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
        {
            try
            {
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("Global...compiling\t");
                }
                Extensions ext = Extensions.Parse(from, ref args);

                bool items, mobiles;
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("1\t");
                }
                if (!CheckObjectTypes(from, command, ext, out items, out mobiles))
                {
                    return;
                }

                ArrayList list = new ArrayList();

                if (items)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("2\t");
                    }
                    foreach (Item item in World.Items.Values)
                    {
                        if (ext.IsValid(item))
                        {
                            list.Add(item);
                        }
                    }
                }

                if (mobiles)
                {
                    if (LoggingCustom.CommandDebug)
                    {
                        LoggingCustom.LogCommandDebug("3\t");
                    }
                    foreach (Mobile mob in World.Mobiles.Values)
                    {
                        if (ext.IsValid(mob))
                        {
                            list.Add(mob);
                        }
                    }
                }
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("startfilter:list with " + list.Count + " in it\t");
                }
                ext.Filter(list);
                if (LoggingCustom.CommandDebug)
                {
                    LoggingCustom.LogCommandDebug("4\t");
                }
                obj = list;
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
		public override void Process( Mobile from, BaseCommand command, string[] args )
		{
			if ( command.ValidateArgs( this, new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args ) ) )
				from.BeginTarget( -1, command.ObjectTypes == ObjectTypes.All, TargetFlags.None, new TargetStateCallback( OnTarget ), new object[]{ command, args } );
		}
Exemple #16
0
        public override void ExecuteList( CommandEventArgs e, ArrayList list )
        {
            if ( list.Count == 0 )
            {
                LogFailure( "Nothing was found to use this command on." );
                return;
            }

            try
            {
                BaseCommand[] commands = new BaseCommand[m_BatchCommands.Count];
                CommandEventArgs[] eventArgs = new CommandEventArgs[m_BatchCommands.Count];

                for ( int i = 0; i < m_BatchCommands.Count; ++i )
                {
                    BatchCommand bc = (BatchCommand)m_BatchCommands[i];

                    string commandString, argString;
                    string[] args;

                    bc.GetDetails( out commandString, out argString, out args );

                    BaseCommand command = (BaseCommand)m_Scope.Commands[commandString];

                    commands[i] = command;
                    eventArgs[i] = new CommandEventArgs( e.Mobile, commandString, argString, args );

                    if ( command == null )
                    {
                        e.Mobile.SendMessage( "That is either an invalid command name or one that does not support this modifier: {0}.", commandString );
                        return;
                    }
                    else if ( e.Mobile.AccessLevel < command.AccessLevel )
                    {
                        e.Mobile.SendMessage( "You do not have access to that command: {0}.", commandString );
                        return;
                    }
                    else if ( !command.ValidateArgs( m_Scope, eventArgs[i] ) )
                    {
                        return;
                    }
                }

                for ( int i = 0; i < commands.Length; ++i )
                {
                    BaseCommand command = commands[i];
                    BatchCommand bc = (BatchCommand)m_BatchCommands[i];

                    if ( list.Count > 20 )
                        CommandLogging.Enabled = false;

                    ArrayList usedList;

                    if ( Utility.InsensitiveCompare( bc.Object, "Current" ) == 0 )
                    {
                        usedList = list;
                    }
                    else
                    {
                        Hashtable propertyChains = new Hashtable();

                        usedList = new ArrayList( list.Count );

                        for ( int j = 0; j < list.Count; ++j )
                        {
                            object obj = list[j];

                            if ( obj == null )
                                continue;

                            Type type = obj.GetType();

                            PropertyInfo[] chain = (PropertyInfo[])propertyChains[type];

                            string failReason = "";

                            if ( chain == null && !propertyChains.Contains( type ) )
                                propertyChains[type] = chain = Properties.GetPropertyInfoChain( e.Mobile, type, bc.Object, PropertyAccess.Read, ref failReason );

                            if ( chain == null )
                                continue;

                            PropertyInfo endProp = Properties.GetPropertyInfo( ref obj, chain, ref failReason );

                            if ( endProp == null )
                                continue;

                            try
                            {
                                obj = endProp.GetValue( obj, null );

                                if ( obj != null )
                                    usedList.Add( obj );
                            }
                            catch
                            {
                            }
                        }
                    }

                    command.ExecuteList( eventArgs[i], usedList );

                    if ( list.Count > 20 )
                        CommandLogging.Enabled = true;

                    command.Flush( e.Mobile, list.Count > 20 );
                }
            }
            catch ( Exception ex )
            {
                e.Mobile.SendMessage( ex.Message );
            }
        }
Exemple #17
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
                {
                    Extensions ext = Extensions.Parse(from, ref args);

                    bool items, mobiles;

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

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

                    Container cont = (Container)targeted;

                    Item[] found = cont.FindItemsByType(typeof(Item), true);

                    ArrayList list = new ArrayList();

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

                    ext.Filter(list);

                    RunCommand(from, list, command, args);
                }
                catch (Exception e)
                {
                    from.SendMessage(e.Message);
                    Server.Diagnostics.ExceptionLogging.LogException(e);
                }
            }
        }
Exemple #18
0
        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];

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

                Extensions ext = Extensions.Parse(from, ref args);


                if (!CheckObjectTypes(from, command, ext, out bool items, out bool 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 (ext.IsValid(obj))
                    {
                        objs.Add(obj);
                    }
                }

                eable.Free();

                ext.Filter(objs);

                RunCommand(from, objs, command, args);
            }
            catch (Exception ex)
            {
                from.SendMessage(ex.Message);
            }
        }
		public virtual void Process( Mobile from, BaseCommand command, string[] args )
		{
			RunCommand( from, command, args );
		}
		public void RunCommand( Mobile from, BaseCommand command, string[] args )
		{
			try
			{
				object obj = null;

				Compile( from, command, ref args, ref obj );

				RunCommand( from, obj, command, args );
			}
			catch ( Exception ex )
			{
				from.SendMessage( ex.Message );
			}
		}
Exemple #21
0
 public override void Process(Mobile from, BaseCommand command, string[] args)
 {
     BoundingBoxPicker.Begin(from, (map, start, end) => OnTarget(from, map, start, end, command, args));
 }
		public virtual void Register( BaseCommand command )
		{
			for ( int i = 0; i < command.Commands.Length; ++i )
				m_Commands[command.Commands[i]] = command;
		}
        public bool CheckObjectTypes(Mobile from, BaseCommand command, Extensions ext, out bool items, out bool mobiles)
        {
            items = mobiles = false;

            ObjectConditional cond = ObjectConditional.Empty;

            foreach (BaseExtension check in ext)
            {
                if (check is WhereExtension)
                {
                    cond = (check as WhereExtension).Conditional;

                    break;
                }
            }

            bool condIsItem   = cond.IsItem;
            bool condIsMobile = cond.IsMobile;

            switch (command.ObjectTypes)
            {
            case ObjectTypes.All:
            case ObjectTypes.Both:
            {
                if (condIsItem)
                {
                    items = true;
                }

                if (condIsMobile)
                {
                    mobiles = true;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (condIsItem)
                {
                    items = true;
                }
                else if (condIsMobile)
                {
                    from.SendMessage("You may not use a mobile type condition for this command.");
                    return(false);
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (condIsMobile)
                {
                    mobiles = true;
                }
                else if (condIsItem)
                {
                    from.SendMessage("You may not use an item type condition for this command.");
                    return(false);
                }

                break;
            }
            }

            return(true);
        }
 public virtual void Process(Mobile from, BaseCommand command, string[] args)
 {
     RunCommand(from, command, args);
 }
Exemple #25
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Mobile.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Mobile));
                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_Columns, m_List, m_Page, m_Mobile));
                return;
            }

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

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, 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_Columns, m_List, m_Page, m_Mobile));
                }

                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceMobileGump(m_From, m_Columns, 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_Columns, 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_Columns, 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_Columns, 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_Columns, m_List, m_Page, m_Mobile));

                break;
            }

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

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

                break;
            }
            }
        }
Exemple #26
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted)
            {
                m_From.SendGump(new InterfaceGump(m_From, m_Columns, m_List, m_Page, m_Item));
                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_Columns, m_List, m_Page, m_Item));
                return;
            }

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

            case 2:                     // Properties
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, 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_Columns, m_List, m_Page, m_Item));
                break;
            }

            case 4:                     // Go there
            {
                m_From.SendGump(new InterfaceItemGump(m_From, m_Columns, 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_Columns, 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) && !BaseCommand.IsAccessible(m_From, owner) /* !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_Columns, m_List, m_Page, m_Item));
                    m_From.AddToBackpack(m_Item);
                }

                break;
            }
            }
        }
		public void RunCommand( Mobile from, object obj, BaseCommand command, string[] args )
		{
		//	try
		//	{
				CommandEventArgs e = new CommandEventArgs( from, command.Commands[0], GenerateArgString( args ), args );

				if ( !command.ValidateArgs( this, e ) )
					return;

				bool flushToLog = false;

				if ( obj is ArrayList )
				{
					ArrayList list = (ArrayList)obj;

					if ( list.Count > 20 )
						CommandLogging.Enabled = false;
					else if ( list.Count == 0 )
						command.LogFailure( "Nothing was found to use this command on." );

					command.ExecuteList( e, list );

					if ( list.Count > 20 )
					{
						flushToLog = true;
						CommandLogging.Enabled = true;
					}
				}
				else if ( obj != null )
				{
					if ( command.ListOptimized )
					{
						ArrayList list = new ArrayList();
						list.Add( obj );
						command.ExecuteList( e, list );
					}
					else
					{
						command.Execute( e, obj );
					}
				}

				command.Flush( from, flushToLog );
		//	}
		//	catch ( Exception ex )
		//	{
		//		from.SendMessage( ex.Message );
		//	}
		}
 public virtual void Compile(Mobile from, BaseCommand command, ref string[] args, ref object obj)
 {
     obj = null;
 }
		public virtual void Compile( Mobile from, BaseCommand command, ref string[] args, ref object obj )
		{
			obj = null;
		}
Exemple #30
0
 public override void Process(Mobile from, BaseCommand command, string[] args)
 {
     BoundingBoxPicker.Begin(from, new BoundingBoxCallback(OnTarget), new object[] { command, args });
 }
		public bool CheckObjectTypes( BaseCommand command, Extensions ext, out bool items, out bool mobiles )
		{
			items = mobiles = false;

			ObjectConditional cond = ObjectConditional.Empty;

            foreach (BaseExtension check in ext)
            {
                if (check is WhereExtension)
                {
                    cond = (check as WhereExtension).Conditional;

                    break;
                }
            }

			bool condIsItem = cond.IsItem;
			bool condIsMobile = cond.IsMobile;

			switch ( command.ObjectTypes )
			{
				case ObjectTypes.All:
				case ObjectTypes.Both:
				{
					if ( condIsItem )
						items = true;

					if ( condIsMobile )
						mobiles = true;

					break;
				}
				case ObjectTypes.Items:
				{
					if ( condIsItem )
					{
						items = true;
					}
					else if ( condIsMobile )
					{
						command.LogFailure( "You may not use a mobile type condition for this command." );
						return false;
					}

					break;
				}
				case ObjectTypes.Mobiles:
				{
					if ( condIsMobile )
					{
						mobiles = true;
					}
					else if ( condIsItem )
					{
						command.LogFailure( "You may not use an item type condition for this command." );
						return false;
					}

					break;
				}
			}

			return true;
		}
Exemple #32
0
        public void OnTarget(Mobile from, object targeted, BaseCommand command, string[] args)
        {
            if (!BaseCommand.IsAccessible(from, targeted))
            {
                from.SendLocalizedMessage(500447); // That is not accessible.
                from.BeginTarget(
                    -1,
                    command.ObjectTypes == ObjectTypes.All,
                    TargetFlags.None,
                    (m, t, a) => OnTarget(m, t, command, a),
                    args
                    );
                return;
            }

            switch (command.ObjectTypes)
            {
            case ObjectTypes.Both:
            {
                if (!(targeted is Item or Mobile))
                {
                    from.SendMessage("This command does not work on that.");
                    return;
                }

                break;
            }

            case ObjectTypes.Items:
            {
                if (targeted is not Item)
                {
                    from.SendMessage("This command only works on items.");
                    return;
                }

                break;
            }

            case ObjectTypes.Mobiles:
            {
                if (targeted is not Mobile)
                {
                    from.SendMessage("This command only works on mobiles.");
                    return;
                }

                break;
            }
            }

            RunCommand(from, targeted, command, args);

            from.BeginTarget(
                -1,
                command.ObjectTypes == ObjectTypes.All,
                TargetFlags.None,
                (m, t, a) => OnTarget(m, t, command, a),
                args
                );
        }