Advertisement
Styckz

MonsterDensityPlugin

Jul 16th, 2017
362
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.53 KB | None | 0 0
  1. using System.Linq;
  2. using Turbo.Plugins.Default;
  3. namespace Turbo.Plugins.glq
  4. {
  5.     public class MonsterDensityPlugin : BasePlugin, IInGameWorldPainter
  6.     {
  7.         public bool ShowLabel { get; set; }
  8.         public bool ShowCircle { get; set; }
  9.         public bool ShowProgression { get; set; }
  10.         public bool ShowMark { get; set; }
  11.         public bool LimitByProgression { get; set; }
  12.         public int Distance { get; set; }
  13.         public int MaxRadius { get; set; }
  14.         public int ping { get; set; }
  15.         public float DisplayLimit { get; set; }
  16.         public WorldDecoratorCollection LabelDecorator { get; set; }
  17.         public WorldDecoratorCollection CircleDecorator { get; set; }
  18.         public WorldDecoratorCollection MarkDecorator { get; set; }
  19.         IWorldCoordinate MCoordinate { get; set; }
  20.         int Mcount { get; set; }
  21.         public MonsterDensityPlugin()
  22.         {
  23.             Enabled = true;
  24.         }
  25.  
  26.         public override void Load(IController hud)
  27.         {
  28.             base.Load(hud);
  29.             DisplayLimit = 1;
  30.             LimitByProgression = false; // False = Limits by Count, True = Limits by Calculated Progression
  31.             ShowLabel = true;
  32.             ShowCircle = true;
  33.             ShowMark = true;
  34.             ShowProgression = true;
  35.             Distance = 10;
  36.             MaxRadius = 15;
  37.             ping = 333;
  38.             LabelDecorator = new WorldDecoratorCollection(
  39.                 new GroundLabelDecorator(Hud) {
  40.                     BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0),
  41.                     TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 0, 255, 255, true, false, 160, 0, 0, 0, true),
  42.                 }
  43.                 );
  44.             MarkDecorator = new WorldDecoratorCollection(
  45.                 new GroundCircleDecorator(Hud)
  46.                 {
  47.                     Brush = Hud.Render.CreateBrush(255, 0, 255, 255, 0),
  48.                     Radius = 1f,
  49.                 }
  50.                 );
  51.  
  52.         }
  53.  
  54.         public void PaintWorld(WorldLayer layer)
  55.         {
  56.             var inRift = Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift;
  57.             double MRiftProgression = 0;
  58.             int density = 0;
  59.             var monsters = Hud.Game.AliveMonsters.Where(x => x.IsOnScreen);
  60.             CircleDecorator = new WorldDecoratorCollection(
  61.                 new GroundCircleDecorator(Hud)
  62.                 {
  63.                     Brush = Hud.Render.CreateBrush(255, 0, 255, 255, 1.5f),
  64.                     Radius = MaxRadius,
  65.                     RadiusTransformator = new StandardPingRadiusTransformator(Hud, ping),
  66.                 }
  67.                 );
  68.             foreach (var monster in monsters)
  69.             {
  70.                 double MonsterRiftProgression = 0;
  71.                 if (monster.IsOnScreen)
  72.                 {
  73.                     int count = Hud.Game.AliveMonsters.Count(m => (monster.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate) - m.RadiusBottom) <= Distance);
  74.                     var monsters2 = Hud.Game.AliveMonsters.Where(mm => (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && mm.SummonerAcdDynamicId == 0 && mm.IsElite || (monster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= MaxRadius && !mm.IsElite);
  75.                     if (inRift)
  76.                     {
  77.                         foreach (var monster2 in monsters2)
  78.                         {
  79.                             MonsterRiftProgression += monster2.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  80.  
  81.                         }
  82.                     }
  83.                     if (count >= density && MonsterRiftProgression >= MRiftProgression)
  84.                     {
  85.                         MCoordinate = monster.FloorCoordinate;
  86.                         Mcount = count;
  87.                         density = count;
  88.                         MRiftProgression = MonsterRiftProgression;
  89.                     }
  90.                 }
  91.             }
  92.             foreach (var monster in monsters)
  93.             {
  94.                 if (monster.IsOnScreen && ((LimitByProgression && MRiftProgression >= DisplayLimit) || (!LimitByProgression && Mcount >= DisplayLimit)))
  95.                 {
  96.                     if (ShowLabel)
  97.                     {
  98.                        
  99.                         if(!inRift)
  100.                         {
  101.                             LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
  102.                         }
  103.                         else
  104.                         {
  105.                             if(ShowProgression)
  106.                             {
  107.                                 LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount + "(" + MaxRadius + "yards Progression:" + MRiftProgression.ToString("f2") + ")");
  108.                             }
  109.                             else
  110.                             {
  111.                                 LabelDecorator.Paint(layer, monster, MCoordinate, Distance + "yards Density:" + Mcount);
  112.                             }
  113.                            
  114.                         }    
  115.                     }
  116.                     if (ShowCircle)
  117.                     {
  118.                         CircleDecorator.Paint(layer, monster, MCoordinate, null);
  119.                     }
  120.                     if (ShowMark)
  121.                     {
  122.                         MarkDecorator.Paint(layer, monster, MCoordinate, null);
  123.                     }
  124.                 }
  125.                 return;
  126.             }
  127.  
  128.         }
  129.     }
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement