Advertisement
jarppaaja

MonstersToHuntInGR rev 971

Feb 10th, 2019
772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.14 KB | None | 0 0
  1. // MonstersToHuntInGR.cs "$Revision: 971 $" "$Date: 2019-02-10 13:12:39 +0200 (su, 10 helmi 2019) $"
  2. using SharpDX.Direct2D1;
  3. using Turbo.Plugins;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.plugins.JarJar.DefaultUI
  7. {
  8.     // RiftProgression calculation:
  9.     // See: http://www.warpath.eu/index.html
  10.  
  11.     public class MonstersToHuntInGR : BasePlugin, ICustomizer, IInGameWorldPainter
  12.     {
  13.         // Monster decorators by type.
  14.         public WorldDecoratorCollection EliteDecorator { get; set; }
  15.         public WorldDecoratorCollection BlueDecorator { get; set; }
  16.         public WorldDecoratorCollection GreenDecorator { get; set; }
  17.         public WorldDecoratorCollection GreyDecorator { get; set; }
  18.  
  19.         // Special decorators.
  20.         public bool ShowMonsterCount { get; set; } = true;
  21.         public float BossCirleRadius { get; set; } = 50f;
  22.         public WorldDecoratorCollection BossDecorator { get; set; }         // Draws 50 yeard circle around boss.
  23.         public WorldDecoratorCollection PlayerDecorator { get; set; }       // Draws player hitbox to show where player is during boss/elite fights.
  24.  
  25.         public float RiftProgressionLimitGood { get; set; } = 2.50f;        // 33% of rift orb value
  26.         public float RiftProgressionLimitBest { get; set; } = 3.75f;        // 50% of rift orb value
  27.         public float RiftProgressionRange { get; set; } = 50f;
  28.  
  29.         public float xRatio = 0.80f;   // Minimap top left corner for ShowMonsterCount: EliteCountLabel.
  30.         public float yRatio = 0.04f;
  31.  
  32.         SimpleLabel EliteCountLabel;
  33.  
  34.         public MonstersToHuntInGR()
  35.         {
  36.             Enabled = true;
  37.  
  38.             ShowMonsterCount = true;
  39.  
  40.             // Progression Orb       = 7.5f
  41.             RiftProgressionLimitBest = 3.75f;   // 7.5 / 2
  42.             RiftProgressionLimitGood = 2.5f;    // 7.5 / 3
  43.  
  44.             RiftProgressionRange = 50f;         // Almost whole screen.
  45.         }
  46.  
  47.         public void Customize()
  48.         {
  49.             // Disable default coloring plugin.
  50.             Hud.TogglePlugin<Turbo.Plugins.Default.MonsterRiftProgressionColoringPlugin>(false);
  51.         }
  52.  
  53.         public override void Load(IController hud)
  54.         {
  55.             base.Load(hud);
  56.  
  57.             float x = Hud.Window.Size.Width * xRatio;
  58.             float y = Hud.Window.Size.Height * yRatio;
  59.             var font1 = Hud.Render.CreateFont("tahoma", 12, 255, 255, 51, 0, true, false, 255, 0, 0, 0, true);     // red #ff3300
  60.             EliteCountLabel = new SimpleLabel(font1).WithPosition(x, y);
  61.  
  62.             IBrush shadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1);
  63.  
  64.             BossDecorator = new WorldDecoratorCollection(
  65.                 new GroundCircleDecorator(Hud)
  66.                 {
  67.                     Brush = Hud.Render.CreateBrush(255, 192, 96, 0, 1.5f),  // Dim orange
  68.                     Radius = BossCirleRadius,
  69.                 }
  70.                 );
  71.             PlayerDecorator = new WorldDecoratorCollection(
  72.                 new GroundCircleDecorator(Hud)
  73.                 {
  74.                     Brush = Hud.Render.CreateBrush(255, 153, 204, 255, 3.5f, DashStyle.DashDot),    // Light blue
  75.                     Radius = -1,
  76.                 }
  77.                 );
  78.             EliteDecorator = new WorldDecoratorCollection(
  79.                 new MapShapeDecorator(Hud)
  80.                 {
  81.                     ShapePainter = new CircleShapePainter(Hud),
  82.                     Brush = Hud.Render.CreateBrush(255, 255, 200, 100, 2),  // Dim yellow
  83.                     ShadowBrush = shadowBrush,
  84.                     Radius = 4f,
  85.                 },
  86.                 new GroundCircleDecorator(Hud)
  87.                 {
  88.                     Brush = Hud.Render.CreateBrush(255, 255, 0, 255, 2f),   // Violet
  89.                     Radius = -1,    // Show monster hitbox
  90.                 }
  91.                 );
  92.             BlueDecorator = new WorldDecoratorCollection(
  93.                 new MapShapeDecorator(Hud)
  94.                 {
  95.                     ShapePainter = new CircleShapePainter(Hud),
  96.                     Brush = Hud.Render.CreateBrush(255, 60, 128, 255, 3),   // Blue (dodger)
  97.                     ShadowBrush = shadowBrush,
  98.                     Radius = 3.5f,
  99.                 }
  100.                 );
  101.             GreenDecorator = new WorldDecoratorCollection(
  102.                 new MapShapeDecorator(Hud)
  103.                 {
  104.                     ShapePainter = new CircleShapePainter(Hud),
  105.                     Brush = Hud.Render.CreateBrush(255, 128, 255, 0, 3),    // Green
  106.                     ShadowBrush = shadowBrush,
  107.                     Radius = 3f,
  108.                 }
  109.                 );
  110.             GreyDecorator = new WorldDecoratorCollection(
  111.                 new MapShapeDecorator(Hud)
  112.                 {
  113.                     Brush = Hud.Render.CreateBrush(128, 200, 200, 200, 0),  // Grey
  114.                     ShadowBrush = shadowBrush,
  115.                     ShapePainter = new CircleShapePainter(Hud),
  116.                     Radius = 2f,
  117.                 }
  118.                 );
  119.         }
  120.  
  121.         float helperRadius;
  122.         public void PaintWorld(WorldLayer layer)
  123.         {
  124.             if (Hud.Game.IsInTown) return;
  125.             if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap)) return;
  126.  
  127.             bool inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  128.             int eliteCount = 0;
  129.             foreach (var monster in Hud.Game.AliveMonsters)
  130.             {
  131.                 if (monster.IsElite)
  132.                 {
  133.                     // Boss fight for Nephalem rift happens outside "SpecialArea.Rift" so we check these regardless of the area.
  134.                     eliteCount += 1;
  135.                     EliteDecorator.Paint(layer, monster, monster.FloorCoordinate, null);
  136.                     if (monster.SnoMonster.Priority == MonsterPriority.boss)
  137.                     {
  138.                         BossDecorator.Paint(layer, monster, monster.FloorCoordinate, null);
  139.                     }
  140.                     continue;
  141.                 }
  142.                 if (inRift)
  143.                 {
  144.                     // Decorators for near monsters that can advance progression.
  145.                     // - there is few monster with zero progression we ignore.
  146.                     if (monster.NormalizedXyDistanceToMe < RiftProgressionRange && monster.SnoMonster.RiftProgression > 0)
  147.                     {
  148.                         if (monster.SnoMonster.RiftProgression < RiftProgressionLimitGood)
  149.                         {
  150.                             GreyDecorator.Paint(layer, monster, monster.FloorCoordinate, null);     // Trash.
  151.                         }
  152.                         else if (monster.SnoMonster.RiftProgression < RiftProgressionLimitBest)
  153.                         {
  154.                             GreenDecorator.Paint(layer, monster, monster.FloorCoordinate, null);    // Some value.
  155.                         }
  156.                         else
  157.                         {
  158.                             BlueDecorator.Paint(layer, monster, monster.FloorCoordinate, null);     // Rest is best.
  159.                         }
  160.                     }
  161.                 }
  162.             }
  163.             if (eliteCount > 0)
  164.             {
  165.                 if (ShowMonsterCount)
  166.                 {
  167.                     EliteCountLabel.PaintLeft(eliteCount.ToString());
  168.                 }
  169.                 PlayerDecorator.Paint(layer, Hud.Game.Me, Hud.Game.Me.FloorCoordinate, null);
  170.             }
  171.         }
  172.  
  173.         class SimpleLabel
  174.         {
  175.             public IFont TextFont;
  176.             public float X;
  177.             public float Y;
  178.  
  179.             public SimpleLabel(IController hud, string fontFamily, float size, SharpDX.Color textColor, bool bold = false)
  180.                 :
  181.                 this(hud.Render.CreateFont(fontFamily, size, textColor.A, textColor.R, textColor.G, textColor.B, bold, false, true))
  182.             { }
  183.  
  184.             public SimpleLabel(IFont font)
  185.             {
  186.                 TextFont = font;
  187.             }
  188.  
  189.             public SimpleLabel WithPosition(float x, float y)
  190.             {
  191.                 this.X = x;
  192.                 this.Y = y;
  193.                 return this;
  194.             }
  195.  
  196.             public SharpDX.DirectWrite.TextMetrics GetTextMetrics(string text)
  197.             {
  198.                 return TextFont.GetTextLayout(text).Metrics;
  199.             }
  200.  
  201.             public float PaintLeft(string text)
  202.             {
  203.                 return PaintLeft(X, Y, text);
  204.             }
  205.             public float PaintLeft(float x, float y, string text)
  206.             {
  207.                 var layout = TextFont.GetTextLayout(text);
  208.                 TextFont.DrawText(layout, x, y);
  209.                 return layout.Metrics.Height;
  210.             }
  211.  
  212.             public float PaintRight(string text)
  213.             {
  214.                 return PaintRight(X, Y, text);
  215.             }
  216.             public float PaintRight(float x, float y, string text)
  217.             {
  218.                 var layout = TextFont.GetTextLayout(text);
  219.                 TextFont.DrawText(layout, x - layout.Metrics.Width, y - layout.Metrics.Height);
  220.                 return layout.Metrics.Height;
  221.             }
  222.         }
  223.     }
  224. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement