Advertisement
Guest User

SR_BaneOfStrickenPlugin

a guest
Dec 31st, 2018
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.46 KB | None | 0 0
  1. // http://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-plugin-review-zone/635586-v7-3-english-glq-baneofthestrickenplugin.html
  2. // modified by P!N4C0L4D4 for StormReaver
  3.  
  4. using Turbo.Plugins.Default;
  5. using System;
  6. using System.Linq;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9.  
  10. namespace Turbo.Plugins._SR.Items
  11. {
  12.     public class SR_BaneOfTheStrickenPlugin : BasePlugin, IInGameTopPainter, INewAreaHandler
  13.     {
  14.         public bool DrawClassOnIcons { get; set; }      //Draw ClassNames per Dafault on every Stricken Icon
  15.        
  16.         public IFont TextFont { get; set; }
  17.         private int[] StackCount { get; set; }
  18.         private bool[] cooling { get; set; }
  19.         public TopLabelDecorator StackCountDecorator { get; set; }
  20.         public float xPos { get; set; }
  21.         public float XWidth { get; set; }
  22.         public float YHeight { get; set; }
  23.         private IBrush StackBrush;
  24.         private Dictionary<HeroClass, string> classShorts;
  25.         public IFont ClassFont { get; set; }
  26.        
  27.         public bool IsGuardianAlive
  28.         {
  29.             get
  30.             {
  31.                 return riftQuest != null && (riftQuest.QuestStepId == 3 || riftQuest.QuestStepId == 16);
  32.             }
  33.         }
  34.        
  35.         private IQuest riftQuest
  36.         {
  37.             get
  38.             {
  39.                 return Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == 337492) ?? // rift
  40.                        Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == 382695);   // gr
  41.             }
  42.         }
  43.        
  44.         public SR_BaneOfTheStrickenPlugin()
  45.         {
  46.             Enabled = true;
  47.            
  48.             DrawClassOnIcons = false;
  49.         }
  50.  
  51.         public override void Load(IController hud)
  52.         {
  53.             base.Load(hud);
  54.            
  55.             StackCountDecorator = new TopLabelDecorator(Hud)
  56.             {
  57.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, false, false, 250, 0, 0, 0, true),
  58.                 HintFunc = () => "Bane Of The Stricken Count of trigger times(The monomeric BOSS is accurate)"
  59.             };
  60.            
  61.             StackCount = new int[4];
  62.             cooling = new bool[4];
  63.            
  64.             StackBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0);
  65.            
  66.             classShorts = new Dictionary<HeroClass, string>();
  67.             classShorts.Add(HeroClass.Barbarian, "Barb");
  68.             classShorts.Add(HeroClass.Monk, "Monk");
  69.             classShorts.Add(HeroClass.Necromancer, "Necro");
  70.             classShorts.Add(HeroClass.Wizard, "Wiz");
  71.             classShorts.Add(HeroClass.WitchDoctor, "WD");
  72.             classShorts.Add(HeroClass.Crusader, "Sader");
  73.             classShorts.Add(HeroClass.DemonHunter, "DH");  
  74.             ClassFont = Hud.Render.CreateFont("tahoma", 7, 230, 255, 255, 255, true, false, 255, 0, 0, 0, true);
  75.         }
  76.        
  77.         public void OnNewArea(bool newGame, ISnoArea area)
  78.         {
  79.             if (newGame)
  80.             {
  81.                 for (int i = 0; i < 4; i++)
  82.                 {
  83.                     StackCount[i] = 0;
  84.                 }
  85.             }
  86.         }
  87.        
  88.         public void DrawStackCount(IPlayer player)
  89.         {
  90.             if (!player.Powers.BuffIsActive(Hud.Sno.SnoPowers.BaneOfTheStrickenPrimary.Sno, 0)) return;
  91.             int count = Hud.Game.AliveMonsters.Count(m => m.SnoMonster.Priority == MonsterPriority.boss);
  92.             if (count == 0) return;
  93.            
  94.             var uiBar = Hud.Render.MonsterHpBarUiElement;
  95.             var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1;
  96.             if ((monster == null) || (uiBar == null) || (monster.SnoMonster.Priority != MonsterPriority.boss)) return;
  97.             int HitnRng = 1;
  98.             int _count = 0;
  99.  
  100.             _count = Hud.Game.AliveMonsters.Count(m => (player.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate)) <= 10);
  101.             if (_count < 1) _count = 1;
  102.             Random rng;
  103.             rng = new Random(Hud.Game.CurrentGameTick);
  104.             HitnRng = rng.Next(1, _count);
  105.            
  106.             var w = uiBar.Rectangle.Height * 2 * 2;
  107.             var h = uiBar.Rectangle.Height * 2;
  108.             var x = uiBar.Rectangle.Right + uiBar.Rectangle.Height * 5;
  109.             var y = uiBar.Rectangle.Y + uiBar.Rectangle.Height * 0.3f;
  110.            
  111.             var bgTex = Hud.Texture.GetTexture(3166997520);
  112.             var tex = Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.Unique_Gem_018_x1);
  113.             var rect = new RectangleF(uiBar.Rectangle.Right + uiBar.Rectangle.Height * 5f + xPos, uiBar.Rectangle.Y - uiBar.Rectangle.Height * 1.5f / 6, uiBar.Rectangle.Height * 1.5f, uiBar.Rectangle.Height * 1.5f);
  114.            
  115.             var index = player.PortraitIndex;
  116.             if (player.Powers.BuffIsActive(Hud.Sno.SnoPowers.BaneOfTheStrickenPrimary.Sno, 2))
  117.             {
  118.                 if (!cooling[index])
  119.                 {
  120.                     cooling[index] = true;
  121.                     if(HitnRng == 1) StackCount[index]++;
  122.                 }
  123.             }
  124.             else
  125.             {
  126.                 cooling[index] = false;
  127.             }
  128.            
  129.             StackCountDecorator.TextFunc = () => StackCount[index].ToString();
  130.             StackBrush.DrawRectangle(rect);
  131.             bgTex.Draw(rect.Left, rect.Top, rect.Width, rect.Height);
  132.             tex.Draw(rect.Left, rect.Top, rect.Width, rect.Height);
  133.             var layout = ClassFont.GetTextLayout(player.BattleTagAbovePortrait + "\n(" + classShorts[player.HeroClassDefinition.HeroClass] + ")");
  134.            
  135.             if (DrawClassOnIcons || Hud.Window.CursorInsideRect(rect.X, rect.Y, rect.Width, rect.Height))
  136.             {
  137.                 ClassFont.DrawText(layout, x - (layout.Metrics.Width * 0.1f) + xPos, y - h * 3);
  138.             }
  139.             StackCountDecorator.Paint(x + xPos, y, w, h, HorizontalAlign.Center);
  140.             xPos += rect.Width + h;
  141.         }
  142.  
  143.         public void PaintTopInGame(ClipState clipState)
  144.         {
  145.             if (clipState != ClipState.BeforeClip) return;
  146.            
  147.             if (!IsGuardianAlive)
  148.             {
  149.                 for (int i = 0; i < 4; i++)
  150.                 {
  151.                     StackCount[i] = 0;
  152.                 }
  153.                
  154.                 return;
  155.             }
  156.            
  157.             foreach (IPlayer player in Hud.Game.Players)
  158.             {
  159.                 DrawStackCount(player);
  160.             }
  161.            
  162.             xPos = 0;
  163.         }
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement