Item.Perfections - Power_Cooldown_Reduction_Percent_All rounding prob menu

User Tag List

Results 1 to 8 of 8
  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)

    Item.Perfections - Power_Cooldown_Reduction_Percent_All rounding prob

    Hi
    I created simple plugin to calculate item attribute specific perfection values using item.Perfections collection for Hud.Inventory.HoveredItem.
    I works perfectly but CDR % (Power_Cooldown_Reduction_Percent_All) seems to be calculated oddly compared to other attributes with similar percentage values.
    perfection.Cur can never be perfection.Min or perfection.Max due to rounding differences so it is hard to compare against minimum and maximum allowed values.
    I created following workaround for my own code to overcome this.
    public static int calculateRank(IItemPerfection perfection)
    {
    // Calculate with 4 digit (rounded) precision - Power_Cooldown_Reduction_Percent_All has "rounding errors"!
    const int mult = 10000;
    double cur = Math.Round(mult * perfection.Cur + 0.5) / mult;
    double min = Math.Round(mult * perfection.Min + 0.5) / mult;
    double max = Math.Round(mult * perfection.Max + 0.5) / mult;
    return (int)calculate(cur, min, max);
    }
    This is easy to test with attached test plugin.
    Note that is must be explicitly be enabled: Hud.TogglePlugin<TestPerfectionPlugin>(true);

    BTW, I noticed that Hud.Inventory.HoveredItem does not "find" follower amulet or rings. It is NULL when hovered over.
    And item.Location Unknown1 and 2 and 3 seems to refer follower relic and hands.
    See attached test plugin code.
    You might want to fix these small problems
    --
    BR,
    JarJar
    Attached Files Attached Files

    Item.Perfections - Power_Cooldown_Reduction_Percent_All rounding prob
  2. #2
    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)
    I noticed that Resource_Regen_Per_Second has same rounding prob as Power_Cooldown_Reduction_Percent_All.
    OTOH Crit_Percent_Bonus_Capped and Attacks_Per_Second_Percent works perfectly

    2017.10.10 14.58.07.051 ITEM 'Dead Man's Legacy' P2_Unique_Quiver_007 in:RightHand p=65% type=Quiver group=quiver: offhands/quiver
    P=YES Dexterity_Item [626-750]=744 [{VALUE}|+|] Dexterity rank=a DEX 95
    P=YES Crit_Percent_Bonus_Capped [0,08-0,1]=0,08 rank=b CHC 0
    P=YES Power_Cooldown_Reduction_Percent_All [0,05-0,08]=0,07995605 Reduces cooldown of all skills by [{VALUE1}*100|1|]%. rank=e CDR 100
    P=NO Resource_Regen_Per_Second [1,35-1,5]=1,416016 Increases Hatred Regeneration by [{VALUE}|2|] per Second rank=ReGe+ 44
    P=YES Power_Damage_Percent_Bonus [0,75-1]=0,96 Increases {VALUE1} Damage by [{VALUE2}*100]% what_power=DemonHunter rank=d iDMG% 83
    P=YES Resource_Max_Bonus [9-12]=12 [{VALUE}|+|] Maximum Discipline rank=c ReBo+ 100
    P=NO Attacks_Per_Second_Percent [0,15-0,2]=0,19 Attack Speed Increased by [{VALUE}|1|*100]% rank=IAS 79
    P=<> Quiver [1-1]=1
    P=<> Item_Power_Passive [0,5-0,6]=0,55

  3. #3
    JackCeparou's Avatar Savvy ? 🐒
    Reputation
    534
    Join Date
    Mar 2017
    Posts
    588
    Thanks G/R
    51/490
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    double - Division in c# not going the way I expect - Stack Overflow

    Divide anything by an integer and it will return an integer.
    public static int calculateRank(IItemPerfection perfection)
    {
    // Calculate with 4 digit (rounded) precision - Power_Cooldown_Reduction_Percent_All has "rounding errors"!
    const double mult = 10000;
    double cur = Math.Round(mult * perfection.Cur + 0.5) / mult;
    double min = Math.Round(mult * perfection.Min + 0.5) / mult;
    double max = Math.Round(mult * perfection.Max + 0.5) / mult;
    return (int)calculate(cur, min, max);
    }
    Hide the Rum! --> Default theme customization 101 <--

  4. #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)
    The problem is that Hud.Inventory.HoveredItem.Perfections[N].Cur is 0,07995605 when it should be the same as Hud.Inventory.HoveredItem.Perfections[N].Max (0,08) like item popup windows states for attribute "Reduces cooldown of all skills by 8.0%".
    IMO Turbo.Plugins.IItemPerfection implementation does not work correctly in all cases, at least Resource_Regen_Per_Second and Power_Cooldown_Reduction_Percent_All IItemPerfection object returned to me seems to have this problem.

    My rounding workaround code was not perfect, it worked only for upper limit (max value), never for lower limit (min value). Have to fix that, until IItemPerfection starts to return correctly rounded values.

    Here some IItemPerfection min, max and cur values generated from code:
    Hud.Debug(string.Format("{0} [{1}-{2}]={3}", perfection.Attribute.Code, perfection.Min.ToString("G7"), perfection.Max.ToString("G7"), perfection.Cur.ToString("G7")));

    For example "Block_Chance_Bonus_Item" IItemPerfection is very interesting, how come it can be 0,1599121 when min and max values are 0,16!

    Dexterity_Item [626-750]=744
    Crit_Percent_Bonus_Capped [0,08-0,1]=0,08
    Power_Cooldown_Reduction_Percent_All [0,05-0,08]=0,07995605
    Resource_Regen_Per_Second [1,35-1,5]=1,416016
    Power_Damage_Percent_Bonus [0,75-1]=0,96
    Resource_Max_Bonus [9-12]=12
    Attacks_Per_Second_Percent [0,15-0,2]=0,19
    Damage_Weapon_Percent_All [0,06-0,1]=0,07
    Dexterity_Item [825-1000]=859
    Vitality_Item [825-1000]=910
    Resource_Max_Bonus [9-12]=12
    Resource_Cost_Reduction_Percent_All [0,4-0,5]=0,4899902
    Block_Chance_Bonus_Item [0,11-0,11]=0,1099854
    Armor_Bonus_Item [559-595]=589
    Crit_Percent_Bonus_Capped [0,08-0,1]=0,085
    Strength_Item [626-750]=661
    Block_Chance_Item [0,1-0,2]=0,1199951
    Block_Amount_Item_Min [17000-19000]=18976
    Vitality_Item [825-1000]=917
    Sockets [1-1]=1
    Resistance_All [110-130]=118
    Block_Chance_Bonus_Item [0,16-0,16]=0,1599121
    Crit_Damage_Percent [0,51-1]=0,91
    Strength_Item [825-1000]=940

    [Edit] Fixed version here:
    0.0001 seems to be good delta value to consider two values "the same", in this case either min or max value.
    This way I can have 0% or 100% attribute perfection even if current perfection value has slight "rounding errors".
    public int calculateRank(IItemPerfection perfection)
    {
    double cur = perfection.Cur;
    double min = perfection.Min;
    double max = perfection.Max;
    // Current value can have rounding errors which can affect min/max comparision, fix it here.
    if (Math.Abs(max - cur) < 0.0001) cur = max; else if (Math.Abs(cur - min) < 0.0001) cur = min;
    return (int)calculate(cur, min, max);
    }
    Last edited by JarJarD3; 10-10-2017 at 02:33 PM.

  5. #5
    JackCeparou's Avatar Savvy ? 🐒
    Reputation
    534
    Join Date
    Mar 2017
    Posts
    588
    Thanks G/R
    51/490
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, you need to look at the problem the other way around.

    The values come directly from memory.
    I bet than the D3 UI simply make a rounding at 2 decimal places, using the same exact values.. (and D3 data files probably store the rounded min/max values)

    Originally Posted by JarJarD3 View Post
    For example "Block_Chance_Bonus_Item" IItemPerfection is very interesting, how come it can be 0,1599121 when min and max values are 0,16! => see below

    Power_Cooldown_Reduction_Percent_All [0,05-0,08]=0,07995605 => Math.Round(0.07995605, 2) ~= 0.08
    Resource_Regen_Per_Second [1,35-1,5]=1,416016 => that's totally ok => Math.Round(1.416016, 2) ~= 1.42
    Resource_Cost_Reduction_Percent_All [0,4-0,5]=0,4899902 => well => Math.Round(0.4899902, 2) ~= 0.49 => Math.Round(0.4899902, 1) ~= 0.5
    Block_Chance_Bonus_Item [0,11-0,11]=0,1099854 => Math.Round(0.1099854, 2) ~= 0.11
    Block_Chance_Item [0,1-0,2]=0,1199951 => Math.Round(0.1199951, 2) ~= 0.12
    Block_Chance_Bonus_Item [0,16-0,16]=0,1599121 => Math.Round(0.1599121, 2) ~= 0.16
    If KJ has made an error reading these values, they will be way more different than just some 'rounding' errors.

    Edit : if your issue is to compute the perfection percentage, take a look here and there, that's how I handle it without a hitch
    Last edited by JackCeparou; 10-10-2017 at 03:38 PM.
    Hide the Rum! --> Default theme customization 101 <--

  6. #6
    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)
    Thanks for the info and I can live with minor rounding myself.
    This is awesome plugin environment you have made and it is a pleasure to work with it.
    Mostly by trial and error but I'm progressing all the time...

    What is best forum to post plugin implementation related questions?
    I might need some advice how to position UI stuff like labels resolution independently.
    Now my code calculates everything on my 1920x1200 monitor.
    I've seen some code with magic numbers for UI positioning that could be related to scaling things related to window size or ...?
    Any documentation or pointers about the subject would be nice.

    Further more can you tell me how item.Perfection is calculated?
    Is it average of all item Perfections array or just some selected (important) ones?
    And how is damage calculated?
    Using Damage_Weapon_Min/Damage_Weapon_Delta and Damage_Min/Damage_Delta or some other formula?

    IItemPerfection is really nice and easy and makes my work straight forward to calculate attribute specific perfections from min/max and cur values.
    --
    BR,
    JarJar

  7. #7
    JackCeparou's Avatar Savvy ? 🐒
    Reputation
    534
    Join Date
    Mar 2017
    Posts
    588
    Thanks G/R
    51/490
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by JarJarD3 View Post
    This is awesome plugin environment you have made and it is a pleasure to work with it.
    Well, all credits to KillerJohn, I registered the day I read about the C# plugins engine ^^ (on the old board)

    Originally Posted by JarJarD3 View Post
    What is best forum to post plugin implementation related questions?
    I might need some advice how to position UI stuff like labels resolution independently.
    Now my code calculates everything on my 1920x1200 monitor.
    I've seen some code with magic numbers for UI positioning that could be related to scaling things related to window size or ...?
    Any documentation or pointers about the subject would be nice.
    This is a vast subject, but long story short to handle all screen ratio you need to compute from only one dimension (height or width, simpler one being height)

    Originally Posted by JarJarD3 View Post
    Further more can you tell me how item.Perfection is calculated?
    Dunno, only KJ can answer this.
    Hide the Rum! --> Default theme customization 101 <--

  8. #8
    User5981's Avatar First Dev On The Internet
    Reputation
    379
    Join Date
    Aug 2017
    Posts
    765
    Thanks G/R
    30/358
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Supported version for all Resu plugins

Similar Threads

  1. [Question] Item perfection discussion
    By User5981 in forum TurboHUD Discussions
    Replies: 4
    Last Post: 10-11-2017, 01:15 AM
  2. [Question] Show item perfection?
    By Elimin in forum TurboHUD Support
    Replies: 3
    Last Post: 05-27-2017, 06:38 AM
  3. [Selling] EU Softcore 792+ Paragon, Barb/Crus , All bis Items , Perfect Raekor/IK6/WW sets
    By receiver in forum Diablo 3 Buy Sell Trade
    Replies: 3
    Last Post: 04-28-2015, 05:29 AM
  4. [Help]Retrieving backpack item attributes doesn't work perfectly
    By AGPS in forum Diablo 3 Memory Editing
    Replies: 19
    Last Post: 08-09-2012, 06:55 PM
  5. [Selling] 12 perfect gold find items - bin!
    By andyps in forum Diablo 3 Buy Sell Trade
    Replies: 1
    Last Post: 07-15-2012, 07:44 AM
All times are GMT -5. The time now is 01: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