Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- using System.Text;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.glq
- {
- public class GLQ_AncientParthanCount : BasePlugin, IInGameTopPainter
- {
- public IFont TextFont { get; set; }
- public float XWidth { get; set; }
- public float YHeight { get; set; }
- public int Percent { get; private set; }
- private StringBuilder textBuilder;
- public GLQ_AncientParthanCount()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- TextFont = Hud.Render.CreateFont("tahoma", 9, 255, 170, 90, 90, false, false, true);
- XWidth = 0.7f;
- YHeight = 0.4f;
- Percent = 0;
- textBuilder = new StringBuilder();
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (!Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.AncientParthanDefenders.Sno))
- {
- Percent = 0;
- return;
- }
- var count = Hud.Game.AliveMonsters.Count(m => (m.Stunned || m.Frozen) && m.NormalizedXyDistanceToMe <= 25);
- if (count == 0) return;
- if (Percent == 0)
- {
- SetDamageReductionPercent();
- }
- var dr = 100 * (1 - Math.Pow(1 - Percent * 0.01d, count));
- textBuilder.Clear();
- textBuilder.AppendFormat("古帕触发数: {0} 特效值:{1}%", count, Percent);
- textBuilder.AppendLine();
- textBuilder.AppendFormat("古帕总减伤: {0}%", dr.ToString("f2"));
- var layout = TextFont.GetTextLayout(textBuilder.ToString());
- var XPos = Hud.Window.Size.Width * XWidth;
- var YPos = Hud.Window.Size.Height * YHeight;
- TextFont.DrawText(layout, XPos, YPos);
- }
- private void SetDamageReductionPercent()
- {
- if (Hud.Game.Me.CubeSnoItem2 != null && Hud.Game.Me.CubeSnoItem2.LegendaryPower.Sno == Hud.Sno.SnoPowers.AncientParthanDefenders.Sno)
- {
- Percent = 12;
- }
- else
- {
- var parthans = Hud.Game.Items.First(item => item.Location == ItemLocation.Bracers).Perfections.FirstOrDefault(p => p.Attribute.Code == "Item_Power_Passive");
- Percent = parthans == null ? 10 : (int)Math.Round(parthans.Cur * 100);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement