/// <summary> /// Step 1. /// Approach the Vendor and see if we have a profile for him. /// If we do, we subscribe to the render frame event to capture the next AC frame. /// We do this so that all AC data from this frame is given a chance to propagate to other plugins: Virindi Item Tool /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void WorldFilter_ApproachVendor(object sender, ApproachVendorEventArgs e) { try { if (!Settings.SettingsManager.AutoBuySell.Enabled.Value) return; if (VirindiItemTool.PluginCore.ActivityState != VirindiItemTool.PluginCore.ePluginActivityState.Idle) return; // Init our LootCore object at the very last minute (looks for VTClassic.dll if its not already loaded) if (lootProfile == null) lootProfile = new VTClassic.LootCore(); else ((VTClassic.LootCore)lootProfile).UnloadProfile(); FileInfo fileInfo = new FileInfo(PluginCore.PluginPersonalFolder + @"\" + CoreManager.Current.WorldFilter[e.MerchantId].Name + ".utl"); if (!fileInfo.Exists) { if (Settings.SettingsManager.AutoBuySell.TestMode.Value) Debug.WriteToChat("AutoBuySell.WorldFilter_ApproachVendor(), vendor profile file not found at: " + fileInfo.FullName); return; } // Load our loot profile ((VTClassic.LootCore)lootProfile).LoadProfile(fileInfo.FullName, false); CoreManager.Current.RenderFrame += new EventHandler<EventArgs>(Current_RenderFrame); } catch (Exception ex) { Debug.LogException(ex); } }
public void Start() { if (started) return; // Init our LootCore object at the very last minute (looks for VTClassic.dll if its not already loaded) if (lootProfile == null) lootProfile = new VTClassic.LootCore(); FileInfo fileInfo = new FileInfo(PluginCore.PluginPersonalFolder + @"\" + CoreManager.Current.CharacterFilter.Name + ".AutoPack.utl"); if (!fileInfo.Exists) { // Try to find a Default.AutoPack.utl fileInfo = new FileInfo(PluginCore.PluginPersonalFolder + @"\" + "Default.AutoPack.utl"); if (!fileInfo.Exists) return; } CoreManager.Current.Actions.AddChatText("<{" + PluginCore.PluginName + "}>: " + "Auto Pack - Started.", 5, Settings.SettingsManager.Misc.OutputTargetWindow.Value); // Load our loot profile ((VTClassic.LootCore)lootProfile).LoadProfile(fileInfo.FullName, false); idsRequested = false; blackLitedItems.Clear(); CoreManager.Current.RenderFrame += new EventHandler<EventArgs>(Current_RenderFrame); started = true; }
/// <summary> /// This will return an item to sell in the following Priority: Any Non SpellComponent (Pea)/TradeNote, SpellComponent (Peas), TradeNote /// </summary> /// <param name="looter"></param> /// <returns></returns> private WorldObject GetSellItem(VTClassic.LootCore looter) { Collection <WorldObject> sellObjects = new Collection <WorldObject>(); foreach (WorldObject playerObj in CoreManager.Current.WorldFilter.GetInventory()) { // Safety check to prevent equipped items from being sold. if (playerObj.Values(LongValueKey.EquipableSlots, 0) > 0) { continue; } // Convert the vendor item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithID(playerObj.Id); if (itemInfo == null) { Debug.WriteToChat("AutoBuySell.GetSellItem(), itemInfo == null for " + playerObj.Name); continue; } // Get the loot profile result for this object // result.IsNoLoot will always be false so we must check the Keep # against items in inventory. uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo); if (!result.IsSell) { continue; } sellObjects.Add(playerObj); } if (sellObjects.Count == 0) { return(null); } foreach (WorldObject sellObject in sellObjects) { if (sellObject.ObjectClass != ObjectClass.SpellComponent && sellObject.ObjectClass != ObjectClass.TradeNote) { return(sellObject); } } WorldObject cheapest = null; foreach (WorldObject sellObject in sellObjects) { if (sellObject.ObjectClass != ObjectClass.TradeNote) { if (cheapest == null || cheapest.Values(LongValueKey.Value) > sellObject.Values(LongValueKey.Value)) { cheapest = sellObject; } } } if (cheapest != null) { return(cheapest); } foreach (WorldObject sellObject in sellObjects) { if (cheapest == null || cheapest.Values(LongValueKey.Value) > sellObject.Values(LongValueKey.Value)) { cheapest = sellObject; } } return(cheapest); }
public void Start(FileInfo lootProfileFileInfo) { if (started) return; if (!lootProfileFileInfo.Exists) return; // Init our LootCore object at the very last minute (looks for VTClassic.dll if its not already loaded) if (lootProfile == null) lootProfile = new VTClassic.LootCore(); // Load our loot profile ((VTClassic.LootCore)lootProfile).LoadProfile(lootProfileFileInfo.FullName, false); idsRequested = false; itemIdsAdded.Clear(); CoreManager.Current.RenderFrame += new EventHandler<EventArgs>(Current_RenderFrame); started = true; }
/// <summary> /// This will return an object to buy. Keep # rules are returned first, then Keep rules. /// </summary> /// <param name="looter"></param> /// <param name="openVendor"></param> /// <param name="buyAmount"></param> /// <returns></returns> private WorldObject GetBuyItem(VTClassic.LootCore looter, Vendor openVendor, out int buyAmount) { // See if we can find a Keep # rule first. foreach (WorldObject vendorObj in openVendor) { // Convert the vendor item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithVendorObjectTemplateID(vendorObj.Id); if (itemInfo == null) { Debug.WriteToChat("AutoBuySell.GetBuyItem(), itemInfo == null for " + vendorObj.Name); continue; } // Get the loot profile result for this object // result.IsNoLoot will always be false so we must check the Keep # against items in inventory. // The keep # is returned as Data1 uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo); if (!result.IsKeepUpTo) { continue; } // Find out how many of this item we have in our inventory int currentAmountInInventory = 0; foreach (WorldObject playerObj in CoreManager.Current.WorldFilter.GetInventory()) { if (vendorObj.Name == playerObj.Name) { if (playerObj.Values(LongValueKey.StackCount) == 0) { currentAmountInInventory++; } else { currentAmountInInventory += playerObj.Values(LongValueKey.StackCount); } } } // If we have more than our Keep #, lets continue through the rest of the vendors item if (currentAmountInInventory >= result.Data1) { continue; } // Ok, we need to buy some of this item, how many should we buy? buyAmount = result.Data1 - currentAmountInInventory; // We can't add more than 5000 of any one item to the vendor buy pane. if (buyAmount > 5000) { buyAmount = 5000; } return(vendorObj); } // Ok, we didn't find a Keep # rule, lets search all Keep rules now. foreach (WorldObject vendorObj in openVendor) { // Convert the vendor item into a VT GameItemInfo object uTank2.LootPlugins.GameItemInfo itemInfo = uTank2.PluginCore.PC.FWorldTracker_GetWithVendorObjectTemplateID(vendorObj.Id); if (itemInfo == null) { Debug.WriteToChat("AutoBuySell.GetBuyItem(), itemInfo == null for " + vendorObj.Name); continue; } // Get the loot profile result for this object // result.IsNoLoot will always be false uTank2.LootPlugins.LootAction result = looter.GetLootDecision(itemInfo); if (!result.IsKeep) { continue; } // Ok, we need to buy some of this item, how many should we buy? buyAmount = 5000; return(vendorObj); } buyAmount = 0; return(null); }