/
PrimalAncientProbabilityPlugin.cs
165 lines (133 loc) · 7.74 KB
/
PrimalAncientProbabilityPlugin.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
// https://github.com/User5981/Resu
// Primal Ancient Probability Plugin for TurboHUD Version 25/07/2019 22:43
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 ancientDecorator { get; set; }
public TopLabelDecorator primalDecorator { get; set; }
public string ancientText{ get; set; }
public string primalText{ get; set; }
public double ancientMarker{ get; set; }
public double primalMarker{ get; set; }
public double legendaryCount{ get; set; }
public double prevInventoryLegendaryCount { get; set; }
public double prevInventoryAncientCount { get; set; }
public double prevInventoryPrimalCount { get; set; }
public bool RunOnlyOnce { get; set; }
public HashSet<string> legendaries = new HashSet<string>() {"0"};
public PrimalAncientProbabilityPlugin()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
ancientText = String.Empty;
primalText = String.Empty;
ancientMarker = 0;
primalMarker = 0;
legendaryCount = 0;
prevInventoryLegendaryCount = 0;
prevInventoryAncientCount = 0;
prevInventoryPrimalCount = 0;
RunOnlyOnce = true;
}
public void OnLootGenerated(IItem item, bool gambled)
{
if (item != null && item.SnoItem != null && item.SnoItem.MainGroupCode != "gems_unique" && item.SnoItem.MainGroupCode != "potion")
{
string itemID = item.SnoItem.Sno.ToString() + item.CreatedAtInGameTick.ToString();
if (item.IsLegendary && !legendaries.Contains(itemID)) legendaryCount++;
if (item.AncientRank == 1 && !legendaries.Contains(itemID)) ancientMarker = legendaryCount;
if (item.AncientRank == 2 && !legendaries.Contains(itemID)) primalMarker = legendaryCount;
if (item.IsLegendary && !legendaries.Contains(itemID)) legendaries.Add(itemID);
}
}
public void OnNewArea(bool newGame, ISnoArea area)
{
if (newGame)
{
legendaries.Clear();
legendaries.Add("0");
}
}
public void PaintTopInGame(ClipState clipState)
{
if (Hud.Game.Me.CurrentLevelNormal != 70 && Hud.Game.Me.CurrentLevelNormal > 0) {ancientMarker = legendaryCount; return;}
if (Hud.Game.Me.HighestSoloRiftLevel < 70 && Hud.Game.Me.HighestSoloRiftLevel > 0) primalMarker = legendaryCount;
if(RunOnlyOnce)
{
legendaryCount = Hud.Tracker.CurrentAccountTotal.DropLegendary;
ancientMarker = legendaryCount;
primalMarker = legendaryCount;
RunOnlyOnce = false;
}
long PrimalAncientTotal = Hud.Tracker.CurrentAccountTotal.DropPrimalAncient;
long AncientTotal = Hud.Tracker.CurrentAccountTotal.DropAncient;
long LegendariesTotal = Hud.Tracker.CurrentAccountTotal.DropLegendary;
string TotalPercPrimal = ((float)PrimalAncientTotal / (float)LegendariesTotal).ToString("0.00%");
string TotalPercAncient = ((float)AncientTotal / (float)LegendariesTotal).ToString("0.00%");
ancientDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 6, 220, 227, 153, 25, true, false, 255, 0, 0, 0, true),
TextFunc = () => ancientText,
HintFunc = () => "Chance for the next Legendary drop to be Ancient." + Environment.NewLine + "Total Ancient drops : " + AncientTotal + " (" + TotalPercAncient + ") of Legendary drops",
};
primalDecorator = new TopLabelDecorator(Hud)
{
TextFont = Hud.Render.CreateFont("arial", 6, 180, 255, 64, 64, true, false, 255, 0, 0, 0, true),
TextFunc = () => primalText,
HintFunc = () => "Chance for the next Legendary drop to be Primal Ancient." + Environment.NewLine + "Total Primal Ancient drops : " + PrimalAncientTotal + " (" + TotalPercPrimal + ") of Legendary drops",
};
double probaAncient = 0;
double probaPrimal = 0;
double powAncient = legendaryCount-ancientMarker;
double powPrimal = legendaryCount-primalMarker;
double ancientMaths = 90.2246666/100;
double primalMaths = 99.7753334/100;
if (powAncient == 0) powAncient = 1;
if (powPrimal == 0) powPrimal = 1;
probaAncient = (1 - Math.Pow(ancientMaths, powAncient))*100;
probaPrimal = (1 - Math.Pow(primalMaths, powPrimal))*100;
probaAncient = Math.Round(probaAncient, 2);
probaPrimal = Math.Round(probaPrimal, 2);
ancientText = "A: " + probaAncient + "%";
primalText = "P: " + probaPrimal + "%";
var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_progressBar_healthBall").Rectangle;
ancientDecorator.Paint(uiRect.Right - (uiRect.Width/1.6f), uiRect.Top + uiRect.Height * 0.88f, 50f, 50f, HorizontalAlign.Left);
if (Hud.Game.Me.HighestSoloRiftLevel >= 70)
{
primalDecorator.Paint(uiRect.Right - (uiRect.Width / 4.1f), uiRect.Top + uiRect.Height * 0.88f, 50f, 50f, HorizontalAlign.Left);
}
bool KanaiRecipe = Hud.Render.GetUiElement("Root.NormalLayer.Kanais_Recipes_main").Visible;
double InventoryLegendaryCount = 0;
double InventoryAncientCount = 0;
double InventoryPrimalCount = 0;
foreach (var item in Hud.Inventory.ItemsInInventory)
{
if (item != null)
{
if (item.SnoItem == null || item.SnoItem.MainGroupCode == "gems_unique" || item.SnoItem.MainGroupCode == "potion") continue;
string itemID = item.SnoItem.Sno.ToString() + item.CreatedAtInGameTick.ToString();
if (item.IsLegendary && !legendaries.Contains(itemID)) InventoryLegendaryCount++;
if (item.AncientRank == 1 && !legendaries.Contains(itemID)) InventoryAncientCount++;
if (item.AncientRank == 2 && !legendaries.Contains(itemID)) InventoryPrimalCount++;
if (item.IsLegendary && !legendaries.Contains(itemID)) legendaries.Add(itemID);
}
}
if (KanaiRecipe)
{
if (InventoryLegendaryCount > prevInventoryLegendaryCount) legendaryCount++; prevInventoryLegendaryCount = InventoryLegendaryCount;
if (InventoryAncientCount > prevInventoryAncientCount) ancientMarker = legendaryCount; prevInventoryAncientCount = InventoryAncientCount;
if (InventoryPrimalCount > prevInventoryPrimalCount) primalMarker = legendaryCount; prevInventoryPrimalCount = InventoryPrimalCount;
}
else prevInventoryLegendaryCount = InventoryLegendaryCount; prevInventoryAncientCount = InventoryAncientCount; prevInventoryPrimalCount = InventoryPrimalCount;
}
}
}