Advertisement
s4000

DAV_EliteInfoPlugin

Aug 31st, 2019
4,729
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.32 KB | None | 0 0
  1. // combined of elite bar, elite circle, health bar on elite, elite line, Zei Circle for Boss
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using System.Globalization;
  6. using Turbo.Plugins.Default;
  7.  
  8. namespace Turbo.Plugins.DavMonster
  9. {
  10.     public class DAV_EliteInfoPlugin : BasePlugin, IInGameWorldPainter, ICustomizer {
  11.         public float XPos { get; set; }
  12.         public float YPos { get; set; }
  13.         public float offsetZ { get; set; } = 0f;
  14.         public bool showDebuff_CC { get; set; } = true;
  15.         public bool showCurse { get; set; } = true;
  16.         public WorldDecoratorCollection ZeiDecorator { get; set; }
  17.         public DAV_EliteInfo Elite_Boss { get; set; }
  18.         public DAV_EliteInfo Elite_Null { get; set; }
  19.         public DAV_EliteInfo Elite_Rare { get; set; }
  20.         public DAV_EliteInfo Elite_Judd { get; set; }
  21.         public Dictionary<int, DAV_EliteInfo> Elite_Blue { get; set; } = new Dictionary<int, DAV_EliteInfo>();
  22.         public Dictionary<string, IFont> Affix_Font { get; set; } = new Dictionary<string, IFont>();
  23.         public Dictionary<MonsterAffix, Tuple<int, string, string>> DisplayAffix { get; set; } = new Dictionary<MonsterAffix, Tuple<int, string, string>>();
  24.  
  25.         public DAV_EliteInfoPlugin() {
  26.             Enabled = true;
  27.             Order = 2005;
  28.         }
  29.  
  30.         public override void Load(IController hud) {
  31.             base.Load(hud);
  32.  
  33.             XPos = Hud.Window.Size.Width * 0.2f;
  34.             YPos = Hud.Window.Size.Height * 0.005f;
  35.  
  36.             //Colorization
  37.             Elite_Boss = new DAV_EliteInfo(Hud, 153, 51, 255);
  38.             Elite_Null = new DAV_EliteInfo(Hud, 178, 102, 255);
  39.             Elite_Rare = new DAV_EliteInfo(Hud, 255, 153, 51);
  40.             Elite_Judd = new DAV_EliteInfo(Hud, 255, 51, 51);
  41.             Elite_Blue.Add(1, new DAV_EliteInfo(Hud, 51, 153, 255));
  42.             Elite_Blue.Add(2, new DAV_EliteInfo(Hud, 0, 204, 0));
  43.             Elite_Blue.Add(3, new DAV_EliteInfo(Hud, 154, 205, 50));
  44.             Elite_Blue.Add(4, new DAV_EliteInfo(Hud, 255, 153, 204));
  45.             Elite_Blue.Add(5, new DAV_EliteInfo(Hud, 96, 96, 96));
  46.  
  47.             ZeiDecorator = new WorldDecoratorCollection(
  48.                 new GroundCircleDecorator(Hud) {
  49.                     Brush = Hud.Render.CreateBrush(255,192,96,0, 1),
  50.                     Radius = 50f
  51.                 }
  52.             );
  53.  
  54.             Affix_Font.Add("Normal", Hud.Render.CreateFont("arial", 6, 255, 240, 240, 240, false, false, true));
  55.             Affix_Font.Add("Lightning", Hud.Render.CreateFont("arial", 6, 255, 240, 240, 0, false, false, true));
  56.             Affix_Font.Add("Fire", Hud.Render.CreateFont("arial", 6, 255, 255, 70, 0, false, false, true));
  57.             Affix_Font.Add("Arcane", Hud.Render.CreateFont("arial", 6, 255, 140, 45, 225, false, false, true));
  58.             Affix_Font.Add("Cold", Hud.Render.CreateFont("arial", 6, 255, 0, 190, 255, false, false, true));
  59.             Affix_Font.Add("Poison", Hud.Render.CreateFont("arial", 6, 255, 128, 255, 0, false, false, true));
  60.             Affix_Font.Add("Danger", Hud.Render.CreateFont("arial", 6, 255, 255, 128, 0, false, false, true));
  61.  
  62.             DisplayAffix.Add(MonsterAffix.Wormhole, new Tuple<int, string, string>(1, "蟲洞", "Danger"));
  63.             DisplayAffix.Add(MonsterAffix.Juggernaut, new Tuple<int, string, string>(2, "強韌", "Danger"));
  64.             DisplayAffix.Add(MonsterAffix.Waller, new Tuple<int, string, string>(3, "築牆", "Danger"));
  65.             DisplayAffix.Add(MonsterAffix.Teleporter, new Tuple<int, string, string>(4, "傳送", "Danger"));
  66.             DisplayAffix.Add(MonsterAffix.Shielding, new Tuple<int, string, string>(5, "護盾", "Danger"));
  67.             DisplayAffix.Add(MonsterAffix.Illusionist, new Tuple<int, string, string>(6, "幻像", "Danger"));
  68.             DisplayAffix.Add(MonsterAffix.Electrified, new Tuple<int, string, string>(7, "帶電", "Lightning"));
  69.             DisplayAffix.Add(MonsterAffix.Orbiter, new Tuple<int, string, string>(8, "電球", "Lightning"));
  70.             DisplayAffix.Add(MonsterAffix.Thunderstorm, new Tuple<int, string, string>(9, "雷霆風暴", "Lightning"));
  71.             DisplayAffix.Add(MonsterAffix.FireChains, new Tuple<int, string, string>(10, "火鏈", "Fire"));
  72.             DisplayAffix.Add(MonsterAffix.Desecrator, new Tuple<int, string, string>(11, "褻瀆", "Fire"));
  73.             DisplayAffix.Add(MonsterAffix.Molten, new Tuple<int, string, string>(12, "熔火", "Fire"));
  74.             DisplayAffix.Add(MonsterAffix.Mortar, new Tuple<int, string, string>(13, "炮轟", "Fire"));
  75.             DisplayAffix.Add(MonsterAffix.FrozenPulse, new Tuple<int, string, string>(14, "冰凍衝擊", "Cold"));
  76.             DisplayAffix.Add(MonsterAffix.Frozen, new Tuple<int, string, string>(15, "凍結", "Cold"));
  77.             DisplayAffix.Add(MonsterAffix.Arcane, new Tuple<int, string, string>(16, "秘法", "Arcane"));
  78.             DisplayAffix.Add(MonsterAffix.Jailer, new Tuple<int, string, string>(17, "囚禁", "Arcane"));
  79.             DisplayAffix.Add(MonsterAffix.Plagued, new Tuple<int, string, string>(18, "瘟疫", "Poison"));
  80.             DisplayAffix.Add(MonsterAffix.Poison, new Tuple<int, string, string>(19, "毒素加持", "Poison"));
  81.             DisplayAffix.Add(MonsterAffix.Horde, new Tuple<int, string, string>(20, "族群", "Normal"));
  82.             DisplayAffix.Add(MonsterAffix.MissileDampening, new Tuple<int, string, string>(21, "投射抑制", "Normal"));
  83.             DisplayAffix.Add(MonsterAffix.ExtraHealth, new Tuple<int, string, string>(22, "強命", "Normal"));
  84.             DisplayAffix.Add(MonsterAffix.Fast, new Tuple<int, string, string>(23, "快速", "Normal"));
  85.             DisplayAffix.Add(MonsterAffix.Vampiric, new Tuple<int, string, string>(24, "吸血", "Normal"));
  86.             DisplayAffix.Add(MonsterAffix.Knockback, new Tuple<int, string, string>(25, "擊退", "Normal"));
  87.             DisplayAffix.Add(MonsterAffix.Nightmarish, new Tuple<int, string, string>(26, "夢魘", "Normal"));
  88.             DisplayAffix.Add(MonsterAffix.Vortex, new Tuple<int, string, string>(27, "漩渦", "Normal"));
  89.             DisplayAffix.Add(MonsterAffix.Avenger, new Tuple<int, string, string>(28, "復仇者", "Normal"));
  90.             DisplayAffix.Add(MonsterAffix.Reflect, new Tuple<int, string, string>(29, "傷害反彈", "Normal"));
  91.             DisplayAffix.Add(MonsterAffix.HealthLink, new Tuple<int, string, string>(30, "生命鏈接", "Normal"));
  92.         }
  93.  
  94.         public void PaintWorld(WorldLayer layer) {
  95.             var packs = Hud.Game.MonsterPacks.Where(x => x.MonstersAlive.Any()).OrderBy(m => m.IsFullChampionPack);
  96.             var bosses = Hud.Game.AliveMonsters.Where(m => (m.Rarity == ActorRarity.Boss || m.Rarity == ActorRarity.Unique) && m.SummonerAcdDynamicId == 0);
  97.             var nullpacks = Hud.Game.AliveMonsters.Where(m => (m.Rarity == ActorRarity.Champion || m.Rarity == ActorRarity.Rare) && m.SummonerAcdDynamicId == 0 && m.Pack == null);
  98.  
  99.             float yref = YPos;
  100.             foreach(IMonster m in bosses) {
  101.                 Elite_Boss.DrawInfo(layer, m, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
  102.                 yref += 0.2f;
  103.                 if (Hud.Game.Me.Powers.BuffIsActive(403468, 0))
  104.                     ZeiDecorator.Paint(layer, m, m.FloorCoordinate, null);
  105.             }
  106.  
  107.             foreach(IMonster nullpack in nullpacks) {
  108.                 if (nullpack.Rarity == ActorRarity.Rare)
  109.                     Elite_Rare.DrawInfo(layer, nullpack, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
  110.                 else Elite_Null.DrawInfo(layer, nullpack, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
  111.                 yref += 0.4f;
  112.             }
  113.  
  114.             var blueNum = 1;
  115.             foreach(IMonsterPack MonPack in packs){
  116.                 var monsters = MonPack.MonstersAlive.Where(m => m.Rarity != ActorRarity.RareMinion && m.SummonerAcdDynamicId == 0).OrderBy(p => p.CurHealth);
  117.                 if (monsters.Count() == 0) continue;
  118.  
  119.                 // Elite Affix
  120.                 var aff_x = XPos;
  121.                 float aff_h = 0f;
  122.                 var PackAffix = MonPack.AffixSnoList.ToList();
  123.                 PackAffix.Sort((a, b) => (DisplayAffix[a.Affix].Item1).CompareTo(DisplayAffix[b.Affix].Item1));
  124.  
  125.                 foreach(var affix in PackAffix) {
  126.                     var affixInfo = DisplayAffix[affix.Affix];
  127.                     var AffixFont = Affix_Font[affixInfo.Item3];
  128.                     var custname = AffixFont.GetTextLayout(affixInfo.Item2);
  129.                     AffixFont.DrawText(custname, aff_x, yref);
  130.                     aff_x += (float) custname.Metrics.Width + 5;
  131.                     aff_h = (float) custname.Metrics.Height;
  132.                 }
  133.                 yref += aff_h;
  134.  
  135.                 DAV_EliteInfo ColorInfo = null;
  136.                 if (MonPack.IsFullChampionPack) {
  137.                     ColorInfo = Elite_Blue[blueNum];
  138.  
  139.                     if (blueNum < Elite_Blue.Count)
  140.                         blueNum++;
  141.                 }
  142.                 else if (MonPack.AffixSnoList.Any(a => a.Affix == MonsterAffix.Juggernaut))
  143.                     ColorInfo = Elite_Judd;
  144.                 else
  145.                     ColorInfo = Elite_Rare;
  146.  
  147.                 foreach(var monster in monsters)
  148.                     ColorInfo.DrawInfo(layer, monster, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
  149.  
  150.                 yref += 0.2f;
  151.             }
  152.         }
  153.  
  154.         public void Customize() {
  155.             Hud.RunOnPlugin<StandardMonsterPlugin>(plugin => {
  156.                 plugin.EliteChampionDecorator.Enabled = false;
  157.                 plugin.EliteLeaderDecorator.Enabled = false;
  158.                 plugin.EliteMinionDecorator.Enabled = false;
  159.                 plugin.EliteUniqueDecorator.Enabled = false;
  160.                 plugin.KeywardenDecorator.Enabled = false;
  161.             });
  162.         }
  163.     }
  164.  
  165.     public class DAV_EliteInfo {
  166.         public bool Enabled { get; set; }
  167.         public IController Hud { get; set; }
  168.  
  169.         public float barH { get; set; }
  170.         public float barW { get; set; }
  171.         public float barHmon { get; set; }
  172.         public float barWmon { get; set; }
  173.         public float distance { get; set; }
  174.         public IBrush Brush_BG { get; set; }
  175.         public IBrush Brush_Border { get; set; }
  176.         public IBrush Brush_Health { get; set; }
  177.         public IBrush Brush_Line { get; set; }
  178.         public IBrush Brush_Invulnerable { get; set; }
  179.         public IFont Font_White { get; set; }
  180.         public IFont Font_Mon { get; set; }
  181.         public WorldDecoratorCollection EliteDecorator { get; set; }
  182.  
  183.         public DAV_EliteInfo(IController hud, int r, int g, int b, float Monsize = 3f, float dist = 45f) {
  184.             Enabled = true;
  185.             Hud = hud;
  186.  
  187.             barH = Hud.Window.Size.Height * 0.012f; //0.014f
  188.             barW = Hud.Window.Size.Width * 0.11f;
  189.             barHmon = barH * 1.6f; // 1.4f
  190.             barWmon = barW * 0.35f;
  191.             distance = dist;
  192.             Font_White = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, false, false, false); //255, 255, 255, 255, true);
  193.             Font_Mon = Hud.Render.CreateFont("tahoma", 8f, 200, 255, 255, 255, false, false, true);
  194.             Brush_BG = Hud.Render.CreateBrush(255, 125, 120, 120, 0);
  195.             Brush_Border = Hud.Render.CreateBrush(255, 255, 255, 255, -1);
  196.             Brush_Health = Hud.Render.CreateBrush(255, r, g, b, 0);
  197.             Brush_Line = Hud.Render.CreateBrush(153, r, g, b, -1);
  198.             Brush_Invulnerable = Hud.Render.CreateBrush(255, 255, 0, 0, 3);
  199.  
  200.             EliteDecorator = new WorldDecoratorCollection(
  201.                 new MapShapeDecorator(Hud) {
  202.                     Brush = Hud.Render.CreateBrush(180, r, g, b, 0),
  203.                     Radius = 8,
  204.                     ShapePainter = new CircleShapePainter(Hud)
  205.                 },
  206.                 new GroundCircleDecorator(Hud) {
  207.                     Brush = Hud.Render.CreateBrush(255, r, g, b, 6),
  208.                     Radius = Monsize
  209.                 },
  210.                 new GroundCircleDecorator(Hud) {
  211.                     Brush = Hud.Render.CreateBrush(255, 255, 255, 255, 1.5f),
  212.                     Radius = Monsize
  213.                 }
  214.             );
  215.         }
  216.  
  217.         private string Debuff(IMonster m, bool showDebuff) {
  218.             if (!showDebuff) return "";
  219.            
  220.             string textDebuff = null;
  221.             if (m.Locust) textDebuff += "Locust";
  222.             if (m.Haunted) textDebuff += (textDebuff == null ? "Haunt" : ", Haunt");
  223.             if (m.Palmed) textDebuff += (textDebuff == null ? "Palm" : ", Palm");
  224.             if (m.MarkedForDeath) textDebuff += (textDebuff == null ? "Mark" : ", Mark");
  225.             if (m.Strongarmed) textDebuff += (textDebuff == null ? "Strongarm" : ", Strongarm");
  226.            
  227.             string textCC = null;
  228.             if (m.Frozen) textCC += "Frozen";
  229.             if (m.Chilled) textCC += (textCC == null ? "Chill" : ", Chill");
  230.             if (m.Slow) textCC += (textCC == null ? "Slow" : ", Slow");
  231.             if (m.Stunned) textCC += (textCC == null ? "Stun" : ", Stun");
  232.             if (m.Invulnerable) textCC += (textCC == null ? "Invulnerable" : ", Invulnerable");
  233.             if (m.Blind) textCC += (textCC == null ? "Blind" : ", Blind");
  234.            
  235.             var output = "\t" + textDebuff + (textDebuff != null && textCC != null ? " | " : "") + textCC;
  236.             return output;
  237.         }
  238.        
  239.         private string Curse(IMonster m) {
  240.             string Curses = "";
  241.             if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471845) == 1) //471845 1 power: Frailty
  242.                 Curses += "F";
  243.             if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471869) == 1)  //471869 1 power: Leech
  244.                 Curses += (Curses == "" ? "L" : " L");
  245.             if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471738) == 1) //471738 1 power: Decrepify
  246.                 Curses += (Curses == "" ? "D" : " D");
  247.            
  248.             return Curses;
  249.         }
  250.        
  251.         public void DrawInfo(WorldLayer layer, IMonster monster, float Pos_X, ref float Pos_Y, float offset, bool showDebuff, bool showCurse){
  252.             EliteDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
  253.  
  254.             if (monster.CentralXyDistanceToMe >= distance)
  255.                 Brush_Line.DrawLineWorld(monster.FloorCoordinate, Hud.Game.Me.FloorCoordinate);
  256.  
  257.             var CurPercent = monster.CurHealth / monster.MaxHealth;
  258.             if (CurPercent < 0 || CurPercent > 1)
  259.                 CurPercent = 1;
  260.  
  261.             //Draw Rectangles
  262.             Brush_BG.DrawRectangle(Pos_X, Pos_Y, barW, barH);
  263.             Brush_Health.DrawRectangle(Pos_X, Pos_Y, (float) CurPercent * barW, barH);
  264.         //  Brush_Border.DrawRectangle(Pos_X, Pos_Y, barW, barH); // white border for bar on screen
  265.  
  266.             var name = Font_White.GetTextLayout(monster.SnoMonster.NameLocalized);
  267.             Font_White.DrawText(name, Pos_X + 3, Pos_Y + (barH - (float)name.Metrics.Height)/2);
  268.  
  269.             var HPtext = (CurPercent * 100).ToString("0.0") + "%";
  270.             var textLayout = Font_White.GetTextLayout(HPtext + Debuff(monster, showDebuff));
  271.             Font_White.DrawText(textLayout, Pos_X + barW + 4 , Pos_Y + (barH - (float)textLayout.Metrics.Height)/2);
  272.            
  273.             if (showCurse) {
  274.                 var curseInfo = Curse(monster);
  275.                 textLayout = Font_White.GetTextLayout(curseInfo);
  276.                 Font_White.DrawText(textLayout, Pos_X + barW - textLayout.Metrics.Width - 6, Pos_Y + (barH - (float)textLayout.Metrics.Height)/2);
  277.             }
  278.  
  279.             if (monster.IsOnScreen){
  280.                 var Mon_X = monster.FloorCoordinate.ToScreenCoordinate().X - barWmon / 2;
  281.                 var Mon_Y = monster.FloorCoordinate.ToScreenCoordinate().Y + barHmon + offset;
  282.  
  283.                 Brush_BG.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
  284.                 Brush_Health.DrawRectangle(Mon_X, Mon_Y, (float) CurPercent * barWmon, barHmon);
  285.                 if (monster.Invulnerable) Brush_Invulnerable.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
  286.                 else Brush_Border.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
  287.  
  288.                 var textLayout2 = Font_Mon.GetTextLayout(HPtext);
  289.                 Font_Mon.DrawText(HPtext, Mon_X + (barWmon - textLayout2.Metrics.Width)/2 , Mon_Y + (barHmon - textLayout2.Metrics.Height)/2);
  290.             }
  291.             else {
  292.                 var missing = Font_White.GetTextLayout("X");
  293.                 Font_White.DrawText(missing, Pos_X - 17, Pos_Y + (barH - missing.Metrics.Height)/2);
  294.             }
  295.  
  296.             Pos_Y += barH * 1.1f; // * 1.3f;
  297.         }
  298.     }
  299. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement