Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MyMonsterColoring.cs "$Revision: 1531 $" "$Date: 2019-03-29 16:54:25 +0200 (pe, 29 maalis 2019) $"
- using SharpDX;
- using SharpDX.Direct2D1;
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.User
- {
- // See: https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-community-plugins/782208-v9-minimal-plugin-theme.html
- // https://pastebin.com/MFRAU43k
- public class MyMonsterColoring : BasePlugin, ICustomizer, IInGameTopPainter, IInGameWorldPainter
- {
- public float TrashBreakpoint { get; set; } = 2.50f; // 33% of rift orb value breakpoint.
- public float KillBreakpoint { get; set; } = 3.75f; // 50% of rift orb value breakpoint.
- // Monster decorators by type.
- public WorldDecoratorCollection EliteDecorator { get; set; } // Supports GroundLabelDecorator, other decorators do not!
- public WorldDecoratorCollection EliteMinionDecorator { get; set; } // Supports GroundLabelDecorator, other decorators do not!
- public WorldDecoratorCollection BlueDecorator { get; set; }
- public WorldDecoratorCollection GreenDecorator { get; set; }
- public WorldDecoratorCollection GreyDecorator { get; set; }
- // Special decorators.
- public WorldDecoratorCollection BossDecorator { get; set; } // Draws 50 yard circle around boss.
- public WorldDecoratorCollection PlayerDecorator { get; set; } // Draws player hitbox to show where player is during boss/elite fights.
- public WorldDecoratorCollection KillDecorator { get; set; } // All monsters that award rift progression when RiftProgressionEnabled
- public bool IsRiftProgressionEnabled { get; set; } = true; // Show rift progression percent (label).
- public float RiftProgressionLimit { get; set; } = 1.15f; // Rift pprogression percent limit to include in calculations.
- public double RiftProgressionRange { get; set; } = 50; // Calculate rift pprogression from monsters inside this range.
- public bool ShowKillDensityOnMinimap { get; set; } = true; // Show rift progression density on minimap for trash mobs to kill them.
- public float KillDensityLimit { get; set; } = 1.15f; // Rift pprogression percent limit to include
- public IFont ProgressionLabelBright { get; set; } // Rift pprogression labels and configuration below.
- public IFont ProgressionLabelDim { get; set; }
- public IBrush BackgroundBrush { get; set; } // BackgroundBrush for the label is it overlaps with other data.
- public bool ProgressionLabelRightAligned { get; set; } = false; // Right-align text relative to X coordinate.
- public bool ProgressionLabelOnMinimap { get; set; } = false; // Postion label relative to minimap X coordinate.
- public float XRatioTop { get; set; } = 0.250f; // Label X offset relative to screen (or minimap).
- public float YRatioTop { get; set; } = 0.025f; // Label Y offset relative to screen (always).
- public int RiftProgressionCooldown { get; set; } = 60; // Ticks until KillDecorator disappers to smooth KillDecorator work.
- public float BossCirleRadius { get; set; } = 50f;
- float labelX => Hud.Window.Size.Width * XRatioTop; // Default label position calculation functions.
- float labelY => Hud.Window.Size.Height * YRatioTop;
- public MyMonsterColoring() { Enabled = true; Order = 500; }
- public override void Load(IController hud)
- {
- base.Load(hud);
- var textColor = Color.Lime; // Bright green with black tranparent shadow.
- ProgressionLabelBright = Hud.Render.CreateFont("tahoma", 10, textColor.A, textColor.R, textColor.G, textColor.B, true, false, 160, 0, 0, 0, true);
- textColor = Color.Green; // Dim green with black tranparent shadow.
- ProgressionLabelDim = Hud.Render.CreateFont("tahoma", 10, textColor.A, textColor.R, textColor.G, textColor.B, true, false, 160, 0, 0, 0, true);
- var ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1);
- BossDecorator = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 192, 96, 0, 1.5f), // Dim orange circle
- Radius = BossCirleRadius,
- }
- );
- PlayerDecorator = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 153, 204, 255, 3.5f, DashStyle.DashDot), // Light blue dash-dotted circle
- Radius = -1,
- }
- );
- KillDecorator = new WorldDecoratorCollection( // This is fancy!
- new MapShapeDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(60, 102, 204, 255, 0), // Background blueish
- ShadowBrush = ShadowBrush,
- ShapePainter = new CircleShapePainter(Hud),
- Radius = 4,
- },
- new MapShapeDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(90, 0, 102, 255, 1.0f), // With border
- ShadowBrush = ShadowBrush,
- ShapePainter = new CircleShapePainter(Hud),
- Radius = 5,
- }
- );
- EliteDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, 255, 200, 100, 2), // Dim yellow circle
- ShadowBrush = ShadowBrush,
- Radius = 4f,
- },
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 255, 0, 255, 2f), // Violet circle for monster hitbox
- Radius = -1, // Show monster hitbox
- }
- );
- EliteMinionDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, 255, 255, 255, 2), // White circle
- ShadowBrush = ShadowBrush,
- Radius = 4f,
- },
- new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 255, 0, 255, 2f, DashStyle.Dash), // Violet dashed circle for monster hitbox
- Radius = -1, // Show monster hitbox
- }
- );
- BlueDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, 60, 128, 255, 3), // Dodger blue circle
- ShadowBrush = ShadowBrush,
- Radius = 3.5f,
- }
- );
- GreenDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- ShapePainter = new CircleShapePainter(Hud),
- Brush = Hud.Render.CreateBrush(255, 128, 255, 0, 3), // Green circle
- ShadowBrush = ShadowBrush,
- Radius = 3f,
- }
- );
- GreyDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(128, 217, 217, 217, 0), // Light grey dot for normal trash mobs
- ShadowBrush = ShadowBrush,
- ShapePainter = new CircleShapePainter(Hud),
- Radius = 2.5f,
- }
- );
- }
- public void Customize()
- {
- Hud.RunOnPlugin<MonsterRiftProgressionColoringPlugin>(plugin =>
- {
- plugin.Enabled = false;
- });
- Hud.RunOnPlugin<StandardMonsterPlugin>(plugin =>
- {
- plugin.Enabled = false;
- });
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (Hud.Game.IsInTown) return;
- if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map)) return;
- if (IsRiftProgressionEnabled && Hud.Game.CurrentQuestProgress < Hud.Game.MaxQuestProgress)
- {
- var text = string.Format("Progress {0:0.0}%", progressionPercent);
- if (ProgressionLabelBright != null && progressionPercent > RiftProgressionLimit)
- {
- DrawProgressionText(ProgressionLabelBright, text);
- }
- else if (ProgressionLabelDim != null && progressionPercent > 0)
- {
- DrawProgressionText(ProgressionLabelDim, text);
- }
- }
- }
- void DrawProgressionText(IFont font, string text)
- {
- var layout = font.GetTextLayout(text);
- float x = labelX;
- if (ProgressionLabelOnMinimap)
- {
- x += Hud.Render.MinimapUiElement?.Rectangle.X ?? 0;
- }
- if (ProgressionLabelRightAligned)
- {
- x -= layout.Metrics.Width;
- }
- float y = labelY;
- if (BackgroundBrush != null)
- {
- // We have to inflate this a bit.
- BackgroundBrush.DrawRectangle(x - 2f, y - 2f, layout.Metrics.Width + 4f, layout.Metrics.Height + 4f);
- }
- font.DrawText(layout, x, y);
- }
- bool hasTrashProgression; // Trash is decorated differently if enouugh progression from trash mobs.
- double progressionPercent;
- int progressionCooldown;
- public void PaintWorld(WorldLayer layer)
- {
- if (Hud.Game.IsInTown) return;
- if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map)) return;
- bool inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
- int eliteCount = 0;
- bool isKillDecorator = false;
- if (inRift && (IsRiftProgressionEnabled || ShowKillDensityOnMinimap))
- {
- // Calculate all monsters with progression within range.
- float progressionTrash = 0;
- float progressionGood = 0;
- foreach (var monster in Hud.Game.AliveMonsters.Where(x => x.SnoMonster.RiftProgression > 0 && x.NormalizedXyDistanceToMe < RiftProgressionRange))
- {
- if (monster.SnoMonster.RiftProgression < TrashBreakpoint)
- {
- progressionTrash += monster.SnoMonster.RiftProgression;
- }
- else
- {
- progressionGood += monster.SnoMonster.RiftProgression;
- }
- }
- progressionPercent = (progressionTrash + progressionGood) / Hud.Game.MaxQuestProgress * 100d;
- if (ShowKillDensityOnMinimap)
- {
- var progressionTrashPercent = progressionTrash / Hud.Game.MaxQuestProgress * 100d;
- if (progressionTrashPercent > KillDensityLimit)
- {
- isKillDecorator = true;
- hasTrashProgression = true;
- progressionCooldown = Hud.Game.CurrentGameTick + RiftProgressionCooldown;
- }
- else if (hasTrashProgression)
- {
- if (progressionCooldown > Hud.Game.CurrentGameTick)
- {
- isKillDecorator = true;
- }
- else
- {
- hasTrashProgression = false;
- }
- }
- }
- }
- else if (progressionPercent > 0)
- {
- progressionPercent = 0;
- }
- foreach (var monster in Hud.Game.AliveMonsters)
- {
- if (monster.IsElite) // Elites are drawn always
- {
- eliteCount += 1;
- if (monster.Rarity == ActorRarity.RareMinion && EliteMinionDecorator != null)
- {
- EliteMinionDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
- }
- else
- {
- EliteDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
- }
- if (monster.SnoMonster.Priority == MonsterPriority.boss && BossDecorator != null)
- {
- BossDecorator.Paint(layer, monster, monster.FloorCoordinate, null);
- }
- if (eliteCount == 1 && PlayerDecorator != null)
- {
- PlayerDecorator.Paint(layer, Hud.Game.Me, Hud.Game.Me.FloorCoordinate, null);
- }
- }
- else if (inRift) // Rift progression, some mobs far out can be left out from drawing!
- {
- if (monster.SnoMonster.RiftProgression > 0 && monster.NormalizedXyDistanceToMe < RiftProgressionRange)
- {
- if (monster.SnoMonster.RiftProgression < TrashBreakpoint)
- {
- if (isKillDecorator && KillDecorator != null)
- {
- KillDecorator.Paint(layer, monster, monster.FloorCoordinate, null); // Progression to kill!
- }
- else
- {
- GreyDecorator.Paint(layer, monster, monster.FloorCoordinate, null); // Trash.
- }
- }
- else if (monster.SnoMonster.RiftProgression < KillBreakpoint)
- {
- GreenDecorator.Paint(layer, monster, monster.FloorCoordinate, null); // Some value.
- }
- else
- {
- BlueDecorator.Paint(layer, monster, monster.FloorCoordinate, null); // Rest is best.
- }
- }
- }
- else // Draw all mobs we can see.
- {
- GreyDecorator.Paint(layer, monster, monster.FloorCoordinate, null); // What ever.
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement