Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Mod of the plugin HealthBarOnElitePlugin of BM. The original can be found:
- // https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-community-plugins/612943-english-bm-healthbaroneliteplugin.html
- using Turbo.Plugins.Default;
- using System.Linq;
- namespace Turbo.Plugins.BM
- {
- public class HealthBarOnElitePlugin_Mod : BasePlugin, IInGameTopPainter, ICustomizer
- {
- private IBrush DefaultBrush { get; set; } = null;
- private IBrush BorderBrush { get; set; } = null;
- private IBrush BackGroundBrush { get; set; }
- private IBrush InvulnerableBrush { get; set; }
- private IBrush ChampionBrush { get; set; }
- private IBrush RareBrush { get; set; }
- private IBrush JuggerBrush { get; set; }
- private IBrush BossBrush { get; set; }
- private IBrush GrayBrush { get; set; }
- private IBrush GrayBorder { get; set; }
- private IBrush NormalBorderBrush { get; set; }
- private IBrush ShieldBorderBrush { get; set; }
- private IBrush InvisibleBorderBrush { get; set; }
- private IFont TextFont { get; set; }
- private IFont TextFontHaunt { get; set; }
- private IFont TextFontLocust { get; set; }
- private float WidthR { get; set; } = 0;
- private float HeightR { get; set; } = 0;
- public float SizeFont { get; set; }
- public float YOffset { get; set; } = 0f;
- public float YOffsetExtraBoss { get; set; } = 0f;
- public HealthBarOnElitePlugin_Mod()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30005;
- SizeFont = 9.0f;
- BackGroundBrush = Hud.Render.CreateBrush(255, 100, 100, 100, 0);
- InvulnerableBrush = Hud.Render.CreateBrush(200, 0, 0, 0, 0);
- ChampionBrush = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
- RareBrush = Hud.Render.CreateBrush(255, 255, 148, 20, 0);
- JuggerBrush = Hud.Render.CreateBrush(255, 255, 50, 0, 0);
- BossBrush = Hud.Render.CreateBrush(255, 150, 50, 255, 0);
- GrayBrush = Hud.Render.CreateBrush(235, 120, 120, 120, 0);
- GrayBorder = Hud.Render.CreateBrush(220, 50, 50, 50, -1);
- NormalBorderBrush = Hud.Render.CreateBrush(255, 0, 100, 0, -1);
- ShieldBorderBrush = Hud.Render.CreateBrush(255, 255, 255, 0, -1);
- InvisibleBorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1);
- }
- public void Customize()
- {
- TextFont = Hud.Render.CreateFont("tahoma", SizeFont, 255, 255, 255, 255, false, false, true);
- TextFontLocust = Hud.Render.CreateFont("tahoma", SizeFont + 1f, 255, 0, 200, 0, true, false, 255, 0, 0, 0, true);
- TextFontHaunt = Hud.Render.CreateFont("tahoma", SizeFont + 1f, 255, 255, 0, 0, true, false, 255, 0, 0, 0, true);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- //var monsters = Hud.Game.AliveMonsters.Where(m => (m.Rarity == ActorRarity.Champion || m.Rarity == ActorRarity.Rare || m.Rarity == ActorRarity.Boss || m.Rarity == ActorRarity.Unique) && (m.SummonerAcdDynamicId == 0));
- var monsters = Hud.Game.AliveMonsters.Where(m => (m.Rarity != ActorRarity.Normal && m.Rarity != ActorRarity.Hireling) && (m.SummonerAcdDynamicId == 0));
- if (monsters.Any())
- {
- float percent = 100; string hptext = string.Empty; WidthR = TextFont.GetTextLayout("100]").Metrics.Width; HeightR = TextFont.GetTextLayout("100]").Metrics.Height * 0.90f;
- foreach(var monster in monsters)
- {
- percent = (float) (monster.CurHealth/monster.MaxHealth);
- if ((percent < 0) || (percent > 100)) { percent = 1; hptext = "bug"; }
- else { hptext = ValueToString(percent * 100 , ValueFormat.NormalNumberNoDecimal); }
- var x = monster.FloorCoordinate.ToScreenCoordinate().X - WidthR/2; var y = monster.FloorCoordinate.ToScreenCoordinate().Y - HeightR/2 + YOffset;
- if (monster.Rarity != ActorRarity.RareMinion)
- {
- BorderBrush = NormalBorderBrush;
- if (monster.Invulnerable)
- {
- if (monster.Invisible) { BorderBrush = InvisibleBorderBrush; }
- else if ( monster.Attackable && monster.AffixSnoList.Any(a => a.Affix == MonsterAffix.Shielding) ) { BorderBrush = ShieldBorderBrush; }
- InvulnerableBrush.DrawRectangle(x, y, WidthR, HeightR);
- }
- else
- {
- if (monster.Rarity == ActorRarity.Champion) { DefaultBrush = ChampionBrush; }
- else if (monster.Rarity == ActorRarity.Rare) { DefaultBrush = (monster.AffixSnoList.Any(a => a.Affix == MonsterAffix.Juggernaut))? JuggerBrush : RareBrush; }
- else { DefaultBrush = BossBrush; if (monster.Rarity == ActorRarity.Boss) y+= YOffsetExtraBoss; }
- BackGroundBrush.DrawRectangle(x, y, WidthR, HeightR);
- DefaultBrush.DrawRectangle(x, y, percent * WidthR, HeightR);
- }
- BorderBrush.DrawRectangle(x - 1, y - 1, WidthR + 2, HeightR + 2);
- }
- else
- {
- GrayBrush.DrawEllipse(monster.FloorCoordinate.ToScreenCoordinate().X, monster.FloorCoordinate.ToScreenCoordinate().Y + YOffset, WidthR/2f , HeightR/2f );
- GrayBorder.DrawEllipse(monster.FloorCoordinate.ToScreenCoordinate().X, monster.FloorCoordinate.ToScreenCoordinate().Y + YOffset, WidthR/2f + 1 , HeightR/2f + 1);
- }
- var layout = TextFont.GetTextLayout(hptext);
- TextFont.DrawText(layout, x + (WidthR - layout.Metrics.Width)/2f, y + (HeightR - layout.Metrics.Height)/2f);
- if (monster.Locust)
- {
- layout = TextFontLocust.GetTextLayout("L");
- TextFontLocust.DrawText(layout, x - layout.Metrics.Width - 5 , y + (HeightR - layout.Metrics.Height)/2f);
- }
- if (monster.Haunted)
- {
- layout = TextFontHaunt.GetTextLayout("H");
- TextFontHaunt.DrawText(layout, x + WidthR + 4, y + (HeightR - layout.Metrics.Height)/2f);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement