Advertisement
zjqyf

GLQ_BaneOfTheStrickenPlugin.cs

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