Advertisement
JackCeparou

GLQ_AncientParthanCount

Jul 31st, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Text;
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.glq
  7. {
  8.     public class GLQ_AncientParthanCount : BasePlugin, IInGameTopPainter
  9.     {
  10.         public IFont TextFont { get; set; }
  11.         public float XWidth { get; set; }
  12.         public float YHeight { get; set; }
  13.         public int Percent { get; private set; }
  14.         private StringBuilder textBuilder;
  15.  
  16.         public GLQ_AncientParthanCount()
  17.         {
  18.             Enabled = true;
  19.         }
  20.  
  21.         public override void Load(IController hud)
  22.         {
  23.             base.Load(hud);
  24.             TextFont = Hud.Render.CreateFont("tahoma", 9, 255, 170, 90, 90, false, false, true);
  25.             XWidth = 0.7f;
  26.             YHeight = 0.4f;
  27.             Percent = 0;
  28.             textBuilder = new StringBuilder();
  29.         }
  30.  
  31.         public void PaintTopInGame(ClipState clipState)
  32.         {
  33.             if (clipState != ClipState.BeforeClip) return;
  34.             if (!Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.AncientParthanDefenders.Sno))
  35.             {
  36.                 Percent = 0;
  37.                 return;
  38.             }
  39.  
  40.             var count = Hud.Game.AliveMonsters.Count(m => (m.Stunned || m.Frozen) && m.NormalizedXyDistanceToMe <= 25);
  41.             if (count == 0) return;
  42.  
  43.             if (Percent == 0)
  44.             {
  45.                 SetDamageReductionPercent();
  46.             }
  47.  
  48.             var dr = 100 * (1 - Math.Pow(1 - Percent * 0.01d, count));
  49.  
  50.             textBuilder.Clear();
  51.             textBuilder.AppendFormat("古帕触发数: {0} 特效值:{1}%", count, Percent);
  52.             textBuilder.AppendLine();
  53.             textBuilder.AppendFormat("古帕总减伤: {0}%", dr.ToString("f2"));
  54.  
  55.             var layout = TextFont.GetTextLayout(textBuilder.ToString());
  56.             var XPos = Hud.Window.Size.Width * XWidth;
  57.             var YPos = Hud.Window.Size.Height * YHeight;
  58.             TextFont.DrawText(layout, XPos, YPos);
  59.         }
  60.  
  61.         private void SetDamageReductionPercent()
  62.         {
  63.             if (Hud.Game.Me.CubeSnoItem2 != null && Hud.Game.Me.CubeSnoItem2.LegendaryPower.Sno == Hud.Sno.SnoPowers.AncientParthanDefenders.Sno)
  64.             {
  65.                 Percent = 12;
  66.             }
  67.             else
  68.             {
  69.                 var parthans = Hud.Game.Items.First(item => item.Location == ItemLocation.Bracers).Perfections.FirstOrDefault(p => p.Attribute.Code == "Item_Power_Passive");
  70.                 Percent = parthans == null ? 10 : (int)Math.Round(parthans.Cur * 100);
  71.             }
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement