Advertisement
RuneB

ArchonWizPlugin7_0

Feb 21st, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 9.62 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2.  
  3. namespace Turbo.Plugins.RuneB
  4. {
  5.     public class ArchonWizPlugin : BasePlugin
  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 override void Customize()
  42.         {
  43.             Hud.RunOnPlugin<FeetBuffListPlugin>(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 override void PaintWorld(WorldLayer layer)
  96.         {
  97.             if (Hud.Game.IsInGame && Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.Wizard && !(Hud.Game.Me.IsInTown && !ShowInTown))
  98.             {
  99.                 //if (Hud.Game.Me.IsInTown && !ShowInTown) return;
  100.  
  101.                 var me = Hud.Game.Me;
  102.                 UpdateSkills(me);
  103.  
  104.                 //If Disentegration wave is used draw zei circle
  105.                 if (me.Powers.BuffIsActive(392891, 4) && ShowZeiCircle)
  106.                     ZeiRanceIndicator.Paint(me, me.FloorCoordinate, null);
  107.  
  108.                 //Draw missing buff warnings
  109.                 if (ShowWarnings && !me.IsDead)
  110.                     DrawWarnings(me);
  111.  
  112.                 //Draw individual indicators for each tal rasha element
  113.                 if (me.Powers.BuffIsActive(429855, 5) && ShowRashaElements)
  114.                     TalRashaElements(me);
  115.  
  116.                 //Draw Archon cooldown
  117.                 if (ShowArchonCD && ArchonSkill != null)
  118.                     ArchonCooldownLabel.Paint(HudWidth * 0.5f - LW / 2, HudHeight * 0.515f, LW, LH, HorizontalAlign.Center);
  119.  
  120.                 //Draw Archon time remaining
  121.                 if (ShowArchonRemain)
  122.                     ArchonRemaining(me);
  123.             }
  124.         }
  125.  
  126.         private void ArchonRemaining(IPlayer me)
  127.         {
  128.             if (me.Powers.BuffIsActive(134872, 2))
  129.             {
  130.                 if (!TimerRunning)
  131.                     Tick = Hud.Game.CurrentGameTick;
  132.                 TimerRunning = true;
  133.  
  134.                 var r = 20f - ((Hud.Game.CurrentGameTick - Tick) / 60.0d);
  135.                 if (r > 3f)
  136.                 {
  137.                     var layout = ArchonRemainFont.GetTextLayout(string.Format("{0:N1}", r));
  138.                     ArchonRemainFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.515f);
  139.                 }
  140.                 else {
  141.                     var layout = ArchonRemainSoonFont.GetTextLayout(string.Format("{0:N1}", r));
  142.                     ArchonRemainSoonFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.505f);
  143.                 }
  144.             }
  145.             else TimerRunning = false;
  146.         }
  147.  
  148.         private void TalRashaElements(IPlayer me)
  149.         {
  150.             RashaBackgroundBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) - RLSize * 1.6f, HudHeight * RLYpos - RLSize * 0.1f, RLSize * 4.1f, RLSize * 1.1f);
  151.  
  152.             if (me.Powers.BuffIsActive(429855, 1)) ArcaneBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) - RLSize * 1.5f, HudHeight * RLYpos, RLSize * RLSizeMod, RLSize * RLSizeMod);
  153.             else DrawGreyBrush(-RLSize * 1.5f);
  154.  
  155.             if (me.Powers.BuffIsActive(429855, 2)) ColdBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) - RLSize / 2, HudHeight * RLYpos, RLSize * RLSizeMod, RLSize * RLSizeMod);
  156.             else DrawGreyBrush(-RLSize / 2);
  157.  
  158.             if (me.Powers.BuffIsActive(429855, 3)) FireBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) + RLSize / 2, HudHeight * RLYpos, RLSize * RLSizeMod, RLSize * RLSizeMod);
  159.             else DrawGreyBrush(RLSize / 2);
  160.  
  161.             if (me.Powers.BuffIsActive(429855, 4)) LightningBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) + RLSize * 1.5f, HudHeight * RLYpos, RLSize * RLSizeMod, RLSize * RLSizeMod);
  162.             else DrawGreyBrush(RLSize * 1.5f);
  163.         }
  164.  
  165.         private void DrawGreyBrush(float xPos)
  166.         {
  167.             GreyBrush.DrawRectangle((HudWidth * 0.5f - RLSize * .5f) + xPos, HudHeight * RLYpos, RLSize * RLSizeMod, RLSize * RLSizeMod);
  168.         }
  169.  
  170.         public string ArchonStatusText()
  171.         {
  172.             string s = "";
  173.             if (ArchonSkill.CooldownFinishTick > Hud.Game.CurrentGameTick && ArchonSkill.SnoPower.NameLocalized.Equals("Archon"))
  174.             {
  175.                 var c = (ArchonSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
  176.                 s = string.Format("{0:N1}", c);
  177.             }
  178.             return s;
  179.         }
  180.  
  181.         private void DrawWarnings(IPlayer me)
  182.         {
  183.             //IN ARCHON
  184.             if (me.Powers.BuffIsActive(134872, 2)) //Archon
  185.             {
  186.                 if (!me.Powers.BuffIsActive(135663, 0)) //Bubble
  187.                 {
  188.                     var layout = WarningFont.GetTextLayout("Bubble Up");
  189.                     WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.47f);
  190.                 }
  191.             }
  192.  
  193.             //NOT IN ARCHON
  194.             else {
  195.                 if (MWeaponSkill != null)
  196.                 {
  197.                     var layout = WarningFont.GetTextLayout("Missing Magic Weapon");
  198.                     if (!me.Powers.BuffIsActive(76108, 0))
  199.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.47f);
  200.                 }
  201.  
  202.                 if (EArmorSkill != null)
  203.                 {
  204.                     var layout = WarningFont.GetTextLayout("Missing Energy Armor");
  205.                     if (!me.Powers.BuffIsActive(86991, 0))
  206.                         WarningFont.DrawText(layout, HudWidth * 0.5f - (layout.Metrics.Width * 0.5f), HudHeight * 0.49f);
  207.                 }
  208.             }
  209.         }
  210.  
  211.         private void UpdateSkills(IPlayer me)
  212.         {
  213.             me.Powers.UsedSkills.ForEach(skill =>
  214.             {
  215.                 if (skill.SnoPower.Sno == 134872) ArchonSkill = skill;
  216.                 if (skill.SnoPower.Sno == 76108) MWeaponSkill = skill;
  217.                 if (skill.SnoPower.Sno == 86991) EArmorSkill = skill;
  218.             });
  219.         }
  220.     }
  221. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement