Advertisement
JackCeparou

EliteDangerousAffixMinimapPlugin (Z)

Feb 10th, 2017
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.95 KB | None | 0 0
  1. namespace Turbo.Plugins.Zzz
  2. {
  3.     // all credits to Z : http://turbohud.freeforums.net/user/788
  4.     // rewritten to new 17.2.9.0 api as requested : http://turbohud.freeforums.net/thread/3833/request-juggernault-affixes-mini-map
  5.  
  6.     using System.Collections.Generic;
  7.     using System.Linq;
  8.     using Turbo.Plugins.Default;
  9.  
  10.     public class EliteDangerousAffixMinimapPlugin : BasePlugin
  11.     {
  12.         public WorldDecoratorCollection
  13.             EliteLeaderDecorator,
  14.             EliteLeaderDecorator_Dangerous,
  15.             EliteChampionDecorator,
  16.             EliteChampionDecorator_Dangerous;
  17.         // public List<MonsterAffix> DangerousAffix { get; set; }
  18.  
  19.         public class customDict : Dictionary<MonsterAffix, string>
  20.         {
  21.             public new void Add(MonsterAffix inpMonsterAffix, string inpString = "")
  22.             {
  23.                 base.Add(inpMonsterAffix, inpString);
  24.             }
  25.         }
  26.  
  27.         public customDict DangerousAffix { get; set; }
  28.         public bool MinimapLabelEnabled { get; set; }
  29.  
  30.         public EliteDangerousAffixMinimapPlugin()
  31.         {
  32.             Enabled = true;
  33.             MinimapLabelEnabled = true;
  34.             DangerousAffix = new customDict();
  35.         }
  36.  
  37.         public override void Load(IController hud)
  38.         {
  39.             base.Load(hud);
  40.  
  41.             IBrush shadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1);
  42.             IBrush DangerousMapLabelBrush = Hud.Render.CreateBrush(220, 255, 0, 0, 0);
  43.             IFont DangerousLabelFont = Hud.Render.CreateFont("tahoma", 10f, 200, 255, 255, 0, false, false, 128, 0, 0, 0, true);
  44.             IRadiusTransformator DangerousPingSpeed = new StandardPingRadiusTransformator(Hud, 500);
  45.  
  46.             // Yellow Leader
  47.             EliteLeaderDecorator = new WorldDecoratorCollection(
  48.                 new MapShapeDecorator(Hud)
  49.                 {
  50.                     Brush = Hud.Render.CreateBrush(180, 255, 148, 20, 0),
  51.                     ShadowBrush = shadowBrush,
  52.                     Radius = 10,
  53.                     ShapePainter = new CircleShapePainter(Hud)
  54.                 }
  55.             );
  56.             EliteLeaderDecorator_Dangerous = new WorldDecoratorCollection(
  57.                 new MapShapeDecorator(Hud)
  58.                 {
  59.                     Brush = DangerousMapLabelBrush,
  60.                     ShadowBrush = shadowBrush,
  61.                     Radius = 10,
  62.                     ShapePainter = new CircleShapePainter(Hud),
  63.                     RadiusTransformator = DangerousPingSpeed
  64.                 },
  65.                 new MapLabelDecorator(Hud)
  66.                 {
  67.                     LabelFont = DangerousLabelFont,
  68.                 }
  69.             );
  70.  
  71.             // Blue
  72.             EliteChampionDecorator = new WorldDecoratorCollection(
  73.                 new MapShapeDecorator(Hud)
  74.                 {
  75.                     Brush = Hud.Render.CreateBrush(180, 64, 128, 255, 0),
  76.                     ShadowBrush = shadowBrush,
  77.                     Radius = 10,
  78.                     ShapePainter = new CircleShapePainter(Hud),
  79.                 }
  80.             );
  81.             EliteChampionDecorator_Dangerous = new WorldDecoratorCollection(
  82.                 new MapShapeDecorator(Hud)
  83.                 {
  84.                     Brush = DangerousMapLabelBrush,
  85.                     ShadowBrush = shadowBrush,
  86.                     Radius = 10,
  87.                     ShapePainter = new CircleShapePainter(Hud),
  88.                     RadiusTransformator = DangerousPingSpeed
  89.                 },
  90.                 new MapLabelDecorator(Hud)
  91.                 {
  92.                     LabelFont = DangerousLabelFont,
  93.                 }
  94.             );
  95.         }
  96.  
  97.         public override void Customize()
  98.         {
  99.             if (Enabled)
  100.             {
  101.                 // These are actually optional, set to false if you want only red  blip, set to true (or comment out) if you want the original yellow/blue blip underneath the red blip
  102.                 // Hud.GetPlugin<StandardMonsterPlugin>().EliteLeaderDecorator.Enabled = false;
  103.                 // Hud.GetPlugin<StandardMonsterPlugin>().EliteChampionDecorator.Enabled = false;
  104.  
  105.                 MinimapLabelEnabled = true;
  106.  
  107.                 DangerousAffix.Add(MonsterAffix.Juggernaut, "JuG");
  108.                 DangerousAffix.Add(MonsterAffix.Illusionist, "Ill");
  109.                 DangerousAffix.Add(MonsterAffix.Reflect, "RD");
  110.                 DangerousAffix.Add(MonsterAffix.Poison, "P");
  111.                 DangerousAffix.Add(MonsterAffix.Arcane, "Ar");
  112.                 DangerousAffix.Add(MonsterAffix.Shielding, "Shd");
  113.  
  114.                 // additional examples
  115.                 DangerousAffix.Add(MonsterAffix.Molten, "Molt");
  116.                 DangerousAffix.Add(MonsterAffix.Desecrator, "Des");
  117.                 DangerousAffix.Add(MonsterAffix.Wormhole, "Worm");
  118.                 // DangerousAffix.Add(MonsterAffix.Waller); // no string defined means it's empty, will not write anything to minimap
  119.                 // DangerousAffix.Add(MonsterAffix.Desecrator, Hud.Collections.GetMonsterAffixName(MonsterAffix.Desecrator)); // get from the default name
  120.                 // DangerousAffix.Add(MonsterAffix.Frozen, Hud.GetPlugin<z_EliteMonsterAffixPluginModified>().CustomAffixNames[MonsterAffix.Frozen]); // get from the default customaffixname, it has to be enabled! or it will throw an exception
  121.             }
  122.         }
  123.  
  124.         public override void PaintWorld(WorldLayer layer)
  125.         {
  126.             var MonstersList = Hud.Game.AliveMonsters;
  127.  
  128.             foreach (var thisMonster in MonstersList)
  129.             {
  130.                 if (thisMonster.Rarity == ActorRarity.Rare || thisMonster.Rarity == ActorRarity.Champion)
  131.                 {
  132.                     var AffixText = "";
  133.                     var thisEliteDecorator = EliteLeaderDecorator;
  134.                     var Dangerous = false;
  135.                     /* // edit JackCeparou
  136.                     foreach (KeyValuePair<MonsterAffix, string> searchAffix in DangerousAffix)
  137.                     {
  138.                         if (thisMonster.HasAffix(searchAffix.Key))
  139.                         {
  140.                             if (MinimapLabelEnabled)
  141.                             {
  142.                                 AffixText += searchAffix.Value + " ";
  143.                             }
  144.                             Dangerous = true;
  145.                         }
  146.                     }/**/
  147.                     if (thisMonster.AffixSnoList.Any(a => DangerousAffix.ContainsKey(a.Affix)))
  148.                     {
  149.                         var affixes = thisMonster.AffixSnoList.Select(a => a.Affix).ToList();
  150.                         AffixText = string.Join(" ", DangerousAffix
  151.                             .Where(da => affixes.Contains(da.Key))
  152.                             .Select(da => da.Value));
  153.  
  154.                         Dangerous = true;
  155.                     } // end of edit JackCeparou
  156.  
  157.                     switch (thisMonster.Rarity)
  158.                     {
  159.                         case ActorRarity.Rare:
  160.                             if (Dangerous)
  161.                             {
  162.                                 thisEliteDecorator = EliteLeaderDecorator_Dangerous;
  163.                             }
  164.                             else
  165.                             {
  166.                                 thisEliteDecorator = EliteLeaderDecorator;
  167.                             }
  168.                             break;
  169.                         case ActorRarity.Champion:
  170.                             if (Dangerous)
  171.                             {
  172.                                 thisEliteDecorator = EliteChampionDecorator_Dangerous;
  173.                             }
  174.                             else
  175.                             {
  176.                                 thisEliteDecorator = EliteChampionDecorator;
  177.                             }
  178.                             break;
  179.                     }
  180.                     thisEliteDecorator.Paint(layer, thisMonster, thisMonster.FloorCoordinate, AffixText);
  181.                 }
  182.             }
  183.         }
  184.     }
  185. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement