Advertisement
Guest User

NecromancerSkeletonIndicatorPlugin

a guest
Feb 28th, 2019
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 11.80 KB | None | 0 0
  1. // https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-community-plugins/631248-v7-3-english-zx-necromancerskeletonindicatorplugin.html
  2.  
  3. namespace Turbo.Plugins.ZX
  4. {
  5.     using Turbo.Plugins.Default;
  6.     using System.Linq;
  7.     using System.Text;
  8.     using System.Collections.Generic;
  9.  
  10.     public class NecromancerSkeletonIndicatorPlugin : BasePlugin, IInGameWorldPainter, IInGameTopPainter
  11.     {
  12.         public WorldDecoratorCollection CommandSkeletonDecorator, SkeletonMageDecorator;
  13.         public TopLabelDecorator CommandSkeletonCountLabel, SkeletonMageCountLabel, CombinedSkeletonCountLabel;
  14.         public string CommandSkeletonLabel, SkeletonMageLabel;
  15.         public int CommandSkeletonCount, SkeletonMageCount;
  16.         public float barW, barH, barX, barY, cmb_barW, cmb_barH, cmb_barX, cmb_barY;
  17.         public bool CommandSkeletonEnabled, SkeletonMageEnabled, CombinedCountEnabled;
  18.  
  19.         private static uint CommandSkeletonSkillSNO = 453801;
  20.         public HashSet<ActorSnoEnum> CommandSkeletonActorSNOs = new HashSet<ActorSnoEnum>
  21.         {
  22.             ActorSnoEnum._p6_necro_commandskeletons_a, // 473147, // CommandSkeleton - No Rune
  23.             ActorSnoEnum._p6_necro_commandskeletons_b, // 473420, // CommandSkeleton - Dark Mending
  24.             ActorSnoEnum._p6_necro_commandskeletons_c, // 473426, // CommandSkeleton - Frenzy
  25.             ActorSnoEnum._p6_necro_commandskeletons_d, // 473418  // CommandSkeleton - Kill Command
  26.             ActorSnoEnum._p6_necro_commandskeletons_e, // 473428, // CommandSkeleton - Enforcer
  27.             ActorSnoEnum._p6_necro_commandskeletons_f  // 473417, // CommandSkeleton - Freezing Grasp
  28.  
  29.         };
  30.  
  31.         private static uint SkeletonMageSkillSNO = 462089;
  32.         public HashSet<ActorSnoEnum> SkeletonMageActorSNOs = new HashSet<ActorSnoEnum>
  33.         {
  34.             ActorSnoEnum._p6_necro_skeletonmage_a, // 472275, // Skeleton Mage - No Rune
  35.             ActorSnoEnum._p6_necro_skeletonmage_b, // 472588, // Skeleton Mage - Gift of Death
  36.             ActorSnoEnum._p6_necro_skeletonmage_c, // 472606, // Skeleton Mage - Singularity
  37.             ActorSnoEnum._p6_necro_skeletonmage_d, // 472715  // Skeleton Mage - Life Support
  38.             ActorSnoEnum._p6_necro_skeletonmage_e, // 472769, // Skeleton Mage - Contamination
  39.             ActorSnoEnum._p6_necro_skeletonmage_f_archer // 472801, // Skeleton Mage - Archer
  40.         };
  41.  
  42.  
  43.         public NecromancerSkeletonIndicatorPlugin()
  44.         {
  45.             Enabled = true;
  46.  
  47.             // Modify this to make the count combined
  48.             CombinedCountEnabled = false;
  49.  
  50.             // Enable both indicator or disable the indicator a specific skill
  51.             CommandSkeletonEnabled = true;
  52.             SkeletonMageEnabled = true;
  53.  
  54.             // Inits variables
  55.             CommandSkeletonCount = 0;
  56.             SkeletonMageCount = 0;
  57.             CommandSkeletonLabel = "";
  58.             SkeletonMageLabel = "";
  59.         }
  60.  
  61.         public override void Load(IController hud)
  62.         {
  63.             base.Load(hud);
  64.  
  65.             // Unlike the old XML system where it draws x,y,w,h in terms of percentage of screen size, the new plugin uses actual pixel coordinates
  66.             // To convert x,y,w,h sizes from the XML system to the new plugin system, multiply the screensize with percentage. ie. XML size of 2 => 0.02f * screensize
  67.  
  68.             // Display coordinated for non-combined indicators
  69.             barW = Hud.Window.Size.Width * 0.012f;
  70.             barH = Hud.Window.Size.Height * 0.0175f;
  71.             barX = Hud.Window.Size.Width * 0.475f;
  72.             barY = Hud.Window.Size.Height * 0.36f;
  73.  
  74.             // Display coordinated for combined indicators
  75.             cmb_barW = Hud.Window.Size.Width * 0.0175f;
  76.             cmb_barH = Hud.Window.Size.Height * 0.0175f;
  77.             cmb_barX = (Hud.Window.Size.Width * 0.5f) - (cmb_barW * 0.5f);
  78.             cmb_barY = Hud.Window.Size.Height * 0.33f;
  79.  
  80.             // Decorator under each sekeleton melee
  81.             CommandSkeletonDecorator = new WorldDecoratorCollection(
  82.                 new GroundCircleDecorator(Hud)
  83.                 {
  84.                     Brush = Hud.Render.CreateBrush(240, 50, 200, 0, 1),
  85.                     Radius = 0.5f,
  86.                 },
  87.                 new GroundLabelDecorator(Hud)
  88.                 {
  89.                     BackgroundBrush = Hud.Render.CreateBrush(220, 200, 200, 0, 0),
  90.                     TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, true, false, false)
  91.                 },
  92.                 new MapShapeDecorator(Hud)
  93.                 {
  94.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  95.                     Brush = Hud.Render.CreateBrush(220, 200, 200, 0, 0),
  96.                     Radius = 0f,
  97.                     RadiusTransformator = new StandardPingRadiusTransformator(Hud, 250)
  98.                 }
  99.             );
  100.  
  101.             // Decorator under each sekeleton mages
  102.             SkeletonMageDecorator = new WorldDecoratorCollection(
  103.                 new GroundCircleDecorator(Hud)
  104.                 {
  105.                     Brush = Hud.Render.CreateBrush(240, 200, 50, 0, 1),
  106.                     Radius = 0.5f,
  107.                 },
  108.                 new GroundLabelDecorator(Hud)
  109.                 {
  110.                     BackgroundBrush = Hud.Render.CreateBrush(220, 200, 200, 0, 0),
  111.                     TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 255, 255, true, false, false)
  112.                 },
  113.                 new MapShapeDecorator(Hud)
  114.                 {
  115.                     ShapePainter = new RotatingTriangleShapePainter(Hud),
  116.                     Brush = Hud.Render.CreateBrush(220, 200, 200, 0, 0),
  117.                     Radius = 0f,
  118.                     RadiusTransformator = new StandardPingRadiusTransformator(Hud, 250)
  119.                 }
  120.             );
  121.  
  122.             // Label Decorator for non-combined indicator
  123.             CommandSkeletonCountLabel = new TopLabelDecorator(Hud)
  124.             {
  125.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 240, 0, false, false, false),
  126.                 BackgroundTexture1 = Hud.Texture.Button2TextureBrown,
  127.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  128.                 BackgroundTextureOpacity2 = 0.25f
  129.             };
  130.             SkeletonMageCountLabel = new TopLabelDecorator(Hud)
  131.             {
  132.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 240, 0, false, false, false),
  133.                 BackgroundTexture1 = Hud.Texture.Button2TextureBrown,
  134.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  135.                 BackgroundTextureOpacity2 = 0.25f
  136.             };
  137.  
  138.             // Label Decorator for combined indicator
  139.             CombinedSkeletonCountLabel = new TopLabelDecorator(Hud)
  140.             {
  141.                 TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 255, 240, 0, false, false, false),
  142.                 BackgroundTexture1 = Hud.Texture.Button2TextureBrown,
  143.                 BackgroundTexture2 = Hud.Texture.BackgroundTextureOrange,
  144.                 BackgroundTextureOpacity2 = 0.25f
  145.             };
  146.         }
  147.  
  148.         public void PaintWorld(WorldLayer layer)
  149.         {
  150.             // Don't draw if not playing a Necromancer; don't draw if is in town
  151.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer || Hud.Game.IsInTown) return;
  152.  
  153.             // For Skeleton Melee, only when equipping the skill
  154.             if (CommandSkeletonEnabled && Hud.Game.Me.Powers.UsedSkills.Where(x => x.SnoPower.Sno == CommandSkeletonSkillSNO) != null)
  155.             {
  156.                 // Iterate all the game actors, find out and count which are skeleton melees summoned by player
  157.                 var CommandSkeletonActors = Hud.Game.Actors.Where(EachActor => CommandSkeletonActorSNOs.Contains(EachActor.SnoActor.Sno) && // Find out which are skeleton melees actors
  158.                                             EachActor.SummonerAcdDynamicId == Hud.Game.Me.SummonerId); // Then find out if they are summoned by the player
  159.                 CommandSkeletonCount = CommandSkeletonActors.Count(); // And then count how many are found
  160.  
  161.                 // Paint circle decorator under each skeleton melee
  162.                 foreach (var EachActor in CommandSkeletonActors)
  163.                 {
  164.                     var text = string.IsNullOrWhiteSpace(CommandSkeletonLabel) ? EachActor.SnoActor.NameLocalized : CommandSkeletonLabel;
  165.                     CommandSkeletonDecorator.Paint(layer, EachActor, EachActor.FloorCoordinate, text);
  166.                 }
  167.             }
  168.             else
  169.             {
  170.                 CommandSkeletonCount = 0;
  171.             }
  172.  
  173.             // For Skeleton Mages, only when equipping the skill
  174.             if (SkeletonMageEnabled && Hud.Game.Me.Powers.UsedSkills.Where(x => x.SnoPower.Sno == SkeletonMageSkillSNO) != null)
  175.             {
  176.                 // Iterate all the game actors, find out and count which are skeleton mages summoned by player
  177.                 var SkeletonMageActors = Hud.Game.Actors.Where(EachActor => SkeletonMageActorSNOs.Contains(EachActor.SnoActor.Sno) && // Find out which are skeleton mages actors
  178.                                          EachActor.SummonerAcdDynamicId == Hud.Game.Me.SummonerId); // Then find out if they are summoned by the player
  179.                 SkeletonMageCount = SkeletonMageActors.Count(); // And then count how many are found
  180.  
  181.                 // Paint circle decorator under each skeleton melee
  182.                 foreach (var EachActor in SkeletonMageActors)
  183.                 {
  184.                     var text = string.IsNullOrWhiteSpace(SkeletonMageLabel) ? EachActor.SnoActor.NameLocalized : SkeletonMageLabel;
  185.                     SkeletonMageDecorator.Paint(layer, EachActor, EachActor.FloorCoordinate, text);
  186.                 }
  187.             }
  188.             else
  189.             {
  190.                 SkeletonMageCount = 0;
  191.             }
  192.         }
  193.  
  194.         public void PaintTopInGame(ClipState clipState)
  195.         {
  196.             // Don't draw if not playing a Necromancer; don't draw if is in town
  197.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer || Hud.Game.IsInTown) return;
  198.             if (clipState != ClipState.BeforeClip) return;
  199.  
  200.  
  201.             if (CombinedCountEnabled)
  202.             {
  203.                 // Drawing for combined count indicator
  204.                 string CommandSkeletonCountText = (CommandSkeletonEnabled && CommandSkeletonCount != 0) ? CommandSkeletonCount.ToString() : "";
  205.                 string SkeletonMageCountText = (SkeletonMageEnabled && SkeletonMageCount != 0) ? SkeletonMageCount.ToString() : "";
  206.                 string ConcatText = (CommandSkeletonCountText != "" && SkeletonMageCountText != "") ? CommandSkeletonCountText + "+" + SkeletonMageCountText : CommandSkeletonCountText + SkeletonMageCountText;
  207.  
  208.                 if (ConcatText != "")
  209.                 {
  210.                     CombinedSkeletonCountLabel.TextFunc = () => ConcatText.ToString();
  211.                     CombinedSkeletonCountLabel.Paint(cmb_barX, cmb_barY, cmb_barW, cmb_barH, HorizontalAlign.Center);
  212.                 }
  213.             }
  214.             else
  215.             {
  216.                 // Drawing for non-combined count indicator
  217.                 if (CommandSkeletonEnabled && CommandSkeletonCount != 0)
  218.                 {
  219.                     CommandSkeletonCountLabel.TextFunc = () => CommandSkeletonCount.ToString();
  220.                     CommandSkeletonCountLabel.Paint(barX, barY, barW, barH, HorizontalAlign.Center);
  221.                 }
  222.  
  223.                 if (SkeletonMageEnabled && SkeletonMageCount != 0)
  224.                 {
  225.                     SkeletonMageCountLabel.TextFunc = () => SkeletonMageCount.ToString();
  226.                     SkeletonMageCountLabel.Paint(Hud.Window.Size.Width - barX - barW, barY, barW, barH, HorizontalAlign.Center);
  227.                 }
  228.             }
  229.         }
  230.     }
  231. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement