Ejemplo n.º 1
0
        //Executes a GameDLL command, Idea taken from jultima http://code.google.com/p/jultima/
        public List <object> _executeCommand(bool ReturnResults, string CommandName, object[] args)
        {
            // Maybe return bool and results as an Out?
            List <object> Results = new List <object>();

            UODLL.SetTop(UOHandle, 0);
            UODLL.PushStrVal(UOHandle, "Call");
            UODLL.PushStrVal(UOHandle, CommandName);
            foreach (var o in args)
            {
                if (o is Int32) // (o.GetType() == typeof(int))
                {
                    UODLL.PushInteger(UOHandle, (int)o);
                }
                else if (o is string)
                {
                    UODLL.PushStrVal(UOHandle, (string)o);
                }
                else if (o is bool)
                {
                    UODLL.PushBoolean(UOHandle, (bool)o);
                }
            }
            if (UODLL.Execute(UOHandle) != 0)
            {
                return(null);
            }
            if (!ReturnResults)
            {
                return(null);
            }
            int objectcnt = UODLL.GetTop(UOHandle);

            for (int i = 1; i <= objectcnt; i++)
            {
                int gettype = UODLL.GetType(UOHandle, 1);
                switch (gettype)
                {
                case 1:
                    Results.Add(UODLL.GetBoolean(UOHandle, i).ToString());

                    break;

                case 3:
                    Results.Add(UODLL.GetInteger(UOHandle, i).ToString());
                    break;

                case 4:
                    Results.Add(Marshal.PtrToStringAnsi(UODLL.GetString(UOHandle, i)));
                    break;

                default:
                    throw new NotImplementedException();
                    break;
                }
            }
            return(Results);
        }
Ejemplo n.º 2
0
 public int ScanItems(bool VisibleOnly)
 {
     UODLL.SetTop(UOHandle, 0);
     UODLL.PushStrVal(UOHandle, "Call");
     UODLL.PushStrVal(UOHandle, "ScanItems");
     UODLL.PushBoolean(UOHandle, VisibleOnly);
     if (UODLL.Execute(UOHandle) != 0)
     {
         return(0);
     }
     return(UODLL.GetInteger(UOHandle, 1));
 }
Ejemplo n.º 3
0
        private int GetInt(string command)
        {
            UODLL.SetTop(UOHandle, 0);
            UODLL.PushStrVal(UOHandle, "Get");
            UODLL.PushStrVal(UOHandle, command);
            var result = UODLL.Execute(UOHandle);

            if (result == 0)
            {
                return(UODLL.GetInteger(UOHandle, 1));
            }
            else
            {
                return(0);
            }
        }
Ejemplo n.º 4
0
        public FoundItem GetItem(int index)
        {
            UODLL.SetTop(UOHandle, 0);
            UODLL.PushStrVal(UOHandle, "Call");
            UODLL.PushStrVal(UOHandle, "GetItem");
            UODLL.PushInteger(UOHandle, index);
            if (UODLL.Execute(UOHandle) != 0)
            {
                return(null);
            }
            FoundItem item = new FoundItem();

            item.ID     = UODLL.GetInteger(UOHandle, 1);
            item.Type   = UODLL.GetInteger(UOHandle, 2);
            item.Kind   = UODLL.GetInteger(UOHandle, 3);
            item.ContID = UODLL.GetInteger(UOHandle, 4);
            item.X      = UODLL.GetInteger(UOHandle, 5);
            item.Y      = UODLL.GetInteger(UOHandle, 6);
            item.Z      = UODLL.GetInteger(UOHandle, 7);
            item.Stack  = UODLL.GetInteger(UOHandle, 8);
            item.Rep    = UODLL.GetInteger(UOHandle, 9);
            item.Col    = UODLL.GetInteger(UOHandle, 10);
            return(item);
        }