Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PartyCooldownPlugin by HaKache
- // Shows chosen skills on CD under players feet using CooldownPainter.
- using System;
- using System.Linq;
- using System.Globalization;
- using SharpDX.DirectInput;
- using SharpDX;
- using Turbo.Plugins.Default;
- using System.Collections.Generic;
- namespace Turbo.Plugins.Extended.Addons
- {
- public class PartyCooldownPlugin : BasePlugin, IInGameTopPainter
- {
- public CooldownPainter SkillPainter { get; set; }
- public CooldownPainter MySkillPainter { get; set; }
- public IFont GreenFont { get; set; }
- public IFont RedFont { get; set; }
- public TopLabelDecorator Label { get; set; }
- public List<uint> WatchedSnos;
- public bool ShowSelf { get; set; }
- public bool ShowOnlyMe { get; set; }
- public bool ShowInTown { get; set; }
- public bool OnlyInGR { get; set; }
- public bool PersonalCooldowns { get; set; }
- public float Offset { get; set; }
- private readonly int[] _skillOrder = { 2, 3, 4, 5, 0, 1 };
- public PartyCooldownPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- ShowSelf = false;
- ShowInTown = true;
- OnlyInGR = false;
- ShowOnlyMe = false;
- PersonalCooldowns = true;
- Offset = 0.055f; // 0 = Middle - Negative = Up - Positive = Down
- WatchedSnos = new List<uint>();
- // Add skills to the watch list below
- // --- Necromancer
- WatchedSnos.Add(465350); // Simulacrum
- WatchedSnos.Add(465839); // Land of the Dead
- // --- Barb
- //WatchedSnos.Add(79528); // Ignore Pain
- //WatchedSnos.Add(79607); // Wrath of the Berserker
- //WatchedSnos.Add(375483); // Warcry
- // --- Monk
- //WatchedSnos.Add(317076); // Inner Sanctuary
- // --- Witch Doctor
- //WatchedSnos.Add(106237); // Spirit Walk
- // --- Demon Hunter
- //WatchedSnos.Add(365311); // Companion
- // --- Wizard
- WatchedSnos.Add(134872); // Archon
- //WatchedSnos.Add(243141); // BH
- GreenFont = Hud.Render.CreateFont("tahoma", 6f, 255, 128, 255, 0, true, false, 220, 0, 0, 0, true);
- RedFont = Hud.Render.CreateFont("tahoma", 6f, 255, 255, 30, 50, true, false, 220, 0, 0, 0, true);
- SkillPainter = new CooldownPainter(Hud, true)
- {
- TextureOpacity = 0.7f,
- CooldownFont = Hud.Render.CreateFont("tahoma", 6f, 255, 255, 255, 255, true, false, 220, 0, 0, 0, true),
- };
- MySkillPainter = new CooldownPainter(Hud, true)
- {
- TextureOpacity = 0.15f,
- CooldownFont = Hud.Render.CreateFont("tahoma", 6f, 255, 255, 255, 255, true, false, 220, 0, 0, 0, true),
- };
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip || !ShowInTown && Hud.Game.Me.IsInTown || OnlyInGR && Hud.Game.SpecialArea != SpecialArea.GreaterRift) return;
- float iconSize = 30f;
- foreach (var player in Hud.Game.Players.Where(p => p.HasValidActor).OrderBy(p => p.HeroId))
- {
- var xPos = player.ScreenCoordinate.X - Hud.Window.Size.Width * 0.015f;
- if (player.IsMe && !ShowSelf || !player.IsMe && ShowOnlyMe) continue;
- var found = false;
- foreach (var i in _skillOrder)
- {
- var skill = player.Powers.SkillSlots[i];
- if (skill == null || !WatchedSnos.Contains(skill.SnoPower.Sno)) continue;
- found = true;
- if (skill.SnoPower.Sno != 134872) {
- var rect = new RectangleF(xPos, player.ScreenCoordinate.Y + Hud.Window.Size.Height * Offset, iconSize, iconSize);
- SkillPainter.Paint(skill, rect);
- xPos += iconSize + 1f;
- }
- else if (skill.SnoPower.Sno == 134872)
- {
- double archonCooldown = 0;
- double archonTimeLeft = 0;
- archonCooldown = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
- var archonBuff = player.Powers.GetBuff(Hud.Sno.SnoPowers.Wizard_Archon.Sno);
- if (archonBuff != null) { archonTimeLeft = archonBuff.TimeLeftSeconds[2]; }
- var txtdrawn = false; var drawn = false;
- foreach (var iicon in Hud.Sno.SnoPowers.Wizard_Archon.Icons) {
- var Texture = Hud.Texture.GetTexture(iicon.TextureId);
- if (Texture != null && (archonCooldown > 0.0 || archonTimeLeft != 0) && !drawn) {
- Texture.Draw(xPos, player.ScreenCoordinate.Y + Hud.Window.Size.Height * Offset, iconSize, iconSize, 0.7f);
- Hud.Texture.BuffFrameTexture.Draw(xPos, player.ScreenCoordinate.Y + Hud.Window.Size.Height * Offset, iconSize, iconSize, 0.7f);
- drawn = true;
- }
- }
- if (archonTimeLeft == 0 && archonCooldown > 0.0 && !txtdrawn)
- {
- var layout = RedFont.GetTextLayout(archonCooldown.ToString("0"));
- RedFont.DrawText(layout, xPos + (iconSize - layout.Metrics.Width) / 2, player.ScreenCoordinate.Y + Hud.Window.Size.Height * Offset + (iconSize - layout.Metrics.Height) / 2);
- txtdrawn = true;
- }
- if (archonTimeLeft != 0 && !txtdrawn)
- {
- var layout = GreenFont.GetTextLayout(archonTimeLeft.ToString("0"));
- GreenFont.DrawText(layout, xPos + (iconSize - layout.Metrics.Width) / 2, player.ScreenCoordinate.Y + Hud.Window.Size.Height * Offset + (iconSize - layout.Metrics.Height) / 2);
- txtdrawn = true;
- }
- xPos += iconSize + 1f;
- }
- }
- if (found)
- xPos += iconSize + 1f;
- }
- if (PersonalCooldowns) {
- var uiSkillX = Hud.Window.Size.Width * 0.446f;
- var uiSkillY = Hud.Window.Size.Height * 0.473f;
- iconSize = 25f;
- var player = Hud.Game.Me;
- foreach (var i in _skillOrder)
- {
- var skill = player.Powers.SkillSlots[i];
- if (player.Powers.SkillSlots[2] != null) {
- var rect = new RectangleF(uiSkillX + 5f, uiSkillY, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[2], rect);
- }
- if (player.Powers.SkillSlots[3] != null) {
- var rect = new RectangleF(uiSkillX + 21f, uiSkillY + 29f, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[3], rect);
- }
- if (player.Powers.SkillSlots[4] != null) {
- var rect = new RectangleF(uiSkillX + 51f, uiSkillY + 44f, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[4], rect);
- }
- if (player.Powers.SkillSlots[5] != null) {
- var rect = new RectangleF(uiSkillX + 131f, uiSkillY + 44f, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[5], rect);
- }
- if (player.Powers.SkillSlots[0] != null) {
- var rect = new RectangleF(uiSkillX + 161f, uiSkillY + 29f, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[0], rect);
- }
- if (player.Powers.SkillSlots[1] != null) {
- var rect = new RectangleF(uiSkillX + 177f, uiSkillY, iconSize, iconSize);
- MySkillPainter.Paint(player.Powers.SkillSlots[1], rect);
- }
- }
- }
- }
- }
- public class CooldownPainter : ITransparentCollection
- {
- public bool Enabled { get; set; }
- public IController Hud { get; set; }
- public IFont CooldownFont { get; set; }
- public IFont GreenFont { get; set; }
- public IFont RedFont { get; set; }
- public float TextureOpacity { get; set; }
- private readonly IWatch _lastTownEliteSimulation;
- public CooldownPainter(IController hud, bool setDefaultStyle)
- {
- Enabled = true;
- Hud = hud;
- _lastTownEliteSimulation = Hud.Time.CreateWatch();
- if (setDefaultStyle)
- {
- TextureOpacity = 0.2f;
- CooldownFont = Hud.Render.CreateFont("tahoma", 6f, 255, 255, 255, 255, true, false, 220, 0, 0, 0, true);
- }
- GreenFont = Hud.Render.CreateFont("tahoma", 6f, 255, 128, 255, 0, true, false, 220, 0, 0, 0, true);
- RedFont = Hud.Render.CreateFont("tahoma", 6f, 255, 255, 30, 50, true, false, 220, 0, 0, 0, true);
- }
- public void Paint(IPlayerSkill skill, RectangleF rect)
- {
- if (skill == null) return;
- if (!skill.IsOnCooldown) return;
- if (TextureOpacity > 0)
- {
- var texture = Hud.Texture.GetTexture(skill.SnoPower.NormalIconTextureId);
- if (texture != null)
- {
- texture.Draw(rect.X, rect.Y, rect.Width, rect.Height, TextureOpacity);
- Hud.Texture.BuffFrameTexture.Draw(rect.X, rect.Y, rect.Width, rect.Height, TextureOpacity);
- }
- }
- if (skill.IsOnCooldown && (skill.CooldownFinishTick > Hud.Game.CurrentGameTick))
- {
- var remaining = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
- var text = remaining > 1.0f ? remaining.ToString("F0", CultureInfo.InvariantCulture) : remaining.ToString("F0", CultureInfo.InvariantCulture);
- var textLayout = CooldownFont.GetTextLayout(text);
- CooldownFont.DrawText(textLayout, rect.X + (rect.Width - (float)Math.Ceiling(textLayout.Metrics.Width)) / 2.0f, rect.Y + (rect.Height - textLayout.Metrics.Height) / 2);
- }
- var rune = skill.Rune;
- if (rune == byte.MaxValue) rune = 0; else rune += 1;
- }
- public IEnumerable<ITransparent> GetTransparents()
- {
- yield return CooldownFont;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement