Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Linq;
- using Turbo.Plugins.Default;
- using Turbo.Plugins.Jack;
- namespace Turbo.Plugins.DM.Rathma
- {
- public class RathmaPlugin : BasePlugin, IInGameTopPainter, ICustomizer
- {
- public bool ShowWarnings { get; set; }
- public bool ShowInTown { get; set; }
- public bool ShowZeiCircle { get; set; }
- public bool ShowLandOfTheDeadCD { get; set; }
- public bool ShowLandOfTheDeadRemain { get; set; }
- public float WarningYPos { get; set; }
- public float WarningYPosIncr { get; set; }
- public float CDandRemainYPos { get; set; }
- public float essenceLevel { get; set; }
- public GroundCircleDecorator ZeiRanceIndicator { get; set; }
- public TopLabelDecorator landofdeadCooldownLabel { get; set; }
- public TopLabelDecorator landofdeadRemainingLabel { get; set; }
- public IFont WarningFont { get; set; }
- public IFont landofthedeadCDFont { get; set; }
- public IFont landofthedeadRemainFont { get; set; }
- public IFont landofthedeadSoonFont { get; set; }
- private IPlayerSkill mageSkill;
- private IPlayerSkill simulacrumSkill;
- private IPlayerSkill boneArmorSkill;
- private IPlayerSkill landofthedeadSkill;
- private float hudWidth { get { return Hud.Window.Size.Width; } }
- private float hudHeight { get { return Hud.Window.Size.Height; } }
- private float _lWidth, _lHeight, _tick;
- private bool _timerRunning = false;
- public RathmaPlugin()
- {
- Enabled = true;
- }
- public void Customize()
- {
- Hud.RunOnPlugin<PlayerBottomBuffListPlugin>(plugin =>
- {
- plugin.BuffPainter.ShowTimeLeftNumbers = true;
- plugin.RuleCalculator.Rules.Add(new BuffRule(465839) { IconIndex = 1, MinimumIconCount = 0, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Land Of The Dead
- plugin.RuleCalculator.Rules.Add(new BuffRule(465350) { IconIndex = 1, MinimumIconCount = 1, ShowTimeLeft = true, ShowStacks = false, IconSizeMultiplier = 1.3f }); // Simulacrum
- });
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- // Public vars
- ShowWarnings = true;
- ShowInTown = true;
- ShowZeiCircle = true;
- ShowLandOfTheDeadCD = true;
- ShowLandOfTheDeadRemain = true;
- WarningYPos = 0.27f;
- WarningYPosIncr = 0.022f; // Distance between warnings
- CDandRemainYPos = 0.5f;
- essenceLevel = 0.95f;
- WarningFont = Hud.Render.CreateFont("tahoma", 13f, 200, 255, 0, 0, false, false, true);
- landofthedeadCDFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, true);
- landofthedeadRemainFont = Hud.Render.CreateFont("tahoma", 10f, 255, 80, 140, 210, false, false, true);
- landofthedeadSoonFont = Hud.Render.CreateFont("tahoma", 14.5f, 255, 255, 0, 0, false, false, true);
- ZeiRanceIndicator = new GroundCircleDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(150, 14, 200, 245, 1.5f),
- Radius = 50f
- };
- landofdeadCooldownLabel = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 10f, 255, 140, 140, 180, false, false, 160, 0, 0, 0, true),
- TextFunc = () => landofdeadCooldown(),
- };
- // Private vars
- _lWidth = 80;
- _lHeight = 15;
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (clipState != ClipState.BeforeClip) return;
- if (Hud.Game.IsInGame && Hud.Game.Me.HeroClassDefinition.HeroClass == HeroClass.Necromancer && !(Hud.Game.Me.IsInTown && !ShowInTown))
- {
- var me = Hud.Game.Me;
- UpdateSkills(me);
- //If zei socketed, draw zei circle
- if (me.Powers.BuffIsActive(403468, 0) && ShowZeiCircle)
- ZeiRanceIndicator.Paint(me, me.FloorCoordinate, null);
- //Draw missing buff warnings
- if (ShowWarnings && !me.IsDead)
- DrawWarnings(me);
- //Draw Land Of The Dead cooldown
- if (landofthedeadSkill != null && ShowLandOfTheDeadCD && !me.Powers.BuffIsActive(465839))
- landofdeadCooldownLabel.Paint(hudWidth * 0.5f - _lWidth / 2, hudHeight * (CDandRemainYPos+0.015f), _lWidth, _lHeight, HorizontalAlign.Center);
- //Draw Land Of The Dead time remaining
- if (landofthedeadSkill != null && ShowLandOfTheDeadRemain)
- landofdeadRemaining(me);
- }
- }
- public string landofdeadCooldown()
- {
- string s = "";
- if (landofthedeadSkill.CooldownFinishTick > Hud.Game.CurrentGameTick)
- {
- var c = (landofthedeadSkill.CooldownFinishTick - Hud.Game.CurrentGameTick) / 60.0d;
- s = string.Format("\u267F {0:N1} \u267F", c);
- }
- return s;
- }
- private void landofdeadRemaining(IPlayer me)
- {
- if (me.Powers.BuffIsActive(465839))
- {
- if (!_timerRunning)
- _tick = Hud.Game.CurrentGameTick;
- _timerRunning = true;
- var r = 10f - ((Hud.Game.CurrentGameTick - _tick) / 60.0d);
- if (r > 3f)
- {
- var layout = landofthedeadRemainFont.GetTextLayout(string.Format("{0:N1}", r));
- landofthedeadRemainFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (CDandRemainYPos + 0.015f));
- }
- else
- {
- string str = string.Format("{0:N1}", r);
- if (r <= 3 && r > 2) str = string.Format("\u231A {0:N1} \u231A", r);
- if (r <= 2 && r > 1) str = string.Format("\u231B {0:N1} \u231B", r);
- if (r <= 1) str = string.Format("\u25B6 {0:N1} \u25C0", r);
- var layout = landofthedeadSoonFont.GetTextLayout(str);
- landofthedeadSoonFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (CDandRemainYPos + 0.005f));
- }
- }
- else _timerRunning = false;
- }
- private void DrawWarnings(IPlayer me)
- {
- if (mageSkill != null)
- {
- var layout = WarningFont.GetTextLayout("\u22EF\u2995 Skeletal Mage \u2996\u22EF");
- if (me.Stats.ResourceCurPri > (me.Stats.ResourceMaxPri * essenceLevel))
- WarningFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * WarningYPos);
- }
- if (boneArmorSkill != null)
- {
- var layout = WarningFont.GetTextLayout("\u22EF\u2995 Bone Armor \u2996\u22EF");
- if (!me.Powers.BuffIsActive(466857, 0))
- WarningFont.DrawText(layout, hudWidth * 0.5f - (layout.Metrics.Width * 0.5f), hudHeight * (WarningYPos+WarningYPosIncr));
- }
- }
- private void UpdateSkills(IPlayer me)
- {
- me.Powers.UsedSkills.ForEach(skill =>
- {
- if (skill.SnoPower.Sno == 462089) mageSkill = skill;
- if (skill.SnoPower.Sno == 466857) boneArmorSkill = skill;
- if (skill.SnoPower.Sno == 465839) landofthedeadSkill = skill;
- });
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement