Beispiel #1
0
      public static void MassMove(Graphic graphic, UOColor color, Serial sourceContainer, Serial destination)
      {
          UOItem source = World.GetItem(sourceContainer);

          if (!source.Exist)
          {
              ScriptErrorException.Throw("Invalid source container.");
              return;
          }

          if (!destination.IsValid)
          {
              ScriptErrorException.Throw("Invalid destination.");
              return;
          }

          UO.PrintInformation("Moving items of type {0} {1} from {2} to {3}", graphic, color, sourceContainer, destination);

          foreach (UOItem item in source.Items)
          {
              if (item.Graphic == graphic && item.Color == color)
              {
                  using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                      item.Move(0, destination);
                      ew.Wait(2000);
                      UO.Wait(200);
                  }
              }
          }

          UO.PrintInformation("MassMove finished.");
      }
Beispiel #2
0
        public void Vyloz(UOItem container)
        {
            UOItem Vyrobek;
            string chyby = "";

            ushort[] VyrobekType = new ushort[5];
            VyrobekType[0] = 0x1876;  // Wire
            VyrobekType[1] = 0x14FB;  // Lock
            VyrobekType[2] = 0x0E34;  // scroll
            VyrobekType[3] = 0x0DF9;  // bavlna
            VyrobekType[4] = 0x0FA0;  // threads


            if (!container.Opened)
            {
                using (ItemOpenedEventWaiter ew = new ItemOpenedEventWaiter(container.Serial))
                {
                    container.Use();
                    if (!ew.Wait(60000))
                    {
                        UO.PrintWarning("Item open timeout");
                        return;
                    }
                }
            }

            for (int i = 0; i < 5; i++)
            {
                while ((World.Player.Backpack.AllItems.Count(VyrobekType[i], 0x0000)) > 0)
                {
                    Vyrobek = World.Player.Backpack.AllItems.FindType(VyrobekType[i], 0x0000);
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(Vyrobek))
                    {
                        Vyrobek.Move(Vyrobek.Amount, container.Serial);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("1");
                            return;
                        }
                    }
                }
            }

            UO.PrintWarning(chyby);
            UO.Print("Prebytky vylozeny!!");
        }
Beispiel #3
0
      public static void MassMove(bool specificcolor)
      {
          UO.Print("Select item type:");
          UOItem typeItem = new UOItem(UIManager.TargetObject());

          if (!typeItem.Exist)
          {
              ScriptErrorException.Throw("Invalid item.");
              return;
          }

          Graphic graphic = typeItem.Graphic;
          UOColor color   = specificcolor ? typeItem.Color : UOColor.Invariant;

          //System.Windows.Forms.DialogResult result = System.Windows.Forms.MessageBox.Show("Check for color?", "Phoenix - MassMove", System.Windows.Forms.MessageBoxButtons.YesNo);
          //if (result == System.Windows.Forms.DialogResult.No)
          //    color = UOColor.Invariant;

          //UO.Print("Select source container:");
          //UOItem source = new UOItem(UIManager.TargetObject());
          UOItem source = new UOItem(typeItem.Container);

          if (!source.Exist)
          {
              ScriptErrorException.Throw("Invalid source container.");
              return;
          }

          UO.Print("Select destination container:");
          UOItem dest = new UOItem(UIManager.TargetObject());

          if (!dest.Exist)
          {
              ScriptErrorException.Throw("Invalid destination.");
              return;
          }

          MassMove(graphic, color, source, dest);
      }
Beispiel #4
0
        private object RunInternal(MethodOverloads methodOverloads, object[] rawParams)
        {
            // TODO: Security
            FileIOPermission phoenixLauncherFile = new FileIOPermission(FileIOPermissionAccess.AllAccess, System.IO.Path.Combine(Core.Directory, "PhoenixLauncher.xml"));

            phoenixLauncherFile.Deny();

            // First create ParameterData array
            ParameterData[] parameters = new ParameterData[rawParams.Length];
            for (int i = 0; i < rawParams.Length; i++)
            {
                parameters[i] = new ParameterData(rawParams[i]);
            }

            // Get valid overloads (array is never empty)
            Method[] methods = methodOverloads.FindOverloads(parameters);

            Exception exception = null;

            foreach (Method m in methods)
            {
                ExecutionInfo info = new ExecutionInfo(m);

                ExecutionAttribute[] execAttributes = (ExecutionAttribute[])m.MethodInfo.GetCustomAttributes(typeof(ExecutionAttribute), false);

                try {
                    // Call all Execution attributes
                    for (int i = 0; i < execAttributes.Length; i++)
                    {
                        execAttributes[i].Starting(m);
                    }

                    // Add execution to running list
                    lock (syncRoot) {
                        if (runningExecutions.Count >= Executions.MaxExecutions)
                        {
                            throw new RuntimeException("Executions limit exceeded.");
                        }

                        RuntimeCore.AddAssemblyObject(info, this);
                        runningExecutions.Add(info);

                        try {
                            // Raise Started event
                            executionStarted.Invoke(this, new ExecutionsChangedEventArgs(info));
                        }
                        catch (Exception e) {
                            Core.ShowMessageBoxAsync("Unhandled exception in Executions.ExecutionStarted event handler.\r\nMessage: " + e.Message, "Warning");
                        }
                    }

                    // Init thread-dependent classes
                    if (!threadInitialized)
                    {
                        ScriptErrorException.ThreadInit();
                        WorldData.World.ThreadInit();
                        Journal.ThreadInit();
                        threadInitialized = true;
                    }

                    // Invoke
                    try {
                        return(m.Invoke(parameters));
                    }
                    catch (System.Reflection.TargetInvocationException e) {
                        // Im interested only in exception thrown by code
                        throw e.InnerException;
                    }
                }
                catch (ParameterException e) {
                    exception = e;
                }
                catch (ExecutionBlockedException e) {
                    exception = e;
                }
                finally {
                    // Remove execution from running list
                    lock (syncRoot) {
                        runningExecutions.Remove(info);
                        RuntimeCore.RemoveAssemblyObject(info);

                        try {
                            // Raise Finished event
                            executionFinished.Invoke(this, new ExecutionsChangedEventArgs(info));
                        }
                        catch (Exception e) {
                            Core.ShowMessageBoxAsync("Unhandled exception in Executions.ExecutionFinished event handler.\r\nMessage: " + e.Message, "Warning");
                        }
                    }

                    // Call all Execution attributes
                    for (int i = 0; i < execAttributes.Length; i++)
                    {
                        execAttributes[i].Finished(m);
                    }
                }
            }

            if (exception != null)
            {
                throw exception;
            }
            else
            {
                throw new InternalErrorException();
            }
        }
Beispiel #5
0
        public void lahve(int pause)
        {
            ushort potionGraphic1 = 0x0F09;
            ushort potionColor1   = 0x0003;
            ushort potionGraphic2 = 0x0F09;
            ushort potionColor2   = 0x0000;
            ushort potionGraphic3 = 0x0F0C;
            ushort potionColor3   = 0x0000;
            ushort potionGraphic4 = 0x0F0B;
            ushort potionColor4   = 0x0000;
            ushort potionGraphic5 = 0x0F07;
            ushort potionColor5   = 0x0000;
            ushort X = 16;
            ushort Y = 81;

            foreach (UOItem item in World.Player.Backpack.Items)
            {
                if (item.Graphic == potionGraphic1 && item.Color == potionColor1)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, truhla.Serial, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                }
            }
            X += 10;
            foreach (UOItem item in World.Player.Backpack.Items)
            {
                if (item.Graphic == potionGraphic2 && item.Color == potionColor2)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, truhla.Serial, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                }
            }
            X += 10;
            foreach (UOItem item in World.Player.Backpack.Items)
            {
                if (item.Graphic == potionGraphic3 && item.Color == potionColor3)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, truhla.Serial, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                }
            }
            X += 10;
            foreach (UOItem item in World.Player.Backpack.Items)
            {
                if (item.Graphic == potionGraphic4 && item.Color == potionColor4)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, truhla.Serial, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                }
            }
            X += 10;
            foreach (UOItem item in World.Player.Backpack.Items)
            {
                if (item.Graphic == potionGraphic5 && item.Color == potionColor5)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, truhla.Serial, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                }
            }
            UO.Print("Konec rovnani");
        }
Beispiel #6
0
        public void arranging(int pause)
        {
            ushort potionGraphic1 = 0x0F09;
            ushort potionColor1   = 0x0003;
            ushort potionGraphic2 = 0x0F09;
            ushort potionColor2   = 0x0000;
            ushort potionGraphic3 = 0x0F0C;
            ushort potionColor3   = 0x0000;
            ushort potionGraphic4 = 0x0F0B;
            ushort potionColor4   = 0x0000;
            ushort potionGraphic5 = 0x0F07;
            ushort potionColor5   = 0x0000;
            ushort vychoziX       = 20;
            ushort maxX           = 160;
            ushort X = 20;
            ushort Y = 20;

            foreach (UOItem item in World.Player.Backpack.AllItems)
            {
                if (item.Graphic == potionGraphic1 && item.Color == potionColor1)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, Aliases.Backpack, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                    X += 5;
                    if (X >= maxX)
                    {
                        Y += 15;
                        X  = vychoziX;
                    }
                }
            }
            X += 5;
            foreach (UOItem item in World.Player.Backpack.AllItems)
            {
                if (item.Graphic == potionGraphic2 && item.Color == potionColor2)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, Aliases.Backpack, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                    X += 5;
                    if (X >= maxX)
                    {
                        Y += 15;
                        X  = vychoziX;
                    }
                }
            }
            foreach (UOItem item in World.Player.Backpack.AllItems)
            {
                if (item.Graphic == potionGraphic3 && item.Color == potionColor3)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, Aliases.Backpack, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                    X += 5;
                    if (X >= maxX)
                    {
                        Y += 15;
                        X  = vychoziX;
                    }
                }
            }
            foreach (UOItem item in World.Player.Backpack.AllItems)
            {
                if (item.Graphic == potionGraphic4 && item.Color == potionColor4)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, Aliases.Backpack, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                    X += 5;
                    if (X >= maxX)
                    {
                        Y += 15;
                        X  = vychoziX;
                    }
                }
            }
            X += 10;
            foreach (UOItem item in World.Player.Backpack.AllItems)
            {
                if (item.Graphic == potionGraphic5 && item.Color == potionColor5)
                {
                    using (ItemUpdateEventWaiter ew = new ItemUpdateEventWaiter(item)) {
                        UO.MoveItem(item.Serial, 1, Aliases.Backpack, X, Y);
                        if (!ew.Wait(5000))
                        {
                            ScriptErrorException.Throw("Nemuzu pohnout s itemem, konec.");
                            return;
                        }
                    }
                    X += 5;
                    if (X >= maxX)
                    {
                        Y += 15;
                        X  = vychoziX;
                    }
                }
            }
            UO.Print("Konec rovnani");
        }