Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Linq;
- using SharpDX;
- namespace Turbo.Plugins.RNN
- {
- public class BloodIsPowerPlugin : BasePlugin, IInGameTopPainter, IAfterCollectHandler, INewAreaHandler
- {
- private IFont FontText { get; set; }
- private float Last { get; set; } = 0f;
- private float Lost { get; set; } = 0f;
- private IBrush Brush1 { get; set; }
- private IBrush Brush2 { get; set; }
- private IBrush Brush3 { get; set; }
- private int[] state { get; set; }
- private int MyIndex { get; set; } = -1;
- private int ticks { get; set; } = 0;
- private bool Remainder { get; set; } = true;
- public bool ShowCircles { get; set; }
- public bool ShowOnlyOnCooldown { get; set; }
- public bool ShowBar { get; set; }
- public BloodIsPowerPlugin()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 31001;
- ShowCircles = false; // Show a circle instead of an icon
- ShowOnlyOnCooldown = false; // Hide the icon when the skill is not on cooldown
- ShowBar = true; // Show bar with the amount of health lost
- FontText = Hud.Render.CreateFont("tahoma", 6, 255, 200, 175, 150, false, false, 255, 0, 0, 0, true);
- Brush1 = hud.Render.CreateBrush(255, 255, 0, 0, 0);
- Brush2 = hud.Render.CreateBrush(255, 255, 255, 255, 1);
- Brush3 = hud.Render.CreateBrush(255, 0, 0, 0, 1);
- state = new int[] {0,0,0,0,0,0,0};
- }
- public void OnNewArea(bool newGame, ISnoArea area)
- {
- if (newGame || (MyIndex != Hud.Game.Me.Index) ) // Fix partialment the newGame limitation
- {
- MyIndex = Hud.Game.Me.Index;
- Last = 0; Lost = 0;
- for(var i = 0; i < 7; i++) state[i] = 0;
- ticks = Hud.Game.CurrentGameTick;
- }
- }
- public void AfterCollect()
- {
- if (!ShowBar) return;
- if (!Hud.Game.IsInGame ) return;
- if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer) return;
- if (Hud.Game.Me.Powers.UsedPassives.Any(p => p.Sno == Hud.Sno.SnoPowers.Necromancer_Passive_BloodIsPower.Sno)) // 465037
- {
- if (Hud.Game.Me.IsDead)
- {
- if (Last > 0)
- {
- Last = 0; Lost = 0;
- for(var i = 0; i < 7; i++) state[i] = 0;
- }
- }
- else
- {
- if (Hud.Game.Me.Defense.HealthCur > Last) { Last = Hud.Game.Me.Defense.HealthCur; }
- else if (Hud.Game.Me.Defense.HealthCur != Last)
- {
- IBuff buff = Hud.Game.Me.Powers.GetBuff(465037);
- if (buff != null)
- {
- var recibido = false; var pendiente = false;
- foreach (var skill in Hud.Game.Me.Powers.CurrentSkills)
- {
- int i = 1 + (int) skill.Key;
- var n = buff.IconCounts[i];
- if (n == 1)
- {
- if (n != state[i])
- {
- state[i] = n;
- recibido = true;
- }
- }
- else
- {
- if (n != state[i]) state[i] = n;
- if (skill.IsOnCooldown && ((Hud.Game.CurrentGameTick - skill.CooldownStartTick) > 60)) pendiente = true;
- }
- }
- if (recibido) { Lost = Remainder? Math.Max(0,Lost - Hud.Game.Me.Defense.HealthMax): 0 ; ticks = Hud.Game.CurrentGameTick; }
- else if (Hud.Game.Me.Defense.HealthCur < Last)
- {
- Lost += Last - Hud.Game.Me.Defense.HealthCur ;
- if (Lost > Hud.Game.Me.Defense.HealthMax)
- {
- if (pendiente) { Lost = Hud.Game.Me.Defense.HealthMax * 0.98f; }
- else { Lost = Remainder? (Lost - Hud.Game.Me.Defense.HealthMax) : 0 ; ticks = Hud.Game.CurrentGameTick; }
- }
- }
- Last = Hud.Game.Me.Defense.HealthCur;
- }
- }
- }
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.IsInGame) return;
- if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer) return;
- if (Hud.Game.Me.Powers.UsedPassives.Any(p => p.Sno == Hud.Sno.SnoPowers.Necromancer_Passive_BloodIsPower.Sno)) // 465037
- {
- IBuff buff = Hud.Game.Me.Powers.GetBuff(465037);
- if (buff != null)
- {
- foreach (var skill in Hud.Game.Me.Powers.CurrentSkills)
- {
- if (ShowOnlyOnCooldown && !skill.IsOnCooldown) continue;
- if (buff.IconCounts[1 + (int) skill.Key] == 1)
- {
- var ui = Hud.Render.GetPlayerSkillUiElement(skill.Key);
- var rect = new RectangleF((float)Math.Round(ui.Rectangle.X) + 0.5f, (float)Math.Round(ui.Rectangle.Y) + 0.5f, (float)Math.Round(ui.Rectangle.Width), (float)Math.Round(ui.Rectangle.Height));
- if (ShowCircles)
- {
- var d = rect.Width * 0.08f ; var r = rect.Width * 0.06f;
- Brush1.DrawEllipse(rect.X + d , rect.Y + d , r, r);
- Brush2.DrawEllipse(rect.X + d , rect.Y + d , r, r);
- }
- else
- {
- var d = rect.Width * 0.08f ; var r = rect.Width * 0.24f;
- Hud.Texture.GetTexture(1161431971).Draw(rect.X + d, rect.Y + d - 1, r, r); // Hud.Sno.SnoPowers.Necromancer_Passive_BloodIsPower.NormalIconTextureId = 1161431971
- Hud.Texture.BuffFrameTexture.Draw(rect.X + d, rect.Y + d - 1, r, r);
- }
- }
- }
- if (ShowBar)
- {
- var uiRect = Hud.Render.GetUiElement("Root.NormalLayer.game_dialog_backgroundScreenPC.game_progressBar_healthBall").Rectangle;
- var x = uiRect.X + uiRect.Width + 4; var y = uiRect.Y + uiRect.Height * 0.94f;
- ((Math.Abs(Hud.Game.CurrentGameTick - ticks) > 30)?Brush3:Brush2).DrawRectangle(x, y, 4, - uiRect.Height * 0.40f );
- Brush1.DrawRectangle(x, y, 4, - uiRect.Height * 0.40f * (Hud.Game.Me.Defense.HealthMax - Lost) / Hud.Game.Me.Defense.HealthMax );
- var layout = FontText.GetTextLayout( "-" + ( Lost / Hud.Game.Me.Defense.HealthMax * 100).ToString("F0") + "%");
- FontText.DrawText(layout,x - layout.Metrics.Width - 2 , y - layout.Metrics.Height/2 );
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement