CDR and RCR Percent plugin menu

User Tag List

Results 1 to 5 of 5
  1. #1
    JarJarD3's Avatar Contributor
    Reputation
    106
    Join Date
    Oct 2017
    Posts
    395
    Thanks G/R
    41/101
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)

    CDR and RCR Percent plugin

    Shows your total CDR and RCR percent in Inventory header.

    Optionally shows CDR values for those items that can have CDR on them.
    Optionally shows RCR values for those items that can have RCR on them.

    Green value is max CDR available.
    White value is max CDR available and can not enchant it as other attribute has been enchanted already.
    White value with plus-sign is CDR that can be enchanted (up to max value).
    Red value is item without CDR and can not enchant it.


    As I don't know exact specifics about RCR per item, I used range from 5.0-8.0% for all items except Yang's Recurve 40.0-50.0%.

    This might have some usage with new S18 Captain Crimson’s Trimmings set.

    Download:
    >>>>> PercentCDR.cs <<<<<

    Install:
    save as plugins/JarJar/PercentCDR.cs

    Inventory image example.

    Inventory images with RCR on items (but not right colors as old image).

    Version history:
    - add RCR range check (5.0-8.0%)
    - added RCR number on equipped items (below CDR number).
    - add NRE check for item.Affixes
    Last edited by JarJarD3; 09-23-2019 at 12:01 PM. Reason: add NRE check for item.Affixes

    CDR and RCR Percent plugin
  2. Thanks RNN (1 members gave Thanks to JarJarD3 for this useful post)
  3. #2
    RNN's Avatar Legendary
    Reputation
    816
    Join Date
    Sep 2018
    Posts
    1,060
    Thanks G/R
    104/779
    Trade Feedback
    0 (0%)
    Mentioned
    15 Post(s)
    Tagged
    0 Thread(s)
    I like it, it will be useful for next season. Captain Crimson's set seems like a good set for farming builds.
    You show only the cdr of each item, you could do the same with the rcr in the lower right corner (or just below the cdr), or make it optional at least.
    The color code would simplify it: green if it reached the maximum value, red and orange if they have not reached it, and it will be orange if it can be achieved by enchanting the item. But this preference is personal, I will make this modification for my own use if I decide to play the first days of the season
    Last edited by RNN; 08-11-2019 at 08:12 AM.

  4. #3
    JarJarD3's Avatar Contributor
    Reputation
    106
    Join Date
    Oct 2017
    Posts
    395
    Thanks G/R
    41/101
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Originally Posted by RNN View Post
    I like it, it will be useful for next season. Captain Crimson's set seems like a good set for farming builds.
    You show only the cdr of each item, you could do the same with the rcr in the lower right corner (or just below the cdr), or make it optional at least.
    The color code would simplify it: green if it reached the maximum value, red and orange if they have not reached it, and it will be orange if it can be achieved by enchanting the item. But this preference is personal, I will make this modification for my own use if I decide to play the first days of the season
    I'll try to do it.
    It seems (according to my item database) that RCR can not be found on these items:
    • belt
    • boots
    • bracers
    • chestarmor
    • helm
    • pants
    • (follower item)


    So the item search must be changed to handle this.
    And I would place RCR below CDR for simplicity.

  5. #4
    JarJarD3's Avatar Contributor
    Reputation
    106
    Join Date
    Oct 2017
    Posts
    395
    Thanks G/R
    41/101
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Added RCR number on equipped items (below CDR number).
    Check new example images.

    As I don't know how RCR is available on items (min-max) and there is special item buffs for RCR this only shows current RCR value or if it can be enchanted to have RCR.

  6. Thanks RNN, alternate_ (2 members gave Thanks to JarJarD3 for this useful post)
  7. #5
    alternate_'s Avatar Member
    Reputation
    3
    Join Date
    Feb 2020
    Posts
    39
    Thanks G/R
    17/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this little great thing somehow got broken with latest release, tried to fix it:
    Code:
    // PercentCDR.cs "$Revision: 2592 $" "$Date: 2019-09-23 19:59:38 +0300 (ma, 23 syys 2019) $"
    // https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-community-plugins/796632-cdr-rcr-percent-plugin.html
    // https://pastebin.com/3s40U47n
    using System;
    using System.Globalization;
    using System.Linq;
    using SharpDX;
    using Turbo.Plugins.Default;
    
    namespace Turbo.Plugins.JarJar
    {
        public class PercentCDR : BasePlugin, IInGameTopPainter
        {
            public bool ShowCooldownReduction { get; set; } = true;
            public bool ShowCooldownReductionItems { get; set; } = true;
            public bool ShowResourceCostReduction { get; set; } = true;
            public bool ShowResourceCostReductionItems { get; set; } = true;
    
            public IFont LabelHeader { get; set; }
            public IFont LabelCDR { get; set; }
            public IFont PerfectCDR { get; set; }
            public IFont LabelRCR { get; set; }
            public IFont PerfectRCR { get; set; }
            public IFont CanNotEnchantFont { get; set; }
            public float RcrOffset = 15f;   // Works with tahoma 6 pt.
    
            public string FormatCdrRcr { get; set; } = "CDR {0:0.00} % RCR {1:0.00} %";
            public string FormatCdr { get; set; } = "CDR {0:0.00} %";
            public string FormatCdrItem { get; set; } = "{0:0}";
            public string FormatRcr { get; set; } = "RCR {0:0.00} %";
            public string FormatRcrItem { get; set; } = "{0:0}";
            public string EnchantMoreMarker { get; set; } = "+";
            public string CanNotEnchantMarker { get; set; } = "0";
    
            public float InventoryHeaderRatioX { get; set; } = 0.08f;
            public float InventoryHeaderRatioY { get; set; } = 0.12f;
    
            private float rv;
    
            public PercentCDR() { Enabled = true; Order = 100; }
    
            public override void Load(IController hud)
            {
                base.Load(hud);
    
                Color textColor;
                textColor = Color.White;
                LabelHeader = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
    
                textColor = Color.White;
                LabelCDR = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
                textColor = Color.LawnGreen;
                PerfectCDR = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
    
                textColor = Color.White;
                LabelRCR = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
                textColor = Color.LawnGreen;
                PerfectRCR = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
    
                textColor = Color.Firebrick;
                CanNotEnchantFont = Hud.Render.CreateFont("tahoma", 6, 255, textColor.R, textColor.G, textColor.B, true, false, 255, 0, 0, 0, true);
            }
    
            public void PaintTopInGame(ClipState clipState)
            {
                if (clipState != ClipState.Inventory)
                    return;
                if (!Hud.Game.IsInTown)
                    return;
    
                var uiInv = Hud.Inventory.InventoryMainUiElement;
                if (!uiInv.Visible)
                    return;
                var player = Hud.Game.Me;
    
                rv = 32.0f / 600.0f * Hud.Window.Size.Height;
    
                if (ShowCooldownReductionItems || ShowResourceCostReductionItems)
                {
                    var equippedItems = Hud.Game.Items.Where(x => x.Location >= ItemLocation.Head && x.Location <= ItemLocation.Neck);
                    foreach (var item in equippedItems)
                    {
                        var rect = Hud.Inventory.GetItemRect(item);
                        if (rect == System.Drawing.RectangleF.Empty)
                            continue;
                        var cdrItem = (item.Location >= ItemLocation.RightHand && item.Location <= ItemLocation.Waist) || item.Location == ItemLocation.Shoulders ||
                            (item.Location >= ItemLocation.LeftRing && item.Location <= ItemLocation.Neck);
                        var code = item.SnoItem.Code.ToLower();
                        var rcrItem = !(code.Contains("belt") || code.Contains("boots") || code.Contains("bracer") || code.Contains("chest") || code.Contains("helm") || code.Contains("pants"));
                        if (cdrItem || rcrItem)
                        {
                            handleItem(item, cdrItem, rcrItem, rect);
                        }
                    }
                }
                string labelText;
                if (ShowCooldownReduction && ShowResourceCostReduction)
                {
                    labelText = string.Format(CultureInfo.InstalledUICulture, FormatCdrRcr, player.Stats.CooldownReduction * 100f, player.Stats.ResourceCostReduction * 100f);
                }
                else if (ShowCooldownReduction)
                {
                    labelText = string.Format(CultureInfo.InstalledUICulture, FormatCdr, player.Stats.CooldownReduction * 100f);
                }
                else if (ShowResourceCostReduction)
                {
                    labelText = string.Format(CultureInfo.InstalledUICulture, FormatRcr, player.Stats.ResourceCostReduction * 100f);
                }
                else
                {
                    return;
                }
                var xCoord = uiInv.Rectangle.Left + (uiInv.Rectangle.Width * InventoryHeaderRatioX);
                var yCoord = uiInv.Rectangle.Top + (uiInv.Rectangle.Height * InventoryHeaderRatioY);
                LabelHeader.DrawText(labelText, xCoord, yCoord);
            }
    
            private void handleItem(IItem item, bool cdrItem, bool rcrItem, System.Drawing.RectangleF rect)
            {
                string cdrText = null;
                var cdrFont = LabelCDR;
                if (cdrItem)
                {
                    var perfection = item.Perfections?.FirstOrDefault(x => x.Attribute.Code == "Power_Cooldown_Reduction_Percent_All");
                    if (perfection != null)
                    {
                        var cdr = Math.Round(perfection.Cur * 100, 3);
                        var cdrTest = Math.Round(perfection.Cur * 100, 0);
    
                        var isWeapon = item.SnoItem.HasGroupCode("weapons");
                        var needsMore = isWeapon ? (cdrTest < 10.0) : (cdrTest < 8.0);
                        cdrText = string.Format(CultureInfo.InvariantCulture, FormatCdrItem, cdr);
    
                        if (needsMore)
                        {
                            var enhancedItemMod = GetEnhancedItemMod(item);
                            var isEnchanted = IsEnchantedFor(enhancedItemMod, perfection.Attribute.Code);
                            if (isEnchanted)
                            {
                                cdrText += EnchantMoreMarker;
                            }
                        }
                        else
                        {
                            cdrFont = PerfectCDR;
                        }
                    }
                    else if (item.StatList != null)
                    {
                        foreach (var stat in item.StatList)
                        {
                            if (stat.Id == "cdred")
                            {
                                var cdr = stat.DoubleValue;
                                var cdrTest = cdr;
    
                                var isWeapon = item.SnoItem.HasGroupCode("weapons");
                                var needsMore = isWeapon ? (cdrTest < 10.0) : (cdrTest < 8.0);
                                cdrText = string.Format(CultureInfo.InvariantCulture, FormatCdrItem, cdr);
    
                                if (needsMore)
                                {
                                    var enhancedItemMod = GetEnhancedItemMod(item);
                                    var isEnchanted = IsEnchantedFor(enhancedItemMod, stat.Attribute.Code);
                                    if (isEnchanted)
                                    {
                                        cdrText += EnchantMoreMarker;
                                    }
                                }
                                else
                                {
                                    cdrFont = PerfectCDR;
                                }
                            }
                        }
                    }
                    else
                    {
                        var enhancedItemMod = GetEnhancedItemMod(item);
                        if (enhancedItemMod == null)
                        {
                            cdrText = EnchantMoreMarker;
                        }
                        else
                        {
                            cdrText = CanNotEnchantMarker;
                            cdrFont = CanNotEnchantFont;
                        }
                    }
                }
    
                string rcrText = null;
                var rcrFont = LabelRCR;
                if (rcrItem)
                {
                    var perfection = item.Perfections?.FirstOrDefault(x => x.Attribute.Code == "Resource_Cost_Reduction_Percent_All");
                    if (perfection != null)
                    {
                        var isYang = item.SnoItem.NameEnglish == "Yang's Recurve";  // AFAIK the only exception!
                        var rcr = Math.Round(perfection.Cur * 100, 3);
                        var rcrTest = Math.Round(perfection.Cur * 100, 0);
                        var needsMore = isYang ? (rcrTest < 50.0) : (rcrTest < 8.0);
                        rcrText = string.Format(CultureInfo.InvariantCulture, FormatRcrItem, rcr);
                        if (needsMore)
                        {
                            var enhancedItemMod = GetEnhancedItemMod(item);
                            var isEnchanted = IsEnchantedFor(enhancedItemMod, perfection.Attribute.Code);
                            if (isEnchanted)
                            {
                                rcrText += EnchantMoreMarker;
                            }
                        }
                        else
                        {
                            rcrFont = PerfectRCR;
                        }
                    }
                    else if (item.StatList != null)
                    {
                        foreach (var stat in item.StatList)
                        {
                            if (stat.Id == "rescostred")
                            {
                                var rcr = stat.DoubleValue;
                                var rcrTest = rcr;
    
                                var isYang = item.SnoItem.NameEnglish == "Yang's Recurve";  // AFAIK the only exception!
                                var needsMore = isYang ? (rcrTest < 50.0) : (rcrTest < 8.0);
                                rcrText = string.Format(CultureInfo.InvariantCulture, FormatCdrItem, rcr);
                                if (needsMore)
                                {
                                    var enhancedItemMod = GetEnhancedItemMod(item);
                                    var isEnchanted = IsEnchantedFor(enhancedItemMod, stat.Attribute.Code);
                                    if (isEnchanted)
                                    {
                                        rcrText += EnchantMoreMarker;
                                    }
                                }
                                else
                                {
                                    rcrFont = PerfectRCR;
                                }
                            }
                        }
                    }
                    else
                    {
                        var enhancedItemMod = GetEnhancedItemMod(item);
                        if (enhancedItemMod == null)
                        {
                            rcrText = EnchantMoreMarker;
                        }
                        else
                        {
                            rcrText = CanNotEnchantMarker;
                            rcrFont = CanNotEnchantFont;
                        }
                    }
                }
                // Top right corner.
                if (cdrText != null)
                {
                    var layout = cdrFont.GetTextLayout(cdrText);
                    cdrFont.DrawText(layout, rect.Right + (rv / 20.0f), rect.Top + (layout.Metrics.Height / 6f));
                    if (RcrOffset == 0f)
                    {
                        RcrOffset = 1.05f * layout.Metrics.Height;
                        //Hud.Debug("RcrOffset " + RcrOffset.ToString());
                    }
                }
                if (rcrText != null)
                {
                    var layout = rcrFont.GetTextLayout(rcrText);
                    rcrFont.DrawText(layout, rect.Right + (rv / 20.0f), rect.Top + (layout.Metrics.Height / 6f) + RcrOffset);
                }
            }
    
            private static bool IsEnchantedFor(ISnoItemMod itemMod, string code)
            {
                return itemMod != null && itemMod.Attribute.Code == code;
            }
    
            private static ISnoItemMod GetEnhancedItemMod(IItem item)
            {
                var affix = item.EnchantedAffixNew != 0 && item.Affixes != null ? item.Affixes.FirstOrDefault(x => x.Id == item.EnchantedAffixNew) : null;
                return affix != null && affix.Mods.Length > 0 ? affix.Mods[0] : null;
            }
        }
    }
    I was too lazy to refactor the method that checks the value, I'm sorry

Similar Threads

  1. [v9.0] Inventory and Stash Search plugin
    By Razorfish in forum TurboHUD Community Plugins
    Replies: 12
    Last Post: 09-26-2019, 09:15 PM
  2. Quality Gem and Flask add plugin
    By FredDurst in forum Path of Exile
    Replies: 2
    Last Post: 06-15-2019, 08:39 PM
  3. [Buying] ArcheBuddy Key and LP Regen Plugin + give you 15-20 dollars!
    By Totemwolf in forum ArcheAge Buy Sell Trade
    Replies: 12
    Last Post: 01-18-2015, 04:21 PM
  4. [Help] C# plugins and attributes
    By lanman92 in forum Programming
    Replies: 5
    Last Post: 10-05-2009, 07:55 PM
  5. Replies: 5
    Last Post: 10-25-2008, 10:27 PM
All times are GMT -5. The time now is 03:28 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search