Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. using System.Linq;
  2. using Turbo.Plugins.Default;
  3. using Turbo.Plugins.Jack;
  4.  
  5. namespace Turbo.Plugins.DM.Rathma
  6. {
  7. public class RathmaPlugin : BasePlugin, IInGameTopPainter, ICustomizer
  8. {
  9. public bool ShowWarnings { get; set; }
  10. public bool ShowInTown { get; set; }
  11. public bool ShowZeiCircle { get; set; }
  12. public bool ShowLandOfTheDeadCD { get; set; }
  13. public bool ShowLandOfTheDeadRemain { get; set; }
  14. public float WarningYPos { get; set; }
  15. public float WarningYPosIncr { get; set; }
  16. public float CDandRemainYPos { get; set; }
  17. public float essenceLevel { get; set; }
  18.  
  19. public GroundCircleDecorator ZeiRanceIndicator { get; set; }
  20. public TopLabelDecorator landofdeadCooldownLabel { get; set; }
  21. public TopLabelDecorator landofdeadRemainingLabel { get; set; }
  22.  
  23. public IFont WarningFont { get; set; }
  24. public IFont landofthedeadCDFont { get; set; }
  25. public IFont landofthedeadRemainFont { get; set; }
  26. public IFont landofthedeadSoonFont { get; set; }
  27.  
  28. private IPlayerSkill mageSkill;
  29. private IPlayerSkill simulacrumSkill;
  30. private IPlayerSkill boneArmorSkill;
  31. private IPlayerSkill landofthedeadSkill;
  32.  
  33. private float hudWidth { get { return Hud.Window.Size.Width; } }
  34. private float hudHeight { get { return Hud.Window.Size.Height; } }
  35.  
  36. private float _lWidth, _lHeight, _tick;
  37. private bool _timerRunning = false;
  38.  
  39. public RathmaPlugin()
  40. {
  41. Enabled = true;
  42. }
  43.  
  44. public void Customize()
  45. {
  46. Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
  47. {
  48. plugin.BuffPainter.ShowTimeLeftNumbers = true;
  49. plugin.RuleCalculator.Rules.Add(new BuffRule(465839) { IconIndex = 1, MinimumIconCount = 0, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Land Of The Dead
  50. plugin.RuleCalculator.Rules.Add(new BuffRule(465350) { IconIndex = 1, MinimumIconCount = 1, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Simulacrum
  51. });
  52. }
  53.  
  54. public override void Load(IController hud)
  55. {
  56. base.Load(hud);
  57.  
  58. // Public vars
  59. ShowWarnings = true;
  60. ShowInTown = true;
  61. ShowZeiCircle = true;
  62. ShowLandOfTheDeadCD = true;
  63. ShowLandOfTheDeadRemain = true;
  64. WarningYPos = 0.27f;
  65. WarningYPosIncr = 0.022f; // Distance between warnings
  66. CDandRemainYPos = 0.5f;
  67. essenceLevel = 0.95f;
  68.  
  69. WarningFont = Hud.Render.CreateFont("tahoma", 13f, 200, 255, 0, 0, false, false, true);
  70. landofthedeadCDFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, true);
  71. landofthedeadRemainFont = Hud.Render.CreateFont("tahoma", 10f, 255, 80, 140, 210, false, false, true);
  72. landofthedeadSoonFont = Hud.Render.CreateFont("tahoma", 14.5f, 255, 255, 0, 0, false, false, true);
  73.  
  74. ZeiRanceIndicator = new GroundCircleDecorator(Hud)
  75. {
  76. Brush = Hud.Render.CreateBrush(150, 14, 200, 245, 1.5f),
  77. Radius = 50f
  78. };
  79. landofdeadCooldownLabel = new TopLabelDecorator(Hud)
  80. {
  81. TextFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
  82. TextFunc = () => landofdeadCooldown(),
  83. };
  84.  
  85. // Private vars
  86. _lWidth = 80;
  87. _lHeight = 15;
  88.  
  89. }
  90.  
  91. public void PaintTopInGame(ClipState clipState)
  92. {
  93. if (clipState != ClipState.BeforeClip) return;
  94.  
  95. if (Hud.Game.IsInGame && Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.Necromancer && !(Hud.Game.Me.IsInTown && !ShowInTown))
  96. {
  97. var me = Hud.Game.Me;
  98. UpdateSkills(me);
  99.  
  100. //If zei socketed, draw zei circle
  101. if (me.Powers.BuffIsActive(403468, 0) && ShowZeiCircle)
  102. ZeiRanceIndicator.Paint(me, me.FloorCoordinate, null);
  103.  
  104. //Draw missing buff warnings
  105. if (ShowWarnings && !me.IsDead)
  106. DrawWarnings(me);
  107.  
  108. //Draw Land Of The Dead cooldown
  109. if (landofthedeadSkill != null && ShowLandOfTheDeadCD && !me.Powers.BuffIsActive(465839))
  110. landofdeadCooldownLabel.Paint(hudWidth * 0.5f - _lWidth / 2, hudHeight * (CDandRemainYPos+0.015f), _lWidth, _lHeight, HorizontalAlign.Center);
  111.  
  112. //Draw Land Of The Dead time remaining
  113. if (landofthedeadSkill != null && ShowLandOfTheDeadRemain)
  114. landofdeadRemaining(me);
  115. }
  116. }
  117.  
  118. public string landofdeadCooldown()
  119. {
  120. string s = "";
  121. if (landofthedeadSkill.CooldownFinishTick > Hud.Game.CurrentGameTick)
  122. {
  123. var c = (landofthedeadSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
  124. s = string.Format("\u267F {0:N1} \u267F", c);
  125. }
  126. return s;
  127. }
  128.  
  129. private void landofdeadRemaining(IPlayer me)
  130. {
  131. if (me.Powers.BuffIsActive(465839))
  132. {
  133. if (!_timerRunning)
  134. _tick = Hud.Game.CurrentGameTick;
  135. _timerRunning = true;
  136.  
  137. var r = 10f - ((Hud.Game.CurrentGameTick - _tick) / 60.0d);
  138. if (r > 3f)
  139. {
  140. var layout = landofthedeadRemainFont.GetTextLayout(string.Format("{0:N1}", r));
  141. landofthedeadRemainFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (CDandRemainYPos + 0.015f));
  142. }
  143. else
  144. {
  145. string str = string.Format("{0:N1}", r);
  146. if (r <= 3 && r > 2) str = string.Format("\u231A {0:N1} \u231A", r);
  147. if (r <= 2 && r > 1) str = string.Format("\u231B {0:N1} \u231B", r);
  148. if (r <= 1) str = string.Format("\u25B6 {0:N1} \u25C0", r);
  149. var layout = landofthedeadSoonFont.GetTextLayout(str);
  150. landofthedeadSoonFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (CDandRemainYPos + 0.005f));
  151. }
  152. }
  153. else _timerRunning = false;
  154. }
  155.  
  156. private void DrawWarnings(IPlayer me)
  157. {
  158. if (mageSkill != null)
  159. {
  160. var layout = WarningFont.GetTextLayout("\u22EF\u2995 Skeletal Mage \u2996\u22EF");
  161. if (me.Stats.ResourceCurPri > (me.Stats.ResourceMaxPri * essenceLevel))
  162. WarningFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * WarningYPos);
  163. }
  164. if (boneArmorSkill != null)
  165. {
  166. var layout = WarningFont.GetTextLayout("\u22EF\u2995 Bone Armor \u2996\u22EF");
  167. if (!me.Powers.BuffIsActive(466857, 0))
  168. WarningFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (WarningYPos+WarningYPosIncr));
  169. }
  170. }
  171.  
  172. private void UpdateSkills(IPlayer me)
  173. {
  174. me.Powers.UsedSkills.ForEach(skill =>
  175. {
  176. if (skill.SnoPower.Sno == 462089) mageSkill = skill;
  177. if (skill.SnoPower.Sno == 466857) boneArmorSkill = skill;
  178. if (skill.SnoPower.Sno == 465839) landofthedeadSkill = skill;
  179. });
  180. }
  181. }
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement