Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Turbo.Plugins.RNN
- {
- public class PacksCounter : BasePlugin, IInGameTopPainter, IMonsterKilledHandler, INewAreaHandler, IAfterCollectHandler
- {
- private uint InRiftLastAreaSno { get; set; }
- private bool MapRiftGR { 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 OnlyGR { get; set; }
- public bool ResetAtEachLevel { get; set; }
- public bool Vertical { get; set; }
- public PacksCounter()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30001;
- Xpor = 0.18f; // 0.89f Valid values: from 0 to 1 .
- Ypor = 0.002f; // 0.91f Valid values: from 0 to 1 .
- OnlyGR = false;
- ResetAtEachLevel = false;
- Vertical = false;
- 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 (MapRiftGR)
- {
- if ( ((monster.Rarity == ActorRarity.Champion) || (monster.Rarity == ActorRarity.Rare)) && (monster.SummonerAcdDynamicId == 0))
- {
- if ((Hud.Game.RiftPercentage < 100) || !Hud.Game.Me.InGreaterRift)
- {
- var p = monster.Pack;
- if (p == null) return;
- if (DicPacks.ContainsKey(p))
- {
- DicPacks[p][1] = DicPacks[p][1] + 1 ;
- }
- else
- {
- DicPacks.Add(p,new int[] {1,1}); // Hud.Sound.Speak("Pack Not Found " + monster.Rarity); // por si acaso
- }
- }
- }
- }
- }
- public void AfterCollect()
- {
- if ((InRiftLastAreaSno != 0) && (Hud.Game.Quests.FirstOrDefault(q => (q.SnoQuest.Sno == 337492) && (q.State == QuestState.started || q.State == QuestState.completed )) == null))
- {
- InRiftLastAreaSno = 0;
- }
- }
- public void OnNewArea(bool newGame, ISnoArea area)
- {
- if (newGame)
- {
- InRiftLastAreaSno = 0;
- MapRiftGR = false;
- }
- if ((area.HostAreaSno == 288482) || (area.Sno == 288482))
- {
- MapRiftGR = true;
- if (InRiftLastAreaSno != area.Sno)
- {
- if ((InRiftLastAreaSno == 0) || ResetAtEachLevel)
- {
- DicPacks.Clear();
- }
- InRiftLastAreaSno = area.Sno;
- }
- }
- else
- {
- MapRiftGR = false;
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- if (MapRiftGR && (!OnlyGR || Hud.Game.Me.InGreaterRift))
- {
- 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;
- if (Vertical)
- {
- var layout = FontW.GetTextLayout("P: " + (blues + rares) + " [" + (bluesdead + raresdead) + "]");
- FontW.DrawText(layout, x , y );
- y += layout.Metrics.Height;
- layout = FontB.GetTextLayout("B: " + blues + " [" + bluesdead + "]");
- FontB.DrawText(layout, x , y );
- y += layout.Metrics.Height;
- layout = FontY.GetTextLayout("Y: " + rares + " [" + raresdead + "]");
- FontY.DrawText(layout, x , y );
- }
- else
- {
- var layout = FontW.GetTextLayout("Packs: " + (blues + rares) + " [" + (bluesdead + raresdead) + "]");
- FontW.DrawText(layout, x , y );
- x += layout.Metrics.Width;
- layout = FontW.GetTextLayout(" /");
- FontW.DrawText(layout, x , y );
- x += layout.Metrics.Width;
- layout = FontB.GetTextLayout( " " + blues + " [" + bluesdead + "]");
- FontB.DrawText(layout, x , y );
- x += layout.Metrics.Width;
- layout = FontW.GetTextLayout(" /");
- FontW.DrawText(layout, x , y );
- x += layout.Metrics.Width;
- layout = FontY.GetTextLayout( " " + rares + " [" + raresdead + "]");
- FontY.DrawText(layout, x , y );
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement