Advertisement
RNNCode

OtherClassMarkers

Nov 29th, 2020 (edited)
707
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 12.34 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System.Collections.Generic;
  3. using System;
  4. using System.Linq;
  5.  
  6. namespace Turbo.Plugins.RNN
  7. {
  8.     public class OtherClassMarkers : BasePlugin, ICustomizer, IInGameWorldPainter, INewAreaHandler
  9.     {
  10.         public Dictionary<HeroClass, int[] > HeroBrush { get; set; } = new Dictionary<HeroClass, int[]> ();
  11.  
  12.         private Dictionary<HeroClass, WorldDecoratorCollection> DecoratorbyClass { get; set; } = new Dictionary<HeroClass, WorldDecoratorCollection>();
  13.  
  14.         private Dictionary<uint, uint> HeroIdTexture { get; set; } = new Dictionary<uint, uint>();
  15.  
  16.         private Dictionary<ActorSnoEnum, uint> ActorSnoTexture { get; set; } = new Dictionary<ActorSnoEnum, uint>
  17.         {
  18.                 {(ActorSnoEnum) 75207, 3785199803}, {(ActorSnoEnum) 74706, 2939779782}, //dh
  19.                 {(ActorSnoEnum)  6544,   44435619}, {(ActorSnoEnum)  6526,  876580014}, //wiz
  20.                 {(ActorSnoEnum)  6485, 3925954876}, {(ActorSnoEnum)  6481, 1603231623}, //wd
  21.                 {(ActorSnoEnum)  3301, 3921484788}, {(ActorSnoEnum)  3285, 1030273087}, //barb
  22.                 {(ActorSnoEnum)  4721, 2227317895}, {(ActorSnoEnum)  4717, 2918463890}, //monk
  23.                 {(ActorSnoEnum)238284, 3742271755}, {(ActorSnoEnum)238286, 3435775766}, //crus
  24.                 {(ActorSnoEnum)454021, 3285997023}, {(ActorSnoEnum)454402,  473831658} //necro
  25.         };
  26.  
  27.         private int MyIndex { get; set; } = -1;
  28.  
  29.         private ITexture HeroTexture { get; set;}
  30.  
  31.         private IBrush SancBrushOther { get; set; }
  32.         private IBrush SancBrushMe { get; set; }
  33.         private IFont TextFont { get; set; }
  34.         private IBrush BrushShield { get; set; }
  35.         private IBrush BrushDead { get; set; }
  36.  
  37.         public bool NoGR {get; set;}
  38.  
  39.         public bool ShowInTown {get; set;}
  40.  
  41.         public bool MyCircle {get; set;}
  42.         public bool MyCircleColorOverride {get; set;}
  43.         public bool MyCircleCenter {get; set;}
  44.  
  45.         public bool CircleMapOthers {get; set;}
  46.         public bool CircleGroundOthers {get; set;}
  47.         public bool CircleGroundCenterOthers {get; set;}
  48.  
  49.         public bool SancIpOthers {get; set;}
  50.         public bool MySancIP  {get; set;}
  51.  
  52.         public float CircleGroundRadius {get; set;}
  53.  
  54.         public bool NamesGroundOthers {get; set;}
  55.         public bool NamesMapOthers {get; set;}
  56.  
  57.         public bool AvatarGroundOthers {get; set;}
  58.         public bool AvatarMapOthers {get; set;}
  59.  
  60.         public bool MyCircleImmune {get; set;} = true;          // Show other circle when I'm immune
  61.         public bool AvatarLeaderMapOthers {get; set;} = false;
  62.  
  63.         public OtherClassMarkers()
  64.         {
  65.             Enabled = true;
  66.         }
  67.  
  68.         public override void Load(IController hud)
  69.         {
  70.             base.Load(hud);
  71.             Order = 300950;
  72.  
  73.             ShowInTown = true;
  74.             NoGR = false;
  75.  
  76.             MyCircle = true;
  77.             MyCircleColorOverride = true;   // If true my color will always be white
  78.             MyCircleCenter = true;          // Circles Red&White For Me
  79.  
  80.             CircleMapOthers = true;
  81.             CircleGroundOthers = true;
  82.             CircleGroundRadius = 4f;        // Radius of the outer circle in the Ground. Assign positive values, or -1 to show the player's Hitbox
  83.             CircleGroundCenterOthers = true;
  84.  
  85.             MySancIP = true;        // To know if I have ip and if I am inside a sanctuary. Only if MyCircleCenter is true
  86.             SancIpOthers = false;   // To know if another player have ip && is inside a sanctuary
  87.  
  88.             NamesGroundOthers = true;
  89.             NamesMapOthers = true;
  90.  
  91.             AvatarGroundOthers = false;
  92.             AvatarMapOthers = true;
  93.  
  94.             AvatarLeaderMapOthers = true;   // Show frame for Leader on map (only if AvatarMapOthers = true)
  95.  
  96.             //HeroClass.Barbarian , HeroClass.Crusader , HeroClass.DemonHunter, HeroClass.Monk , HeroClass.WitchDoctor, HeroClass.Wizard, HeroClass.Necromancer
  97.             HeroBrush[HeroClass.Barbarian] =    new int[5] {255,237, 20, 20, 4};    // new int[5] { opacity , Red, Green , Blue ,  stroke }
  98.             HeroBrush[HeroClass.Crusader] =     new int[5] {255,255,204,  0, 4};
  99.             HeroBrush[HeroClass.DemonHunter] =  new int[5] {255,  0,168,255, 4};
  100.             HeroBrush[HeroClass.Monk] =         new int[5] {255, 35,225, 6, 4};
  101.             HeroBrush[HeroClass.WitchDoctor] =  new int[5] {255,255,132,  0, 4};
  102.             HeroBrush[HeroClass.Wizard] =       new int[5] {255, 220, 150,255, 4};
  103.             HeroBrush[HeroClass.Necromancer] =  new int[5] {255, 64,192,176, 4};
  104.             HeroBrush[HeroClass.None] =         new int[5] {255,255,255,255, 4};  // Color Override
  105.  
  106.             SancBrushOther = Hud.Render.CreateBrush(255, 255 , 255, 255, 3);
  107.             SancBrushMe = Hud.Render.CreateBrush(255, 64, 128, 255, 3);  //SancBrushMe = Hud.Render.CreateBrush(255, 0 , 255, 0, 3);  //64, 128, 255
  108.             TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, false, false, true);
  109.  
  110.             BrushShield = Hud.Render.CreateBrush(255, 255, 255, 255, 3f, SharpDX.Direct2D1.DashStyle.Dash);
  111.             BrushDead = Hud.Render.CreateBrush(255, 255, 100, 100, -1);
  112.  
  113.             IUiElement ui; string text;
  114.             for (var i = 0; i < 4; i++)
  115.             {
  116.                 text = "Root.NormalLayer.portraits.stack.party_stack.portrait_" + i + ".leaderIcon";
  117.                 ui = Hud.Render.GetUiElement(text);
  118.                 if (ui == null) Hud.Render.RegisterUiElement(text, ui, null);
  119.             }
  120.         }
  121.  
  122.         public void OnNewArea(bool newGame, ISnoArea area)
  123.         {
  124.             if (newGame || (MyIndex != Hud.Game.Me.Index) )
  125.             {
  126.                 MyIndex = Hud.Game.Me.Index;
  127.  
  128.                 if (!MyCircleColorOverride)
  129.                 {
  130.                     DecoratorbyClass[HeroClass.None].Decorators.Clear();
  131.                     int[] c = HeroBrush[Hud.Game.Me.HeroClassDefinition.HeroClass];
  132.                     addDecoratorbyClass(HeroClass.None, c[0],c[1],c[2],c[3],c[4]);
  133.                 }
  134.             }
  135.         }
  136.  
  137.         public void Customize()
  138.         {
  139.             Hud.TogglePlugin<OtherPlayersPlugin>(false);  // disables default plugin OtherPlayersPlugin
  140.             if (AvatarMapOthers) Hud.TogglePlugin<HeadStonePlugin>(false);  // disables default plugin HeadStonePlugin
  141.  
  142.             foreach (HeroClass heroClass in Enum.GetValues(typeof(HeroClass)))
  143.             {
  144.                 if ((uint)heroClass == (uint.MaxValue - 1)) continue;       //igual a if (heroClass == HeroClass.All) continue;  , pero de esta forma es también compatible con ros-bot
  145.                 DecoratorbyClass.Add( heroClass, new WorldDecoratorCollection() );
  146.                 int[] c =  HeroBrush[(heroClass == HeroClass.None && !MyCircleColorOverride)?Hud.Game.Me.HeroClassDefinition.HeroClass:heroClass];
  147.                 addDecoratorbyClass(heroClass, c[0],c[1],c[2],c[3],c[4]);
  148.             }
  149.         }
  150.  
  151.         public void addDecoratorbyClass(HeroClass hero, int o,int r,int g, int b, int t)
  152.         {
  153.             var groundLabelBackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0);
  154.  
  155.             if ((CircleGroundOthers && (hero != HeroClass.None)) || ( MyCircle && (hero == HeroClass.None)))
  156.                 DecoratorbyClass[hero].Decorators.Add(
  157.                     new GroundCircleDecorator(Hud)
  158.                     {
  159.                         Brush = Hud.Render.CreateBrush(o,r,g,b,t),
  160.                         Radius = CircleGroundRadius,
  161.                     }
  162.                 );
  163.             if  (hero != HeroClass.None)
  164.             {
  165.                 if (CircleMapOthers)
  166.                     DecoratorbyClass[hero].Decorators.Add(
  167.                     new MapShapeDecorator(Hud)
  168.                     {
  169.                         Brush = Hud.Render.CreateBrush(o,r,g,b,t),
  170.                         ShapePainter = new CircleShapePainter(Hud),
  171.                         Radius = 3f
  172.                     }
  173.                     );
  174.                 if (CircleGroundCenterOthers)
  175.                     DecoratorbyClass[hero].Decorators.Add(
  176.                     new GroundCircleDecorator(Hud)
  177.                     {
  178.                         Brush = Hud.Render.CreateBrush(o,r,g,b, 19),
  179.                         Radius = 0.6f,
  180.                     }
  181.                     );
  182.                 if (NamesMapOthers)
  183.                     DecoratorbyClass[hero].Decorators.Add(
  184.                         new MapLabelDecorator(Hud)
  185.                         {
  186.                             LabelFont = Hud.Render.CreateFont("tahoma", 6f, o,r,g,b, false, false, 128, 0, 0, 0, true),
  187.                             Up = false,
  188.                             RadiusOffset = 7f,
  189.                         }
  190.                     );
  191.                 if (NamesGroundOthers)
  192.                     DecoratorbyClass[hero].Decorators.Add(
  193.                         new GroundLabelDecorator(Hud)
  194.                         {
  195.                             BackgroundBrush = groundLabelBackgroundBrush,
  196.                             BorderBrush = Hud.Render.CreateBrush(o,r,g,b, 1),
  197.                             TextFont = Hud.Render.CreateFont("tahoma", 6f, o,r,g,b, false, false, 128, 0, 0, 0, true),
  198.                             OffsetY = (AvatarGroundOthers)? 23f:0f,
  199.                         }
  200.                     );
  201.             }
  202.             else if (MyCircleCenter)
  203.             {
  204.                 DecoratorbyClass[hero].Decorators.Add(
  205.                     new GroundCircleDecorator(Hud)
  206.                     {
  207.                         Brush = Hud.Render.CreateBrush(255, 255, 0, 0, 6.0f),
  208.                         Radius = 0.3f
  209.                     }
  210.                 );
  211.                 DecoratorbyClass[hero].Decorators.Add(
  212.                     new GroundCircleDecorator(Hud)
  213.                     {
  214.                         Brush = Hud.Render.CreateBrush(255,255,255, 255, 4.0f),
  215.                         Radius = 0.7f
  216.                     }
  217.                 );
  218.             }
  219.         }
  220.  
  221.         public void PaintWorld(WorldLayer layer)
  222.         {
  223.             if (layer != WorldLayer.Ground) return;
  224.             if (!Hud.Game.IsInGame) return;
  225.             if (NoGR && Hud.Game.Me.InGreaterRiftRank > 0) return;
  226.             if (Hud.Game.IsInTown && !ShowInTown) return;
  227.  
  228.             var players = Hud.Game.Players.Where(p => p.CoordinateKnown);
  229.             foreach (var pl in players)
  230.             {
  231.                 if ( (Hud.Game.Me.SnoArea.Sno != pl.SnoArea.Sno) && ((Hud.Game.Me.SnoArea.HostAreaSno == 288482) || (Hud.Game.Me.SnoArea.Sno == 288482)) ) continue;
  232.                 if ( Hud.Game.Me.IsInTown ^ pl.IsInTown) continue;
  233.  
  234.                 if (DecoratorbyClass.TryGetValue(pl.IsMe?HeroClass.None:pl.HeroClassDefinition.HeroClass, out var decorator))
  235.                 {
  236.                     decorator.Paint(layer, pl, pl.FloorCoordinate, pl.BattleTagAbovePortrait /*"Player" + pl.Index*/);
  237.                     decorator.Paint(WorldLayer.Map, pl, pl.FloorCoordinate, pl.BattleTagAbovePortrait /*"Player" + pl.Index*/);
  238.                 }
  239.  
  240.                 if (pl.IsMe)
  241.                 {
  242.                     if (MySancIP && MyCircleCenter)
  243.                     {
  244.                         if (pl.Powers.BuffIsActive(317076, 1)) { SancBrushMe.DrawEllipse(pl.FloorCoordinate.ToScreenCoordinate().X  , pl.FloorCoordinate.ToScreenCoordinate().Y , 14, 10);  }
  245.                         if (pl.Powers.BuffIsActive(79528))
  246.                         {
  247.                             var l = TextFont.GetTextLayout("Ip");
  248.                             TextFont.DrawText(l,pl. FloorCoordinate.ToScreenCoordinate().X - l.Metrics.Width / 2 ,pl.FloorCoordinate.ToScreenCoordinate().Y - l.Metrics.Height / 2);
  249.                         }
  250.                     }
  251.                     if (MyCircleImmune)
  252.                     {
  253.                         if (pl.Powers.BuffIsActive(266254) || pl.Powers.BuffIsActive(439438) || pl.Powers.BuffIsActive(224639) || pl.Powers.BuffIsActive(30290) || pl.Powers.BuffIsActive(96215))
  254.                         {   // Shield, TP, Ghost , buff , Serenity
  255.                             BrushShield.DrawWorldEllipse(1.4f, -1, pl.FloorCoordinate);
  256.                         }
  257.                     }
  258.                 }
  259.                 else
  260.                 {
  261.                     if (!HeroIdTexture.TryGetValue(pl.HeroId, out var TextureSno))
  262.                     {
  263.                         if (pl.HasValidActor)
  264.                         {
  265.                             TextureSno = ActorSnoTexture[pl.SnoActor.Sno];
  266.                             HeroIdTexture.Add(pl.HeroId,TextureSno);
  267.                         }
  268.                         else { TextureSno = ActorSnoTexture[pl.HeroClassDefinition.MaleActorSno]; }
  269.                     }
  270.                     HeroTexture = Hud.Texture.GetTexture(TextureSno);
  271.  
  272.                     if (AvatarMapOthers)
  273.                     {
  274.                         Hud.Render.GetMinimapCoordinates(pl.FloorCoordinate.X, pl.FloorCoordinate.Y, out float mapX, out float mapY);
  275.                         float PlayersHeadOpacity = Hud.Game.AliveMonsters.Any(m => m.Rarity != ActorRarity.Normal && m.SummonerAcdDynamicId == 0 && (m.FloorCoordinate.XYDistanceTo(pl.FloorCoordinate) < 25))? 0.20f: 1.0f;
  276.                         HeroTexture.Draw(mapX - HeroTexture.Width / 20, mapY - HeroTexture.Height / 17, HeroTexture.Width / 10 , HeroTexture.Height / 10, PlayersHeadOpacity);
  277.  
  278.                         if (pl.IsDeadSafeCheck)
  279.                         {
  280.                             BrushDead.DrawEllipse(mapX, mapY - HeroTexture.Height / 100, HeroTexture.Width/ 25, HeroTexture.Width/ 20);
  281.                             BrushDead.DrawLine(mapX - HeroTexture.Width / 25, mapY - HeroTexture.Height / 100, mapX + HeroTexture.Width / 25, mapY - HeroTexture.Height / 100);
  282.                             BrushDead.DrawLine(mapX, mapY - HeroTexture.Height / 20 , mapX , mapY + HeroTexture.Height / 30);
  283.                         }
  284.  
  285.                         if (AvatarLeaderMapOthers && Hud.Render.GetUiElement("Root.NormalLayer.portraits.stack.party_stack.portrait_" + pl.PortraitIndex + ".leaderIcon").Visible)
  286.                             Hud.Texture.BuffFrameTexture.Draw(mapX - HeroTexture.Width / 20, mapY - HeroTexture.Height / 16, HeroTexture.Width / 10 , HeroTexture.Height / 10, 1.0f);
  287.                     }
  288.                     if (pl.IsOnScreen)
  289.                     {
  290.                         if (AvatarGroundOthers)
  291.                             HeroTexture.Draw(pl.FloorCoordinate.ToScreenCoordinate().X - HeroTexture.Width/15, pl.FloorCoordinate.ToScreenCoordinate().Y - HeroTexture.Height/13, HeroTexture.Width/7.5f, HeroTexture.Height/7.5f, 1f);
  292.  
  293.                         if (SancIpOthers)
  294.                         {
  295.                             if (pl.Powers.BuffIsActive(317076, 1))  SancBrushOther.DrawEllipse(pl.FloorCoordinate.ToScreenCoordinate().X  , pl.FloorCoordinate.ToScreenCoordinate().Y , 20, 16);
  296.                             if (pl.Powers.BuffIsActive(79528))
  297.                             {
  298.                                 var l = TextFont.GetTextLayout("Ip");
  299.                                 TextFont.DrawText(l,pl. FloorCoordinate.ToScreenCoordinate().X - l.Metrics.Width / 2 ,pl.FloorCoordinate.ToScreenCoordinate().Y );
  300.                             }
  301.                         }
  302.                     }
  303.                 }
  304.             }
  305.         }
  306.     }
  307. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement