Advertisement
Guest User

UrshisGiftPlugin.cs

a guest
Sep 10th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.37 KB | None | 0 0
  1. // http://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-plugin-review-zone/636940-v7-3-international-resu-urshisgiftplugin.html
  2.  
  3. using System;
  4. using System.Diagnostics;
  5. using System.Globalization;
  6. using System.Linq;
  7. using Turbo.Plugins.Default;
  8. using System.Collections.Generic;
  9.  
  10. namespace Turbo.Plugins.Resu
  11. {
  12.  
  13.     public class UrshisGiftPlugin : BasePlugin, IInGameTopPainter
  14.     {
  15.         public IBrush ShadowBrush { get; set; }
  16.         public IBrush InventoryLockBorderBrush { get; set; }
  17.         public IFont GRupgradeChanceFont { get; set; }
  18.         public int GRlevel { get; set; }
  19.         public int ChanceWantedPercentage { get; set; }
  20.         public int NumberOfAttempts { get; set; }
  21.         public int AddPerc { get; set; }
  22.        
  23.         private HashSet<int> Chances = new HashSet<int> {100,90,80,70,60,30,15,8,4,2,1};
  24.         private HashSet<int> Attemps = new HashSet<int> {1,2,3,4,5};
  25.        
  26.         public UrshisGiftPlugin()
  27.         {
  28.             Enabled = true;
  29.         }
  30.  
  31.         public override void Load(IController hud)
  32.         {
  33.             base.Load(hud);
  34.             ChanceWantedPercentage = 1;
  35.             NumberOfAttempts = 1;
  36.  
  37.             ShadowBrush = Hud.Render.CreateBrush(175, 0, 0, 0, -1.6f);
  38.             GRupgradeChanceFont = Hud.Render.CreateFont("arial", 7, 255, 0, 0, 0, true, false, false);
  39.             GRupgradeChanceFont.SetShadowBrush(128, 39, 229, 224, true);
  40.         }
  41.  
  42.         private int stashTabAbs;
  43.  
  44.         public void PaintTopInGame(ClipState clipState)
  45.         {
  46.             if (clipState != ClipState.Inventory) return;
  47.             if (!Chances.Contains(ChanceWantedPercentage)) return;      //false settings
  48.             if (!Attemps.Contains(NumberOfAttempts)) return;            //false settings
  49.  
  50.             stashTabAbs = Hud.Inventory.SelectedStashTabIndex + Hud.Inventory.SelectedStashPageIndex * Hud.Inventory.MaxStashTabCountPerPage;
  51.  
  52.             foreach (var item in Hud.Game.Items)
  53.             {
  54.                 if (item.SnoItem.MainGroupCode != "gems_unique") continue;
  55.                 if (item.Location == ItemLocation.Stash)
  56.                 {
  57.                     if ((item.InventoryY / 10) != stashTabAbs) continue;
  58.                 }
  59.                 if ((item.InventoryX < 0) || (item.InventoryY < 0)) continue;
  60.  
  61.                 var rect = Hud.Inventory.GetItemRect(item);
  62.                 if (rect == System.Drawing.RectangleF.Empty) continue;
  63.  
  64.                 DrawItemGRupgradeChance(item, rect);
  65.             }
  66.         }
  67.  
  68.         private void DrawItemGRupgradeChance(IItem item, System.Drawing.RectangleF rect)
  69.         {
  70.            
  71.             var jewelRank = item.JewelRank;
  72.             if (jewelRank == -1) {jewelRank = 0;}
  73.            
  74.             if (item.SnoItem.Sno == 3249876973 && jewelRank == 100 ||   // 3249876973 - Esoteric Alteration
  75.                 item.SnoItem.Sno == 3249984784 && jewelRank == 100 ||   // 3249984784 - Mutilation Guard
  76.                 item.SnoItem.Sno == 3248762926 && jewelRank == 150 ||   // 3248762926 - Gogok of Swiftness
  77.                 item.SnoItem.Sno == 3250883209 && jewelRank == 50 ||    // 3250883209 - Iceblink
  78.                 item.SnoItem.Sno == 3249805099 && jewelRank == 50)      // 3249805099 - Boon of the Hoarder
  79.             {
  80.                 var layout = GRupgradeChanceFont.GetTextLayout("max");
  81.                 GRupgradeChanceFont.DrawText(layout, rect.X+24, rect.Y+33);
  82.                
  83.                 return;
  84.             }
  85.            
  86.             if (ChanceWantedPercentage == 100) {AddPerc = 10;}
  87.             else if (ChanceWantedPercentage == 90) {AddPerc = 9;}
  88.             else if (ChanceWantedPercentage == 80) {AddPerc = 8;}
  89.             else if (ChanceWantedPercentage == 70) {AddPerc = 7;}
  90.             else if (ChanceWantedPercentage == 60) {AddPerc = 0;}
  91.             else if (ChanceWantedPercentage == 30) {AddPerc = -1;}
  92.             else if (ChanceWantedPercentage == 15) {AddPerc = -2;}
  93.             else if (ChanceWantedPercentage == 8) {AddPerc = -3;}
  94.             else if (ChanceWantedPercentage == 4) {AddPerc = -4;}
  95.             else if (ChanceWantedPercentage == 2) {AddPerc = -5;}
  96.             else if (ChanceWantedPercentage == 1) {AddPerc = -15;}
  97.  
  98.             GRlevel = jewelRank + AddPerc + (NumberOfAttempts - 1);
  99.             var text = GRlevel.ToString("D", CultureInfo.InvariantCulture);
  100.              
  101.             if (GRlevel < 100)
  102.             {
  103.                 var layout = GRupgradeChanceFont.GetTextLayout(text);
  104.                 GRupgradeChanceFont.DrawText(layout, rect.X+33, rect.Y+33);
  105.             }
  106.             else if (GRlevel >= 100 )
  107.             {
  108.                 var layout = GRupgradeChanceFont.GetTextLayout(text);
  109.                 GRupgradeChanceFont.DrawText(layout, rect.X+27, rect.Y+33);
  110.             }  
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement