Advertisement
jarppaaja

MonstersToHuntInGR rev 863

Jan 24th, 2019
627
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.04 KB | None | 0 0
  1. // MonstersToHuntInGR.cs "$Revision: 863 $" "$Date: 2019-01-24 17:44:52 +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.         public WorldDecoratorCollection DefaultDecorator { get; set; }
  29.  
  30.         float xRatio = 0.80f;   // Minimap top left corner.
  31.         float yRatio = 0.04f;
  32.         SimpleLabel labelMonsterCount;
  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.             labelMonsterCount = new SimpleLabel(font1).WithPosition(x, y);
  61.  
  62.             PowerDecoratorBoss = new GroundCircleDecorator(Hud)
  63.             {
  64.                 Brush = Hud.Render.CreateBrush(255, 192, 96, 0, 1.5f),
  65.                 Radius = 50f,
  66.             };
  67.             IBrush shadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1);
  68.             EliteDecorator = new MapShapeDecorator(Hud)
  69.             {
  70.                 ShapePainter = new CircleShapePainter(Hud),
  71.                 Brush = Hud.Render.CreateBrush(255, 255, 200, 100, 2),    // Dim yellow
  72.                 ShadowBrush = shadowBrush,
  73.                 Radius = 4,
  74.             };
  75.             GoodProgressDecorator = new WorldDecorators()
  76.             {
  77.                 GroundCircle = new GroundCircleDecorator(Hud)
  78.                 {
  79.                     Brush = Hud.Render.CreateBrush(192, 60, 60, 255, -2),   // Blue
  80.                     Radius = 1.25f,
  81.                 },
  82.                 MapShape = new MapShapeDecorator(Hud)
  83.                 {
  84.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  85.                     Brush = Hud.Render.CreateBrush(255, 60, 128, 255, 3),    // Blue (dodger)
  86.                     ShadowBrush = shadowBrush,
  87.                     Radius = 6,
  88.                 },
  89.             };
  90.             BestProgressKeepDecorator = new WorldDecorators()
  91.             {
  92.                 GroundCircle = new GroundCircleDecorator(Hud)
  93.                 {
  94.                     Brush = Hud.Render.CreateBrush(192, 85, 255, 85, -3),   // Green (lighter)
  95.                     Radius = 1.25f,
  96.                 },
  97.                 MapShape = new MapShapeDecorator(Hud)
  98.                 {
  99.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  100.                     Brush = Hud.Render.CreateBrush(255, 128, 255, 0, 3),    // Green
  101.                     ShadowBrush = shadowBrush,
  102.                     Radius = 6,
  103.                 }
  104.             };
  105.             DefaultDecorator = new WorldDecoratorCollection(    // Small grey dot for minor monsters
  106.                 new MapShapeDecorator(Hud)
  107.                 {
  108.                     Brush = Hud.Render.CreateBrush(128, 200, 200, 200, 0),
  109.                     ShadowBrush = shadowBrush,
  110.                     ShapePainter = new CircleShapePainter(Hud),
  111.                     Radius = 2,
  112.                 }
  113.                 );
  114.         }
  115.  
  116.         float helperRadius;
  117.         public void PaintWorld(WorldLayer layer)
  118.         {
  119.             if (Hud.Game.IsInTown) return;
  120.             if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap)) return;
  121.  
  122.             int monsterCount = 0;
  123.             bool inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  124.             foreach (var monster in Hud.Game.AliveMonsters)
  125.             {
  126.                 if (monster.SnoMonster.Priority >= MonsterPriority.high)
  127.                 {
  128.                     if (monster.SnoMonster.Priority == MonsterPriority.boss)
  129.                     {
  130.                         PowerDecoratorBoss.Paint(monster, monster.FloorCoordinate, null);
  131.                         monsterCount += 1;
  132.                     }
  133.                 }
  134.                 // Rift progress hunting.
  135.                 if (inRift)
  136.                 {
  137.                     if (monster.IsElite)
  138.                     {
  139.                         EliteDecorator.Paint(monster, monster.FloorCoordinate, "");
  140.                         monsterCount += 1;
  141.                     }
  142.                     else if (monster.SnoMonster.RiftProgression < RiftProgressionLimitGood)
  143.                     {
  144.                         DefaultDecorator.Paint(layer, monster, monster.FloorCoordinate, "");
  145.                     }
  146.                     else
  147.                     {
  148.                         monsterCount += 1;
  149.                         // GroundCircle for near monsters.
  150.                         if (monster.NormalizedXyDistanceToMe < RiftProgressionRange)
  151.                         {
  152.                             if (monster.SnoMonster.RiftProgression < RiftProgressionLimitBest)
  153.                             {
  154.                                 GoodProgressDecorator.GroundCircle.Paint(monster, monster.FloorCoordinate, "");
  155.                             }
  156.                             else
  157.                             {
  158.                                 BestProgressKeepDecorator.GroundCircle.Paint(monster, monster.FloorCoordinate, "");
  159.                             }
  160.                         }
  161.                         // MapShape for all monsters.
  162.                         if (monster.SnoMonster.RiftProgression < RiftProgressionLimitBest)
  163.                         {
  164.                             GoodProgressDecorator.MapShape.Paint(monster, monster.FloorCoordinate, "");
  165.                         }
  166.                         else
  167.                         {
  168.                             BestProgressKeepDecorator.MapShape.Paint(monster, monster.FloorCoordinate, "");
  169.                         }
  170.                     }
  171.                 }
  172.             }
  173.             if (ShowMonsterCount)
  174.             {
  175.                 labelMonsterCount.PaintLeft(monsterCount.ToString());
  176.             }
  177.         }
  178.  
  179.         class SimpleLabel
  180.         {
  181.             public IFont TextFont;
  182.             public float X;
  183.             public float Y;
  184.  
  185.             public SimpleLabel(IController hud, string fontFamily, float size, SharpDX.Color textColor, bool bold = false)
  186.                 :
  187.                 this(hud.Render.CreateFont(fontFamily, size, textColor.A, textColor.R, textColor.G, textColor.B, bold, false, true))
  188.             { }
  189.  
  190.             public SimpleLabel(IFont font)
  191.             {
  192.                 TextFont = font;
  193.             }
  194.  
  195.             public SimpleLabel WithPosition(float x, float y)
  196.             {
  197.                 this.X = x;
  198.                 this.Y = y;
  199.                 return this;
  200.             }
  201.  
  202.             public SharpDX.DirectWrite.TextMetrics GetTextMetrics(string text)
  203.             {
  204.                 return TextFont.GetTextLayout(text).Metrics;
  205.             }
  206.  
  207.             public float PaintLeft(string text)
  208.             {
  209.                 return PaintLeft(X, Y, text);
  210.             }
  211.             public float PaintLeft(float x, float y, string text)
  212.             {
  213.                 var layout = TextFont.GetTextLayout(text);
  214.                 TextFont.DrawText(layout, x, y);
  215.                 return layout.Metrics.Height;
  216.             }
  217.  
  218.             public float PaintRight(string text)
  219.             {
  220.                 return PaintRight(X, Y, text);
  221.             }
  222.             public float PaintRight(float x, float y, string text)
  223.             {
  224.                 var layout = TextFont.GetTextLayout(text);
  225.                 TextFont.DrawText(layout, x - layout.Metrics.Width, y - layout.Metrics.Height);
  226.                 return layout.Metrics.Height;
  227.             }
  228.         }
  229.     }
  230. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement