Code:
// https://github.com/User5981/Resu
// Primal Ancient Probability Plugin for TurboHUD Version 25/10/2019 14:39
using System;
using System.Globalization;
using Turbo.Plugins.Default;
using System.Linq;
using System.Collections.Generic;
namespace Turbo.Plugins.Resu
{
public class PrimalAncientProbabilityPlugin : BasePlugin, IInGameTopPainter, ILootGeneratedHandler
{
public TopLabelDecorator legendariesDecorator { get; set; }
public TopLabelDecorator ancientDecorator { get; set; }
public TopLabelDecorator primalDecorator { get; set; }
public TopLabelDecorator PrimalCol0Decorator { get; set; }
public TopLabelDecorator PrimalCol1Decorator { get; set; }
public TopLabelDecorator PrimalCol2Decorator { get; set; }
public TopLabelDecorator PrimalCol3Decorator { get; set; }
public TopLabelDecorator PrimalCol4Decorator { get; set; }
public TopLabelDecorator PrimalCol5Decorator { get; set; }
public TopLabelDecorator PrimalCol6Decorator { get; set; }
public TopLabelDecorator PrimalCol7Decorator { get; set; }
public string ancientText{ get; set; }
public string legendariesText{ get; set; }
public string primalText{ get; set; }
public string PrimalCol0Text { get; set; }
public string PrimalCol1Text { get; set; }
public string PrimalCol2Text { get; set; }
public string PrimalCol3Text { get; set; }
public string PrimalCol4Text { get; set; }
public string PrimalCol5Text { get; set; }
public string PrimalCol6Text { get; set; }
public string PrimalCol7Text { get; set; }
public int LegendaryCount { get; private set; }
public int AncientCount { get; private set; }
public int PrimalCount { get; private set; }
public int PrimalCol0 { get; private set; }
public int PrimalCol1 { get; private set; }
public int PrimalCol2 { get; private set; }
public int PrimalCol3 { get; private set; }
public int PrimalCol4 { get; private set; }
public int PrimalCol5 { get; private set; }
public int PrimalCol6 { get; private set; }
public int PrimalCol7 { get; private set; }
public PrimalAncientProbabilityPlugin()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
ancientText = string.Empty;
legendariesText = string.Empty;
primalText = string.Empty;
PrimalCol0Text = string.Empty;
PrimalCol1Text = string.Empty;
PrimalCol2Text = string.Empty;
PrimalCol3Text = string.Empty;
PrimalCol4Text = string.Empty;
PrimalCol5Text = string.Empty;
PrimalCol6Text = string.Empty;
PrimalCol7Text = string.Empty;
AncientCount = 0;
LegendaryCount = 0;
PrimalCount = 0;
PrimalCol0 = 0;
PrimalCol1 = 0;
PrimalCol2 = 0;
PrimalCol3 = 0;
PrimalCol4 = 0;
PrimalCol5 = 0;
PrimalCol6 = 0;
PrimalCol7 = 0;
}
public void OnLootGenerated(IItem item, bool gambled)
{
if (item.IsLegendary)
{
if (item.AncientRank == 1) AncientCount++;
if (item.AncientRank >= 0) LegendaryCount++;
if (item.AncientRank == 2) PrimalCount++;
var Primalws = PrimalCount;
if (Primalws == 0)
PrimalCol0 = LegendaryCount + AncientCount;
if (Primalws == 1)
PrimalCol1 = LegendaryCount + AncientCount - PrimalCol0;
if (Primalws == 2)
PrimalCol2 = LegendaryCount + AncientCount - PrimalCol1;
if (Primalws == 3)
PrimalCol3 = LegendaryCount + AncientCount - PrimalCol2;
if (Primalws == 4)
PrimalCol4 = LegendaryCount + AncientCount - PrimalCol3;
if (Primalws == 5)
PrimalCol5 = LegendaryCount + AncientCount - PrimalCol4;
if (Primalws == 6)
PrimalCol6 = LegendaryCount + AncientCount - PrimalCol5;
if (Primalws == 7)
PrimalCol7 = LegendaryCount + AncientCount - PrimalCol6;
}
}
public void PaintTopInGame(ClipState clipState)
{
if (Hud.Game.Me.CurrentLevelNormal != 70 && Hud.Game.Me.CurrentLevelNormal > 0) { return;}
if (Hud.Game.Me.HighestSoloRiftLevel < 70 && Hud.Game.Me.HighestSoloRiftLevel > 0){ return; }
long PrimalAncientTotal = PrimalCount;
long PrimalAncientStats = Hud.Tracker.CurrentAccountTotal.DropPrimalAncient;
long AncientTotal = AncientCount;
long AncientStats = Hud.Tracker.CurrentAccountTotal.DropAncient;
long LegendariesTotal = LegendaryCount;
long LegendariesStats = Hud.Tracker.CurrentAccountTotal.DropLegendary;
long TotalCount = LegendaryCount + AncientCount;
string TotalPercPrimal = ((float)PrimalAncientTotal / (float)TotalCount).ToString("0.000%");
string TotalPercAncient = ((float)AncientTotal / (float)LegendariesTotal).ToString("0.00%");
PrimalCol0Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol0Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol1Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol1Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol2Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol2Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol3Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol3Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol4Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol4Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol5Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol5Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol6Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol6Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
PrimalCol7Decorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => PrimalCol7Text,
BackgroundBrush = Hud.Render.CreateBrush(50, 0, 0, 0, 0),
};
ancientDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 179,78,233, true, false, 255, 0, 0, 0, true),
TextFunc = () => ancientText,
//HintFunc = () => probaAncient,
BackgroundBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0),
};
legendariesDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => legendariesText,
BackgroundBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0),
};
primalDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 8, 180, 255, 64, 64, true, false, 255, 0, 0, 0, true),
TextFunc = () => primalText,
//HintFunc = () => probaPrimal,
BackgroundBrush = Hud.Render.CreateBrush(0, 0, 0, 0, 0),
};
ancientText = "Д: " + "= " + AncientTotal + " / " + AncientStats + " (" + TotalPercAncient + ")";
primalText = "П: " + "= " + PrimalAncientTotal + " / " + PrimalAncientStats + " (" + TotalPercPrimal + ")";
legendariesText = "Л: " + "= " + LegendariesTotal + " / " + LegendariesStats;
PrimalCol0Text = "0. " + PrimalCol0;
PrimalCol1Text = "1. " + PrimalCol1;
PrimalCol2Text = "2. " + PrimalCol2;
PrimalCol3Text = "3. " + PrimalCol3;
PrimalCol4Text = "4. " + PrimalCol4;
PrimalCol5Text = "5. " + PrimalCol5;
PrimalCol6Text = "6. " + PrimalCol6;
PrimalCol7Text = "7. " + PrimalCol7;
var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_progressBar_healthBall").Rectangle;
PrimalCol4Decorator.Paint(uiRect.Right - (uiRect.Width / 0.445f), uiRect.Top + (uiRect.Height / 2.5f), 35f, 8f, HorizontalAlign.Left);
PrimalCol5Decorator.Paint(uiRect.Right - (uiRect.Width / 0.445f), uiRect.Top + (uiRect.Height / 2.05f), 35f, 8f, HorizontalAlign.Left);
PrimalCol6Decorator.Paint(uiRect.Right - (uiRect.Width / 0.445f), uiRect.Top + (uiRect.Height / 1.728f), 35f, 8f, HorizontalAlign.Left);
PrimalCol7Decorator.Paint(uiRect.Right - (uiRect.Width / 0.445f), uiRect.Top + (uiRect.Height / 1.50f), 35f, 8f, HorizontalAlign.Left);
PrimalCol0Decorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 2.5f), 35f, 8f, HorizontalAlign.Left);
PrimalCol1Decorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 2.05f), 35f, 8f, HorizontalAlign.Left);
PrimalCol2Decorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 1.728f), 35f, 8f, HorizontalAlign.Left);
PrimalCol3Decorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 1.50f), 35f, 8f, HorizontalAlign.Left);
legendariesDecorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 1.30f), 35f, 8f, HorizontalAlign.Left);
ancientDecorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 1.15f), 35f, 8f, HorizontalAlign.Left);
if (Hud.Game.Me.HighestSoloRiftLevel >= 70)
{
primalDecorator.Paint(uiRect.Right - (uiRect.Width / 0.38f), uiRect.Top + (uiRect.Height / 1.02f), 60f, 8f, HorizontalAlign.Left);
}
}
}
}