Advertisement
zerenx

THUD_NecromancerSkeletonIndicatorPlugin.cs

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