Advertisement
RuneB

ArchonWizPlugin.cs

Feb 22nd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 10.20 KB | None | 0 0
  1. using System.Linq;
  2. using Turbo.Plugins.Default;
  3.  
  4. namespace Turbo.Plugins.RuneB
  5. {
  6.     public class ArchonWizPlugin : BasePlugin, IInGameTopPainter, ICustomizer
  7.     {
  8.         public bool ShowWarnings { get; set; }
  9.         public bool ShowInTown { get; set; }
  10.         public bool ShowZeiCircle { get; set; }
  11.         public bool ShowRashaElements { get; set; }
  12.         public bool ShowArchonCD { get; set; }
  13.         public bool ShowArchonRemain { get; set; }
  14.  
  15.         public GroundCircleDecorator ZeiRanceIndicator { get; set; }
  16.         public TopLabelDecorator ArchonCDLabel { get; set; }
  17.         public TopLabelDecorator ArchonCooldownLabel { get; set; }
  18.         public TopLabelDecorator ArchonRemainingLabel { get; set; }
  19.  
  20.         public IFont WarningFont { get; set; }
  21.         public IFont ArchonCDFont { get; set; }
  22.         public IFont ArchonRemainFont { get; set; }
  23.         public IFont ArchonRemainSoonFont { get; set; }
  24.  
  25.         public IBrush RashaBackgroundBrush { get; set; }
  26.         public IBrush FireBrush { get; set; }
  27.         public IBrush ArcaneBrush { get; set; }
  28.         public IBrush LightningBrush { get; set; }
  29.         public IBrush ColdBrush { get; set; }
  30.         public IBrush GreyBrush { get; set; }
  31.  
  32.         private IPlayerSkill ArchonSkill { get { return Hud.Game.Me.Powers.UsedSkills.FirstOrDefault(s => s.SnoPower.Sno == 134872); } }
  33.         private IPlayerSkill MagicWeaponSkill { get { return Hud.Game.Me.Powers.UsedSkills.FirstOrDefault(s => s.SnoPower.Sno == 76108); } }
  34.         private IPlayerSkill EnergyArmorSkill { get { return Hud.Game.Me.Powers.UsedSkills.FirstOrDefault(s => s.SnoPower.Sno == 86991); } }
  35.         private float HudWidth { get { return Hud.Window.Size.Width; } }
  36.         private float HudHeight { get { return Hud.Window.Size.Height; } }
  37.  
  38.         private float _lWidth, _lHeight, _lRashaSize, _lRashaYpos, _lRashaSizeMod, _arcCDRemain, _tick;
  39.         private bool _timerRunning = false;
  40.  
  41.         public ArchonWizPlugin()
  42.         {
  43.             Enabled = true;
  44.         }
  45.  
  46.         public void Customize()
  47.         {
  48.             Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
  49.             {
  50.                 plugin.BuffPainter.ShowTimeLeftNumbers = true;
  51.                 plugin.RuleCalculator.Rules.Add(new BuffRule(134872) { IconIndex = 2, MinimumIconCount = 1, ShowTimeLeft = false, ShowStacks = true, IconSizeMultiplier = 1.3f }); // Archon
  52.                 plugin.RuleCalculator.Rules.Add(new BuffRule(429855) { IconIndex = 5, MinimumIconCount = 1, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Tal Rasha
  53.             });
  54.         }
  55.  
  56.         public override void Load(IController hud)
  57.         {
  58.             base.Load(hud);
  59.  
  60.             // Public vars
  61.             ShowWarnings = true;
  62.             ShowInTown = true;
  63.             ShowZeiCircle = true;
  64.             ShowRashaElements = true;
  65.             ShowArchonCD = true;
  66.             ShowArchonRemain = true;
  67.  
  68.             WarningFont = Hud.Render.CreateFont("tahoma", 10f, 200, 255, 0, 0, false, false, 160, 0, 0, 0, true);
  69.             ArchonCDFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true);
  70.             ArchonRemainFont = Hud.Render.CreateFont("tahoma", 10f, 255, 80, 140, 210, false, false, 160, 0, 0, 0, true);
  71.             ArchonRemainSoonFont = Hud.Render.CreateFont("tahoma", 16f, 255, 255, 0, 0, false, false, 160, 0, 0, 0, true);
  72.  
  73.             RashaBackgroundBrush = Hud.Render.CreateBrush(100, 30, 30, 30, 0);
  74.             GreyBrush = Hud.Render.CreateBrush(255, 50, 50, 50, 0);
  75.             FireBrush = Hud.Render.CreateBrush(255, 200, 130, 30, 0);
  76.             ArcaneBrush = Hud.Render.CreateBrush(255, 180, 80, 180, 0);
  77.             LightningBrush = Hud.Render.CreateBrush(255, 0, 65, 145, 0);
  78.             ColdBrush = Hud.Render.CreateBrush(255, 80, 130, 180, 0);
  79.             ZeiRanceIndicator = new GroundCircleDecorator(Hud)
  80.             {
  81.                 Brush = Hud.Render.CreateBrush(50, 14, 200, 245, 1.5f),
  82.                 Radius = 50f
  83.             };
  84.             ArchonCooldownLabel = new TopLabelDecorator(Hud)
  85.             {
  86.                 TextFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
  87.                 TextFunc = () => ArchonCooldown(),
  88.             };
  89.  
  90.             // Private vars
  91.             _lWidth = 80;
  92.             _lHeight = 15;
  93.             _lRashaSize = 24f;
  94.             _lRashaYpos = 0.585f;
  95.             _lRashaSizeMod = 0.9f;
  96.         }
  97.  
  98.         public void PaintTopInGame(ClipState clipState)
  99.         {
  100.             if (Hud.Game.IsInGame && Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.Wizard && !(Hud.Game.Me.IsInTown && !ShowInTown))
  101.             {
  102.                 var me = Hud.Game.Me;
  103.                 //UpdateSkills(me);
  104.  
  105.                 //If Disentegration wave is used draw zei circle
  106.                 if (me.Powers.BuffIsActive(392891, 4) && ShowZeiCircle)
  107.                     ZeiRanceIndicator.Paint(me, me.FloorCoordinate, null);
  108.  
  109.                 //Draw missing buff warnings
  110.                 if (ShowWarnings && !me.IsDead)
  111.                     DrawWarnings(me);
  112.  
  113.                 //Draw individual indicators for each tal rasha element
  114.                 if (me.Powers.BuffIsActive(429855, 5) && ShowRashaElements)
  115.                     TalRashaElements(me);
  116.  
  117.                 //Draw Archon cooldown
  118.                 if (ShowArchonCD && ArchonSkill != null)
  119.                     ArchonCooldownLabel.Paint(HudWidth * 0.5f - _lWidth / 2, HudHeight * 0.515f, _lWidth, _lHeight, HorizontalAlign.Center);
  120.  
  121.                 //Draw Archon time remaining
  122.                 if (ShowArchonRemain && ArchonSkill != null)
  123.                     ArchonRemaining(me);
  124.             }
  125.         }
  126.  
  127.         public string ArchonCooldown()
  128.         {
  129.             string s = "";
  130.             if (ArchonSkill.CooldownFinishTick > Hud.Game.CurrentGameTick)
  131.             {
  132.                 var c = (ArchonSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
  133.                 s = string.Format("{0:N1}", c);
  134.             }
  135.             return s;
  136.         }
  137.  
  138.         private void ArchonRemaining(IPlayer me)
  139.         {
  140.             if (me.Powers.BuffIsActive(134872, 2))
  141.             {
  142.                 if (!_timerRunning)
  143.                     _tick = Hud.Game.CurrentGameTick;
  144.                 _timerRunning = true;
  145.  
  146.                 var r = 20f - ((Hud.Game.CurrentGameTick - _tick) / 60.0d);
  147.                 if (r > 3f)
  148.                 {
  149.                     var layout = ArchonRemainFont.GetTextLayout(string.Format("{0:N1}", r));
  150.                     ArchonRemainFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.515f);
  151.                 }
  152.                 else {
  153.                     var layout = ArchonRemainSoonFont.GetTextLayout(string.Format("{0:N1}", r));
  154.                     ArchonRemainSoonFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.505f);
  155.                 }
  156.             }
  157.             else _timerRunning = false;
  158.         }
  159.  
  160.         private void TalRashaElements(IPlayer me)
  161.         {
  162.             RashaBackgroundBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize * 1.6f, HudHeight * _lRashaYpos - _lRashaSize * 0.1f, _lRashaSize * 4.1f, _lRashaSize * 1.1f);
  163.  
  164.             if (me.Powers.BuffIsActive(429855, 1)) ArcaneBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize * 1.5f, HudHeight * _lRashaYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  165.             else DrawGreyBrush(-_lRashaSize * 1.5f);
  166.  
  167.             if (me.Powers.BuffIsActive(429855, 2)) ColdBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize / 2, HudHeight * _lRashaYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  168.             else DrawGreyBrush(-_lRashaSize / 2);
  169.  
  170.             if (me.Powers.BuffIsActive(429855, 3)) FireBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + _lRashaSize / 2, HudHeight * _lRashaYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  171.             else DrawGreyBrush(_lRashaSize / 2);
  172.  
  173.             if (me.Powers.BuffIsActive(429855, 4)) LightningBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + _lRashaSize * 1.5f, HudHeight * _lRashaYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  174.             else DrawGreyBrush(_lRashaSize * 1.5f);
  175.         }
  176.  
  177.         private void DrawGreyBrush(float xPos)
  178.         {
  179.             GreyBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + xPos, HudHeight * _lRashaYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  180.         }
  181.  
  182.         private void DrawWarnings(IPlayer me)
  183.         {
  184.             //IN ARCHON
  185.             if (me.Powers.BuffIsActive(134872, 2)) //Archon
  186.             {
  187.                 if (!me.Powers.BuffIsActive(135663, 0)) //Slow Time
  188.                 {
  189.                     var layout = WarningFont.GetTextLayout("Bubble Up");
  190.                     WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.47f);
  191.                 }
  192.             }else
  193.             {//NOT IN ARCHON
  194.                 if (MagicWeaponSkill != null)
  195.                 {
  196.                     var layout = WarningFont.GetTextLayout("Missing Magic Weapon");
  197.                     if (!me.Powers.BuffIsActive(76108, 0))
  198.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.47f);
  199.                 }
  200.  
  201.                 if (EnergyArmorSkill != null)
  202.                 {
  203.                     var layout = WarningFont.GetTextLayout("Missing Energy Armor");
  204.                     if (!me.Powers.BuffIsActive(86991, 0))
  205.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.49f);
  206.                 }
  207.             }
  208.         }
  209.  
  210.         /*private void UpdateSkills(IPlayer me)
  211.         {
  212.             me.Powers.UsedSkills.ForEach(skill =>
  213.             {
  214.                 if (skill.SnoPower.Sno == 134872) _archonSkill = skill;
  215.                 if (skill.SnoPower.Sno == 76108) _magicWeaponSkill = skill;
  216.                 if (skill.SnoPower.Sno == 86991) EnergyArmorSkill = skill;
  217.             });
  218.         }*/
  219.     }
  220. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement