Code:
using System.Linq;
using System.Collections.Generic;
using Turbo.Plugins.Default;
namespace Turbo.Plugins.ABC
{
public class XEliteBarPlugin : BasePlugin, IInGameWorldPainter
{
public WorldDecoratorCollection HitBoxDecorator { get; set; }
public IFont LightFont { get; set; }
public IFont RedFont { get; set; }
public IFont MissingFont { get; set; }
public IFont NameFont { get; set; }
public WorldDecoratorCollection InvulnerableLabelDecorator { get; set; }
public WorldDecoratorCollection InvulnerableShapeDecorator { get; set; }
public float InvulnerableLabelOffsetY { get; set; }
public float InvulnerableShapeOffsetY { get; set; }
public IFont DebuffFont { get; set; }
public IFont AffixFont { get; set; }
public IFont PerFont { get; set; }
public IFont InvulnerableFont { get; set; }
public IBrush RareBrush { get; set; }
public IBrush RareJBrush { get; set; }
public IBrush RareMinionBrush { get; set; }
public IBrush ChampionBrush { get; set; }
public IBrush BossBrush { get; set; }
public IBrush HirelingBrush { get; set; }
public IBrush UniqueBrush { get; set; }
public bool ShowInvulnerable { get; set; }
public bool CircleRareMinionIllusion { get; set; }
public bool CircleRareIllusion { get; set; }
public bool CircleChampionIllusion { get; set; }
public IBrush BackgroundBrush { get; set; }
public IBrush BorderBrush { get; set; }
public bool JuggernautHighlight { get; set; }
public bool MissingHighlight { get; set; }
public bool ShowRareMinions { get ; set; }
public bool ShowDebuffAndCC { get; set; }
public bool ShowBossHitBox { get; set; }
public bool ShowMonsterType { get; set; }
public bool CircleNonIllusion { get; set; }
public float XPos { get; set; }
public float YPos { get; set; }
public float XScaling { get; set; }
public float YScaling { get; set; }
public string PercentageDescriptor { get; set; }
public Dictionary<MonsterAffix, string> DisplayAffix;
private float px, py, h, w2;
public XEliteBarPlugin()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
//Configuration
InvulnerableLabelOffsetY = 5f;
InvulnerableShapeOffsetY = 0f;
ShowInvulnerable = true;
CircleRareMinionIllusion = false;
CircleRareIllusion = false;
CircleChampionIllusion = false;
MissingHighlight = true;
JuggernautHighlight = true;
CircleNonIllusion = true;
ShowRareMinions = true;
ShowDebuffAndCC = true;
ShowBossHitBox = true;
ShowMonsterType = true;
XScaling = 0.8f;
YScaling = 1.25f;
PercentageDescriptor = "0.00";
XPos = Hud.Window.Size.Width * 1f;
YPos = Hud.Window.Size.Height * 1f;
DisplayAffix = new Dictionary<MonsterAffix, string>();
//Colorization
DebuffFont = Hud.Render.CreateFont("tahoma", 7f, 200, 255, 0, 0, true, false, 128, 0, 0, 0, true);
AffixFont = Hud.Render.CreateFont("tahoma", 7f, 200, 255, 0, 0, true, false, 128, 0, 0, 0, true);
PerFont = Hud.Render.CreateFont("tahoma", 7f, 200, 255, 255, 255, true, false, 128, 0, 0, 0, true);
InvulnerableFont = Hud.Render.CreateFont("tahoma", 20f, 200, 255, 0, 0, true, false, 128, 0, 0, 0, true);
HirelingBrush = Hud.Render.CreateBrush(255, 170, 0, 255, 0);
UniqueBrush = Hud.Render.CreateBrush(255, 170, 0, 255, 0);
LightFont = Hud.Render.CreateFont("tahoma", 6f, 160, 255, 255, 255, true, false, 128, 0, 0, 0, true);
RedFont = Hud.Render.CreateFont("tahoma", 6f, 200, 255, 0, 0, true, false, 128, 0, 0, 0, true);
MissingFont = Hud.Render.CreateFont("tahoma", 8f, 200, 255, 0, 0, true, false, 128, 0, 0, 0, true);
NameFont = Hud.Render.CreateFont("tahoma", 6f, 200, 255, 255, 255, true, false, 128, 0, 0, 0, true);
BackgroundBrush = Hud.Render.CreateBrush(255, 0, 0, 0, 0);
BorderBrush = Hud.Render.CreateBrush(255, 255, 255, 255, -1);
RareBrush = Hud.Render.CreateBrush(255, 255, 128, 0, 0);
RareJBrush = Hud.Render.CreateBrush(255, 255, 50, 0, 0);
RareMinionBrush = Hud.Render.CreateBrush(220, 200, 100, 0, 0);
ChampionBrush = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
BossBrush = Hud.Render.CreateBrush(255, 245, 127, 224, 0);
//HitBoxDecorator for Bosses and NonClone-Illusionist
HitBoxDecorator = new WorldDecoratorCollection(
new GroundCircleDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(255, 0, 0, 0, 9),
RadiusTransformator = new StandardPingRadiusTransformator (Hud, 400),
Radius = 1.1f
},
new GroundCircleDecorator(Hud)
{
RadiusTransformator = new StandardPingRadiusTransformator (Hud, 400),
Brush = Hud.Render.CreateBrush(255, 255, 0, 0, 0),
Radius = 1.1f
});
InvulnerableLabelDecorator = new WorldDecoratorCollection(
new GroundLabelDecorator(Hud)
{
//BackgroundBrush = Hud.Render.CreateBrush(180, 255, 255, 0, 0),
//BorderBrush = Hud.Render.CreateBrush(180, 0, 0, 0, -1),
TextFont = Hud.Render.CreateFont("tahoma", 12f, 200, 255, 0, 0, true, false, 100, 0, 0, 0, true),
});
InvulnerableShapeDecorator = new WorldDecoratorCollection(
new GroundShapeDecorator(Hud)
{
RadiusTransformator = new StandardPingRadiusTransformator (Hud, 400),
Brush = Hud.Render.CreateBrush(255, 255, 0, 0, 4),
Radius = 4f,
});
}
private void DrawHealthBar(WorldLayer layer, IMonster m, ref float yref){
if (m.Rarity == ActorRarity.RareMinion && !ShowRareMinions) return; //no minions
if (m.SummonerAcdDynamicId != 0) return; //no clones
var w = m.CurHealth * w2 / m.MaxHealth;
var per = PerFont.GetTextLayout((m.CurHealth * 100 / m.MaxHealth).ToString(PercentageDescriptor)+ "%");
var y = YPos + py * 8 * yref;
IBrush cBrush = null;
IFont cFont = null;
//Brush selection
switch(m.Rarity){
case ActorRarity.Boss:
cBrush = BossBrush;
break;
case ActorRarity.Champion:
cBrush = ChampionBrush;
break;
case ActorRarity.Rare:
cBrush = RareBrush;
break;
case ActorRarity.RareMinion:
cBrush = RareMinionBrush;
break;
case ActorRarity.Unique:
cBrush = UniqueBrush;
break;
case ActorRarity.Hireling:
cBrush = HirelingBrush;
break;
default:
cBrush = BackgroundBrush;
break;
}
//Jugger Highlight
if (JuggernautHighlight && m.Rarity == ActorRarity.Rare && HasAffix(m, MonsterAffix.Juggernaut)){
cFont = RedFont;
cBrush = RareJBrush;
}
else
cFont = NameFont;
//Missing Highlight
if (MissingHighlight && (m.Rarity == ActorRarity.Champion || m.Rarity == ActorRarity.Unique || m.Rarity == ActorRarity.Hireling || m.Rarity == ActorRarity.Rare || m.Rarity == ActorRarity.RareMinion) && !m.IsOnScreen){
var missing = MissingFont.GetTextLayout("\u26A0");
MissingFont.DrawText(missing, XPos - 17, y - py + 1f);
}
//Circle Non-Clones and Boss
if (CircleNonIllusion && m.SummonerAcdDynamicId == 0 && HasAffix(m, MonsterAffix.Illusionist) || m.Rarity == ActorRarity.Boss && ShowBossHitBox){
if (CircleRareMinionIllusion && m.Rarity == ActorRarity.RareMinion)
{
HitBoxDecorator.Paint(layer, m, m.FloorCoordinate, string.Empty);
}
if (CircleRareIllusion && m.Rarity == ActorRarity.Rare)
{
HitBoxDecorator.Paint(layer, m, m.FloorCoordinate, string.Empty);
}
if (CircleChampionIllusion && m.Rarity == ActorRarity.Champion)
{
HitBoxDecorator.Paint(layer, m, m.FloorCoordinate, string.Empty);
}
if (ShowBossHitBox && m.Rarity == ActorRarity.Boss)
{
HitBoxDecorator.Paint(layer, m, m.FloorCoordinate, string.Empty);
}
}
//Show Debuffs on Monster
if (ShowDebuffAndCC){
string textDebuff = null;
if (m.Locust) textDebuff += (textDebuff == null ? "" : "|") + "메뚜기";
if (m.Palmed) textDebuff += (textDebuff == null ? "" : "|") + "폭장";
if (m.Haunted) textDebuff += (textDebuff == null ? "" : "|") + "혼출";
if (m.MarkedForDeath) textDebuff += (textDebuff == null ? "" : "|") + "죽표";
if (m.Strongarmed) textDebuff += (textDebuff == null ? "" : "|") + "팔씨름";
string textCC = null;
if (m.Frozen) textCC += (textCC == null ? "" : "|") + "빙결";
if (m.Chilled) textCC += (textCC == null ? "" : "|") + "오한";
if (m.Slow) textCC += (textCC == null ? "" : "|") + "느림";
if (m.Stunned) textCC += (textCC == null ? "" : "|") + "기절";
if (m.Invulnerable) textCC += (textCC == null ? "" : "|") + "\u2728무적\u2728";
if (m.Blind) textCC += (textCC == null ? "" : "|") + "실명";
var d = DebuffFont.GetTextLayout(textDebuff + (textDebuff != null && textCC != null ? "|" : "") + textCC);
DebuffFont.DrawText(d, XPos + 65 + w2, y - py);
}
if (ShowInvulnerable){
if (m.Rarity == ActorRarity.Champion || m.Rarity == ActorRarity.Rare || m.Rarity == ActorRarity.Boss)
{
if (m.Invulnerable){
InvulnerableLabelDecorator.Paint(layer, m, InvulnerableLabelOffsetY != 0 ? m.FloorCoordinate.Offset(0, 0, InvulnerableLabelOffsetY) : m.FloorCoordinate, "\u2623\u2728무적\u2728\u2623");
InvulnerableShapeDecorator.Paint(layer, m, InvulnerableShapeOffsetY != 0 ? m.FloorCoordinate.Offset(0, 0, InvulnerableShapeOffsetY) : m.FloorCoordinate, null);
}
}
}
//Draw Rectangles
BackgroundBrush.DrawRectangle(XPos, y, w2, h);
BorderBrush.DrawRectangle(XPos, y, w2, h);
cBrush.DrawRectangle(XPos, y, (float)w, h);
PerFont.DrawText(per, XPos + 8 + w2, y - py + 1f);
//Draw MonsterType
if (ShowMonsterType){
var name = cFont.GetTextLayout(m.SnoMonster.NameLocalized);
cFont.DrawText(name, XPos + 3, y - py + 1f);
}
//increase linecount
yref += 1.0f;
}
private void DrawPack(WorldLayer layer, IMonsterPack p, ref float yref){
//Check if any affixes are wished to be displayed
if (DisplayAffix.Any()){
string dAffix = "";
foreach(ISnoMonsterAffix afx in p.AffixSnoList){ //iterate affix list
if (DisplayAffix.Keys.Contains(afx.Affix)) //if affix is an key
dAffix += DisplayAffix[afx.Affix] + " "; //add to output
}
if (!string.IsNullOrEmpty(dAffix)){
var d = AffixFont.GetTextLayout(dAffix);
var y = YPos + py * 8 * yref;
AffixFont.DrawText(d, XPos, y - py);
yref += 1.0f;
}
}
//iterate all alive monsters of pack and print healthbars
foreach(IMonster m in p.MonstersAlive)
DrawHealthBar(layer, m, ref yref);
}
private bool HasAffix(IMonster m, MonsterAffix afx){
return m.AffixSnoList.Any(a => a.Affix == afx);
}
public void PaintWorld(WorldLayer layer)
{
//Spacing
px = Hud.Window.Size.Width * 0.00155f * XScaling;
py = Hud.Window.Size.Height * 0.001667f * YScaling;
h = py * 6;
w2 = px * 60;
var packs = Hud.Game.MonsterPacks.Where(x => x.MonstersAlive.Any());
var bosses = Hud.Game.AliveMonsters.Where(m => m.Rarity == ActorRarity.Boss);
float yref = 0f;
foreach(IMonster m in bosses)
DrawHealthBar(layer, m, ref yref);
yref += 0.5f; //spacing between RG and Elites
foreach(IMonsterPack p in packs){
DrawPack(layer, p, ref yref);
yref += 0.5f; //spacing between Elites
}
}
}
}