Advertisement
RuneB

ArchonWizPlugin.cs

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