Advertisement
HaKache

MonsterHealthBarPlugin

Sep 4th, 2019
667
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.25 KB | None | 0 0
  1. // Extended MonsterHealthBarPlugin
  2. // Adds Iceblink & Piranhas Tracker in Top Debuff List.
  3. // Adds an option to only see HP % on monsters (Disabled by default).
  4. // Adds Frailty Kill Treshold with Early Grave Support & Executioner Support on non-trash monsters.
  5. // Adds a Bottom Buff List including Commanded Skeletons, Firebird, "Touched by Inna" (Lesser Bindings), Single Out Passive, Crus Debuffs...
  6.  
  7. using System;
  8. using System.Globalization;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using Turbo.Plugins.Default;
  12.  
  13. namespace Turbo.Plugins.Extended.Monsters
  14. {
  15.     public class ExtendedMonsterHealthBarPlugin : BasePlugin, ICustomizer, IInGameTopPainter
  16.     {
  17.         public IFont MonsterHitpointsFont { get; set; }
  18.         public IFont MonsterEffectsFont { get; set; }
  19.         public IBrush FrailtyLineBrush { get; set; }
  20.         public IFont MonsterIllusionFont { get; set; }
  21.  
  22.         public bool EnableShortHP { get; set; }
  23.         public bool EnableCCDebuff { get; set; }
  24.         public bool EnableBottomBuffBar { get; set; }
  25.         public bool EnableFrailty { get; set; }
  26.  
  27.         private readonly int[] _skillOrder = { 2, 3, 4, 5, 0, 1 };
  28.  
  29.         public ExtendedMonsterHealthBarPlugin()
  30.         {
  31.             Enabled = true;
  32.  
  33.         EnableShortHP = false;
  34.         EnableCCDebuff = true;
  35.         EnableBottomBuffBar = true;
  36.         EnableFrailty = true;
  37.         }
  38.  
  39.         public void Customize()
  40.         {
  41.         // Disable Default Plugin
  42.             Hud.GetPlugin<TopMonsterHealthBarPlugin>().Enabled = false;
  43.     }
  44.  
  45.         public override void Load(IController hud)
  46.         {
  47.             base.Load(hud);
  48.  
  49.             MonsterHitpointsFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, true, false, true);
  50.             MonsterIllusionFont = Hud.Render.CreateFont("tahoma", 6, 255, 100, 230, 152, true, false, true);
  51.             MonsterEffectsFont = Hud.Render.CreateFont("tahoma", 6, 255, 40, 200, 40, true, false, 128, 0, 0, 0, true);
  52.             FrailtyLineBrush = Hud.Render.CreateBrush(255, 255, 190, 70, 1.5f);
  53.         }
  54.  
  55.         public void PaintTopInGame(ClipState clipState)
  56.         {
  57.             if (clipState != ClipState.BeforeClip) return;
  58.  
  59.             var uiBar = Hud.Render.MonsterHpBarUiElement;
  60.             var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1;
  61.        
  62.             if ((monster == null) || (uiBar == null)) return;
  63.  
  64.             var hpText = ValueToString(monster.CurHealth, ValueFormat.LongNumber) + " / " + ValueToString(monster.MaxHealth, ValueFormat.LongNumber);
  65.             hpText += " - " + ValueToString(monster.CurHealth / (monster.MaxHealth / 100.0f), ValueFormat.LongNumber) + "%";
  66.  
  67.             var hpTextShort = ValueToString(monster.CurHealth / (monster.MaxHealth / 100.0f), ValueFormat.LongNumber) + "%";
  68.  
  69.         var MonsterHPFont = MonsterHitpointsFont;
  70.         if (monster.SummonerAcdDynamicId != 0 && monster.IsElite) MonsterHPFont = MonsterIllusionFont;
  71.  
  72.             var textLayout = MonsterHPFont.GetTextLayout(hpText);
  73.             if (EnableShortHP) textLayout = MonsterHPFont.GetTextLayout(hpTextShort);
  74.             MonsterHPFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2);
  75.  
  76.  
  77.     if (EnableCCDebuff) {
  78.             string textCC = null;
  79.             if (monster.Frozen) textCC += (textCC == null ? "" : ", ") + "frozen";
  80.             if (monster.Chilled) textCC += (textCC == null ? "" : ", ") + "chill";
  81.             if (monster.Slow) textCC += (textCC == null ? "" : ", ") + "slow";
  82.             if (monster.Stunned) textCC += (textCC == null ? "" : ", ") + "stun";
  83.             if (monster.Blind) textCC += (textCC == null ? "" : ", ") + "blind";
  84.             if (monster.Invulnerable) textCC += (textCC == null ? "" : ", ") + "invulnerable";
  85.         // if (monster.GetAttributeValue(Hud.Sno.Attributes.Uninterruptible, uint.MaxValue) == 1) textCC += (textCC == null ? "" : ", ") + "uninterruptible";
  86.  
  87.             string textDebuff = null;
  88.             if (monster.Palmed) textDebuff += (textDebuff == null ? "" : ", ") + "palm";
  89.             if (monster.Locust) textDebuff += (textDebuff == null ? "" : ", ") + "locust";
  90.             if (monster.Haunted) textDebuff += (textDebuff == null ? "" : ", ") + "haunt";
  91.         if ((monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, 347265) == 1) || (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_A, 347265) == 1) || (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_3_Visual_Effect_B, 347265) == 1) || (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_C, 347265) == 1) || (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_5_Visual_Effect_D, 347265) == 1) || (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_6_Visual_Effect_E, 347265) == 1)) textDebuff += (textDebuff == null ? "" : ", ") + "piranhas";
  92.             if (monster.MarkedForDeath) textDebuff += (textDebuff == null ? "" : ", ") + "mark";
  93.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, 428354) == 1) textDebuff += (textDebuff == null ? "" : ", ") + "iceblink";
  94.             if (monster.Strongarmed) textDebuff += (textDebuff == null ? "" : ", ") + "strongarm";
  95.             // if (monster.Phoenixed) textDebuff += (textDebuff == null ? "" : ", ") + "firebird";
  96.  
  97.             var text = textCC + (textCC != null && textDebuff != null ? " | " : "") + textDebuff;
  98.  
  99.             if (monster.DotDpsApplied > 0) text += (string.IsNullOrEmpty(text) ? "" : " | ") + "DoT: " + ValueToString(monster.DotDpsApplied, ValueFormat.LongNumber);
  100.  
  101.             if (text != null)
  102.             {
  103.                 textLayout = MonsterEffectsFont.GetTextLayout(text);
  104.                 MonsterEffectsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top - (uiBar.Rectangle.Height * 0.38f) - textLayout.Metrics.Height);
  105.             }
  106.     }
  107.  
  108.     // Frailty Kill Treshold (With Early Grave & Executioner Support)
  109.     if (EnableFrailty) {
  110.  
  111.     var earlygrave = false;
  112.     var necroIG = Hud.Game.Players.FirstOrDefault(p => (p.HasValidActor && p.HeroClassDefinition.HeroClass == HeroClass.Necromancer));
  113.  
  114.     if (necroIG != null) {
  115.         foreach (var i in _skillOrder)
  116.         {
  117.         var skill = necroIG.Powers.SkillSlots[i];
  118.         if (skill == null) continue;
  119.         if (skill.SnoPower.Sno == 460870 && skill.Rune == 0) { // Early Grave
  120.  
  121.     if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471845) == 1 && monster.Rarity != ActorRarity.Normal)
  122.         { FrailtyLineBrush.DrawLine(uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.18f), uiBar.Rectangle.Top, uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.18f), uiBar.Rectangle.Bottom, 0);
  123.           earlygrave = true; continue;  }
  124.             }
  125.         }
  126.         }
  127.  
  128.     if (Hud.Game.Players.FirstOrDefault(p => (p.HasValidActor && p.Powers.BuffIsActive(483516, 0))) != null) // The Executioner
  129.                 {
  130.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471845) != 1 && monster.Rarity != ActorRarity.Normal && !earlygrave)
  131.         { FrailtyLineBrush.DrawLine(uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.10f), uiBar.Rectangle.Top, uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.10f), uiBar.Rectangle.Bottom, 0); }
  132.         }
  133.  
  134.     if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471845) == 1 && monster.Rarity != ActorRarity.Normal && !earlygrave)
  135.         { FrailtyLineBrush.DrawLine(uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.15f), uiBar.Rectangle.Top, uiBar.Rectangle.Left + (uiBar.Rectangle.Width * 0.15f), uiBar.Rectangle.Bottom, 0); }
  136.  
  137.     } // End Frailty Treshold
  138.  
  139.     // Bottom BuffBar
  140.     if (EnableBottomBuffBar) {
  141.             string otherBuff = null;
  142.  
  143.         // Touched by Inna (Lesser Bindings Bracers)
  144.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, 449222) == 1)
  145.         otherBuff += (otherBuff == null ? "" : " - ") + "Touch of Inna";
  146.  
  147.         // Judgment + Divine Verdict
  148.         // Debilitate Judgment Debuff - Power_Buff_2_Visual_Effect_E, 267600
  149.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_None, 267600) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_A, 267600) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_B, 267600) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_C, 267600) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_D, 267600) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_E, 267600) == 1)
  150.         otherBuff += (otherBuff == null ? "" : " - ") + "Judgment";
  151.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_A, 268530) == 1)
  152.         otherBuff += (otherBuff == null ? "" : " - ") + "Divine Verdict";
  153.  
  154.         // Firebird Debuff
  155.         if (monster.Phoenixed)
  156.         otherBuff += (otherBuff == null ? "" : " - ") + "Firebird";
  157.  
  158.         // Single Out Passive
  159.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, 338859) == 1)
  160.         otherBuff += (otherBuff == null ? "" : " - ") + "Single Out";
  161.  
  162.         // Commanded Skeletons
  163.         if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_D, 453801) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_A, 453801) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_B, 453801) == 1  || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_E, 453801) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_6_Visual_Effect_C, 453801) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_C, 453801) == 1 || monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_4_Visual_Effect_None, 453801) == 1)
  164.         otherBuff += (otherBuff == null ? "" : " - ") + "Command Skeletons";
  165.  
  166.             if (otherBuff != null)
  167.             {
  168.                 var textotherBuff = MonsterEffectsFont.GetTextLayout(otherBuff);
  169.         if (monster.Rarity == ActorRarity.Boss) {
  170.                 MonsterEffectsFont.DrawText(textotherBuff, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textotherBuff.Metrics.Width) / 2, uiBar.Rectangle.Bottom + uiBar.Rectangle.Height / 1.9f);
  171.         } else {
  172.                 MonsterEffectsFont.DrawText(textotherBuff, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textotherBuff.Metrics.Width) / 2, uiBar.Rectangle.Bottom + uiBar.Rectangle.Height / 3.5f);
  173.             }
  174.         }
  175.         }
  176.  
  177. // End
  178.  
  179.         }
  180.     }
  181. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement