EzPlugins

RepairAndSalvagePlugin

Nov 16th, 2024 (edited)
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 18.70 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System;
  3. using System.Text;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Windows.Forms;
  7. using SharpDX.DirectInput;
  8. using System.Runtime.InteropServices;
  9. using System.Text.RegularExpressions;
  10. using System.Drawing;
  11. using System.Threading;
  12.  
  13. namespace Turbo.Plugins.Ez
  14. {
  15.     public class RepairAndSalvagePlugin : BasePlugin, IKeyEventHandler, IInGameTopPainter
  16.     {
  17.         public bool Debug { get; set; } = false;
  18.  
  19.         private static IntPtr D3Hwnd = IntPtr.Zero;
  20.  
  21.         [DllImport("USER32.DLL")]
  22.         private static extern IntPtr FindWindow(string ClassName, string WindowText);
  23.  
  24.         [DllImport("USER32.DLL")]
  25.         private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  26.  
  27.         [DllImport("user32.dll")]
  28.         public static extern bool SetCursorPos(int x, int y);
  29.         [DllImport("user32.dll")]
  30.         public static extern bool GetCursorPos(out Point point);
  31.  
  32.         [DllImport("user32.dll")]
  33.         private static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, IntPtr dwExtraInfo);
  34.  
  35.         public static void SendPressKey(Keys key)
  36.         {
  37.             SendMessage(D3Hwnd, 256U, (IntPtr)((int)key), IntPtr.Zero);
  38.             SendMessage(D3Hwnd, 257U, (IntPtr)((int)key), IntPtr.Zero);
  39.         }
  40.  
  41.         public void mouseLClickUiE(IUiElement uie)  // D3Hwnd
  42.         {
  43.             if (uie.Visible)
  44.             {
  45.                 var x = (int) (uie.Rectangle.X + uie.Rectangle.Width/2.0f);
  46.                 var y = (int) (uie.Rectangle.Y + uie.Rectangle.Height/2.0f);
  47.                 IntPtr lParam = (IntPtr)(y << 16 | (x & 65535));
  48.                 SendMessage(D3Hwnd, 513U, (IntPtr)1, lParam);
  49.                 SendMessage(D3Hwnd, 514U, (IntPtr)1, lParam);
  50.             }
  51.         }
  52.  
  53.         public bool mouseLClickItemInventory(IItem item)
  54.         {
  55.             var rect = Hud.Inventory.GetItemRect(item);
  56.             if (rect != System.Drawing.RectangleF.Empty)
  57.             {
  58.                 var x = (int) (rect.X + rect.Width/2.0f + Hud.Window.Offset.X);
  59.                 var y = (int) (rect.Y + rect.Height/2.0f + Hud.Window.Offset.Y);
  60.                 SetCursorPos(x, y);
  61.                 Thread.Sleep(1);
  62.                 GetCursorPos(out var point);
  63.                 if (point.X == x && point.Y == y) { mouse_event(6U, 0, 0, 0U, IntPtr.Zero); } // It largely eliminates the inconvenience of moving the mouse while processing items
  64.                 else return false;
  65.             }
  66.             return true;
  67.         }
  68.  
  69.         protected IUiElement VENDOR_MAIN;
  70.         protected IUiElement VENDOR_REPAIRALL;
  71.  
  72.         protected IUiElement VENDOR_TAB_0;
  73.         protected IUiElement VENDOR_TAB_1;
  74.         protected IUiElement VENDOR_TAB_2;
  75.         protected IUiElement VENDOR_TAB_3;
  76.         protected IUiElement VENDOR_TAB_4;
  77.  
  78.         protected IUiElement VENDOR_DIALOG_0;
  79.         protected IUiElement VENDOR_DIALOG_1;
  80.         protected IUiElement VENDOR_DIALOG_2;
  81.         protected IUiElement VENDOR_DIALOG_3;
  82.         protected IUiElement VENDOR_DIALOG_4;
  83.  
  84.         protected IUiElement Salvage_Normal_Button;
  85.         protected IUiElement Salvage_Magic_Button;
  86.         protected IUiElement Salvage_Rare_Button;
  87.         protected IUiElement SalvageOneButton;
  88.         protected IUiElement SalvageAuxButton;
  89.         protected IUiElement Chat_Editline;
  90.  
  91.         protected IUiElement Button_OK;
  92.  
  93.         private SharpDX.DirectWrite.TextLayout layout { get; set; } = null;
  94.         private List<IItem> ItemsToSalvage { get; set; } =  new List<IItem>();
  95.         private int[] dataNMR { get; set; }
  96.         private bool ActionOn { get; set; } = false;
  97.         private long msLapseAction { get; set; } = 0;
  98.         private long msLapseActionOk { get; set; } = 0;
  99.         private bool mRepair { get; set; } = false;
  100.         private bool mSalvage { get; set; } = false;
  101.         private bool waitButtonOk { get; set; } = false;
  102.         private bool mCollect { get; set; } = false;
  103.         private bool StopNow { get; set; } = false;
  104.         private Point PointMousePos { get; set; }
  105.  
  106.         private bool _doRepairSalvage  { get; set; } = false;
  107.  
  108.         private bool doRepairSalvage
  109.         {
  110.             get { return _doRepairSalvage; }
  111.             set
  112.             {
  113.                 if (_doRepairSalvage != value)
  114.                 {
  115.                     if (value == true)
  116.                     {
  117.                         ActionOn = true;
  118.                         waitButtonOk = false;
  119.                         mRepair = skipRepair;
  120.                         mSalvage = false;
  121.                         mCollect = true;
  122.                         StopNow = false;
  123.                         ItemsToSalvage.Clear();
  124.                         GetCursorPos(out var point);
  125.                         PointMousePos = point;
  126.                     }
  127.                     else if (RestoreMousePointer)
  128.                     {
  129.                         SetCursorPos(PointMousePos.X, PointMousePos.Y);
  130.                     }
  131.                     if (Chat_Editline.Visible)  SendPressKey(Keys.Enter);
  132.                     _doRepairSalvage = value;
  133.                 }
  134.             }
  135.         }
  136.  
  137.         private bool _LMod_SalvagePlugin_Disable { get; set; } = false;
  138.  
  139.         public bool LMod_SalvagePlugin_Disable
  140.         {
  141.             get { return _LMod_SalvagePlugin_Disable; }
  142.             set
  143.             {
  144.                 if (Enabled)
  145.                 {
  146.                     _LMod_SalvagePlugin_Disable = value;
  147.                     if (_LMod_SalvagePlugin_Disable)
  148.                     {
  149.                         var pl = Hud.AllPlugins.FirstOrDefault(p => p.GetType().FullName == "Turbo.Plugins.LightningMod.SalvagePlugin");
  150.                         if (pl != null && pl.Enabled)
  151.                         {
  152.                             pl.Enabled = false;
  153.                         }
  154.                     }
  155.                 }
  156.             }
  157.         }
  158.  
  159.         public IBrush ItemHighlightBrush { get; set; }
  160.         public IFont InfoFont { get; set; }
  161.  
  162.         public IKeyEvent ToggleKeyEvent { get; set; }
  163.         public long msLapseMin { get; set; } = 10;
  164.         public long msLapseAnvilEnable { get; set; } = 150;
  165.         public long msLapseAnvilDisable { get; set; } = 150;
  166.         public long msLapseWaitButtonOk { get; set; } = 350;
  167.  
  168.         public bool saveItemPrimal { get; set; }
  169.         public bool saveItemAncient { get; set; }
  170.         public string TextAvailable { get; set; }
  171.         public string TextNotAvailable { get; set; }
  172.         public bool ConfirmWihtEnterKey { get; set; }
  173.         public bool IgnoreInventoryLockArea { get; set; }
  174.         public bool RestoreMousePointer { get; set; }
  175.         public bool skipRepair { get; set; }
  176.         public bool SalvageRank0SoulShards { get; set; }
  177.        
  178.         public Dictionary<ISnoItem, int> WhiteList { get; set; } = new Dictionary<ISnoItem, int>();
  179.  
  180.         public RepairAndSalvagePlugin()
  181.         {
  182.             Enabled = true;
  183.         }
  184.  
  185.         public override void Load(IController hud)
  186.         {
  187.             base.Load(hud);
  188.  
  189.             TextAvailable = "Repair&Salvage: Press {0} to Start"; // {0} => Hotkey
  190.             TextNotAvailable = "Repair&Salvage: unavailable, lock area missing";
  191.             saveItemPrimal = true;              // Keep primal items , not salvage
  192.             saveItemAncient = false;            // Keep Ancient items , not salvage
  193.             SalvageRank0SoulShards = false;     // Salvage unupgraded (rank 0) Soul shards.  Upgraded Soul shards (rank 1,2,3) will never be automatically salvaged.
  194.             ConfirmWihtEnterKey = false;        // Use Key Enter or Mouse Virtual for dialog confirmation
  195.             ToggleKeyEvent = Hud.Input.CreateKeyEvent(true, Key.F3, controlPressed: false, altPressed: false, shiftPressed: false); // Hotkey
  196.             IgnoreInventoryLockArea = false;    // If false -> Lock area required in the inventory. If true -> Ignore if you have defined (or not) a lock area in the inventory.
  197.             RestoreMousePointer = true;         // Restore to original position.
  198.             skipRepair = false;                 // Do not repair before salvage.
  199.  
  200.             VENDOR_MAIN = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage", null, null);
  201.             VENDOR_REPAIRALL = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.repair_dialog.RepairAll", VENDOR_DIALOG_3, null);
  202.  
  203.             VENDOR_TAB_0 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.tab_0", VENDOR_MAIN, null);
  204.             VENDOR_TAB_1 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.tab_1", VENDOR_MAIN, null);
  205.             VENDOR_TAB_2 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.tab_2", VENDOR_MAIN, null);
  206.             VENDOR_TAB_3 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.tab_3", VENDOR_MAIN, null);
  207.             VENDOR_TAB_4 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.tab_4", VENDOR_MAIN, null);
  208.  
  209.             VENDOR_DIALOG_0 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.craftweapons_dialog", VENDOR_MAIN, null);
  210.             VENDOR_DIALOG_1 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.craftarmor_dialog", VENDOR_MAIN, null);
  211.             VENDOR_DIALOG_2 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog", VENDOR_MAIN, null);
  212.             VENDOR_DIALOG_3 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.repair_dialog", VENDOR_MAIN, null);
  213.             VENDOR_DIALOG_4 = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.training_dialog", VENDOR_MAIN, null);
  214.  
  215.             Salvage_Normal_Button = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog.salvage_all_wrapper.salvage_normal_button", VENDOR_DIALOG_2, null);
  216.             Salvage_Magic_Button = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog.salvage_all_wrapper.salvage_magic_button", VENDOR_DIALOG_2, null);
  217.             Salvage_Rare_Button = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog.salvage_all_wrapper.salvage_rare_button", VENDOR_DIALOG_2, null);
  218.             SalvageOneButton = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog.salvage_all_wrapper.salvage_button", VENDOR_DIALOG_2, null);
  219.             SalvageAuxButton = Hud.Render.RegisterUiElement("Root.NormalLayer.vendor_dialog_mainPage.salvage_dialog.salvage_button", VENDOR_DIALOG_2, null);
  220.  
  221.             Button_OK = Hud.Render.RegisterUiElement("Root.TopLayer.confirmation.subdlg.stack.wrap.button_ok", null, null);
  222.  
  223.             Chat_Editline = Hud.Render.RegisterUiElement("Root.NormalLayer.chatentry_dialog_backgroundScreen.chatentry_content.chat_editline", null, null);
  224.  
  225.             ItemHighlightBrush = Hud.Render.CreateBrush(255, 200, 200, 100, -1.6f);
  226.             InfoFont = Hud.Render.CreateFont("tahoma", 8, 255, 200, 200, 0, true, false, 255, 0, 0, 0, true);
  227.  
  228.             D3Hwnd = FindWindow("D3 Main Window Class", null); // D3Hwnd = FindWindow(null, "Diablo III");
  229.  
  230.         }
  231.  
  232.         public void OnKeyEvent(IKeyEvent keyEvent)
  233.         {
  234.             if (keyEvent.IsPressed && ToggleKeyEvent.Matches(keyEvent))
  235.             {
  236.                 if (Hud.Game.IsInTown)
  237.                 {
  238.                     if (IgnoreInventoryLockArea || (Hud.Inventory.InventoryLockArea.Width > 0 && Hud.Inventory.InventoryLockArea.Height > 0))
  239.                     {
  240.                         if (VENDOR_MAIN.Visible && VENDOR_TAB_4.Visible)
  241.                         {
  242.                             if (!doRepairSalvage)
  243.                                 doRepairSalvage = true;
  244.                             else
  245.                                 StopNow = true;
  246.                         }
  247.                     }
  248.                 }
  249.             }
  250.         }
  251.  
  252.         private List<IItem> GetItemsToSalvage() // Function to decide which items to salvage
  253.         {
  254.             var result = new List<IItem>();
  255.             var items = Hud.Inventory.ItemsInInventory.Where(i => (i.SnoItem.Kind == ItemKind.loot || i.SnoItem.Kind == ItemKind.potion) && !i.VendorBought && i.ItemsInSocket == null);
  256.             foreach (var item in items)
  257.             {
  258.                 var transmogStat = item.StatList.FirstOrDefault(s => s.Id == "TransmogGBID#1048575");
  259.                 if (transmogStat != null && transmogStat.DoubleValue != -1) continue;  // -1 when undo transmog
  260.                 if (item.IsNormal || item.IsMagic || item.IsRare)
  261.                 {
  262.                     if ( !item.AccountBound && (Hud.Game.Me.CurrentLevelNormal == 70 || IgnoreInventoryLockArea || !item.IsInventoryLocked) )
  263.                         result.Add(item);
  264.                 }
  265.                 else if
  266.                 (
  267.                         (IgnoreInventoryLockArea || !item.IsInventoryLocked)
  268.                     &&  item.EnchantedAffixCounter == 0 && item.Quantity <= 1 && Hud.Game.Me.ArmorySets.FirstOrDefault(armorySet => armorySet?.ContainsItem(item) == true) == null // Not in Armory
  269.                     &&  (!saveItemPrimal || item.AncientRank != 2) && (!saveItemAncient || item.AncientRank != 1)
  270.                     &&  (item.SnoItem.MainGroupCode != "riftkeystone") && (item.SnoItem.MainGroupCode != "horadriccache") && (item.SnoItem.MainGroupCode != "-") && (item.SnoItem.MainGroupCode != "pony")
  271.                     &&  (item.SnoItem.MainGroupCode != "plans") && !item.SnoItem.MainGroupCode.Contains("cosmetic") && (item.SnoItem.MainGroupCode != "gems_unique") // never salvage Whisper of Atonement
  272.                     &&  (item.SnoItem.NameEnglish != "Staff of Herding") && (item.SnoItem.NameEnglish != "Hellforge Ember")
  273.                     &&  (!item.SnoItem.Code.StartsWith("P72_Soulshard") || (SalvageRank0SoulShards && item.JewelRank < 1))  // only salvage non-upgraded Soulshard
  274.                     &&  (!WhiteList.TryGetValue(item.SnoItem, out var rank) || item.AncientRank < rank) // White List
  275.                 )
  276.                     result.Add(item);
  277.             }
  278.             result.Sort((a, b) =>
  279.             {
  280.                 var r = a.InventoryX.CompareTo(b.InventoryX);
  281.                 if (r == 0) r = a.InventoryY.CompareTo(b.InventoryY);
  282.                 return r;
  283.             });
  284.             return result;
  285.         }
  286.  
  287.         public void PaintTopInGame(ClipState clipState)
  288.         {
  289.             if (clipState != ClipState.Inventory) return;
  290.             if (!Hud.Game.IsInGame || !Hud.Game.IsInTown || !Hud.Inventory.InventoryMainUiElement.Visible) return;
  291.             if (VENDOR_MAIN.Visible && VENDOR_TAB_4.Visible)    //BlackSmith (Jeweler and Mystic 3 Tabs, cube 0 Tabs)       //Tabs active 16-13-37-34-73        // (+-1) => Values for non-active tab (mouse over or not)
  292.             {
  293.                 layout = InfoFont.GetTextLayout( (IgnoreInventoryLockArea || (Hud.Inventory.InventoryLockArea.Width > 0 && Hud.Inventory.InventoryLockArea.Height > 0)) ? String.Format(TextAvailable, ToggleKeyEvent.ToString()) : TextNotAvailable );
  294.                 InfoFont.DrawText(layout, VENDOR_MAIN.Rectangle.X + (VENDOR_MAIN.Rectangle.Width * 0.04f), VENDOR_MAIN.Rectangle.X + (VENDOR_MAIN.Rectangle.Height * 0.088f));
  295.  
  296.                 var ItemsToSalvagePaint = GetItemsToSalvage();
  297.                 foreach (var item in ItemsToSalvagePaint)
  298.                 {
  299.                     var itemRect = Hud.Inventory.GetItemRect(item);
  300.                     ItemHighlightBrush.DrawRectangle(itemRect);
  301.                 }
  302.  
  303.                 if (doRepairSalvage && Hud.Game.Me.AnimationState == AcdAnimationState.Idle)
  304.                 {
  305.                     if (Hud.Game.CurrentRealTimeMilliseconds > msLapseAction)
  306.                     {
  307.                         if (Button_OK.Visible)
  308.                         {
  309.                             if (Button_OK.AnimState != 35)          // Minimizing improper press hits of the Accept button
  310.                             {
  311.                                 msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseMin;
  312.                                 if (ConfirmWihtEnterKey)            // use Enter Key
  313.                                     SendPressKey(Keys.Enter);
  314.                                 else                                // or use Virtual Mouse
  315.                                     mouseLClickUiE(Button_OK);
  316.                                 waitButtonOk = false;
  317.                             }
  318.                         }
  319.                         else if (waitButtonOk)
  320.                         {
  321.                             if (Hud.Game.CurrentRealTimeMilliseconds > msLapseActionOk)
  322.                             {
  323.                                 waitButtonOk = false;
  324.                             }
  325.                         }
  326.                         else
  327.                         {
  328.                             msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseMin;
  329.                             if (VENDOR_DIALOG_3.Visible) // Repair
  330.                             {
  331.                                 if (!mRepair)
  332.                                 {
  333.                                     if (VENDOR_REPAIRALL.Visible)
  334.                                     {
  335.                                         var match = Regex.Match(VENDOR_REPAIRALL.ReadText(Encoding.UTF8, true), @"([0-9]+)"); // @"([0-9]+([\.,][0-9]+)*)" for complete number ?
  336.                                         if (match.Success && match.Groups[1].Value != "0")
  337.                                         {
  338.                                             mouseLClickUiE(VENDOR_REPAIRALL);
  339.                                         }
  340.                                         else
  341.                                         {
  342.                                             mRepair = true;
  343.                                             mouseLClickUiE(VENDOR_TAB_2);
  344.                                         }
  345.                                     }
  346.                                 }
  347.                                 else
  348.                                 {
  349.                                     mouseLClickUiE(VENDOR_TAB_2);
  350.                                 }
  351.                             }
  352.                             else if (VENDOR_DIALOG_2.Visible) // Salvage
  353.                             {
  354.                                 if (!mRepair)
  355.                                 {
  356.                                     mouseLClickUiE(VENDOR_TAB_3);
  357.                                 }
  358.                                 else
  359.                                 {
  360.                                     if (!mSalvage)
  361.                                     {
  362.                                         if (mCollect)
  363.                                         {
  364.                                             ItemsToSalvage = GetItemsToSalvage();
  365.                                             if (Hud.Game.Me.CurrentLevelNormal == 70 || IgnoreInventoryLockArea) // Only at level 70 will the buttons be used to save all rare/normal/magic items, and only when their amount is greater than 1
  366.                                             {
  367.                                                 IItem lastNormal = null; IItem lastMagic = null; IItem lastRare = null;
  368.                                                 dataNMR = new int[] {0, 0, 0};
  369.                                                 foreach (var item in ItemsToSalvage.ToArray())
  370.                                                 {
  371.                                                         if (item.IsNormal)      { dataNMR[0] = dataNMR[0] + 1; if (dataNMR[0] == 1) lastNormal = item; else ItemsToSalvage.Remove(item);  }
  372.                                                         else if (item.IsMagic)  { dataNMR[1] = dataNMR[1] + 1; if (dataNMR[1] == 1) lastMagic = item; else ItemsToSalvage.Remove(item);  }
  373.                                                         else if (item.IsRare)   { dataNMR[2] = dataNMR[2] + 1; if (dataNMR[2] == 1) lastRare = item; else ItemsToSalvage.Remove(item);  }
  374.                                                 }
  375.                                                 if (dataNMR[0] > 1) { ItemsToSalvage.Remove(lastNormal); }
  376.                                                 if (dataNMR[1] > 1) { ItemsToSalvage.Remove(lastMagic); }
  377.                                                 if (dataNMR[2] > 1) { ItemsToSalvage.Remove(lastRare); }
  378.                                             }
  379.                                             else mSalvage  = true;
  380.                                             mCollect = false;
  381.                                         }
  382.                                         else
  383.                                         {
  384.                                             IUiElement uie = null;
  385.                                             if (dataNMR[0] > 1)         { dataNMR[0] = 0; uie = Salvage_Normal_Button; }
  386.                                             else if (dataNMR[1] > 1)    { dataNMR[1] = 0; uie = Salvage_Magic_Button; }
  387.                                             else if (dataNMR[2] > 1)    { dataNMR[2] = 0; uie = Salvage_Rare_Button; }
  388.                                             if (uie != null && !StopNow)
  389.                                             {
  390.                                                 if (uie.Visible)
  391.                                                 {
  392.                                                     waitButtonOk = true;
  393.                                                     msLapseActionOk = Hud.Game.CurrentRealTimeMilliseconds + msLapseWaitButtonOk;
  394.                                                     mouseLClickUiE(uie);
  395.                                                 }
  396.                                             }
  397.                                             else mSalvage = true;
  398.                                         }
  399.                                     }
  400.                                     else
  401.                                     {
  402.                                         if (SalvageOneButton.Visible)
  403.                                         {
  404.                                             if (ItemsToSalvage.Any() && !StopNow)
  405.                                             {
  406.                                                 if (SalvageOneButton.AnimState != 19 && SalvageOneButton.AnimState != 20)
  407.                                                 {
  408.                                                     msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseAnvilEnable;
  409.                                                     mouseLClickUiE(SalvageOneButton);
  410.                                                 }
  411.                                                 else
  412.                                                 {
  413.                                                     var item = ItemsToSalvage.First();
  414.                                                     if (item.SeenInInventory)
  415.                                                     {
  416.                                                         if (mouseLClickItemInventory(item))
  417.                                                         {
  418.                                                             if (!item.IsNormal && !item.IsMagic && !item.IsRare)
  419.                                                             {
  420.                                                                 waitButtonOk = true;
  421.                                                                 msLapseActionOk = Hud.Game.CurrentRealTimeMilliseconds + msLapseWaitButtonOk;
  422.                                                             }
  423.                                                             ItemsToSalvage.Remove(item);
  424.                                                         }
  425.                                                     }
  426.                                                     else ItemsToSalvage.Remove(item);
  427.                                                 }
  428.                                             }
  429.                                             else    // No more items to salvage
  430.                                             {
  431.                                                 if (ActionOn)   // I wait a while to disable the anvil
  432.                                                 {
  433.                                                     ActionOn = false;
  434.                                                     msLapseAction = Hud.Game.CurrentRealTimeMilliseconds + msLapseAnvilDisable;
  435.                                                 }
  436.                                                 else // Disabling anvil
  437.                                                 {
  438.                                                     if (SalvageOneButton.AnimState == 19 || SalvageOneButton.AnimState == 20)
  439.                                                         mouseLClickUiE(SalvageOneButton);
  440.                                                     doRepairSalvage = false;
  441.                                                 }
  442.                                             }
  443.                                         }
  444.                                         else
  445.                                         {
  446.                                             doRepairSalvage = false;
  447.                                         }
  448.                                     }
  449.                                 }
  450.                             }
  451.                             else if (VENDOR_DIALOG_0.Visible || VENDOR_DIALOG_1.Visible || (VENDOR_DIALOG_4.Visible && VENDOR_TAB_4.AnimState == 73))
  452.                             {
  453.                                 mouseLClickUiE(VENDOR_TAB_3);
  454.                             }
  455.                             else // should never get here
  456.                             {
  457.                                 doRepairSalvage = false;
  458.                             }
  459.                         }
  460.                     }
  461.                 }
  462.             }
  463.             else if (doRepairSalvage)
  464.             {
  465.                 doRepairSalvage = false;
  466.             }
  467.         }
  468.     }
  469. }
Advertisement
Add Comment
Please, Sign In to add comment