Advertisement
jarppaaja

MonstersToHuntInGR rev 860

Jan 24th, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.40 KB | None | 0 0
  1. // MonstersToHuntInGR.cs "$Revision: 860 $" "$Date: 2019-01-24 14:19:05 +0200 (to, 24 tammi 2019) $"
  2. using Turbo.Plugins;
  3. using Turbo.Plugins.Default;
  4.  
  5. namespace Turbo.plugins.JarJar.DefaultUI
  6. {
  7.     // Idea from: https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-plugin-review-zone/618264-v7-2-international-glq-zeicircleforboss.html
  8.     // RiftProgression calculation:
  9.     // See: http://www.warpath.eu/index.html
  10.  
  11.     public class MonstersToHuntInGR : BasePlugin, ICustomizer, IInGameWorldPainter
  12.     {
  13.         public bool ShowMonsterCount { get; set; }
  14.  
  15.         public class WorldDecorators
  16.         {
  17.             public GroundCircleDecorator GroundCircle;
  18.             public MapShapeDecorator MapShape;
  19.         };
  20.         public GroundCircleDecorator PowerDecoratorBoss;
  21.         public MapShapeDecorator EliteDecorator;
  22.         public WorldDecorators GoodProgressDecorator;
  23.         public WorldDecorators BestProgressKeepDecorator;
  24.         public float RiftProgressionLimitGood;
  25.         public float RiftProgressionLimitBest;
  26.         public float RiftProgressionRange;
  27.  
  28.         float xRatio = 0.80f;   // Minimap top left corner.
  29.         float yRatio = 0.04f;
  30.         SimpleLabel labelMonsterCount;
  31.  
  32.         public MonstersToHuntInGR()
  33.         {
  34.             Enabled = true;
  35.  
  36.             ShowMonsterCount = true;
  37.  
  38.             // Progression Orb       = 7.5f
  39.             RiftProgressionLimitBest = 3.75f;   // 7.5 / 2
  40.             RiftProgressionLimitGood = 2.5f;    // 7.5 / 3
  41.  
  42.             RiftProgressionRange = 50f;         // Almost whole screen.
  43.         }
  44.  
  45.         public void Customize()
  46.         {
  47.             // Disable default coloring plugin.
  48.             Hud.TogglePlugin<Turbo.Plugins.Default.MonsterRiftProgressionColoringPlugin>(false);
  49.         }
  50.  
  51.         public override void Load(IController hud)
  52.         {
  53.             base.Load(hud);
  54.  
  55.             float x = Hud.Window.Size.Width * xRatio;
  56.             float y = Hud.Window.Size.Height * yRatio;
  57.             var font1 = Hud.Render.CreateFont("tahoma", 12, 255, 255, 51, 0, true, false, 255, 0, 0, 0, true);     // red #ff3300
  58.             labelMonsterCount = new SimpleLabel(font1).WithPosition(x, y);
  59.  
  60.             PowerDecoratorBoss = new GroundCircleDecorator(Hud)
  61.             {
  62.                 Brush = Hud.Render.CreateBrush(255, 192, 96, 0, 1.5f),
  63.                 Radius = 50f,
  64.             };
  65.             IBrush shadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1);
  66.             EliteDecorator = new MapShapeDecorator(Hud)
  67.             {
  68.                 ShapePainter = new CircleShapePainter(Hud),
  69.                 Brush = Hud.Render.CreateBrush(255, 255, 200, 100, 2),    // Dim yellow
  70.                 ShadowBrush = shadowBrush,
  71.                 Radius = 4,
  72.             };
  73.             GoodProgressDecorator = new WorldDecorators()
  74.             {
  75.                 GroundCircle = new GroundCircleDecorator(Hud)
  76.                 {
  77.                     Brush = Hud.Render.CreateBrush(192, 60, 60, 255, -2),   // Blue
  78.                     Radius = 1.25f,
  79.                 },
  80.                 MapShape = new MapShapeDecorator(Hud)
  81.                 {
  82.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  83.                     Brush = Hud.Render.CreateBrush(255, 60, 128, 255, 3),    // Blue (dodger)
  84.                     ShadowBrush = shadowBrush,
  85.                     Radius = 6,
  86.                 },
  87.             };
  88.             BestProgressKeepDecorator = new WorldDecorators()
  89.             {
  90.                 GroundCircle = new GroundCircleDecorator(Hud)
  91.                 {
  92.                     Brush = Hud.Render.CreateBrush(192, 85, 255, 85, -3),   // Green (lighter)
  93.                     Radius = 1.25f,
  94.                 },
  95.                 MapShape = new MapShapeDecorator(Hud)
  96.                 {
  97.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  98.                     Brush = Hud.Render.CreateBrush(255, 128, 255, 0, 3),    // Green
  99.                     ShadowBrush = shadowBrush,
  100.                     Radius = 6,
  101.                 }
  102.             };
  103.         }
  104.  
  105.         float helperRadius;
  106.         public void PaintWorld(WorldLayer layer)
  107.         {
  108.             if (Hud.Game.IsInTown) return;
  109.             if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap)) return;
  110.  
  111.             int monsterCount = 0;
  112.             bool inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  113.             foreach (var monster in Hud.Game.AliveMonsters)
  114.             {
  115.                 if (monster.SnoMonster.Priority >= MonsterPriority.high)
  116.                 {
  117.                     if (monster.SnoMonster.Priority == MonsterPriority.boss)
  118.                     {
  119.                         PowerDecoratorBoss.Paint(monster, monster.FloorCoordinate, null);
  120.                         monsterCount += 1;
  121.                     }
  122.                 }
  123.                 // Rift progress hunting.
  124.                 if (inRift)
  125.                 {
  126.                     if (monster.IsElite)
  127.                     {
  128.                         EliteDecorator.Paint(monster, monster.FloorCoordinate, "");
  129.                         monsterCount += 1;
  130.                     }
  131.                     else if (!(monster.SnoMonster.RiftProgression < RiftProgressionLimitGood))  // >=
  132.                     {
  133.                         monsterCount += 1;
  134.                         // GroundCircle for near monsters.
  135.                         if (monster.NormalizedXyDistanceToMe < RiftProgressionRange)
  136.                         {
  137.                             if (monster.SnoMonster.RiftProgression < RiftProgressionLimitBest)
  138.                             {
  139.                                 GoodProgressDecorator.GroundCircle.Paint(monster, monster.FloorCoordinate, "");
  140.                             }
  141.                             else
  142.                             {
  143.                                 BestProgressKeepDecorator.GroundCircle.Paint(monster, monster.FloorCoordinate, "");
  144.                             }
  145.                         }
  146.                         // MapShape for all monsters.
  147.                         if (monster.SnoMonster.RiftProgression < RiftProgressionLimitBest)
  148.                         {
  149.                             GoodProgressDecorator.MapShape.Paint(monster, monster.FloorCoordinate, "");
  150.                         }
  151.                         else
  152.                         {
  153.                             BestProgressKeepDecorator.MapShape.Paint(monster, monster.FloorCoordinate, "");
  154.                         }
  155.                     }
  156.                 }
  157.             }
  158.             if (ShowMonsterCount)
  159.             {
  160.                 labelMonsterCount.PaintLeft(monsterCount.ToString());
  161.             }
  162.         }
  163.  
  164.         class SimpleLabel
  165.         {
  166.             public IFont TextFont;
  167.             public float X;
  168.             public float Y;
  169.  
  170.             public SimpleLabel(IController hud, string fontFamily, float size, SharpDX.Color textColor, bool bold = false)
  171.                 :
  172.                 this(hud.Render.CreateFont(fontFamily, size, textColor.A, textColor.R, textColor.G, textColor.B, bold, false, true))
  173.             { }
  174.  
  175.             public SimpleLabel(IFont font)
  176.             {
  177.                 TextFont = font;
  178.             }
  179.  
  180.             public SimpleLabel WithPosition(float x, float y)
  181.             {
  182.                 this.X = x;
  183.                 this.Y = y;
  184.                 return this;
  185.             }
  186.  
  187.             public SharpDX.DirectWrite.TextMetrics GetTextMetrics(string text)
  188.             {
  189.                 return TextFont.GetTextLayout(text).Metrics;
  190.             }
  191.  
  192.             public float PaintLeft(string text)
  193.             {
  194.                 return PaintLeft(X, Y, text);
  195.             }
  196.             public float PaintLeft(float x, float y, string text)
  197.             {
  198.                 var layout = TextFont.GetTextLayout(text);
  199.                 TextFont.DrawText(layout, x, y);
  200.                 return layout.Metrics.Height;
  201.             }
  202.  
  203.             public float PaintRight(string text)
  204.             {
  205.                 return PaintRight(X, Y, text);
  206.             }
  207.             public float PaintRight(float x, float y, string text)
  208.             {
  209.                 var layout = TextFont.GetTextLayout(text);
  210.                 TextFont.DrawText(layout, x - layout.Metrics.Width, y - layout.Metrics.Height);
  211.                 return layout.Metrics.Height;
  212.             }
  213.         }
  214.     }
  215. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement