Advertisement
Styckz

VernTopMonsterHealthBarPlugin

Jul 16th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.29 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2.  
  3. namespace Turbo.Plugins.User
  4. {
  5.  
  6.     public class VernTopMonsterHealthBarPlugin : BasePlugin, IInGameTopPainter, ICustomizer
  7.     {
  8.  
  9.         public IFont MonsterHitpointsFont { get; set; }
  10.         public IFont MonsterEffectsFont { get; set; }
  11.  
  12.         public IBrush MonsterHitpointsBG { get; set; }
  13.         public IBrush MonsterEffectsBG { get; set; }
  14.  
  15.         public ITexture HPTexture1 { get; set; }
  16.         public ITexture HPTexture2 { get; set; }
  17.  
  18.         public int HPFontSize { get; set; }
  19.         public int EffectFontSize { get; set; }
  20.  
  21.         public VernTopMonsterHealthBarPlugin()
  22.         {
  23.             Enabled = true;
  24.             HPFontSize = 15;
  25.             EffectFontSize = 10;
  26.         }
  27.  
  28.         public override void Load(IController hud)
  29.         {
  30.             base.Load(hud);
  31.  
  32.             MonsterHitpointsFont = Hud.Render.CreateFont("tahoma", HPFontSize, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
  33.             MonsterHitpointsBG = Hud.Render.CreateBrush(255, 190, 10, 5, 0);
  34.             HPTexture1 = Hud.Texture.ButtonTextureGray;
  35.             HPTexture2 = Hud.Texture.BackgroundTextureOrange;
  36.             MonsterEffectsFont = Hud.Render.CreateFont("tahoma", EffectFontSize, 255, 40, 200, 40, true, false, 255, 0, 0, 0, true);
  37.             MonsterEffectsBG = Hud.Render.CreateBrush(196, 0, 0, 0, 0);
  38.  
  39.         }
  40.        
  41.         public void Customize()
  42.         {
  43.             Hud.TogglePlugin<TopMonsterHealthBarPlugin>(false);
  44.         }
  45.  
  46.         public void PaintTopInGame(ClipState clipState)
  47.         {
  48.             if (clipState != ClipState.BeforeClip) return;
  49.  
  50.             var uiBar = Hud.Render.MonsterHpBarUiElement;
  51.  
  52.             var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1;
  53.             if ((monster == null) || (uiBar == null)) return;
  54.  
  55.             var hpText = ValueToString(monster.CurHealth, ValueFormat.NormalNumberNoDecimal) + " / " + ValueToString(monster.MaxHealth, ValueFormat.NormalNumberNoDecimal);
  56.             hpText += " - " + ValueToString(monster.CurHealth / (monster.MaxHealth / 100f), ValueFormat.NormalNumberNoDecimal) + "%";
  57.             float HPPercent = (float) (monster.CurHealth / monster.MaxHealth);
  58.  
  59.             var textLayout = MonsterHitpointsFont.GetTextLayout(hpText);
  60.             HPTexture1.Draw(uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2 -4.5f, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2 - 3.5f, textLayout.Metrics.Width + 9, textLayout.Metrics.Height + 7, 1);
  61.             MonsterHitpointsBG.DrawRectangle(uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2, textLayout.Metrics.Width * HPPercent, textLayout.Metrics.Height);
  62.             HPTexture2.Draw(uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2 -4.5f, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2 - 3.5f, textLayout.Metrics.Width + 9, textLayout.Metrics.Height + 7, 0.65f);
  63.             MonsterHitpointsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2);
  64.  
  65.             string textCC = null;
  66.             if (monster.Frozen) textCC += (textCC == null ? "" : ", ") + "frozen";
  67.             if (monster.Chilled) textCC += (textCC == null ? "" : ", ") + "chill";
  68.             if (monster.Slow) textCC += (textCC == null ? "" : ", ") + "slow";
  69.             if (monster.Stunned) textCC += (textCC == null ? "" : ", ") + "stun";
  70.             if (monster.Invulnerable) textCC += (textCC == null ? "" : ", ") + "invulnerable";
  71.             if (monster.Blind) textCC += (textCC == null ? "" : ", ") + "blind";
  72.  
  73.             string textDebuff = null;
  74.             if (monster.Locust) textDebuff += (textDebuff == null ? "" : ", ") + "locust";
  75.             if (monster.Palmed) textDebuff += (textDebuff == null ? "" : ", ") + "palm";
  76.             if (monster.Haunted) textDebuff += (textDebuff == null ? "" : ", ") + "haunt";
  77.             if (monster.MarkedForDeath) textDebuff += (textDebuff == null ? "" : ", ") + "mark";
  78.             if (monster.Strongarmed) textDebuff += (textDebuff == null ? "" : ", ") + "strongarm";
  79.             if (monster.Phoenixed) textDebuff += (textDebuff == null ? "" : ", ") + "firebird";
  80.  
  81.             var text = textCC + (textCC != null && textDebuff != null ? " | " : "") + textDebuff;
  82.  
  83.             if (monster.DotDpsApplied > 0) text += (string.IsNullOrEmpty(text) ? "" : " | ") + "DOT: " + ValueToString(monster.DotDpsApplied, ValueFormat.LongNumber);
  84.             if (text != null)
  85.             {
  86.                 textLayout = MonsterEffectsFont.GetTextLayout(text);
  87.                 MonsterEffectsBG.DrawRectangle(uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height * 0.38f) + textLayout.Metrics.Height, textLayout.Metrics.Width, textLayout.Metrics.Height);
  88.                 MonsterEffectsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height * 0.38f) + textLayout.Metrics.Height);
  89.             }
  90.         }
  91.  
  92.     }
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement