Advertisement
s4000

DAV_KilledElitePlugin

Jan 4th, 2020
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.15 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using Turbo.Plugins.Default;
  4.  
  5. namespace Turbo.Plugins.DAV
  6. {
  7.     public class DAV_KilledElitePlugin : BasePlugin, IInGameTopPainter, INewAreaHandler, IMonsterKilledHandler {
  8.         public float xPos { get; set; }
  9.         public float yPos { get; set; }
  10.         public float showTimer { get; set; }
  11.         public string msgHeader { get; set; }
  12.         public IFont textFont { get; set; }
  13.  
  14.         private List<Tuple<string, int>> DeadList { get; set; } = new List<Tuple<string, int>>();
  15.         private Dictionary<string, int> DeadCount { get; set; } = new Dictionary<string, int>();
  16.  
  17.         public DAV_KilledElitePlugin() {
  18.             Enabled = true;
  19.         }
  20.  
  21.         public override void Load(IController hud) {
  22.             base.Load(hud);
  23.  
  24.             showTimer = 10f;
  25.             msgHeader = "Dead Elite";
  26.             xPos = Hud.Window.Size.Width * 0.5f;
  27.             yPos = Hud.Window.Size.Height * 160 / 1080;
  28.             textFont = Hud.Render.CreateFont("Arial", 10, 255, 51, 255, 51, true, true, true);
  29.         }
  30.  
  31.         public void PaintTopInGame(ClipState clipState) {
  32.             if (Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
  33.             if (Hud.Game.RiftPercentage == 100) return;
  34.             if (DeadList.Count == 0) return;
  35.  
  36.             var k = 0;
  37.             DeadCount.Clear();
  38.             var curTime = Hud.Game.CurrentGameTick;
  39.             foreach(var monster in DeadList) {
  40.                 if (monster.Item2 + (int)(60 * showTimer) < curTime) {
  41.                     k++;
  42.                     continue;
  43.                 }
  44.                 if (DeadCount.ContainsKey(monster.Item1))
  45.                     DeadCount[monster.Item1]++;
  46.                 else
  47.                     DeadCount.Add(monster.Item1, 1);
  48.             }
  49.  
  50.             var msg = msgHeader;
  51.             foreach (KeyValuePair<string, int> deadElite in DeadCount)
  52.                 msg += "\n" + deadElite.Value.ToString() + " x " + deadElite.Key;
  53.  
  54.             textFont.DrawText(msg, xPos, yPos);
  55.  
  56.             if (k > 0)
  57.                 DeadList.RemoveRange(0, k);
  58.         }
  59.  
  60.         public void OnMonsterKilled(IMonster monster) {
  61.             if (Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
  62.             if (monster.Rarity == ActorRarity.Champion && !monster.Illusion)
  63.                 DeadList.Add(new Tuple<string, int>(monster.SnoMonster.NameLocalized, Hud.Game.CurrentGameTick));
  64.         }
  65.  
  66.         public void OnNewArea(bool newGame, ISnoArea area) {
  67.             if (newGame || area.IsTown)
  68.                 DeadList.Clear();
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement