s4000

DAV_ItemEth

Mar 28th, 2026
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 15.67 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Drawing;
  4. using System.Collections.Generic;
  5. using Turbo.Plugins.Default;
  6.  
  7. namespace Turbo.Plugins.DAV {
  8.  
  9.     public class DAV_ItemEth : BasePlugin, IInGameTopPainter {
  10.         public string MaxText { get; set; } = "Max";
  11.         public IFont EtherealFont { get; set; }
  12.  
  13.         private ITexture powerBackground { get; set; }
  14.         private List<ISnoItem> weaponPowers { get; set; }
  15.         private Dictionary<uint, ISnoPower> passiveMapping { get; set; }
  16.  
  17.         public DAV_ItemEth() {
  18.             Enabled = true;
  19.             Order = int.MinValue + 5;
  20.         }
  21.  
  22.         public void PaintTopInGame(ClipState clipState) {
  23.             if (clipState != ClipState.Inventory || !Hud.Inventory.InventoryMainUiElement.Visible) return;
  24.  
  25.             var stashVisible = Hud.Inventory.StashMainUiElement.Visible;
  26.             var stashTabAbs = Hud.Inventory.SelectedStashTabIndex + Hud.Inventory.SelectedStashPageIndex * Hud.Inventory.MaxStashTabCountPerPage;
  27.             foreach (var item in Hud.Game.Items.Where(x => VisibleEthereal(x, stashVisible, stashTabAbs))) {
  28.                 var rect = Hud.Inventory.GetItemRect(item);
  29.                 if (rect != RectangleF.Empty)
  30.                     DrawEthPower(item, rect);
  31.             }
  32.         }
  33.  
  34.         private bool VisibleEthereal(IItem item, bool stashVisible, int stashTabAbs) {
  35.             return item.SnoItem.IsEthereal && item.Perfections != null // && !item.Unidentified
  36.                 && (item.Location == ItemLocation.Inventory || item.Location == ItemLocation.LeftHand || item.Location == ItemLocation.RightHand
  37.                     || (stashVisible && item.Location == ItemLocation.Stash && item.InventoryY / 10 == stashTabAbs));
  38.         }
  39.  
  40.         private void DrawEthPower(IItem item, RectangleF rect) {
  41.             var ethPowers = item.Perfections.Where(z => z.Attribute?.Index == 1293u);
  42.             if (ethPowers == null) return;
  43.  
  44.             var notEquipped = item.Location == ItemLocation.Stash || item.Location == ItemLocation.Inventory;
  45.             var w = rect.Height / 3f;
  46.             var h = w * 2;
  47.             var y = rect.Bottom - h;
  48.             var x = rect.Right;
  49.             if (notEquipped)
  50.                 x -= w;
  51.             else if (item.Location == ItemLocation.RightHand)
  52.                 x = rect.X - w;
  53.  
  54.             foreach (var perfect in ethPowers) {
  55.                 if (passiveMapping.TryGetValue(perfect.Modifier, out var passivePower)) {
  56.                     var w2 = notEquipped ? rect.Width / 2.25f : w;
  57.                     var x2 = notEquipped ? rect.Right - w2 : rect.Right;
  58.                     var passiveTexture = Hud.Texture.GetTexture(passivePower.NormalIconTextureId);
  59.                     passiveTexture?.Draw(x2, rect.Y, w2, w2);
  60.                 }
  61.                 else {
  62.                     var empowerItem = weaponPowers.FirstOrDefault(z => LegendaryPowerSno(z) == perfect.Modifier);
  63.                     if (empowerItem != null) {
  64.                         powerBackground.Draw(x, y, w, h);
  65.                         Hud.Texture.GetItemTexture(empowerItem)?.Draw(x, y, w, h);
  66.                         if (perfect.Min != perfect.Max) {
  67.                             var curValue = item.Unidentified ? (item.StatList?.FirstOrDefault(a => a.Modifier == perfect.Modifier)?.DoubleValue ?? -1d) : perfect.Cur;
  68.                             var adjCur = PowerValue(perfect.Modifier, curValue, perfect.Max);
  69.                             EtherealFont.DrawText(adjCur > 0 ? $"{adjCur:0}" : MaxText, rect.X, rect.Y); // to test
  70.                         }
  71.                     }
  72.                 }
  73.             }
  74.         }
  75.  
  76.         private uint LegendaryPowerSno(ISnoItem snoItem) {
  77.             if (snoItem.LegendaryPower != null)
  78.                 return snoItem.LegendaryPower.Sno;
  79.  
  80.             switch (snoItem.Sno) { // Craft Items
  81.                 case 3321082205 : return 247769; // Blood-Magic Edge
  82.                 case  962318656 : return 318818; // Reaper's Wraps
  83.                 case   59215970 : return 248501; // Sunder
  84.                 case  370939127 : return 483537; // Spite
  85.                 case  162390824 : return 247585; // Wall of Man
  86.                 case 2740453189 : return 248462; // Cinder Switch
  87.                 case 2775850772 : return 318733; // Cosmic Strand
  88.                 case 2503771951 : return 318852; // Golden Scourge
  89.                 case  820499474 : return 318885; // Piro Marella
  90.             }
  91.  
  92.             return 0;
  93.         }
  94.  
  95.         private double PowerValue(uint powerSno, double curValue, double maxValue) {
  96.             if (curValue == maxValue) return -1d;
  97.  
  98.             switch (powerSno) {
  99.                 case 402458 : // 引劍
  100.                 case 484244 : // 戍衛之傑
  101.                 case 475253 : // 萊蓮娜的影魂鉤
  102.                     return curValue;
  103.             }
  104.  
  105.             return curValue * 100d;
  106.         }
  107.  
  108.         public override void Load(IController hud) {
  109.             base.Load(hud);
  110.  
  111.             EtherealFont = Hud.Render.CreateFont("Arial", 7f, 255, 255, 255, 51, true, false, 153, 0, 0, 0, true);
  112.             powerBackground = Hud.Texture.GetTexture(2725626326); // 993828447
  113.  
  114.             var snoList = Hud.Sno;
  115.             passiveMapping = new Dictionary<uint, ISnoPower> {
  116.                 // Barbarian
  117.                 { 397813, snoList.GetSnoPower(205205) }, { 397814, snoList.GetSnoPower(205175) }, { 397815, snoList.GetSnoPower(217819) }, { 397816, snoList.GetSnoPower(206147) },
  118.                 { 397817, snoList.GetSnoPower(205546) }, { 397818, snoList.GetSnoPower(205187) }, { 397819, snoList.GetSnoPower(205217) }, { 397820, snoList.GetSnoPower(205228) },
  119.                 { 397822, snoList.GetSnoPower(205491) }, { 397831, snoList.GetSnoPower(205848) }, { 397832, snoList.GetSnoPower(204725) }, { 397833, snoList.GetSnoPower(205398) },
  120.                 { 397834, snoList.GetSnoPower(205133) }, { 397835, snoList.GetSnoPower(205707) }, { 397836, snoList.GetSnoPower(205300) }, { 397838, snoList.GetSnoPower(204603) },
  121.                 { 397839, snoList.GetSnoPower(361661) }, { 397841, snoList.GetSnoPower(296572) }, { 397842, snoList.GetSnoPower(340877) },
  122.                 // Crusader
  123.                 { 397843, snoList.GetSnoPower(286177) }, { 397844, snoList.GetSnoPower(302500) }, { 397845, snoList.GetSnoPower(309830) }, { 397846, snoList.GetSnoPower(310626) },
  124.                 { 397847, snoList.GetSnoPower(310640) }, { 397848, snoList.GetSnoPower(310678) }, { 397849, snoList.GetSnoPower(310775) }, { 397850, snoList.GetSnoPower(310783) },
  125.                 { 397851, snoList.GetSnoPower(311629) }, { 397852, snoList.GetSnoPower(310804) }, { 397853, snoList.GetSnoPower(348741) }, { 397854, snoList.GetSnoPower(348773) },
  126.                 { 401366, snoList.GetSnoPower(356052) }, { 401367, snoList.GetSnoPower(356147) }, { 401368, snoList.GetSnoPower(356173) }, { 401369, snoList.GetSnoPower(356176) },
  127.                 { 401370, snoList.GetSnoPower(357218) }, { 401371, snoList.GetSnoPower(357269) },
  128.                 // DemonHunter
  129.                 { 401378, snoList.GetSnoPower(211225) }, { 401379, snoList.GetSnoPower(218385) }, { 401380, snoList.GetSnoPower(155714) }, { 401381, snoList.GetSnoPower(164363) },
  130.                 { 401382, snoList.GetSnoPower(155721) }, { 401383, snoList.GetSnoPower(218350) }, { 401384, snoList.GetSnoPower(210801) }, { 401385, snoList.GetSnoPower(155725) },
  131.                 { 401386, snoList.GetSnoPower(209734) }, { 401387, snoList.GetSnoPower(218398) }, { 401388, snoList.GetSnoPower(155722) }, { 401389, snoList.GetSnoPower(208610) },
  132.                 { 401390, snoList.GetSnoPower(208779) }, { 401391, snoList.GetSnoPower(155715) }, { 401392, snoList.GetSnoPower(155723) }, { 401393, snoList.GetSnoPower(352920) },
  133.                 { 401394, snoList.GetSnoPower(324770) }, { 401395, snoList.GetSnoPower(338859) }, { 439528, snoList.GetSnoPower(439525) },
  134.                 // Monk
  135.                 { 401414, snoList.GetSnoPower(211581) }, { 401415, snoList.GetSnoPower(209029) }, { 401416, snoList.GetSnoPower(209027) }, { 401417, snoList.GetSnoPower(209250) },
  136.                 { 401418, snoList.GetSnoPower(156467) }, { 401419, snoList.GetSnoPower(209628) }, { 401420, snoList.GetSnoPower(209812) }, { 401421, snoList.GetSnoPower(209622) },
  137.                 { 401422, snoList.GetSnoPower(404245) }, { 401423, snoList.GetSnoPower(209104) }, { 401424, snoList.GetSnoPower(156492) }, { 401425, snoList.GetSnoPower(404168) },
  138.                 { 401426, snoList.GetSnoPower(218415) }, { 401427, snoList.GetSnoPower(156484) }, { 401428, snoList.GetSnoPower(315271) }, { 401429, snoList.GetSnoPower(341559) },
  139.                 { 401430, snoList.GetSnoPower(368899) }, { 409335, snoList.GetSnoPower(402633) },
  140.                 // Necromancer
  141.                 { 472668, snoList.GetSnoPower(465917) }, { 472669, snoList.GetSnoPower(465703) }, { 472670, snoList.GetSnoPower(470725) }, { 472671, snoList.GetSnoPower(472965) },
  142.                 { 472672, snoList.GetSnoPower(472962) }, { 472673, snoList.GetSnoPower(470805) }, { 472674, snoList.GetSnoPower(464994) }, { 472675, snoList.GetSnoPower(466415) },
  143.                 { 472676, snoList.GetSnoPower(470764) }, { 472677, snoList.GetSnoPower(470812) }, { 472678, snoList.GetSnoPower(472220) }, { 472679, snoList.GetSnoPower(472795) },
  144.                 { 472693, snoList.GetSnoPower(465952) }, { 472694, snoList.GetSnoPower(473019) }, { 472695, snoList.GetSnoPower(465264) }, { 472697, snoList.GetSnoPower(472905) },
  145.                 { 472698, snoList.GetSnoPower(472949) }, { 472699, snoList.GetSnoPower(465821) }, { 472700, snoList.GetSnoPower(465037) }, { 472701, snoList.GetSnoPower(472910) },
  146.                 // WitchDoctor
  147.                 { 401458, snoList.GetSnoPower(217968) }, { 401459, snoList.GetSnoPower(208571) }, { 401460, snoList.GetSnoPower(208569) }, { 401461, snoList.GetSnoPower(208594) },
  148.                 { 401462, snoList.GetSnoPower(208568) }, { 401463, snoList.GetSnoPower(217826) }, { 401464, snoList.GetSnoPower(208563) }, { 401465, snoList.GetSnoPower(208628) },
  149.                 { 401466, snoList.GetSnoPower(218501) }, { 401467, snoList.GetSnoPower(218588) }, { 401468, snoList.GetSnoPower(208565) }, { 401469, snoList.GetSnoPower(209041) },
  150.                 { 401470, snoList.GetSnoPower(208639) }, { 401471, snoList.GetSnoPower(218191) }, { 401472, snoList.GetSnoPower(208601) }, { 401473, snoList.GetSnoPower(340908) },
  151.                 { 401474, snoList.GetSnoPower(340910) }, { 401475, snoList.GetSnoPower(340909) }, { 442744, snoList.GetSnoPower(442741) },
  152.                 // Wizard
  153.                 { 401476, snoList.GetSnoPower(341344) }, { 401495, snoList.GetSnoPower(208471) }, { 401496, snoList.GetSnoPower(208493) }, { 401497, snoList.GetSnoPower(208472) },
  154.                 { 401498, snoList.GetSnoPower(208547) }, { 401499, snoList.GetSnoPower(226301) }, { 401500, snoList.GetSnoPower(208541) }, { 401501, snoList.GetSnoPower(208478) },
  155.                 { 401502, snoList.GetSnoPower(208468) }, { 401503, snoList.GetSnoPower(208473) }, { 401504, snoList.GetSnoPower(208823) }, { 401505, snoList.GetSnoPower(208474) },
  156.                 { 401506, snoList.GetSnoPower(226348) }, { 401507, snoList.GetSnoPower(298038) }, { 401508, snoList.GetSnoPower(218044) }, { 401509, snoList.GetSnoPower(341540) },
  157.                 { 401510, snoList.GetSnoPower(208477) }, { 401511, snoList.GetSnoPower(342326) },
  158.             };
  159.  
  160.             // from Maxroll
  161.             var snoItems = Hud.Sno.SnoItems;
  162.             weaponPowers = new List<ISnoItem> {
  163.             // Barbarian x 10
  164.                 snoItems.P67_Unique_Mighty_1H_006,  // 重型武器 :   峽灣分嶺斧
  165.                 snoItems.P67_Unique_Mighty_1H_012,  //              岸柏之傲
  166.                 snoItems.P67_Unique_Mighty_1H_102,  //              無憫 P72_Unique_Mighty_1H_102 ?
  167.                 snoItems.P4_Unique_Mighty_1H_104,   //              守誓者
  168.                 snoItems.P61_Unique_Polearm_01,     //              峙
  169.                 snoItems.P61_Unique_Mighty_2H_001,  // 重型武器2H : 審判之鎚
  170.                 snoItems.P68_Unique_Mighty_2H_004,  //              戍衛之傑
  171.                 snoItems.P61_Unique_Mighty_2H_006,  //              夷峰烈怒
  172.                 snoItems.P610_Unique_Mighty_2H_101, //              部族之刃
  173.                 snoItems.P66_Unique_Axe_2H_003,     // 斧2H :      劊子手
  174.             // Crusader x 17
  175.                 snoItems.P1_flail1H_norm_unique_01,     // 連枷 : 喬安娜之證
  176.                 snoItems.Unique_Flail_1H_103_x1,        //          神駒飛馳
  177.                 snoItems.P61_Unique_Flail_1H_105_x1,    //          矛隼之爪
  178.                 snoItems.P67_Unique_Flail_1H_106,       //          黑暗之光
  179.                 snoItems.P65_flail2H_norm_unique_01,    // 連枷2H :   阿克漢的寬容 P76_flail2H_norm_unique_01 ?
  180.                 snoItems.P610_Unique_Flail_2H_101,      //          人世無常
  181.                 snoItems.P61_Unique_Flail_2H_103_x1,    //          妖邪必敗
  182.                 snoItems.P61_Unique_Sword_2H_007_x1,    // 劍2H:       預言之刃
  183.                 snoItems.P61_Unique_Sword_2H_012_x1,    //          忠貞回憶
  184.                 snoItems.P61_CruShield_norm_unique_01,  // 聖教盾 :  佛萊德之怒
  185.                 snoItems.P65_Unique_CruShield_102_x1,   //          傑伏坎盾
  186.                 snoItems.Unique_CruShield_104_x1,       //          阿卡拉特的覺醒
  187.                 snoItems.Unique_Shield_103_x1,          //          喬安娜之衛
  188.                 snoItems.P61_Unique_Shield_106_x1,      //          聖怒之盾
  189.                 snoItems.P2_Unique_Shield_002,          // 盾 :        象牙塔
  190.                 snoItems.P61_Unique_Shield_007,         //          阻絕者
  191.                 snoItems.Unique_Shield_102_x1,          //          埃伯利加羅
  192.             // DemonHunter x 14
  193.                 snoItems.P61_Unique_Dagger_101_x1,  // 匕首 : 家妮之鋒
  194.                 snoItems.P61_Unique_Dagger_102_x1,  //          葛林斯通大君之扇
  195.                 snoItems.P4_Unique_HandXBow_001,    // 弩槍 : 黎明
  196.                 snoItems.P43_Unique_HandXBow_005,   //          維拉之贈
  197.                 snoItems.P4_Unique_HandXBow_02,     //          要塞弩砲
  198.                 snoItems.P69_Unique_Bow_102,        // 弓 :        奧德賽的尾聲
  199.                 snoItems.P61_Unique_Bow_104_x1,     //          楊的反曲弓
  200.                 snoItems.P61_Unique_XBow_001,       // 弩 :        蠍尾獅
  201.                 snoItems.P65_Unique_Xbow_102,       //          沃賈強襲弩
  202.                 snoItems.P65_Unique_Quiver_001,     // 箭筒 : 索罪矢
  203.                 snoItems.P69_Unique_Quiver_004,     //          聖尖矢
  204.                 snoItems.P61_Unique_Quiver_007,     //          亡者遺產
  205.                 snoItems.P69_Unique_Quiver_101,     //          瑟里九號箭包
  206.                 snoItems.Unique_Quiver_102_x1,      //          轟擊者背袋 P72_Unique_Quiver_102 ?
  207.             // Monk x 10
  208.                 snoItems.P1_fistWeapon_norm_unique_01,      // 拳套 : 猛獅之爪
  209.                 snoItems.P67_fistWeapon_norm_unique_02,     //          仇憎之風
  210.                 snoItems.P71_Unique_Fist_003,               //          狂擊
  211.                 snoItems.P67_Unique_Fist_006,               //          流雲橋
  212.                 snoItems.P61_Unique_Fist_009_x1,            //          厄圖拉斯之拳
  213.                 snoItems.P4_Unique_Fist_102,                //          京四郎之刃
  214.                 snoItems.P61_Unique_CombatStaff_2H_001,     // 武杖 : 均衡
  215.                 snoItems.P61_Unique_CombatStaff_2H_003_x1,  //          大殿香炬
  216.                 snoItems.P41_Unique_CombatStaff_2H_005,     //          永恆之悟
  217.                 snoItems.Unique_CombatStaff_2H_009_x1,      //          翔龍
  218.             // Necromancer x 10
  219.                 snoItems.P6_Unique_Scythe1H_02,     // 鐮刀 : 塔格奧的腐壞尖牙
  220.                 snoItems.P61_Unique_Scythe1H_03,    //          輪迴之鐮
  221.                 snoItems.P61_Unique_Scythe2H_01,    // 鐮刀2H :   馬托利斯的石化尖刺
  222.                 snoItems.P65_Unique_Scythe2H_02,    //          血潮長刀
  223.                 snoItems.P6_Unique_Scythe2H_03,     //          萊蓮娜的影魂鉤
  224.                 snoItems.P61_Unique_Scythe2H_04,    //          奈雅的黑死病
  225.                 snoItems.P61_Unique_Phylactery_01,  // 魂棺 : 流逝時光
  226.                 snoItems.P6_Unique_Phylactery_02,   //          骸骨喪鐘
  227.                 snoItems.P61_Unique_Phylactery_03,  //          萊杰的侮蔑
  228.                 snoItems.P65_Unique_Phylactery_04,  //          鐵玫瑰 P74_Unique_Phylactery_04 ?
  229.             // WitchDoctor x 11
  230.                 snoItems.P610_Unique_Spear_004,     // 矛 :        骨牙雕矛
  231.                 snoItems.P68_Unique_Dagger_003,     // 匕首 : 剃頭師
  232.                 snoItems.P61_Unique_Staff_001,      // 法杖 : 蝙蝠法杖
  233.                 snoItems.P2_mojo_norm_unique_02,    // 咒物 : 亨利的追尋
  234.                 snoItems.P4_Unique_Mojo_001,        //          兇邪蟲巢
  235.                 snoItems.P610_Unique_Mojo_001,      //          被踐踏的厄蘇亞肖像
  236.                 snoItems.P66_Unique_Mojo_002,       //          惡怨
  237.                 snoItems.P68_Unique_Mojo_003,       //          滅亡凝視
  238.                 snoItems.Unique_Mojo_102_x1,        //          舒可拉妮的勝利 P72_Unique_Mojo_102 ?
  239.                 snoItems.P1_CeremonialDagger_norm_unique_01,    // 祭祀刀 :  聖穫匕首
  240.                 snoItems.P65_CeremonialDagger_norm_unique_02,   //          箭鏢匕刃
  241.             // Wizard x 15
  242.                 snoItems.P610_Unique_Dagger_010,    // 匕首 : 巫師之刺
  243.                 snoItems.P610_Unique_Sword_1H_107,  // 劍 :        扭曲之劍
  244.                 snoItems.P61_Unique_Sword_1H_112_x1,//          絕命
  245.                 snoItems.P1_Wand_norm_unique_01,    // 魔杖 : 以太行者
  246.                 snoItems.P61_Wand_norm_unique_02,   //          不穩定的權杖
  247.                 snoItems.P610_Unique_Wand_010,      //          天命裂片
  248.                 snoItems.P61_Unique_Wand_101_x1,    //          沃爾魔杖
  249.                 snoItems.P68_Unique_Wand_102,       //          蛇影爍光
  250.                 snoItems.P61_Unique_Staff_009,      // 法杖 : 首相
  251.                 snoItems.P610_Unique_Staff_102,     //          佛爾瑟克的斥責
  252.                 snoItems.P610_Unique_Orb_002,       // 法器 : 蝕刻徽記
  253.                 snoItems.P61_Unique_Orb_003,        //          三連寶球
  254.                 snoItems.P61_Unique_Orb_004,        //          無盡深淵法珠
  255.                 snoItems.Unique_Orb_004_x1,         //          宇宙縮影
  256.                 snoItems.P610_Unique_Orb_005,       //          寒冬疾風
  257.             // Generic x 4
  258.                 snoItems.Unique_Sword_1H_113_x1,    // 劍 :        引劍
  259.                 snoItems.P66_Unique_Mace_1H_001,    // 釘鎚 : 迴盪狂怒
  260.                 snoItems.Unique_Mace_2H_103_x1,     // 釘鎚2H :   焚爐
  261.                 snoItems.P66_Unique_Axe_2H_011,     // 斧2H :  梅希斯密特之劫掠者
  262.             };
  263.         }
  264.     }
  265. }
Advertisement
Add Comment
Please, Sign In to add comment