Advertisement
Styckz

RiftAndQuestsArrow

Jul 28th, 2017
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.81 KB | None | 0 0
  1. using System.Linq;
  2. using Turbo.Plugins.Default;
  3.  
  4. //Inspired by MonsterDensityPlugin (http://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-plugin-review-zone/625142-v7-2-english-glq-monsterdensityplugin.html) by SeaDragon (http://www.ownedcore.com/forums/members/1130723-seadragon.html)
  5.  
  6. namespace Turbo.Plugins.Styckz
  7. {
  8.     public class RiftAndQuestArrow : BasePlugin, IInGameWorldPainter
  9.     {
  10.         public bool ShowGroundLabel { get; set; }
  11.         public bool ShowSearchCircle { get; set; }
  12.         public bool ShowMonsterCircle { get; set; }
  13.         public bool ShowLine { get; set; }
  14.         public bool UseAutoColors { get; set; }
  15.         public int SearchDistance { get; set; }
  16.         public float MinRiftProgress { get; set; }
  17.         public IBrush CustLineBrush { get; set; }
  18.         public WorldDecoratorCollection CustLabelDecorator { get; set; }
  19.         public WorldDecoratorCollection CustCircleDecorator { get; set; }
  20.         public WorldDecoratorCollection CustMarkDecorator { get; set; }
  21.         public IWorldCoordinate MCoordinate { get; set; }
  22.         public int MinCount { get ; set; }
  23.  
  24.         public RiftAndQuestArrow()
  25.         {
  26.             Enabled = true;
  27.             MinRiftProgress = 0.75f;    //Minimum Rift Progress to Display Decorators
  28.             ShowGroundLabel = false;    //Show label with CountAroundCheckableMonsterand Progression
  29.             ShowSearchCircle = false;   //Show a Cirlce of the Search Area around the Monster
  30.             ShowMonsterCircle = false;  //Show a filled Circle at the Monster
  31.             ShowLine = true;            //Show a Line from your Character to the Closest Monster that meets the Progress Limit
  32.             UseAutoColors = true;       //Use Default colors Disable this and reset the Cust* dectorators to the colors you want to use
  33.             SearchDistance = 30;        //How far from to search around the monster for progress
  34.             MinCount = 6;               //Minimum Group Size to point to on a Kill Unique Quest
  35.         }
  36.  
  37.         public override void Load(IController hud)
  38.         {
  39.             base.Load(hud);
  40.  
  41.             CustLineBrush = Hud.Render.CreateBrush(110, 0, 255, 255, 25f,SharpDX.Direct2D1.DashStyle.Solid, SharpDX.Direct2D1.CapStyle.Round, SharpDX.Direct2D1.CapStyle.Triangle);
  42.  
  43.             CustLabelDecorator = new WorldDecoratorCollection(
  44.                 new GroundLabelDecorator(Hud)
  45.                 {
  46.                     BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0),
  47.                     TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 0, 255, 255, true, false, 160, 0, 0, 0, true),
  48.                 }
  49.                 );
  50.  
  51.             CustMarkDecorator = new WorldDecoratorCollection(
  52.                 new GroundCircleDecorator(Hud)
  53.                 {
  54.                     Brush = Hud.Render.CreateBrush(90, 0, 255, 255, 0),
  55.                     Radius = 1.0f,
  56.                 }
  57.                 );
  58.  
  59.             CustCircleDecorator = new WorldDecoratorCollection(
  60.                 new GroundCircleDecorator(Hud)
  61.                 {
  62.                     Brush = Hud.Render.CreateBrush(255, 0, 255, 255, 1.5f),
  63.                     Radius = SearchDistance,
  64.                 }
  65.                 );
  66.         }
  67.  
  68.         private IQuest killUniqueQuest
  69.         {
  70.             get
  71.             {
  72.                 return Hud.Game.Quests.FirstOrDefault(q =>
  73.                     q.SnoQuest.BountyType == BountyType.KillUnique &&
  74.                     q.State == QuestState.started  &&
  75.                     !Hud.Game.Me.IsInTown &&
  76.                     q.SnoQuest.UnassignedStepBnetTitleEnglish != "Bounty: Kill Sledge" &&
  77.                     ((q.SnoQuest.UnassignedStepBnetTitleEnglish == "Bounty: Kill John Gorham Coffin" && Hud.Game.Me.SnoArea.NameEnglish == "Defiled Crypt") ||
  78.                     (q.SnoQuest.UnassignedStepBnetTitleEnglish == "Bounty: Kill Ganthar the Trickster" && Hud.Game.Me.SnoArea.NameEnglish == "Skycrown Battlements") ||
  79.                     (q.SnoQuest.UnassignedStepBnetTitleEnglish == "Bounty: Kill Inquisitor Hamath" && Hud.Game.Me.SnoArea.NameEnglish == "Stinging Winds") ||
  80.                     (q.SnoQuest.UnassignedStepBnetTitleEnglish == "Bounty: The Matriarch's Bones" && Hud.Game.Me.SnoArea.NameEnglish == "Defiled Crypt") ||
  81.                         (q.SnoQuest.UnassignedStepBnetTitleEnglish != "Bounty: Kill John Gorham Coffin"  &&
  82.                          q.SnoQuest.UnassignedStepBnetTitleEnglish != "Bounty: Kill Ganthar the Trickster"  &&
  83.                          q.SnoQuest.UnassignedStepBnetTitleEnglish != "Bounty: Kill Inquisitor Hamath"  &&
  84.                          q.SnoQuest.UnassignedStepBnetTitleEnglish != "Bounty: The Matriarch's Bones"  &&
  85.                          q.SnoQuest.BountySnoArea == Hud.Game.Me.SnoArea))
  86.                 );
  87.             }
  88.         }
  89.  
  90.         private IQuest clearDungeonQuest
  91.         {
  92.             get
  93.             {
  94.                 return Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.BountyType == BountyType.ClearDungeon && q.State == QuestState.started  && (q.SnoQuest.UnassignedStepBnetTitleEnglish.Substring(18) + " Level 2" == Hud.Game.Me.SnoArea.NameEnglish || Hud.Game.Me.SnoArea.NameEnglish.EndsWith(q.SnoQuest.UnassignedStepBnetTitleEnglish.Substring(18))) && !Hud.Game.Me.IsInTown);
  95.             }
  96.         }
  97.  
  98.         public void PaintWorld(WorldLayer layer)
  99.         {
  100.            
  101.  
  102.             if(Hud.Game.SpecialArea != SpecialArea.Rift && Hud.Game.SpecialArea != SpecialArea.GreaterRift && killUniqueQuest == null && clearDungeonQuest == null)return;
  103.  
  104.             if(UseAutoColors && Hud.Game.SpecialArea == SpecialArea.Rift)
  105.             {
  106.                 CustLineBrush = Hud.Render.CreateBrush(110, 198, 107, 52, 25f,SharpDX.Direct2D1.DashStyle.Solid, SharpDX.Direct2D1.CapStyle.Round, SharpDX.Direct2D1.CapStyle.Triangle);
  107.                 CustLabelDecorator.GetDecorators<GroundLabelDecorator>().ForEach(d =>
  108.                 {
  109.                     d.BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0);
  110.                     d.TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 198, 107, 52, true, false, 160, 0, 0, 0, true);
  111.                 });
  112.                 CustMarkDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  113.                 {
  114.                     d.Brush = Hud.Render.CreateBrush(90, 198, 107, 52, 0);
  115.                     d.Radius = 1.0f;
  116.                 });
  117.                 CustCircleDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  118.                 {
  119.                     d.Brush = Hud.Render.CreateBrush(255, 198, 107, 52, 1.5f);
  120.                     d.Radius = SearchDistance;
  121.                 });
  122.                
  123.             }else if(UseAutoColors && Hud.Game.SpecialArea == SpecialArea.GreaterRift)
  124.             {
  125.                 CustLineBrush = Hud.Render.CreateBrush(110, 79, 53, 145, 25f,SharpDX.Direct2D1.DashStyle.Solid, SharpDX.Direct2D1.CapStyle.Round, SharpDX.Direct2D1.CapStyle.Triangle);
  126.                 CustLabelDecorator.GetDecorators<GroundLabelDecorator>().ForEach(d =>
  127.                 {
  128.                     d.BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0);
  129.                     d.TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 79, 53, 145, true, false, 160, 0, 0, 0, true);
  130.                 });
  131.                 CustMarkDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  132.                 {
  133.                     d.Brush = Hud.Render.CreateBrush(90, 79, 53, 145, 0);
  134.                     d.Radius = 1.0f;
  135.                 });
  136.                 CustCircleDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  137.                 {
  138.                     d.Brush = Hud.Render.CreateBrush(255, 79, 53, 145, 1.5f);
  139.                     d.Radius = SearchDistance;
  140.                 });
  141.             }else if(UseAutoColors){
  142.                 CustLineBrush = Hud.Render.CreateBrush(110, 209, 136, 2, 25f,SharpDX.Direct2D1.DashStyle.Solid, SharpDX.Direct2D1.CapStyle.Round, SharpDX.Direct2D1.CapStyle.Triangle);
  143.                 CustLabelDecorator.GetDecorators<GroundLabelDecorator>().ForEach(d =>
  144.                 {
  145.                     d.BackgroundBrush = Hud.Render.CreateBrush(80, 0, 0, 0, 0);
  146.                     d.TextFont = Hud.Render.CreateFont("tahoma", 8f, 255, 209, 136, 2, true, false, 160, 0, 0, 0, true);
  147.                 });
  148.                 CustMarkDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  149.                 {
  150.                     d.Brush = Hud.Render.CreateBrush(90, 209, 136, 2, 0);
  151.                     d.Radius = 1.0f;
  152.                 });
  153.                 CustCircleDecorator.GetDecorators<GroundCircleDecorator>().ForEach(d =>
  154.                 {
  155.                     d.Brush = Hud.Render.CreateBrush(255, 209, 136, 2, 1.5f);
  156.                     d.Radius = SearchDistance;
  157.                 });
  158.             }
  159.  
  160.             double HighestRiftProgress = 0;
  161.             double ClosestMonsterDist = 10000;
  162.             int CountAroundSelectedMonst = 0;
  163.             var CheckableMonsters = Hud.Game.AliveMonsters.Where (mon => mon.Rarity != ActorRarity.RareMinion && mon.SummonerAcdDynamicId == 0);
  164.  
  165.             foreach (var CheckableMonster in CheckableMonsters)
  166.             {
  167.                 double MonsterRiftProgression = 0;
  168.                 int CountAroundCheckableMonster= Hud.Game.AliveMonsters.Count(m => (CheckableMonster.FloorCoordinate.XYZDistanceTo(m.FloorCoordinate) - m.RadiusBottom) <= SearchDistance);
  169.                 var MonstersInRangeOfCheckableMons = Hud.Game.AliveMonsters.Where(mm => (CheckableMonster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= SearchDistance && mm.SummonerAcdDynamicId == 0 && mm.IsElite && mm.Rarity != ActorRarity.RareMinion || (CheckableMonster.FloorCoordinate.XYZDistanceTo(mm.FloorCoordinate) - mm.RadiusBottom) <= SearchDistance && !mm.IsElite);
  170.                 foreach (var MonstersInRangeOfCheckableMon in MonstersInRangeOfCheckableMons)
  171.                 {
  172.                     if(MonstersInRangeOfCheckableMon.Rarity == ActorRarity.Rare || MonstersInRangeOfCheckableMon.Rarity == ActorRarity.Champion){
  173.                         MonsterRiftProgression += (MonstersInRangeOfCheckableMon.SnoMonster.RiftProgression + 30) * 100.0d / this.Hud.Game.MaxQuestProgress;
  174.                     }else{
  175.                         MonsterRiftProgression += MonstersInRangeOfCheckableMon.SnoMonster.RiftProgression * 100.0d / this.Hud.Game.MaxQuestProgress;
  176.                     }
  177.                 }
  178.                 if ((Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift) && CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate) < ClosestMonsterDist && MonsterRiftProgression >= MinRiftProgress)
  179.                 {
  180.                     MCoordinate = CheckableMonster.FloorCoordinate;
  181.                     ClosestMonsterDist = CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate);
  182.                     CountAroundSelectedMonst = CountAroundCheckableMonster;
  183.                     HighestRiftProgress = MonsterRiftProgression;
  184.                 }else if (killUniqueQuest != null && CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate) < ClosestMonsterDist && CountAroundCheckableMonster> MinCount)
  185.                 {
  186.                     MCoordinate = CheckableMonster.FloorCoordinate;
  187.                     ClosestMonsterDist = CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate);
  188.                     CountAroundSelectedMonst = CountAroundCheckableMonster;
  189.                 }else if (clearDungeonQuest!= null && CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate) < ClosestMonsterDist && CountAroundCheckableMonster > 0)
  190.                 {
  191.                     MCoordinate = CheckableMonster.FloorCoordinate;
  192.                     ClosestMonsterDist = CheckableMonster.FloorCoordinate.XYZDistanceTo(Hud.Game.Me.FloorCoordinate);
  193.                     CountAroundSelectedMonst = CountAroundCheckableMonster;
  194.                 }
  195.             }
  196.  
  197.             foreach (var CheckableMonster in CheckableMonsters)
  198.             {
  199.                 if ((Hud.Game.SpecialArea == SpecialArea.Rift || Hud.Game.SpecialArea == SpecialArea.GreaterRift) && HighestRiftProgress >= MinRiftProgress)
  200.                 {
  201.                     if (ShowGroundLabel)
  202.                     {
  203.                         CustLabelDecorator.Paint(layer, CheckableMonster, MCoordinate, SearchDistance + "yards Density:" + CountAroundSelectedMonst + "| Progression:" + HighestRiftProgress.ToString("f2"));
  204.                     }
  205.                     if (ShowSearchCircle)
  206.                     {
  207.                         CustCircleDecorator.Paint(layer, CheckableMonster, MCoordinate, null);
  208.                     }
  209.                     if (ShowLine)
  210.                     {
  211.                         CustLineBrush.DrawLineWorld(Hud.Game.Me.FloorCoordinate, MCoordinate);
  212.                     }
  213.                     if (ShowMonsterCircle)
  214.                     {
  215.                         CustMarkDecorator.Paint(layer, CheckableMonster, MCoordinate, null);
  216.                     }
  217.                 }else if(CountAroundSelectedMonst > 1){
  218.                     if (ShowGroundLabel)
  219.                     {
  220.                         CustLabelDecorator.Paint(layer, CheckableMonster, MCoordinate, SearchDistance + "yards Density:" + CountAroundSelectedMonst + "| Progression:" + HighestRiftProgress.ToString("f2"));
  221.                     }
  222.                     if (ShowSearchCircle)
  223.                     {
  224.                         CustCircleDecorator.Paint(layer, CheckableMonster, MCoordinate, null);
  225.                     }
  226.                     if (ShowLine)
  227.                     {
  228.                         CustLineBrush.DrawLineWorld(Hud.Game.Me.FloorCoordinate, MCoordinate);
  229.                     }
  230.                     if (ShowMonsterCircle)
  231.                     {
  232.                         CustMarkDecorator.Paint(layer, CheckableMonster, MCoordinate, null);
  233.                     }
  234.                 }
  235.                 return;
  236.             }
  237.         }
  238.     }
  239. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement