Advertisement
axyd

ArchonWizPlugin

Jan 20th, 2019
593
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.68 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.         public bool AlwaysShowZei { get; set; }
  16.         public float WarningYPos { get; set; }
  17.         public float WarningYPosIncr { get; set; }
  18.         public float ArchonCDandRemainYPos { get; set; }
  19.         public float RashaIndicatorsYpos { get; set; }
  20.  
  21.         public GroundCircleDecorator ZeiRanceIndicator { get; set; }
  22.         public TopLabelDecorator ArchonCDLabel { get; set; }
  23.         public TopLabelDecorator ArchonCooldownLabel { get; set; }
  24.         public TopLabelDecorator ArchonRemainingLabel { get; set; }
  25.  
  26.         public IFont WarningFont { get; set; }
  27.         public IFont ArchonCDFont { get; set; }
  28.         public IFont ArchonRemainFont { get; set; }
  29.         public IFont ArchonRemainSoonFont { get; set; }
  30.  
  31.         public IBrush RashaBackgroundBrush { get; set; }
  32.         public IBrush FireBrush { get; set; }
  33.         public IBrush ArcaneBrush { get; set; }
  34.         public IBrush LightningBrush { get; set; }
  35.         public IBrush ColdBrush { get; set; }
  36.         public IBrush GreyBrush { get; set; }
  37.  
  38.         private IPlayerSkill _archonSkill;
  39.         private IPlayerSkill _magicWeaponSkill;
  40.         private IPlayerSkill _energyArmorSkill;
  41. /*AXYD added*/
  42.         private IPlayerSkill _stormArmorSkill;
  43.         private IPlayerSkill _iceArmorSkill;
  44.         private IPlayerSkill _familiarSkill;
  45.         public bool ShowStormArmor = false;
  46.         public bool ShowIceArmor = false;
  47.         public bool ShowFamiliar = false;          
  48. /*add end*/
  49.         private float HudWidth{get {return Hud.Window.Size.Width; }}
  50.         private float HudHeight{get { return Hud.Window.Size.Height; }}
  51.  
  52.         private float _lWidth, _lHeight, _lRashaSize, _lRashaSizeMod, _arcCDRemain, _tick;
  53.         private bool _timerRunning = false;
  54.  
  55.         public ArchonWizPlugin()
  56.         {
  57.             Enabled = true;
  58.         }
  59.  
  60.         public void Customize()
  61.         {
  62.             Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
  63.             {
  64.                 plugin.BuffPainter.ShowTimeLeftNumbers = true;
  65.                 plugin.RuleCalculator.Rules.Add(new BuffRule(134872) { IconIndex = 2, MinimumIconCount = 1, ShowTimeLeft = false, ShowStacks = true, IconSizeMultiplier = 1.3f }); // Archon
  66.                 plugin.RuleCalculator.Rules.Add(new BuffRule(429855) { IconIndex = 5, MinimumIconCount = 1, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Tal Rasha
  67.             });
  68.         }
  69.  
  70.         public override void Load(IController hud)
  71.         {
  72.             base.Load(hud);
  73.  
  74.             // Public vars
  75.             ShowWarnings = true;
  76.             ShowInTown = true;
  77.             ShowZeiCircle = true;
  78.             ShowRashaElements = true;
  79.             ShowArchonCD = true;
  80.             ShowArchonRemain = true;
  81.             AlwaysShowElements = false;
  82.             AlwaysShowZei = false;
  83.             WarningYPos = 0.27f;
  84.             WarningYPosIncr = 0.022f; // Distance between warnings
  85.             ArchonCDandRemainYPos = 0.495f; // Just below tal rasha icons = 0.605f;
  86.             RashaIndicatorsYpos = 0.585f;
  87.  
  88.             WarningFont = Hud.Render.CreateFont("tahoma", 13f, 200, 255, 0, 0, false, false, true);
  89.             ArchonCDFont = Hud.Render.CreateFont("tahoma", 12f, 255, 140, 140, 180, false, false, true);
  90.             ArchonRemainFont = Hud.Render.CreateFont("tahoma", 12f, 255, 80, 140, 210, false, false, true);
  91.             ArchonRemainSoonFont = Hud.Render.CreateFont("tahoma", 14.5f, 255, 255, 0, 0, false, false, true);
  92.  
  93.             RashaBackgroundBrush = Hud.Render.CreateBrush(100, 30, 30, 30, 0);
  94.             GreyBrush = Hud.Render.CreateBrush(255, 50, 50, 50, 0);
  95.             FireBrush = Hud.Render.CreateBrush(255, 200, 130, 30, 0);
  96.             ArcaneBrush = Hud.Render.CreateBrush(255, 180, 80, 180, 0);
  97.             LightningBrush = Hud.Render.CreateBrush(255, 0, 65, 145, 0);
  98.             ColdBrush = Hud.Render.CreateBrush(255, 80, 130, 180, 0);
  99.             ZeiRanceIndicator = new GroundCircleDecorator(Hud)
  100.             {
  101.                 Brush = Hud.Render.CreateBrush(50, 165, 223, 255, 4.5f),
  102.                 Radius = 50f
  103.             };
  104.             ArchonCooldownLabel = new TopLabelDecorator(Hud)
  105.             {
  106.                 TextFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
  107.                 TextFunc = ArchonCooldown,
  108.             };
  109.  
  110.             // Private vars
  111.             _lWidth = 80;
  112.             _lHeight = 15;
  113.             _lRashaSize = 24f;
  114.             _lRashaSizeMod = 0.9f;
  115.  
  116.         }
  117.  
  118.         public void PaintTopInGame(ClipState clipState)
  119.         {
  120.             if (clipState != ClipState.BeforeClip) return;
  121.  
  122.             if (Hud.Game.IsInGame && Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.Wizard && !(Hud.Game.Me.IsInTown && !ShowInTown))
  123.             {
  124.                 var me = Hud.Game.Me;
  125.                 UpdateSkills(me);
  126.  
  127.                 //If Disentegration Wave is channelled, draw zei circle
  128.                 if ((me.Powers.BuffIsActive(392891, 4) || AlwaysShowZei) && ShowZeiCircle)
  129.                     ZeiRanceIndicator.Paint(me, me.FloorCoordinate, null);
  130.              
  131.                 //Draw missing buff warnings
  132.                 if (ShowWarnings && !me.IsDead)
  133.                     DrawWarnings(me);
  134.  
  135.                 //Draw indicators for each tal rasha element
  136.                 if ((me.Powers.BuffIsActive(429855, 5) || AlwaysShowElements) && ShowRashaElements)
  137.                     TalRashaElements(me);
  138.  
  139.                 //Draw Archon cooldown
  140.                 if (_archonSkill != null && ShowArchonCD)
  141.                     ArchonCooldownLabel.Paint(HudWidth * 0.5f - _lWidth / 2, HudHeight * (ArchonCDandRemainYPos+0.015f), _lWidth, _lHeight, HorizontalAlign.Center);
  142.  
  143.                 //Draw Archon time remaining
  144.                 if (_archonSkill != null && ShowArchonRemain)
  145.                     ArchonRemaining(me);
  146.             }
  147.         }
  148.  
  149.         public string ArchonCooldown()
  150.         {
  151.             string s = "";
  152.             if (_archonSkill.CooldownFinishTick > Hud.Game.CurrentGameTick)
  153.             {
  154.                 var c = (_archonSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
  155.                 s = string.Format("\u267F {0:N1} \u267F", c);
  156.             }
  157.             return s;
  158.         }
  159.  
  160.         private void ArchonRemaining(IPlayer me)
  161.         {
  162.             if (me.Powers.BuffIsActive(134872, 2))
  163.             {
  164.                 if (!_timerRunning)
  165.                     _tick = Hud.Game.CurrentGameTick;
  166.                 _timerRunning = true;
  167.  
  168.                 var r = 20f - ((Hud.Game.CurrentGameTick - _tick) / 60.0d);
  169.                 if (r > 3f)
  170.                 {
  171.                     var layout = ArchonRemainFont.GetTextLayout(string.Format("{0:N1}", r));
  172.                     ArchonRemainFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * (ArchonCDandRemainYPos + 0.015f));
  173.                 }
  174.                 else
  175.                 {
  176.                     string str = string.Format("{0:N1}", r);
  177.                     if (r <= 3 && r > 2) str = string.Format("\u231A {0:N1} \u231A", r);
  178.                     if (r <= 2 && r > 1) str = string.Format("\u231B {0:N1} \u231B", r);
  179.                     if (r <= 1) str = string.Format("\u25B6 {0:N1} \u25C0", r);
  180.                     var layout = ArchonRemainSoonFont.GetTextLayout(str);
  181.                     ArchonRemainSoonFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * (ArchonCDandRemainYPos + 0.005f));
  182.                 }
  183.             }
  184.             else _timerRunning = false;
  185.         }
  186.  
  187.         private void TalRashaElements(IPlayer me)
  188.         {
  189.             RashaBackgroundBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize * 1.6f, HudHeight * RashaIndicatorsYpos - _lRashaSize * 0.1f, _lRashaSize * 4.1f, _lRashaSize * 1.1f);
  190.  
  191.             if (me.Powers.BuffIsActive(429855, 1)) ArcaneBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize * 1.5f, HudHeight * RashaIndicatorsYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  192.             else DrawGreyBrush(-_lRashaSize * 1.5f);
  193.  
  194.             if (me.Powers.BuffIsActive(429855, 2)) ColdBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) - _lRashaSize / 2, HudHeight * RashaIndicatorsYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  195.             else DrawGreyBrush(-_lRashaSize / 2);
  196.  
  197.             if (me.Powers.BuffIsActive(429855, 3)) FireBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + _lRashaSize / 2, HudHeight * RashaIndicatorsYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  198.             else DrawGreyBrush(_lRashaSize / 2);
  199.  
  200.             if (me.Powers.BuffIsActive(429855, 4)) LightningBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + _lRashaSize * 1.5f, HudHeight * RashaIndicatorsYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  201.             else DrawGreyBrush(_lRashaSize * 1.5f);
  202.         }
  203.  
  204.         private void DrawGreyBrush(float xPos)
  205.         {
  206.             GreyBrush.DrawRectangle((HudWidth * 0.5f - _lRashaSize * .5f) + xPos, HudHeight * RashaIndicatorsYpos, _lRashaSize * _lRashaSizeMod, _lRashaSize * _lRashaSizeMod);
  207.         }
  208.  
  209.         private void DrawWarnings(IPlayer me)
  210.         {
  211.             //IN ARCHON
  212.             if (me.Powers.BuffIsActive(134872, 2)) //Archon
  213.             {
  214.                 if (!me.Powers.BuffIsActive(135663, 0)) //Slow Time
  215.                 {
  216.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + /*me.Powers.GetBuff(135663).SnoPower.NameLocalized*/"Bubble Up" + " \u2996\u22EF"); // UsedWizardPowers returns "Archon" instead of "Slow Time" so i used GetBuff() instead
  217.                     WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * WarningYPos);
  218.                 }
  219.             }
  220.             else
  221.             {//NOT IN ARCHON
  222.                 if (_magicWeaponSkill != null)
  223.                 {
  224.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + Hud.Sno.SnoPowers.Wizard_MagicWeapon.NameLocalized + " \u2996\u22EF");
  225.                     if (!me.Powers.BuffIsActive(76108, 0))
  226.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * WarningYPos);
  227.                 }
  228.  
  229.                 if (_energyArmorSkill != null)
  230.                 {
  231.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + Hud.Sno.SnoPowers.Wizard_EnergyArmor.NameLocalized + " \u2996\u22EF");
  232.                     if (!me.Powers.BuffIsActive(86991, 0) && !me.Powers.BuffIsActive(86991, 1) && !me.Powers.BuffIsActive(86991, 2) && !me.Powers.BuffIsActive(86991, 3) && !me.Powers.BuffIsActive(86991, 4) && !me.Powers.BuffIsActive(86991, 5))
  233.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * (WarningYPos+WarningYPosIncr));
  234.                 }
  235. /*Axyd added*/             
  236.                 if (_stormArmorSkill != null && ShowStormArmor == true)
  237.                 {
  238.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + Hud.Sno.SnoPowers.Wizard_StormArmor.NameLocalized + " \u2996\u22EF");
  239.                     if (!me.Powers.BuffIsActive(74499, 0) && !me.Powers.BuffIsActive(74499, 1) && !me.Powers.BuffIsActive(74499, 2) && !me.Powers.BuffIsActive(74499, 3) && !me.Powers.BuffIsActive(74499, 4) && !me.Powers.BuffIsActive(74499, 5))
  240.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * (WarningYPos+WarningYPosIncr));
  241.                 }                
  242.                
  243.                 if (_iceArmorSkill != null && ShowIceArmor == true)
  244.                 {
  245.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + Hud.Sno.SnoPowers.Wizard_IceArmor.NameLocalized + " \u2996\u22EF");
  246.                     if (!me.Powers.BuffIsActive(73223, 0) && !me.Powers.BuffIsActive(73223, 1) && !me.Powers.BuffIsActive(73223, 2) && !me.Powers.BuffIsActive(73223, 3) && !me.Powers.BuffIsActive(73223, 4) && !me.Powers.BuffIsActive(73223, 5))
  247.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * (WarningYPos+WarningYPosIncr));
  248.                 }
  249.                
  250.                 if (_familiarSkill != null && ShowFamiliar == true)
  251.                 {
  252.                     var layout = WarningFont.GetTextLayout("\u22EF\u2995 " + Hud.Sno.SnoPowers.Wizard_Familiar.NameLocalized + " \u2996\u22EF");
  253.                     if (!me.Powers.BuffIsActive(99120, 0))
  254.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * WarningYPos);
  255.                 }
  256. /*add end*/
  257.             }
  258.         }
  259.  
  260.         private void UpdateSkills(IPlayer me)
  261.         {
  262.             _archonSkill = null;
  263.             _magicWeaponSkill = null;
  264.             _energyArmorSkill = null;
  265. /*Axyd added*/
  266.             _stormArmorSkill = null;
  267.             _iceArmorSkill = null;
  268.             _familiarSkill = null;
  269. /*add end*/        
  270.            
  271.             me.Powers.UsedSkills.ForEach(skill =>
  272.             {          
  273.                 if (skill.SnoPower.Sno == 134872) _archonSkill = skill;
  274.                 if (skill.SnoPower.Sno == 76108) _magicWeaponSkill = skill;
  275.                 if (skill.SnoPower.Sno == 86991) _energyArmorSkill = skill;
  276. /*Axyd added*/
  277.                 if (skill.SnoPower.Sno == 74499) _stormArmorSkill = skill;
  278.                 if (skill.SnoPower.Sno == 73223) _iceArmorSkill = skill;
  279.                 if (skill.SnoPower.Sno == 99120) _familiarSkill = skill;
  280. /*add end*/
  281.             });
  282.         }
  283.     }
  284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement