Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // combined of elite bar, elite circle, health bar on elite, elite line, Zei Circle for Boss
- using System;
- using System.Linq;
- using System.Collections.Generic;
- using System.Globalization;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.DavMonster
- {
- public class DAV_EliteInfoPlugin : BasePlugin, IInGameWorldPainter, ICustomizer {
- public float XPos { get; set; }
- public float YPos { get; set; }
- public float offsetZ { get; set; } = 0f;
- public bool showDebuff_CC { get; set; } = true;
- public bool showCurse { get; set; } = true;
- public WorldDecoratorCollection ZeiDecorator { get; set; }
- public DAV_EliteInfo Elite_Boss { get; set; }
- public DAV_EliteInfo Elite_Null { get; set; }
- public DAV_EliteInfo Elite_Rare { get; set; }
- public DAV_EliteInfo Elite_Judd { get; set; }
- public Dictionary<int, DAV_EliteInfo> Elite_Blue { get; set; } = new Dictionary<int, DAV_EliteInfo>();
- public Dictionary<string, IFont> Affix_Font { get; set; } = new Dictionary<string, IFont>();
- public Dictionary<MonsterAffix, Tuple<int, string, string>> DisplayAffix { get; set; } = new Dictionary<MonsterAffix, Tuple<int, string, string>>();
- public DAV_EliteInfoPlugin() {
- Enabled = true;
- Order = 2005;
- }
- public override void Load(IController hud) {
- base.Load(hud);
- XPos = Hud.Window.Size.Width * 0.2f;
- YPos = Hud.Window.Size.Height * 0.005f;
- //Colorization
- Elite_Boss = new DAV_EliteInfo(Hud, 153, 51, 255);
- Elite_Null = new DAV_EliteInfo(Hud, 178, 102, 255);
- Elite_Rare = new DAV_EliteInfo(Hud, 255, 153, 51);
- Elite_Judd = new DAV_EliteInfo(Hud, 255, 51, 51);
- Elite_Blue.Add(1, new DAV_EliteInfo(Hud, 51, 153, 255));
- Elite_Blue.Add(2, new DAV_EliteInfo(Hud, 0, 204, 0));
- Elite_Blue.Add(3, new DAV_EliteInfo(Hud, 154, 205, 50));
- Elite_Blue.Add(4, new DAV_EliteInfo(Hud, 255, 153, 204));
- Elite_Blue.Add(5, new DAV_EliteInfo(Hud, 96, 96, 96));
- ZeiDecorator = new WorldDecoratorCollection(
- new GroundCircleDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(255,192,96,0, 1),
- Radius = 50f
- }
- );
- Affix_Font.Add("Normal", Hud.Render.CreateFont("arial", 6, 255, 240, 240, 240, false, false, true));
- Affix_Font.Add("Lightning", Hud.Render.CreateFont("arial", 6, 255, 240, 240, 0, false, false, true));
- Affix_Font.Add("Fire", Hud.Render.CreateFont("arial", 6, 255, 255, 70, 0, false, false, true));
- Affix_Font.Add("Arcane", Hud.Render.CreateFont("arial", 6, 255, 140, 45, 225, false, false, true));
- Affix_Font.Add("Cold", Hud.Render.CreateFont("arial", 6, 255, 0, 190, 255, false, false, true));
- Affix_Font.Add("Poison", Hud.Render.CreateFont("arial", 6, 255, 128, 255, 0, false, false, true));
- Affix_Font.Add("Danger", Hud.Render.CreateFont("arial", 6, 255, 255, 128, 0, false, false, true));
- DisplayAffix.Add(MonsterAffix.Wormhole, new Tuple<int, string, string>(1, "蟲洞", "Danger"));
- DisplayAffix.Add(MonsterAffix.Juggernaut, new Tuple<int, string, string>(2, "強韌", "Danger"));
- DisplayAffix.Add(MonsterAffix.Waller, new Tuple<int, string, string>(3, "築牆", "Danger"));
- DisplayAffix.Add(MonsterAffix.Teleporter, new Tuple<int, string, string>(4, "傳送", "Danger"));
- DisplayAffix.Add(MonsterAffix.Shielding, new Tuple<int, string, string>(5, "護盾", "Danger"));
- DisplayAffix.Add(MonsterAffix.Illusionist, new Tuple<int, string, string>(6, "幻像", "Danger"));
- DisplayAffix.Add(MonsterAffix.Electrified, new Tuple<int, string, string>(7, "帶電", "Lightning"));
- DisplayAffix.Add(MonsterAffix.Orbiter, new Tuple<int, string, string>(8, "電球", "Lightning"));
- DisplayAffix.Add(MonsterAffix.Thunderstorm, new Tuple<int, string, string>(9, "雷霆風暴", "Lightning"));
- DisplayAffix.Add(MonsterAffix.FireChains, new Tuple<int, string, string>(10, "火鏈", "Fire"));
- DisplayAffix.Add(MonsterAffix.Desecrator, new Tuple<int, string, string>(11, "褻瀆", "Fire"));
- DisplayAffix.Add(MonsterAffix.Molten, new Tuple<int, string, string>(12, "熔火", "Fire"));
- DisplayAffix.Add(MonsterAffix.Mortar, new Tuple<int, string, string>(13, "炮轟", "Fire"));
- DisplayAffix.Add(MonsterAffix.FrozenPulse, new Tuple<int, string, string>(14, "冰凍衝擊", "Cold"));
- DisplayAffix.Add(MonsterAffix.Frozen, new Tuple<int, string, string>(15, "凍結", "Cold"));
- DisplayAffix.Add(MonsterAffix.Arcane, new Tuple<int, string, string>(16, "秘法", "Arcane"));
- DisplayAffix.Add(MonsterAffix.Jailer, new Tuple<int, string, string>(17, "囚禁", "Arcane"));
- DisplayAffix.Add(MonsterAffix.Plagued, new Tuple<int, string, string>(18, "瘟疫", "Poison"));
- DisplayAffix.Add(MonsterAffix.Poison, new Tuple<int, string, string>(19, "毒素加持", "Poison"));
- DisplayAffix.Add(MonsterAffix.Horde, new Tuple<int, string, string>(20, "族群", "Normal"));
- DisplayAffix.Add(MonsterAffix.MissileDampening, new Tuple<int, string, string>(21, "投射抑制", "Normal"));
- DisplayAffix.Add(MonsterAffix.ExtraHealth, new Tuple<int, string, string>(22, "強命", "Normal"));
- DisplayAffix.Add(MonsterAffix.Fast, new Tuple<int, string, string>(23, "快速", "Normal"));
- DisplayAffix.Add(MonsterAffix.Vampiric, new Tuple<int, string, string>(24, "吸血", "Normal"));
- DisplayAffix.Add(MonsterAffix.Knockback, new Tuple<int, string, string>(25, "擊退", "Normal"));
- DisplayAffix.Add(MonsterAffix.Nightmarish, new Tuple<int, string, string>(26, "夢魘", "Normal"));
- DisplayAffix.Add(MonsterAffix.Vortex, new Tuple<int, string, string>(27, "漩渦", "Normal"));
- DisplayAffix.Add(MonsterAffix.Avenger, new Tuple<int, string, string>(28, "復仇者", "Normal"));
- DisplayAffix.Add(MonsterAffix.Reflect, new Tuple<int, string, string>(29, "傷害反彈", "Normal"));
- DisplayAffix.Add(MonsterAffix.HealthLink, new Tuple<int, string, string>(30, "生命鏈接", "Normal"));
- }
- public void PaintWorld(WorldLayer layer) {
- var packs = Hud.Game.MonsterPacks.Where(x => x.MonstersAlive.Any()).OrderBy(m => m.IsFullChampionPack);
- var bosses = Hud.Game.AliveMonsters.Where(m => (m.Rarity == ActorRarity.Boss || m.Rarity == ActorRarity.Unique) && m.SummonerAcdDynamicId == 0);
- var nullpacks = Hud.Game.AliveMonsters.Where(m => (m.Rarity == ActorRarity.Champion || m.Rarity == ActorRarity.Rare) && m.SummonerAcdDynamicId == 0 && m.Pack == null);
- float yref = YPos;
- foreach(IMonster m in bosses) {
- Elite_Boss.DrawInfo(layer, m, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
- yref += 0.2f;
- if (Hud.Game.Me.Powers.BuffIsActive(403468, 0))
- ZeiDecorator.Paint(layer, m, m.FloorCoordinate, null);
- }
- foreach(IMonster nullpack in nullpacks) {
- if (nullpack.Rarity == ActorRarity.Rare)
- Elite_Rare.DrawInfo(layer, nullpack, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
- else Elite_Null.DrawInfo(layer, nullpack, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
- yref += 0.4f;
- }
- var blueNum = 1;
- foreach(IMonsterPack MonPack in packs){
- var monsters = MonPack.MonstersAlive.Where(m => m.Rarity != ActorRarity.RareMinion && m.SummonerAcdDynamicId == 0).OrderBy(p => p.CurHealth);
- if (monsters.Count() == 0) continue;
- // Elite Affix
- var aff_x = XPos;
- float aff_h = 0f;
- var PackAffix = MonPack.AffixSnoList.ToList();
- PackAffix.Sort((a, b) => (DisplayAffix[a.Affix].Item1).CompareTo(DisplayAffix[b.Affix].Item1));
- foreach(var affix in PackAffix) {
- var affixInfo = DisplayAffix[affix.Affix];
- var AffixFont = Affix_Font[affixInfo.Item3];
- var custname = AffixFont.GetTextLayout(affixInfo.Item2);
- AffixFont.DrawText(custname, aff_x, yref);
- aff_x += (float) custname.Metrics.Width + 5;
- aff_h = (float) custname.Metrics.Height;
- }
- yref += aff_h;
- DAV_EliteInfo ColorInfo = null;
- if (MonPack.IsFullChampionPack) {
- ColorInfo = Elite_Blue[blueNum];
- if (blueNum < Elite_Blue.Count)
- blueNum++;
- }
- else if (MonPack.AffixSnoList.Any(a => a.Affix == MonsterAffix.Juggernaut))
- ColorInfo = Elite_Judd;
- else
- ColorInfo = Elite_Rare;
- foreach(var monster in monsters)
- ColorInfo.DrawInfo(layer, monster, XPos, ref yref, offsetZ, showDebuff_CC, showCurse);
- yref += 0.2f;
- }
- }
- public void Customize() {
- Hud.RunOnPlugin<StandardMonsterPlugin>(plugin => {
- plugin.EliteChampionDecorator.Enabled = false;
- plugin.EliteLeaderDecorator.Enabled = false;
- plugin.EliteMinionDecorator.Enabled = false;
- plugin.EliteUniqueDecorator.Enabled = false;
- plugin.KeywardenDecorator.Enabled = false;
- });
- }
- }
- public class DAV_EliteInfo {
- public bool Enabled { get; set; }
- public IController Hud { get; set; }
- public float barH { get; set; }
- public float barW { get; set; }
- public float barHmon { get; set; }
- public float barWmon { get; set; }
- public float distance { get; set; }
- public IBrush Brush_BG { get; set; }
- public IBrush Brush_Border { get; set; }
- public IBrush Brush_Health { get; set; }
- public IBrush Brush_Line { get; set; }
- public IBrush Brush_Invulnerable { get; set; }
- public IFont Font_White { get; set; }
- public IFont Font_Mon { get; set; }
- public WorldDecoratorCollection EliteDecorator { get; set; }
- public DAV_EliteInfo(IController hud, int r, int g, int b, float Monsize = 3f, float dist = 45f) {
- Enabled = true;
- Hud = hud;
- barH = Hud.Window.Size.Height * 0.012f; //0.014f
- barW = Hud.Window.Size.Width * 0.11f;
- barHmon = barH * 1.6f; // 1.4f
- barWmon = barW * 0.35f;
- distance = dist;
- Font_White = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, false, false, false); //255, 255, 255, 255, true);
- Font_Mon = Hud.Render.CreateFont("tahoma", 8f, 200, 255, 255, 255, false, false, true);
- Brush_BG = Hud.Render.CreateBrush(255, 125, 120, 120, 0);
- Brush_Border = Hud.Render.CreateBrush(255, 255, 255, 255, -1);
- Brush_Health = Hud.Render.CreateBrush(255, r, g, b, 0);
- Brush_Line = Hud.Render.CreateBrush(153, r, g, b, -1);
- Brush_Invulnerable = Hud.Render.CreateBrush(255, 255, 0, 0, 3);
- EliteDecorator = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(180, r, g, b, 0),
- Radius = 8,
- ShapePainter = new CircleShapePainter(Hud)
- },
- new GroundCircleDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(255, r, g, b, 6),
- Radius = Monsize
- },
- new GroundCircleDecorator(Hud) {
- Brush = Hud.Render.CreateBrush(255, 255, 255, 255, 1.5f),
- Radius = Monsize
- }
- );
- }
- private string Debuff(IMonster m, bool showDebuff) {
- if (!showDebuff) return "";
- string textDebuff = null;
- if (m.Locust) textDebuff += "Locust";
- if (m.Haunted) textDebuff += (textDebuff == null ? "Haunt" : ", Haunt");
- if (m.Palmed) textDebuff += (textDebuff == null ? "Palm" : ", Palm");
- if (m.MarkedForDeath) textDebuff += (textDebuff == null ? "Mark" : ", Mark");
- if (m.Strongarmed) textDebuff += (textDebuff == null ? "Strongarm" : ", Strongarm");
- string textCC = null;
- if (m.Frozen) textCC += "Frozen";
- if (m.Chilled) textCC += (textCC == null ? "Chill" : ", Chill");
- if (m.Slow) textCC += (textCC == null ? "Slow" : ", Slow");
- if (m.Stunned) textCC += (textCC == null ? "Stun" : ", Stun");
- if (m.Invulnerable) textCC += (textCC == null ? "Invulnerable" : ", Invulnerable");
- if (m.Blind) textCC += (textCC == null ? "Blind" : ", Blind");
- var output = "\t" + textDebuff + (textDebuff != null && textCC != null ? " | " : "") + textCC;
- return output;
- }
- private string Curse(IMonster m) {
- string Curses = "";
- if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471845) == 1) //471845 1 power: Frailty
- Curses += "F";
- if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471869) == 1) //471869 1 power: Leech
- Curses += (Curses == "" ? "L" : " L");
- if (m.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_2_Visual_Effect_None, 471738) == 1) //471738 1 power: Decrepify
- Curses += (Curses == "" ? "D" : " D");
- return Curses;
- }
- public void DrawInfo(WorldLayer layer, IMonster monster, float Pos_X, ref float Pos_Y, float offset, bool showDebuff, bool showCurse){
- EliteDecorator.Paint(layer, monster, monster.FloorCoordinate, monster.SnoMonster.NameLocalized);
- if (monster.CentralXyDistanceToMe >= distance)
- Brush_Line.DrawLineWorld(monster.FloorCoordinate, Hud.Game.Me.FloorCoordinate);
- var CurPercent = monster.CurHealth / monster.MaxHealth;
- if (CurPercent < 0 || CurPercent > 1)
- CurPercent = 1;
- //Draw Rectangles
- Brush_BG.DrawRectangle(Pos_X, Pos_Y, barW, barH);
- Brush_Health.DrawRectangle(Pos_X, Pos_Y, (float) CurPercent * barW, barH);
- // Brush_Border.DrawRectangle(Pos_X, Pos_Y, barW, barH); // white border for bar on screen
- var name = Font_White.GetTextLayout(monster.SnoMonster.NameLocalized);
- Font_White.DrawText(name, Pos_X + 3, Pos_Y + (barH - (float)name.Metrics.Height)/2);
- var HPtext = (CurPercent * 100).ToString("0.0") + "%";
- var textLayout = Font_White.GetTextLayout(HPtext + Debuff(monster, showDebuff));
- Font_White.DrawText(textLayout, Pos_X + barW + 4 , Pos_Y + (barH - (float)textLayout.Metrics.Height)/2);
- if (showCurse) {
- var curseInfo = Curse(monster);
- textLayout = Font_White.GetTextLayout(curseInfo);
- Font_White.DrawText(textLayout, Pos_X + barW - textLayout.Metrics.Width - 6, Pos_Y + (barH - (float)textLayout.Metrics.Height)/2);
- }
- if (monster.IsOnScreen){
- var Mon_X = monster.FloorCoordinate.ToScreenCoordinate().X - barWmon / 2;
- var Mon_Y = monster.FloorCoordinate.ToScreenCoordinate().Y + barHmon + offset;
- Brush_BG.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
- Brush_Health.DrawRectangle(Mon_X, Mon_Y, (float) CurPercent * barWmon, barHmon);
- if (monster.Invulnerable) Brush_Invulnerable.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
- else Brush_Border.DrawRectangle(Mon_X, Mon_Y, barWmon, barHmon);
- var textLayout2 = Font_Mon.GetTextLayout(HPtext);
- Font_Mon.DrawText(HPtext, Mon_X + (barWmon - textLayout2.Metrics.Width)/2 , Mon_Y + (barHmon - textLayout2.Metrics.Height)/2);
- }
- else {
- var missing = Font_White.GetTextLayout("X");
- Font_White.DrawText(missing, Pos_X - 17, Pos_Y + (barH - missing.Metrics.Height)/2);
- }
- Pos_Y += barH * 1.1f; // * 1.3f;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement