Created
December 14, 2019 23:30
-
-
Save knight84/4abd7344cfc52a45050e57d0a2519d0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Turbo.Plugins.Default; | |
using System; | |
using System.Linq; | |
using System.Collections.Generic; | |
namespace Turbo.Plugins.RNN | |
{ | |
public class PacksGR : BasePlugin, IInGameTopPainter, IMonsterKilledHandler, INewAreaHandler | |
{ | |
private bool inGR { get; set; } | |
private Dictionary<IMonsterPack, int[]> DicPacks { get; set; } = new Dictionary<IMonsterPack, int[]>(); | |
private IFont FontW { get; set; } | |
private IFont FontY { get; set; } | |
private IFont FontB { get; set; } | |
public float Xpor { get; set; } | |
public float Ypor { get; set; } | |
public bool Vertical { get; set; } | |
public PacksGR() | |
{ | |
Enabled = true; | |
} | |
public override void Load(IController hud) | |
{ | |
base.Load(hud); | |
Order = 30001; | |
Xpor = 0.14f; // 0.89f Valid values: from 0 to 1 . | |
Ypor = 0.94f; // 0.91f Valid values: from 0 to 1 . | |
Vertical = true; | |
FontW = Hud.Render.CreateFont("tahoma", 8, 255, 255, 255, 255, false, false, 255, 0, 0, 0, true); | |
FontY = Hud.Render.CreateFont("tahoma", 8, 255, 243, 215, 0, false, false, 255, 0, 0, 0, true); | |
FontB = Hud.Render.CreateFont("tahoma", 8, 255, 48, 140, 255, false, false, 255, 0, 0, 0, true); | |
} | |
public void OnMonsterKilled(IMonster monster) | |
{ | |
if (Hud.Game.RiftPercentage < 100) | |
{ | |
if ( ((monster.Rarity == ActorRarity.Champion) || (monster.Rarity == ActorRarity.Rare)) && (monster.SummonerAcdDynamicId == 0)) | |
{ | |
var p = monster.Pack; | |
if (DicPacks.ContainsKey(p)) | |
{ | |
DicPacks[p][1] = DicPacks[p][1] + 1 ; | |
} | |
} | |
} | |
} | |
public void OnNewArea(bool newGame, ISnoArea area) | |
{ | |
if (newGame) | |
{ | |
inGR = false; DicPacks.Clear(); | |
} | |
} | |
public void PaintTopInGame(ClipState clipState) | |
{ | |
if (clipState != ClipState.BeforeClip) return; | |
if (!Hud.Game.IsInGame) return; | |
if (Hud.Game.Me.InGreaterRift) | |
{ | |
if (inGR == false) { inGR = true; } | |
foreach(IMonsterPack p in Hud.Game.MonsterPacks) | |
{ | |
int n = p.MonstersAlive.Where(a => ( ((a.Rarity == ActorRarity.Champion) || (a.Rarity == ActorRarity.Rare)) && (a.SummonerAcdDynamicId == 0)) ).Count(); | |
if (n > 0) // Solo actualizaremos packs con elites cerca. Además me di cuenta de un problema si no exijo esto porque .. al iniciar rápido una nueva GR existen packs de la GR anterior | |
{ | |
if (DicPacks.TryGetValue(p,out var h)) | |
{ | |
if (n > h[0]) { DicPacks[p][0] = n; } | |
} | |
else | |
{ | |
DicPacks.Add(p,new int[] {n,0}); | |
} | |
} | |
} | |
int blues = 0, bluesdead = 0, rares = 0, raresdead = 0; | |
foreach(IMonsterPack p in DicPacks.Keys) | |
{ | |
bool deads = DicPacks[p][0] == DicPacks[p][1]; | |
if (p.IsFullChampionPack) | |
{ | |
blues += 1; | |
if (deads) { bluesdead += 1; } | |
} | |
else | |
{ | |
rares += 1; | |
if (deads) { raresdead += 1; } | |
} | |
} | |
var x = Hud.Window.Size.Width * Xpor; | |
var y = Hud.Window.Size.Height * Ypor; | |
var layout = FontW.GetTextLayout("p: " + (blues + rares) + " [" + (bluesdead + raresdead) + "]"); | |
FontW.DrawText(layout, x , y ); | |
if (Vertical) { y += layout.Metrics.Height; } | |
else { x += layout.Metrics.Width + 10; } | |
layout = FontB.GetTextLayout("b: " + blues + " [" + bluesdead + "]"); | |
FontB.DrawText(layout, x , y ); | |
if (Vertical) { y += layout.Metrics.Height; } | |
else { x += layout.Metrics.Width + 10; } | |
layout = FontY.GetTextLayout("y: " + rares + " [" + raresdead + "]"); | |
FontY.DrawText(layout, x , y ); | |
} | |
else | |
{ | |
if (inGR) { inGR = false; DicPacks.Clear(); } | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment