forked from mumungan/StoneKplugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SummonerMonsterBarCountDifLabel.cs
450 lines (422 loc) · 19.8 KB
/
SummonerMonsterBarCountDifLabel.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
// Special thanks to Gigi and SeaDragon. This Plugin bases on Gigi's EliteBarPlugin and SeaDragon(glq)' MonstersCountPlugin
//Gigi's EliteBarPlugin
//https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-approved-plugins/612897-english-gigi-elitebarplugin.html
//https://github.com/d3gigi/plugins/blob/master/Gigi/EliteBarPlugin.cs
// SeaDragon(glq)' MonstersCountPlugin
//https://www.ownedcore.com/forums/diablo-3/turbohud/turbohud-approved-plugins/612942-international-glq-monsterscountplugin.html
//https://pastebin.com/Jm1V3cvk
using System.Linq;
using System;
using System.Collections.Generic;
using Turbo.Plugins.Default;
using System.Text;
namespace Turbo.Plugins.Stone
{
public class SummonerMonsterBarCountPlugin : BasePlugin, IInGameWorldPainter
{
public WorldDecoratorCollection Decorator { get; set; }
public WorldDecoratorCollection Decoratorred { get; set; }
public WorldDecoratorCollection Decoratorgray { get; set; }
public IFont DefaultTextFont { get; set; }
public IFont LightFont { get; set; }
public IFont RedFont { get; set; }
public IFont NameFont { get; set; }
public IBrush BackgroundBrush { get; set; }
public IBrush BorderBrush { get; set; }
public IBrush RareBrush { get; set; }
public IBrush RareJuggerBrush { get; set; }
public IBrush RareMinionBrush { get; set; }
public IBrush ChampionBrush { get; set; }
public IBrush BossBrush { get; set; }
public bool JuggernautHighlight { get; set; }
public bool ShowMonsterType { get; set; }
public bool ShowMeScreenBaseYard { get; set; }
public bool ShowMeScreenMaxYard { get; set; }
public bool ShowSummonerCount { get; set; }
public bool ShowSummonerEliteBar { get; set; }
public bool ShowSummonerNormalMonsterBar { get; set; }
public bool showdifLabel { get; set; }
public float XPos { get; set; }
public float YPos { get; set; }
public float XScaling { get; set; }
public float YScaling { get; set; }
public int BaseYard { get; set; }
public int MaxYard { get; set; }
public string PercentageDescriptor { get; set; }
public Dictionary<MonsterAffix, string> DisplayAffix;
private StringBuilder textBuilder;
private Dictionary<string, string> SummonerMonsternames1 = new Dictionary<string, string>();
private Dictionary<string, string> SummonerMonsternames2 = new Dictionary<string, string>();
private float px, py, h, w2;
public SummonerMonsterBarCountPlugin()
{
Enabled = true;
}
public override void Load(IController hud)
{
base.Load(hud);
ShowMeScreenBaseYard = true; // 1. MeScreenBaseYard on, off
ShowMeScreenMaxYard = true; // 2. MeScreenMaxYard on, off
ShowSummonerCount = true; // 3. SummonerCount on, off
ShowSummonerEliteBar = true; // 4. EliteSummonerBar on, off
ShowSummonerNormalMonsterBar = true; //5.NormalSummonerBar on, off
showdifLabel = true; // 6. diffrient Label Color on, off
JuggernautHighlight = true;
ShowMonsterType = true;
XScaling = 0.5f;
YScaling = 1.2f;
PercentageDescriptor = "0";
XPos = Hud.Window.Size.Width * 0.76f;
YPos = Hud.Window.Size.Height * 0.05f;
BaseYard = 40;
MaxYard = 120;
DisplayAffix = new Dictionary<MonsterAffix, string>();
SummonerMonsternames1.Add("Retching Cadaver", "6646");
SummonerMonsternames1.Add("Deathspitter", "6638");
SummonerMonsternames1.Add("Spewing Horror", "6640");
SummonerMonsternames1.Add("Dust Retcher", "6641");
SummonerMonsternames2.Add("Tomb Guardian", "450352");
SummonerMonsternames2.Add("Vengeful Summoner", "5390");
SummonerMonsternames2.Add("Returned Summoner", "5388");
SummonerMonsternames2.Add("Tortured Summoner", "329319");
textBuilder = new StringBuilder();
Decorator = new WorldDecoratorCollection(
new MapShapeDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(180, 255, 50, 50, 0),
ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
ShapePainter = new CircleShapePainter(Hud),
Radius = 2,
},
new GroundLabelDecorator(Hud)
{
BackgroundBrush = Hud.Render.CreateBrush(255, 200, 50, 50, 0),
TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
}
);
Decoratorred = new WorldDecoratorCollection(
new MapShapeDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(180, 255, 50, 50, 0),
ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
ShapePainter = new CircleShapePainter(Hud),
Radius = 2,
},
new GroundLabelDecorator(Hud)
{
BackgroundBrush = Hud.Render.CreateBrush(255, 200, 50, 50, 0),
TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
}
);
Decoratorgray = new WorldDecoratorCollection(
new MapShapeDecorator(Hud)
{
Brush = Hud.Render.CreateBrush(128, 255, 255, 255, 0),
ShadowBrush = Hud.Render.CreateBrush(96, 0, 0, 0, 1),
ShapePainter = new CircleShapePainter(Hud),
Radius = 2,
},
new GroundLabelDecorator(Hud)
{
BackgroundBrush = Hud.Render.CreateBrush(128, 255, 255, 255, 0),
TextFont = Hud.Render.CreateFont("tahoma", 6.5f, 255, 255, 255, 255, false, false, false),
}
);
//Colorization
DefaultTextFont = Hud.Render.CreateFont("tahoma", 11, 255, 255, 128, 0, false, false, 250, 0, 0, 0, true);
LightFont = Hud.Render.CreateFont("tahoma", 7f, 128, 255, 255, 255, true, false, true);
RedFont = Hud.Render.CreateFont("tahoma", 7f, 255, 255, 0, 0, true, false, true);
NameFont = Hud.Render.CreateFont("tahoma", 7f, 255, 255, 255, 255, true, false, true);
BackgroundBrush = Hud.Render.CreateBrush(255, 125, 120, 120, 0);
BorderBrush = Hud.Render.CreateBrush(0, 255, 255, 255, 1);
RareBrush = Hud.Render.CreateBrush(255, 255, 128, 0, 0);
RareJuggerBrush = Hud.Render.CreateBrush(255, 255, 0, 0, 0);
RareMinionBrush = Hud.Render.CreateBrush(204, 200, 100, 0, 0);
ChampionBrush = Hud.Render.CreateBrush(255, 0, 128, 255, 0);
BossBrush = Hud.Render.CreateBrush(255, 200, 20, 0, 0);
}
private void DrawHealthBar(WorldLayer layer, IMonster m, ref float yref)
{
var w = m.CurHealth * w2 / m.MaxHealth;
var per = LightFont.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;
default:
cBrush = BackgroundBrush;
break;
}
//Jugger Highlight
if (JuggernautHighlight && m.Rarity == ActorRarity.Rare && HasAffix(m, MonsterAffix.Juggernaut))
{
cFont = RedFont;
cBrush = RareJuggerBrush;
}
else
cFont = NameFont;
//Draw Rectangles
BackgroundBrush.DrawRectangle(XPos, y, w2, h);
BorderBrush.DrawRectangle(XPos, y, w2, h);
cBrush.DrawRectangle(XPos, y, (float)w, h);
LightFont.DrawText(per, XPos + 8 + w2, y - py);
//Draw MonsterType
if (ShowMonsterType)
{
var name = cFont.GetTextLayout(m.SnoMonster.NameLocalized);
cFont.DrawText(name, XPos + 3, y - py);
}
//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 = LightFont.GetTextLayout(dAffix);
var y = YPos + py * 8 * yref;
LightFont.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)
{
px = Hud.Window.Size.Width * 0.00155f * XScaling;
py = Hud.Window.Size.Height * 0.001667f * YScaling;
h = py * 6;
w2 = px * 60;
float yref = 0.01f;
int summonerelite1count = 0;
int summonerelite2count = 0;
int summonedelite1count = 0;
int summonedelite2count = 0;
int summonedcount = 0;
int summoner1count = 0;
int summoner2count = 0;
int monstersCountBaseYard = 0;
int monstersCountMaxYard = 0;
if (ShowMeScreenBaseYard)
{
var monsters1 = Hud.Game.AliveMonsters.Where(m => ((m.SummonerAcdDynamicId == 0 && m.IsElite) || !m.IsElite) && m.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate) <= BaseYard);
foreach (var monster in monsters1)
{
monstersCountBaseYard++;
}
var text1 = string.Format("{0} 야드 : {1}", BaseYard, monstersCountBaseYard);
var layer1 = DefaultTextFont.GetTextLayout(text1);
DefaultTextFont.DrawText(layer1, Hud.Window.Size.Width * 0.34f, Hud.Window.Size.Height * 0.22f);
}
if (ShowMeScreenMaxYard)
{
var monsters2 = Hud.Game.AliveMonsters.Where(m => ((m.SummonerAcdDynamicId == 0 && m.IsElite) || !m.IsElite) && m.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate) <= MaxYard);
foreach (var monster in monsters2)
{
monstersCountMaxYard++;
}
var text2 = string.Format("{0} 야드 : {1}", MaxYard, monstersCountMaxYard);
var layer2 = DefaultTextFont.GetTextLayout(text2);
DefaultTextFont.DrawText(layer2, Hud.Window.Size.Width * 0.34f, Hud.Window.Size.Height * 0.24f);
}
if (showdifLabel)
{
var monsters3 = Hud.Game.AliveMonsters.Where(m => (m.SummonerAcdDynamicId == 0 && m.IsElite) || !m.IsElite);
foreach (var monster in monsters3)
{
var smtext = ValueToString(monster.CurHealth * 100 / monster.MaxHealth, ValueFormat.NormalNumberNoDecimal) + "%";
if (SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameLocalized))
{
if (monster.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate) < BaseYard)
{
if (monster.IsElite)
{
Decoratorred.Paint(layer, monster, monster.FloorCoordinate, "E어미");
}
else
{
Decoratorred.Paint(layer, monster, monster.FloorCoordinate, "어미" + smtext);
}
}
else
{
if (monster.IsElite)
{
Decoratorgray.Paint(layer, monster, monster.FloorCoordinate, "E어미");
}
else
{
Decoratorgray.Paint(layer, monster, monster.FloorCoordinate, "어미" + smtext);
}
}
}
if (SummonerMonsternames2.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameLocalized))
{
if (monster.FloorCoordinate.XYDistanceTo(Hud.Game.Me.FloorCoordinate) < BaseYard)
{
if (monster.IsElite)
{
Decoratorred.Paint(layer, monster, monster.FloorCoordinate, "E소환사");
}
else
{
Decoratorred.Paint(layer, monster, monster.FloorCoordinate, "소환사" + smtext);
}
}
else
{
if (monster.IsElite)
{
Decoratorgray.Paint(layer, monster, monster.FloorCoordinate, "E소환사");
}
else
{
Decoratorgray.Paint(layer, monster, monster.FloorCoordinate, "소환사" + smtext);
}
}
}
}
}
var monsters = Hud.Game.AliveMonsters;
foreach (var monster in monsters)
{
if (monster.IsElite)
{
if (SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameLocalized))
{
if (monster.SummonerAcdDynamicId == 0) summonerelite1count++;
else summonedelite1count++;
if (ShowSummonerEliteBar)
{
DrawHealthBar(layer, monster, ref yref);
yref += 0.5f;
}
if (!showdifLabel)
{
Decorator.Paint(layer, monster, monster.FloorCoordinate, "E어미");
}
}
if (SummonerMonsternames2.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames2.ContainsKey(monster.SnoMonster.NameLocalized))
{
if (monster.SummonerAcdDynamicId == 0) summonerelite2count++;
else summonedelite2count++;
if (ShowSummonerEliteBar)
{
DrawHealthBar(layer, monster, ref yref);
yref += 0.5f;
}
if (!showdifLabel)
{
Decorator.Paint(layer, monster, monster.FloorCoordinate, "E소환사");
}
}
}
}
foreach (var monster in monsters)
{
var smtext = ValueToString(monster.CurHealth * 100 / monster.MaxHealth, ValueFormat.NormalNumberNoDecimal) + "%";
if (!monster.IsElite)
{
if (monster.SummonerAcdDynamicId != 0) summonedcount++;
if (SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames1.ContainsKey(monster.SnoMonster.NameLocalized))
{
summoner1count++;
if (ShowSummonerNormalMonsterBar)
{
DrawHealthBar(layer, monster, ref yref);
yref += 0.5f;
}
if (!showdifLabel)
{
Decorator.Paint(layer, monster, monster.FloorCoordinate, "어미" + smtext);
}
}
if (SummonerMonsternames2.ContainsKey(monster.SnoMonster.NameEnglish) || SummonerMonsternames2.ContainsKey(monster.SnoMonster.NameLocalized))
{
summoner2count++;
if (ShowSummonerNormalMonsterBar)
{
DrawHealthBar(layer, monster, ref yref);
yref += 0.5f;
}
if (!showdifLabel)
{
Decorator.Paint(layer, monster, monster.FloorCoordinate, "소환사" + smtext);
}
}
}
}
if (ShowSummonerCount)
{
textBuilder.Clear();
if (summonerelite1count > 0)
{
textBuilder.AppendFormat("어미정예: {0}", summonerelite1count);
textBuilder.AppendLine();
}
if (summonedelite1count > 0)
{
textBuilder.AppendFormat("어미환영: {0}", summonedelite1count);
textBuilder.AppendLine();
}
if (summonerelite2count > 0)
{
textBuilder.AppendFormat("소환사정예: {0}", summonerelite2count);
textBuilder.AppendLine();
}
if (summonedelite2count > 0)
{
textBuilder.AppendFormat("소환사환영: {0}", summonedelite2count);
textBuilder.AppendLine();
}
if (summoner1count > 0)
{
textBuilder.AppendFormat("어미: {0}", summoner1count);
textBuilder.AppendLine();
}
if (summoner2count > 0)
{
textBuilder.AppendFormat("소환사: {0}", summoner2count);
textBuilder.AppendLine();
}
if (summonedcount > 0)
{
textBuilder.AppendLine();
textBuilder.AppendFormat("소환몹: {0}", summonedcount);
textBuilder.AppendLine();
}
var layout = DefaultTextFont.GetTextLayout(textBuilder.ToString());
DefaultTextFont.DrawText(layout, Hud.Window.Size.Width * 0.77f, Hud.Window.Size.Height * 0.61f);
}
}
}
}