Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.User
- {
- public class VernTopMonsterHealthBarPlugin : BasePlugin, IInGameTopPainter, ICustomizer
- {
- public IFont MonsterHitpointsFont { get; set; }
- public IFont MonsterEffectsFont { get; set; }
- public IBrush MonsterHitpointsBG { get; set; }
- public IBrush MonsterEffectsBG { get; set; }
- public ITexture HPTexture1 { get; set; }
- public ITexture HPTexture2 { get; set; }
- public int HPFontSize { get; set; }
- public int EffectFontSize { get; set; }
- public VernTopMonsterHealthBarPlugin()
- {
- Enabled = true;
- HPFontSize = 15;
- EffectFontSize = 10;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- MonsterHitpointsFont = Hud.Render.CreateFont("tahoma", HPFontSize, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
- MonsterHitpointsBG = Hud.Render.CreateBrush(255, 190, 10, 5, 0);
- HPTexture1 = Hud.Texture.ButtonTextureGray;
- HPTexture2 = Hud.Texture.BackgroundTextureOrange;
- MonsterEffectsFont = Hud.Render.CreateFont("tahoma", EffectFontSize, 255, 40, 200, 40, true, false, 255, 0, 0, 0, true);
- MonsterEffectsBG = Hud.Render.CreateBrush(196, 0, 0, 0, 0);
- }
- public void Customize()
- {
- Hud.TogglePlugin<TopMonsterHealthBarPlugin>(false);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- var uiBar = Hud.Render.MonsterHpBarUiElement;
- var monster = Hud.Game.SelectedMonster2 ?? Hud.Game.SelectedMonster1;
- if ((monster == null) || (uiBar == null)) return;
- var hpText = ValueToString(monster.CurHealth, ValueFormat.NormalNumberNoDecimal) + " / " + ValueToString(monster.MaxHealth, ValueFormat.NormalNumberNoDecimal);
- hpText += " - " + ValueToString(monster.CurHealth / (monster.MaxHealth / 100f), ValueFormat.NormalNumberNoDecimal) + "%";
- float HPPercent = (float) (monster.CurHealth / monster.MaxHealth);
- var textLayout = MonsterHitpointsFont.GetTextLayout(hpText);
- 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);
- 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);
- 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);
- MonsterHitpointsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height - textLayout.Metrics.Height) / 2);
- string textCC = null;
- if (monster.Frozen) textCC += (textCC == null ? "" : ", ") + "frozen";
- if (monster.Chilled) textCC += (textCC == null ? "" : ", ") + "chill";
- if (monster.Slow) textCC += (textCC == null ? "" : ", ") + "slow";
- if (monster.Stunned) textCC += (textCC == null ? "" : ", ") + "stun";
- if (monster.Invulnerable) textCC += (textCC == null ? "" : ", ") + "invulnerable";
- if (monster.Blind) textCC += (textCC == null ? "" : ", ") + "blind";
- string textDebuff = null;
- if (monster.Locust) textDebuff += (textDebuff == null ? "" : ", ") + "locust";
- if (monster.Palmed) textDebuff += (textDebuff == null ? "" : ", ") + "palm";
- if (monster.Haunted) textDebuff += (textDebuff == null ? "" : ", ") + "haunt";
- if (monster.MarkedForDeath) textDebuff += (textDebuff == null ? "" : ", ") + "mark";
- if (monster.Strongarmed) textDebuff += (textDebuff == null ? "" : ", ") + "strongarm";
- if (monster.Phoenixed) textDebuff += (textDebuff == null ? "" : ", ") + "firebird";
- var text = textCC + (textCC != null && textDebuff != null ? " | " : "") + textDebuff;
- if (monster.DotDpsApplied > 0) text += (string.IsNullOrEmpty(text) ? "" : " | ") + "DOT: " + ValueToString(monster.DotDpsApplied, ValueFormat.LongNumber);
- if (text != null)
- {
- textLayout = MonsterEffectsFont.GetTextLayout(text);
- 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);
- MonsterEffectsFont.DrawText(textLayout, uiBar.Rectangle.Left + (uiBar.Rectangle.Width - textLayout.Metrics.Width) / 2, uiBar.Rectangle.Top + (uiBar.Rectangle.Height * 0.38f) + textLayout.Metrics.Height);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement