Exemplo n.º 1
0
        internal static void ExportAutoloot(string listname)
        {
            SaveFileDialog sd = new SaveFileDialog();

            sd.Filter           = "Enhanced Razor Export|*.raz";
            sd.Title            = "Export Autoloot List";
            sd.FileName         = "AU." + listname + ".raz";
            sd.RestoreDirectory = true;

            if (sd.ShowDialog() == DialogResult.OK)
            {
                DataSet   m_Dataset      = new DataSet();
                DataTable autoloot_items = new DataTable("AUTOLOOT_ITEMS");
                autoloot_items.Columns.Add("List", typeof(string));
                autoloot_items.Columns.Add("Item", typeof(RazorEnhanced.AutoLoot.AutoLootItem));
                m_Dataset.Tables.Add(autoloot_items);
                m_Dataset.AcceptChanges();

                List <AutoLoot.AutoLootItem> items = Settings.AutoLoot.ItemsRead(listname);

                foreach (RazorEnhanced.AutoLoot.AutoLootItem item in items)
                {
                    DataRow row = m_Dataset.Tables["AUTOLOOT_ITEMS"].NewRow();
                    row["List"] = listname;
                    row["Item"] = item;
                    m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows.Add(row);
                }

                try
                {
                    m_Dataset.RemotingFormat          = SerializationFormat.Binary;
                    m_Dataset.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
                    Stream          stream   = File.Create(sd.FileName);
                    GZipStream      compress = new GZipStream(stream, CompressionMode.Compress);
                    BinaryFormatter bin      = new BinaryFormatter();
                    bin.Serialize(compress, m_Dataset);
                    compress.Close();
                    stream.Close();
                    AutoLoot.AddLog("List: " + listname + " exported");
                }
                catch (Exception ex)
                {
                    AutoLoot.AddLog("Export list fail");
                    AutoLoot.AddLog(ex.ToString());
                }
            }
            else
            {
                AutoLoot.AddLog("Export list cancelled.");
            }
        }
Exemplo n.º 2
0
        internal static void ProfileChange(string name)
        {
            // Salvo parametri di uscita
            RazorEnhanced.Settings.General.SaveExitData();
            PasswordMemory.ProfileChangeInit();
            Assistant.Engine.MainWindow.Initializing = true;

            // Stop timer script
            if (RazorEnhanced.Scripts.Timer != null)
            {
                RazorEnhanced.Scripts.Timer.Close();
            }

            // Stop forzato di tutti i thread agent
            if (Assistant.Engine.MainWindow.AutolootCheckBox.Checked == true)
            {
                Assistant.Engine.MainWindow.AutolootCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.ScavengerCheckBox.Checked == true)
            {
                Assistant.Engine.MainWindow.ScavengerCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.OrganizerStop.Enabled == true)
            {
                Assistant.Engine.MainWindow.OrganizerStop.PerformClick();
            }

            if (Assistant.Engine.MainWindow.BuyCheckBox.Checked == true)
            {
                Assistant.Engine.MainWindow.BuyCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.SellCheckBox.Checked == true)
            {
                Assistant.Engine.MainWindow.SellCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.DressStopButton.Enabled == true)
            {
                Assistant.Engine.MainWindow.DressStopButton.PerformClick();
            }

            if (Assistant.Engine.MainWindow.BandageHealenableCheckBox.Checked == true)
            {
                Assistant.Engine.MainWindow.BandageHealenableCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.DressStopButton.Enabled == true)
            {
                Assistant.Engine.MainWindow.DressStopButton.PerformClick();
            }

            // Stop filtri
            if (Assistant.Engine.MainWindow.AutoCarverCheckBox.Enabled == true)
            {
                Assistant.Engine.MainWindow.AutoCarverCheckBox.Checked = false;
            }

            if (Assistant.Engine.MainWindow.MobFilterCheckBox.Enabled == true)
            {
                Assistant.Engine.MainWindow.MobFilterCheckBox.Checked = false;
            }

            // Stop video recorder
            Assistant.MainForm.StopVideoRecorder();

            // Svuoto logbox e reset select index
            //	Assistant.Engine.MainWindow.AutoLootLogBox.Items.Clear();
            AutoLoot.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.ScavengerLogBox.Items.Clear();
            Scavenger.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.OrganizerLogBox.Items.Clear();
            Organizer.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.SellLogBox.Items.Clear();
            SellAgent.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.BuyLogBox.Items.Clear();
            BuyAgent.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.DressLogBox.Items.Clear();
            Dress.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.FriendLogBox.Items.Clear();
            Friend.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.RestockLogBox.Items.Clear();
            Restock.AddLog("Profile Changed!");

            Assistant.Engine.MainWindow.BandageHealLogBox.Items.Clear();
            BandageHeal.AddLog("Profile Changed!");

            // Cambio file
            //if (name == "default")
            //	RazorEnhanced.Settings.ProfileFiles = "RazorEnhanced.settings";
            //else
            //	RazorEnhanced.Settings.ProfileFiles = "RazorEnhanced." + name + ".settings";

            // Rimuovo cache password e disabilito vecchi filtri
            Assistant.Filters.Filter.DisableAll();

            // Chiuto toolbar
            if (RazorEnhanced.ToolBar.ToolBarForm != null)
            {
                RazorEnhanced.ToolBar.ToolBarForm.Close();
            }

            // Chiuto toolbar
            if (RazorEnhanced.SpellGrid.SpellGridForm != null)
            {
                RazorEnhanced.SpellGrid.SpellGridForm.Close();
            }

            // Carico save profilo
            RazorEnhanced.Settings.Load(name);

            // Abilito patch UOMod
            UoMod.ProfileChange();

            // Refresh list
            Assistant.Engine.MainWindow.AutoLootListSelect.SelectedIndex  = -1;
            Assistant.Engine.MainWindow.ScavengerListSelect.SelectedIndex = -1;
            Assistant.Engine.MainWindow.OrganizerListSelect.SelectedIndex = -1;
            Assistant.Engine.MainWindow.SellListSelect.SelectedIndex      = -1;
            Assistant.Engine.MainWindow.BuyListSelect.SelectedIndex       = -1;
            Assistant.Engine.MainWindow.DressListSelect.SelectedIndex     = -1;
            Assistant.Engine.MainWindow.FriendListSelect.SelectedIndex    = -1;
            Assistant.Engine.MainWindow.RestockListSelect.SelectedIndex   = -1;

            // Reinizzializzo razor
            Engine.MainWindow.SafeAction(s => s.LoadSettings());
            //Assistant.Engine.MainWindow.LoadSettings();

            // Riapro toollbar se le condizioni lo permettono
            if (RazorEnhanced.Settings.General.ReadBool("AutoopenToolBarCheckBox"))
            {
                RazorEnhanced.ToolBar.Open();
            }

            // Riapro la spellgrid se le condizioni lo permettono
            if (RazorEnhanced.Settings.General.ReadBool("GridOpenLoginCheckBox"))
            {
                RazorEnhanced.SpellGrid.Open();
            }

            Assistant.Engine.MainWindow.Initializing = false;
            SetLast(name);

            PasswordMemory.ProfileChangeEnd();

            if (World.Player != null)             // Reinit script timer se cambio profilo avvene da loggati
            {
                RazorEnhanced.Scripts.Init();
            }
        }
Exemplo n.º 3
0
        internal static void AutoRun()
        {
            if (World.Player.IsGhost)
            {
                Thread.Sleep(2000);
                return;
            }

            if (AutoLootSerialCorpseRefresh.Count > 0 && Assistant.Engine.MainWindow.AutolootCheckBox.Checked && !Targeting.HasTarget && Player.Visible)
            {
                try
                {
                    int itemserial = 0;
                    if (AutoLootSerialCorpseRefresh.TryPeek(out itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.InRange(new Assistant.Point2D(World.Player.Position.X, World.Player.Position.Y), new Assistant.Point2D(item.Position.X, item.Position.Y), AutoLoot.MaxRange) && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            RazorEnhanced.Items.WaitForContents(Items.FindBySerial(itemserial), 1000);
                            AutoLoot.AddLog("- Refresh Corpse: 0x" + itemserial.ToString("X8"));
                            Thread.Sleep(AutoLoot.AutoLootDelay);
                            if (item.Updated)
                            {
                                AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            }
                        }
                        else
                        {
                            AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            AutoLootSerialCorpseRefresh.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }

            if (AutoLoot.SerialToGrabList.Count > 0 && Assistant.Engine.MainWindow.AutolootCheckBox.Checked && Player.Visible)
            {
                try
                {
                    AutoLoot.SerialToGrab data;
                    if (AutoLoot.SerialToGrabList.TryPeek(out data))
                    {
                        Assistant.Item item = Assistant.World.FindItem(data.ItemSerial);

                        if (item == null)
                        {
                            AutoLoot.SerialToGrabList.TryDequeue(out data);
                            return;
                        }

                        if (item.RootContainer == World.Player)
                        {
                            AutoLoot.SerialToGrabList.TryDequeue(out data);
                            return;
                        }

                        Assistant.Item corpse = Assistant.World.FindItem(data.CorpseSerial);

                        if (corpse == null)
                        {
                            AutoLoot.SerialToGrabList.TryDequeue(out data);
                            return;
                        }

                        if (Utility.InRange(new Assistant.Point2D(World.Player.Position.X, World.Player.Position.Y), new Assistant.Point2D(corpse.Position.X, corpse.Position.Y), AutoLoot.MaxRange) && CheckZLevel(corpse.Position.Z, World.Player.Position.Z))
                        {
                            if ((World.Player.MaxWeight - World.Player.Weight) < 5)
                            {
                                RazorEnhanced.AutoLoot.AddLog("- Max weight reached, Wait untill free some space");
                                RazorEnhanced.Misc.SendMessage("AUTOLOOT: Max weight reached, Wait untill free some space");
                                Thread.Sleep(2000);
                            }
                            else
                            {
                                RazorEnhanced.AutoLoot.AddLog("- Item Match found (" + item.Serial.ToString() + ") ... Looting");
                                RazorEnhanced.Items.Move(item.Serial, AutoLoot.AutoLootBag, 0);
                                Thread.Sleep(AutoLoot.AutoLootDelay);
                                AutoLoot.SerialToGrabList.TryDequeue(out data);
                            }
                        }
                        else
                        {
                            AutoLoot.SerialToGrabList.TryDequeue(out data);
                            AutoLoot.SerialToGrabList.Enqueue(data);
                        }
                    }
                }
                catch { }
            }

            if (ScavengerSerialToGrab.Count > 0 && Assistant.Engine.MainWindow.ScavengerCheckBox.Checked)
            {
                try
                {
                    int itemserial = 0;
                    if (ScavengerSerialToGrab.TryPeek(out itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            return;
                        }

                        if (item.RootContainer == World.Player)
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.InRange(new Assistant.Point2D(World.Player.Position.X, World.Player.Position.Y), new Assistant.Point2D(item.Position.X, item.Position.Y), Scavenger.MaxRange) && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            if ((World.Player.MaxWeight - World.Player.Weight) < 5)
                            {
                                RazorEnhanced.Scavenger.AddLog("- Max weight reached, Wait untill free some space");
                                RazorEnhanced.Misc.SendMessage("SCAVENGER: Max weight reached, Wait untill free some space");
                                Thread.Sleep(2000);
                            }
                            else
                            {
                                RazorEnhanced.Scavenger.AddLog("- Item Match found (" + item.Serial.ToString() + ") ... Grabbing");
                                RazorEnhanced.Items.Move(item.Serial, Scavenger.ScavengerBag, 0);
                                Thread.Sleep(Scavenger.ScavengerDelay);
                                ScavengerSerialToGrab.TryDequeue(out itemserial);
                            }
                        }
                        else
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            ScavengerSerialToGrab.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }

            if (CorpseToCutSerial.Count > 0 && Filters.AutoCarver)
            {
                try
                {
                    int itemserial = 0;
                    if (CorpseToCutSerial.TryPeek(out itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.InRange(new Assistant.Point2D(Assistant.World.Player.Position.X, Assistant.World.Player.Position.Y), new Assistant.Point2D(item.Position.X, item.Position.Y), 1) && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            Items.UseItem(Items.FindBySerial(Filters.AutoCarverBlade));
                            Target.WaitForTarget(1000, true);
                            Target.TargetExecute(item.Serial);
                            Items.Message(item.Serial, 10, "*Cutting*");
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            Thread.Sleep(RazorEnhanced.Settings.General.ReadInt("ObjectDelay"));
                        }
                        else
                        {
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            CorpseToCutSerial.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }
        }
Exemplo n.º 4
0
        ////////////// AUTOLOOT START //////////////
        internal static void ImportAutoloot()
        {
            DataSet        m_Dataset      = new DataSet();
            DataTable      m_DatasetTable = new DataTable();
            OpenFileDialog od             = new OpenFileDialog();

            od.Filter           = "Enhanced Razor Export|*.raz";
            od.Title            = "Import Autoloot List";
            od.RestoreDirectory = true;

            if (od.ShowDialog() == DialogResult.OK)
            {
                if (File.Exists(od.FileName))
                {
                    try
                    {
                        m_Dataset.RemotingFormat          = SerializationFormat.Binary;
                        m_Dataset.SchemaSerializationMode = SchemaSerializationMode.IncludeSchema;
                        Stream          stream     = File.Open(od.FileName, FileMode.Open);
                        GZipStream      decompress = new GZipStream(stream, CompressionMode.Decompress);
                        BinaryFormatter bin        = new BinaryFormatter();
                        m_Dataset = bin.Deserialize(decompress) as DataSet;
                        decompress.Close();
                        stream.Close();
                    }
                    catch
                    {
                        AutoLoot.AddLog("File is corrupted!");
                    }
                }
                else
                {
                    AutoLoot.AddLog("Unable to access file!");
                }
                if (m_Dataset.Tables.Contains("AUTOLOOT_ITEMS"))
                {
                    m_DatasetTable = m_Dataset.Tables["AUTOLOOT_ITEMS"];
                    if (m_DatasetTable.Rows.Count > 0)
                    {
                        if (RazorEnhanced.Settings.AutoLoot.ListExists(m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows[0]["List"].ToString()))
                        {
                            AutoLoot.AddLog("List: " + m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows[0]["List"].ToString() + " already exist");
                        }
                        else
                        {
                            AutoLoot.AddList(m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows[0]["List"].ToString());
                            List <RazorEnhanced.AutoLoot.AutoLootItem> itemlist = new List <AutoLoot.AutoLootItem>();
                            foreach (DataRow row in m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows)
                            {
                                itemlist.Add((RazorEnhanced.AutoLoot.AutoLootItem)row["Item"]);
                            }
                            RazorEnhanced.Settings.AutoLoot.ItemInsertFromImport(m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows[0]["List"].ToString(), itemlist);
                            RazorEnhanced.AutoLoot.InitGrid();
                            AutoLoot.AddLog("List: " + m_Dataset.Tables["AUTOLOOT_ITEMS"].Rows[0]["List"].ToString() + " imported!");
                        }
                    }
                    else
                    {
                        AutoLoot.AddLog("This list is empty!");
                    }
                }
                else
                {
                    AutoLoot.AddLog("This file not contain Autoloot data!");
                }
            }
            else
            {
                AutoLoot.AddLog("Import list cancelled.");
            }
        }
        //	internal static volatile bool HoldingItem = false;

        internal static void AutoRun()
        {
            if (World.Player == null || !Client.Running)
            {
                return;
            }

            if (World.Player.IsGhost)
            {
                Thread.Sleep(2000);
                return;
            }

            bool lootHidden = RazorEnhanced.Settings.General.ReadBool("AllowHiddenLooting");

            if (AutoLootSerialCorpseRefresh.Count > 0 &&
                Assistant.Engine.MainWindow.AutolootCheckBox.Checked &&
                !Targeting.HasTarget &&
                (Player.Visible || lootHidden))
            {
                try
                {
                    if (AutoLootSerialCorpseRefresh.TryPeek(out int itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.Distance(World.Player.Position.X, World.Player.Position.Y, item.Position.X, item.Position.Y) <= AutoLoot.MaxRange && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            RazorEnhanced.Items.WaitForContents(Items.FindBySerial(itemserial), 1000);
                            AutoLoot.AddLog("- Refresh Corpse: 0x" + itemserial.ToString("X8"));
                            Thread.Sleep(AutoLoot.AutoLootDelay);
                            if (item.Updated)
                            {
                                AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            }
                        }
                        else
                        {
                            AutoLootSerialCorpseRefresh.TryDequeue(out itemserial);
                            AutoLootSerialCorpseRefresh.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }
            uint lootbag = AutoLoot.GetLootBag();

            // at login, backpack is sometimes null
            if (lootbag != 0)
            {
                ProcessLootList(lootbag);
            }

            if (ScavengerSerialToGrab.Count > 0 && Assistant.Engine.MainWindow.ScavengerCheckBox.Checked)
            {
                try
                {
                    if (ScavengerSerialToGrab.TryPeek(out int itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            return;
                        }

                        if (item.IsLootableTarget)
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.Distance(World.Player.Position.X, World.Player.Position.Y, item.Position.X, item.Position.Y) <= Scavenger.MaxRange && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            if ((World.Player.MaxWeight - World.Player.Weight) < 5)
                            {
                                RazorEnhanced.Scavenger.AddLog("- Max weight reached, Wait untill free some space");
                                RazorEnhanced.Misc.SendMessage("SCAVENGER: Max weight reached, Wait untill free some space", true);
                                Thread.Sleep(2000);
                            }
                            else
                            {
                                RazorEnhanced.Scavenger.AddLog("- Item Match found (" + item.Serial.ToString() + ") ... Grabbing");
                                RazorEnhanced.Items.Move(item.Serial, Convert.ToInt32(Scavenger.GetScavengerBag()), 0);
                                Thread.Sleep(Scavenger.ScavengerDelay);
                                ScavengerSerialToGrab.TryDequeue(out itemserial);
                            }
                        }
                        else
                        {
                            ScavengerSerialToGrab.TryDequeue(out itemserial);
                            ScavengerSerialToGrab.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }

            if (CorpseToCutSerial.Count > 0 && Filters.AutoCarver)
            {
                try
                {
                    if (CorpseToCutSerial.TryPeek(out int itemserial))
                    {
                        Assistant.Item item = Assistant.World.FindItem(itemserial);

                        if (item == null)
                        {
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            return;
                        }

                        if (Utility.Distance(World.Player.Position.X, World.Player.Position.Y, item.Position.X, item.Position.Y) <= 1 && CheckZLevel(item.Position.Z, World.Player.Position.Z))
                        {
                            Items.UseItem(Items.FindBySerial(Filters.AutoCarverBlade));
                            Target.WaitForTarget(1000, true);
                            Target.TargetExecute(item.Serial);
                            Items.Message(item.Serial, 10, "*Cutting*");
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            Thread.Sleep(RazorEnhanced.Settings.General.ReadInt("ObjectDelay"));
                        }
                        else
                        {
                            CorpseToCutSerial.TryDequeue(out itemserial);
                            CorpseToCutSerial.Enqueue(itemserial);
                        }
                    }
                }
                catch { }
            }
            Thread.Sleep(250);
        }