Can anyone tell me how I could make it so this plugin doesn't auto level a certain gem? Specifically Cast on Damage Take
I reckon eventually there will be options to choose gems you want to level, at very least in form of a plugin.
Hi go to "\Plugins\GemLeveler\" open there the GemLeveler.cs and replace everything in it with this Code: using System; using System.Collections.Generic; using System.Linq; using log4net; using Loki.Game; using Loki.Game.Inventory; using Loki.Game.Objects.Components; using Loki.Game.Objects.Items; using Loki.Utilities; using Loki.Utilities.Plugins; namespace BotGui.Plugins.GemLeveler { public class GemLeveler : IPlugin { #region Implementation of IEquatable<IPlugin> /// <summary> /// Indicates whether the current object is equal to another object of the same type. /// </summary> /// <returns> /// true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false. /// </returns> /// <param name="other">An object to compare with this object.</param> public bool Equals(IPlugin other) { return Name.Equals(other.Name); } #endregion private static readonly ILog Log = Logger.GetLoggerInstanceForType(); private readonly bool _debugStatements = false; private readonly WaitTimer _levelWait = WaitTimer.FiveSeconds; private readonly Random _random = new Random(); #region Implementation of IPlugin public string Author { get { return "Apoc"; } } public Version Version { get { return new Version(0, 1, 0, 0); } } public string Name { get { return "Gem Leveler"; } } public string Description { get { return "Levels gems as they become available for... leveling!"; } } /// <summary> Executes the start action. This is called when the bot starts. </summary> public void OnStart() { } /// <summary> Executes the stop action. This is called when the bot is stopped. </summary> public void OnStop() { } /// <summary> Executes the pulse action. This is called every "tick" of the bot. </summary> public void OnPulse() { // We never want to update gems while stash is open, because we access all inventories, which causes // more stash pages to be requested than we want. if (GuiApi.IsStashWindowOpen) return; // Sooo... yeah... // We basically only want to level a gem every couple of seconds. // Anywhere between 1 and 3 seconds seems fine. if (_levelWait.IsFinished) { _levelWait.Reset(TimeSpan.FromMilliseconds(_random.Next(1000, 3000))); LevelGems(); } } /// <summary> /// Executes the initialize action. This is called at initial bot startup. (When the bot itself is started, not /// when Start() is called) /// </summary> public void OnInitialize() { } /// <summary> Executes the shutdown action. This is called when the bot is shutting down. (Not when Stop() is called) </summary> public void OnShutdown() { } /// <summary> Executes the enabled action. This is called when the user has enabled this specific plugin via the GUI. </summary> public void OnEnabled() { } /// <summary> Executes the disabled action. This is called whent he user has disabled this specific plugin via the GUI. </summary> public void OnDisabled() { } /// <summary> Executes the config action. This is called when the user clicks on the config button.</summary> public void OnConfig() { } #endregion private void LevelGems() { // Ok, so this is gonna be kinda tricky, but it works as you'd expect. // Basically, we get the 8 slots we can have items socketed in, and return the items in there. // So we can pull the gems in those items. // Here goes nuttin' Inventories inv = LokiPoe.Me.Inventory; // We basically just union all these inventories, grab the first item (since they can only have 1 item) // And drop them in the list. List<InventoryItem> items = new[] { inv.LeftHand, inv.RightHand, inv.OffLeftHand, inv.OffRightHand, inv.Head, inv.Chest, inv.Gloves, inv.Boots }.Select(i => i.Items.FirstOrDefault()).Where(i => i != null).ToList(); // We need these stats for the "can level" checks. int myS = LokiPoe.Me.GetStat(StatType.Strength); int myD = LokiPoe.Me.GetStat(StatType.Dexterity); int myI = LokiPoe.Me.GetStat(StatType.Intelligence); uint myL = LokiPoe.Me.Level; // Now, for each item, we need to check all the available skill gems. // There's a max of 6, so we can simply iterate 6 :) foreach (InventoryItem inventoryItem in items) { // This is a base-class of Weapon and Armor. This is exactly why it was split! var item = inventoryItem.Item as SocketableItem; if (item == null) { if (_debugStatements) { Log.Debug(inventoryItem.FullName + " is not socketable. Is this item a quiver or other non-socketable armor/weapon?"); } continue; } // Now, iterate the gems of the item... (There's always 6, but in case API changes to only provide 4 for gloves/boots, then we'll be safe) for (int idx = 0; idx < item.SocketedGems.Length; idx++) { SkillGem gem = item.SocketedGems[idx]; // Not all sockets will have gems. // So check the ones we actually care about. // Thanks! if (gem == null) { continue; } // Srsly, ignore gems that aren't ready to be leveled. if (gem.ExperiencePercent < 100) { continue; } // ignore specific gems, just copy this as often as needed // first gem to be ignored if (gem.Name == "Name of Gem in Quotes") { continue; } // second gem to be ignored if (gem.Name == "Name of Gem in Quotes") { continue; } if (gem.Experience == gem.ExperienceMaxLevel) { if (_debugStatements) { Log.Debug("I can't level up " + gem.Name + " because it is already at max level!"); } continue; } // Now we just need to get the stats required for the next level. int s, d, i, l; gem.GetAttributeRequirements(out s, out d, out i, out l); bool canLevel = true; if (myL < l) { canLevel = false; if (_debugStatements) { Log.Debug("I'm not at the required level to level up " + gem.Name + "! (" + myL + "/" + l + ")"); } } if (myS < s) { canLevel = false; if (_debugStatements) { Log.Debug("I don't have enough strength to level up " + gem.Name + "! (" + myS + "/" + s + ")"); } } if (myD < d) { canLevel = false; if (_debugStatements) { Log.Debug("I don't have enough dexterity to level up " + gem.Name + "! (" + myD + "/" + d + ")"); } } if (myI < i) { canLevel = false; if (_debugStatements) { Log.Debug("I don't have enough intelligence to level up " + gem.Name + "! (" + myI + "/" + i + ")"); } } if (canLevel) { Log.Debug("I can level up " + gem.Name + "!"); inventoryItem.LevelSkillGem(idx); Log.Debug(gem.Name + " has been leveled!"); // Wait before we level the next gem so we don't spam gem level ups. return; } } } } } } now search for Code: // ignore specific gems, just copy this as often as needed // first gem to be ignored if (gem.Name == "Name of Gem in Quotes") and there you can exclude gems. I haven't tested it, so i don't take any responsibility EDIT: I'm not sure but it could be that the file get overwritten on the next exilebuddy update. So check it before you start the bot again after an update or make a seperate plugin for it
You can just rename the plugin, and move it to a new folder to avoid having it overwritten. I haven't quite figured out how I want to deal with enabling/disabling gems. Some people tend to level 1 gem "Arc" and then not level another gem "Arc". So just going by name won't always be the best route. I'll figure something out soon though. Just going by name is fine though!
That was a quick and fast solution When I'm bored i will extend it, to ignore specific gems on specific armor/weapon or another solution. Will think about it
For the record this did get over rode with the newest beta updates Luckily my Cast when damage taken gem was only level 3 when i caught it, was able to scour it down. I'll use Apoc's solution on just making it a seperate plug in for the moment.
Code: // ignore specific gems, just copy this as often as needed // first gem to be ignored if (gem.Name == "Cast when Damage Taken") { continue; } Share the code for Cast when Damage Taken. Thank flexus!