Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // CurseMeter.cs "$Revision: 2567 $" "$Date: 2019-08-29 09:15:36 +0300 (to, 29 elo 2019) $"
- // https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-community-plugins/797381-cursemeter.html
- // CurseMeter - https://pastebin.com/sNdA8Rn6
- // Modifiers - https://pastebin.com/drejrEcm
- // Runes - https://pastebin.com/vSfQm5x6
- using System;
- using System.Linq;
- using SharpDX;
- using Turbo.Plugins.Default;
- using Turbo.Plugins.User;
- namespace Turbo.Plugins.JarJar.DefaultUI
- {
- public class CurseMeter : BasePlugin, IInGameTopPainter
- {
- private const int FRAILTY = 0;
- private const int DECREPIFY = 1;
- private const int LEECH = 2;
- private const int CURSE_COUNT = 3;
- public float offsetX { get; set; } = 0.60f; // Percent-X pos
- public float offsetY { get; set; } = 0.025f; // Percent-Y pos
- public float BarH { get; set; } = 16.0f; // Bar height
- public float BarW { get; set; } = 192.0f; // Bar width
- public bool ShowOnlyInGr { get; set; } = false;
- public double CurseDetectionRange { get; set; } = 50f; // Set to -1f to query all monsters
- public string[] TextLabel { get; set; } = new string[3]
- {
- "Frailty {0}/{1} {2:0}% ",
- "Decrepify {0}/{1} {2:0}% ",
- "Leech {0}/{1} {2:0}% ",
- };
- public IFont[] TextFont { get; set; } = new IFont[CURSE_COUNT];
- public IBrush[] BarBrush { get; set; } = new IBrush[CURSE_COUNT];
- public IBrush BorderBrush { get; set; }
- private readonly ISnoPower[] cursePower = new ISnoPower[CURSE_COUNT];
- private readonly uint[] curseModifier = new uint[CURSE_COUNT]
- {
- Modifiers.Frailty,
- Modifiers.Decrepify,
- Modifiers.Leech,
- };
- private readonly int[] curseCount = new int[CURSE_COUNT];
- private float barOffset = 0f;
- public CurseMeter() { Enabled = true; Order = 500; } // Overlaps with WorkToDoEstimate!
- public override void Load(IController hud)
- {
- base.Load(hud);
- var curseColor = new Color[CURSE_COUNT];
- curseColor[FRAILTY] = Color.Aquamarine;
- curseColor[DECREPIFY] = Color.CadetBlue;
- curseColor[LEECH] = Color.HotPink;
- for (var i = 0; i < curseColor.Length; ++i)
- {
- var textColor = curseColor[i];
- TextFont[i] = Hud.Render.CreateFont("tahoma", 8f, 255, textColor.R, textColor.G, textColor.B, true, false, 220, 32, 32, 32, true);
- BarBrush[i] = Hud.Render.CreateBrush(255, textColor.R, textColor.G, textColor.B, 0);
- }
- var borderColor = Color.Red;
- BorderBrush = hud.Render.CreateBrush(255, borderColor.R, borderColor.G, borderColor.B, -1);
- var p = Hud.Sno.SnoPowers;
- cursePower[FRAILTY] = p.Necromancer_Frailty;
- cursePower[DECREPIFY] = p.Necromancer_Decrepify;
- cursePower[LEECH] = p.Necromancer_Leech;
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip)
- return;
- if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map))
- return;
- if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer)
- return;
- if (ShowOnlyInGr)
- {
- if (!(Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift || Hud.Game.SpecialArea == SpecialArea.ChallengeRift || Hud.Game.RiftPercentage > 0.0))
- return;
- }
- var monsterCount = 0;
- Array.Clear(curseCount, 0, curseCount.Length);
- var monsters = CurseDetectionRange > 0d
- ? Hud.Game.AliveMonsters.Where(x => x.NormalizedXyDistanceToMe < CurseDetectionRange)
- : Hud.Game.AliveMonsters;
- foreach (var monster in monsters)
- {
- monsterCount += 1;
- for (var i = 0; i < CURSE_COUNT; ++i)
- {
- if (monster.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, curseModifier[i]) != -1d)
- {
- curseCount[i] += 1;
- }
- }
- }
- var player = Hud.Game.Me;
- var textX = Hud.Window.Size.Width * offsetX;
- var posY = Hud.Window.Size.Height * offsetY;
- var grimScythe = player.Powers.GetUsedSkill(Hud.Sno.SnoPowers.Necromancer_GrimScythe);
- var cursedScythe = grimScythe?.Rune == Runes.Necromancer.GrimScythe.CursedScythe;
- for (var i = 0; i < CURSE_COUNT; ++i)
- {
- if (cursedScythe || player.Powers.GetUsedSkill(cursePower[i]) != null)
- {
- var percent = monsterCount == 0 ? 0f : (float)curseCount[i] / monsterCount;
- var text = string.Format(TextLabel[i], curseCount[i], monsterCount, percent * 100f);
- var layout = TextFont[i].GetTextLayout(text);
- TextFont[i].DrawText(layout, textX, posY);
- if (percent > 0f)
- {
- if (barOffset < layout.Metrics.Width)
- {
- barOffset = layout.Metrics.Width;
- }
- var x = textX + barOffset;
- BarBrush[i].DrawRectangle(x, posY, BarW * percent, BarH);
- BorderBrush.DrawRectangle(x, posY, BarW, BarH);
- }
- posY += layout.Metrics.Height;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement