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 BandOfMight : BasePlugin, INewAreaHandler, IInGameTopPainter, ICustomizer, IAfterCollectHandler
- {
- private int Indice { get; set; } = -1;
- private bool Alerted { get; set; }
- private int FinishTick { get; set; } = 0;
- private int AlertedTick { get; set; } = 0;
- private ITexture BMTexture { get; set; } = null;
- private IFont WhiteFont { get; set; }
- private float x { get; set; } = 0f;
- private float y { get; set; } = 0f;
- private float SizeIconWidth { get; set; }
- private float SizeIconHeight { get; set; }
- private uint powersno { get; set; } = 447060;
- private int powerindex { get; set; } = 1;
- private uint textureid { get; set; } = 3995670063;
- public uint DurationBuffLost { get; set; } = 5;
- 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 BandOfMight()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 30001;
- ShowIcon = true;
- 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 = false;
- BeepFrecuency = 1000;
- BeepDuration = 50;
- Xpor = 0.525f; // Valid values: from 0 to 1 . To set the x coordinate of the icon
- Ypor = 0.452f; // Valid values: from 0 to 1 . To set the y coordinate of the icon
- SizeMultiplier = 0.45f;
- BMTexture = Hud.Texture.GetTexture(textureid);
- }
- 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", 18f * SizeMultiplier, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
- }
- 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;
- AlertedTick = 0;
- }
- }
- 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.BuffIsActive(powersno))
- {
- 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; AlertedTick = Hud.Game.CurrentGameTick;
- if (!Hud.Game.IsInTown && !Hud.Game.Me.Powers.BuffIsActive(224639))
- {
- if (BeepOption) Console.Beep(BeepFrecuency, BeepDuration);
- else Play_Sound(FileSound);
- }
- }
- }
- else
- {
- if (Alerted && ((Hud.Game.CurrentGameTick - AlertedTick) > 120) ) { Alerted = false; }
- }
- }
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame || Hud.Game.IsInTown) return;
- if (Hud.Game.Me.Powers.BuffIsActive(powersno) && ShowIcon)
- {
- 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 = BMTexture.Width * SizeMultiplier; SizeIconHeight = BMTexture.Height * SizeMultiplier;
- if (left == 0)
- {
- double elapsed = (Hud.Game.CurrentGameTick - FinishTick) / 60;
- if (elapsed > DurationBuffLost) return;
- BMTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- Hud.Texture.DebuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 0.8f);
- var layout = WhiteFont.GetTextLayout( ((elapsed < 1)? "":"-") + elapsed.ToString("F0") );
- WhiteFont.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height))/2.0f));
- }
- else
- {
- BMTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- Hud.Texture.BuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, 1f);
- var 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))/2.0f));
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment