Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using Turbo.Plugins.Default;
- using System.Linq;
- using System.Threading;
- namespace Turbo.Plugins.RNN
- {
- public class Chilanik : BasePlugin, INewAreaHandler, IInGameTopPainter, ICustomizer, IAfterCollectHandler
- {
- private int Indice { get; set; } = -1;
- private bool Alerted { get; set; }
- private int FinishTick { get; set; } = 0;
- private SharpDX.DirectWrite.TextLayout layout { get; set; }
- private ITexture BGTexture { get; set; } = null;
- private ITexture FGTexture { get; set; } = null;
- private IFont WhiteFont { get; set; }
- private IFont CooldownFont { get; set; }
- private IFont StacksFont { get; set; }
- private float x { get; set; } = 0f;
- private float y { get; set; } = 0f;
- private float SizeIconWidth { get; set; }
- private float SizeIconHeight { get; set; }
- public uint powersno { get; set; } = 0;
- public int powerindex { get; set; } = 0;
- public uint textureid { get; set; } = 0; // Texture id for skills
- public ISnoItem snoItem { get; set; } = null; // ISnoItem for Item Texture. Read interfaces\controllers\sno\ISnoItemList.cs
- public uint powersno4cd { get; set; } = 0; // powersno alternative for cooldown (from skill)
- public uint DurationBuffLost { get; set; } = 10;
- public bool ShowStacks { get; set; }
- public bool ShowIcon { get; set; }
- public bool SoundEnabled { get; set; }
- public string FileSound { get; set; }
- public bool BeepOption { get; set; }
- public int BeepFrecuency { get; set; }
- public int BeepDuration { get; set; }
- public float EarlyAlert { get; set; }
- public float Xpor { get; set; }
- public float Ypor { get; set; }
- public float IconSize { get; set; } = 28f;
- public float SizeMultiplier { get; set; } = 1.0f;
- public Chilanik()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30001;
- ShowIcon = true;
- ShowStacks = false;
- SoundEnabled = true;
- FileSound = "notification_8.wav"; // File to be played. It must be in the Sounds\ folder
- EarlyAlert = 1f; // You can choose to be notified in advance. Valid values: from 0 to 4. If it is zero it will notify us just when the bonus ends
- BeepOption = true;
- BeepFrecuency = 1000;
- BeepDuration = 50;
- Xpor = 0.557f; // Valid values: from 0 to 1 . To set the x coordinate of the icon // 0.461f mirror // 0.541f just beside
- Ypor = 0.452f; // Valid values: from 0 to 1 . To set the y coordinate of the icon
- SizeMultiplier = 0.50f;
- powersno = 318821;
- powerindex = 1;
- textureid = 0;
- snoItem = Hud.Sno.SnoItems.Unique_BarbBelt_101_x1; // if it has a value other than null, textureid will be ignored, and the texture of this item will be drawn. // Chilanik
- powersno4cd = 375483; // powersno alternative for cooldown (from skill). If == 0, it will take the same value as powersno. // Warcry, for Chilanik
- }
- public void Customize()
- {
- if ((EarlyAlert < 0) || (EarlyAlert > 4)) { EarlyAlert = 0; }
- EarlyAlert = EarlyAlert + 0.2f; // para compensar el retraso en la reproduccion.
- WhiteFont = Hud.Render.CreateFont("tahoma", 17f * SizeMultiplier, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
- CooldownFont = Hud.Render.CreateFont("tahoma", 10f * SizeMultiplier, 220, 255, 255, 0, true, false, 255, 0, 0, 0, true);
- StacksFont = Hud.Render.CreateFont("tahoma", 9f * SizeMultiplier, 220, 255, 255, 255, true, false, 255, 0, 0, 0, true);
- if (snoItem != null)
- {
- BGTexture = Hud.Texture.InventoryLegendaryBackgroundSmall;
- FGTexture = Hud.Texture.GetItemTexture(snoItem);
- }
- else
- {
- FGTexture = (textureid > 0)? Hud.Texture.GetTexture(textureid): Hud.Texture.InventoryLegendaryBackgroundSmall ;
- }
- if (powersno4cd == 0) { powersno4cd = powersno; }
- }
- public void OnNewArea(bool newGame, ISnoArea area)
- {
- if ((newGame) || (Indice != Hud.Game.Me.Index))
- {
- Indice = Hud.Game.Me.Index;
- Alerted = true;
- FinishTick = Hud.Game.CurrentGameTick - (int) DurationBuffLost * 65;
- }
- }
- public void Play_Sound(string Sonido)
- {
- var playSonido = Hud.Sound.LoadSoundPlayer(Sonido);
- ThreadPool.QueueUserWorkItem(state =>
- {
- try { playSonido.PlaySync(); }
- catch (Exception) { }
- } );
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame) return;
- if (Hud.Game.Me.Powers.GetBuff(powersno) == null) return;
- double left = Hud.Game.Me.Powers.GetBuff(powersno).TimeLeftSeconds[powerindex];
- if (left == 0)
- {
- if (Hud.Game.Me.Powers.GetBuff(powersno).IconCounts[powerindex] > 0) { return; }
- }
- else
- {
- FinishTick = (int) (Hud.Game.CurrentGameTick + (left * 60));
- }
- if (SoundEnabled)
- {
- if (left <= EarlyAlert)
- {
- if (!Alerted)
- {
- Alerted = true;
- if (!Hud.Game.IsInTown && !Hud.Game.Me.Powers.BuffIsActive(224639))
- {
- if (BeepOption) Console.Beep(BeepFrecuency, BeepDuration);
- else Play_Sound(FileSound);
- }
- }
- }
- else
- {
- if (Alerted) { Alerted = false; }
- }
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame || Hud.Game.IsInTown) return;
- if (ShowIcon)
- {
- if (Hud.Game.Me.Powers.GetBuff(powersno) == null) return;
- if (Hud.Game.Me.Powers.BuffIsActive(224639)) return;
- double left = Hud.Game.Me.Powers.GetBuff(powersno).TimeLeftSeconds[powerindex];
- x = Hud.Window.Size.Width * Xpor; y = Hud.Window.Size.Height * Ypor;
- SizeIconWidth = Hud.Texture.InventoryLegendaryBackgroundSmall.Width * SizeMultiplier; SizeIconHeight = Hud.Texture.InventoryLegendaryBackgroundSmall.Height * SizeMultiplier;
- if (left == 0)
- {
- double elapsed = (Hud.Game.CurrentGameTick - FinishTick) / 60;
- if (elapsed > DurationBuffLost) return;
- if (BGTexture != null) BGTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- if (FGTexture != null) FGTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- Hud.Texture.DebuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 0.8f);
- layout = WhiteFont.GetTextLayout( ((elapsed < 1)? "":"-") + elapsed.ToString("F0") );
- }
- else
- {
- if (BGTexture != null) BGTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- if (FGTexture != null) FGTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- Hud.Texture.BuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- layout = WhiteFont.GetTextLayout( ( left < 1)? String.Format("{0:N1}",left) : String.Format("{0:0}",(int) (left + 0.80)) ); // Redondeará a X si es menor a X.20
- }
- WhiteFont.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height))/1.75f));
- if (ShowStacks)
- {
- layout = StacksFont.GetTextLayout(Hud.Game.Me.Powers.GetBuff(powersno).IconCounts[powerindex].ToString());
- StacksFont.DrawText(layout, x + (SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width)) - 2, y + 1);
- }
- var skill = Hud.Game.Me.Powers.UsedSkills.FirstOrDefault(s => s.SnoPower.Sno == powersno4cd);
- if (skill != null)
- {
- if (skill.IsOnCooldown)
- {
- var c = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60f;
- CooldownFont.DrawText(CooldownFont.GetTextLayout(c.ToString( (c < 1)? "F1" : "F0")), x + 2, y + 1 );
- }
- else
- {
- CooldownFont.DrawText(CooldownFont.GetTextLayout("🞴"), x + 2, y );
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment