Advertisement
RuneB

ArchonWizPlugin

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