Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // PortraitInfosPlugin
- // Plugin version of XML portraits Template (DPS meter, EHP Bar, Tracker). Adds a hint for support players (zDPS).
- // Go to config/ui_default/ui_default_main.xml and disable the portraits template : <portraits enabled="0">
- using System.Globalization;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Turbo.Plugins.Default;
- namespace Turbo.Plugins.Extended.Addons
- {
- public class PortraitInfosPlugin : BasePlugin, IInGameTopPainter
- {
- public TopLabelDecorator PortraitStats1Decorator { get; set; }
- public TopLabelDecorator PortraitStats2Decorator { get; set; }
- public TopLabelDecorator PortraitStats3Decorator { get; set; }
- public TopLabelDecorator SupportHintDecorator { get; set; }
- public IFont TrackerFont { get; set; }
- public TopLabelDecorator EhpBarDecorator { get; set; }
- public TopLabelDecorator EhpBarFillDecorator { get; set; }
- public bool EnableDamageMeter { get; set; }
- public bool EnableToughnessBar { get; set; }
- public bool EnableTrackerHint { get; set; }
- public bool EnableSupportHint { get; set; }
- public PortraitInfosPlugin()
- {
- Enabled = true;
- Order = 40000;
- EnableDamageMeter = true;
- EnableToughnessBar = true;
- EnableTrackerHint = true;
- EnableSupportHint = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- TrackerFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 200, 0, true, false, 192, 0, 0, 0, true);
- PortraitStats1Decorator = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 0, 220, 255, true, false, 192, 0, 0, 0, true),
- TextFunc = () => ValueToString(Hud.Game.Me.Damage.CurrentDps, ValueFormat.LongNumber),
- HintFunc = () => "Current DPS",
- };
- PortraitStats2Decorator = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 0, 220, 255, true, false, 192, 0, 0, 0, true),
- TextFunc = () => ValueToString(Hud.Game.Me.Damage.RunDps, ValueFormat.LongNumber),
- HintFunc = () => "Run DPS",
- };
- PortraitStats3Decorator = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 220, 0, true, false, 192, 0, 0, 0, true),
- TextFunc = () => ValueToString(Hud.Game.Me.Damage.TotalDamage, ValueFormat.LongNumber),
- HintFunc = () => "Total Damage",
- };
- SupportHintDecorator = new TopLabelDecorator(Hud)
- {
- TextFont = Hud.Render.CreateFont("tahoma", 8, 255, 255, 120, 0, true, false, 192, 0, 0, 0, true),
- TextFunc = () => "Z",
- };
- EhpBarDecorator = new TopLabelDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(255, 75, 75, 75, 0),
- TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 220, 0, true, false, 192, 0, 0, 0, true),
- HintFunc = () => "Effective Toughness",
- };
- EhpBarFillDecorator = new TopLabelDecorator(Hud)
- {
- BackgroundBrush = Hud.Render.CreateBrush(255, 25, 130, 25, 0),
- TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 220, 0, true, false, 192, 0, 0, 0, true),
- };
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (Hud.Render.UiHidden) return;
- if (clipState != ClipState.BeforeClip) return;
- if (Hud.Game.Me.PortraitUiElement.Rectangle == null) return;
- if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map)) return;
- // Damage Meter on your personal portrait
- if (EnableDamageMeter)
- {
- var uiRect = Hud.Game.Me.PortraitUiElement.Rectangle;
- PortraitStats1Decorator.Paint(uiRect.Left + uiRect.Width * 0.35f, uiRect.Top + uiRect.Height * 0.44f, uiRect.Width * 0.48f, uiRect.Height * 0.14f, HorizontalAlign.Right);
- PortraitStats2Decorator.Paint(uiRect.Left + uiRect.Width * 0.35f, uiRect.Top + uiRect.Height * 0.525f, uiRect.Width * 0.48f, uiRect.Height * 0.14f, HorizontalAlign.Right);
- PortraitStats3Decorator.Paint(uiRect.Left + uiRect.Width * 0.35f, uiRect.Top + uiRect.Height * 0.61f, uiRect.Width * 0.48f, uiRect.Height * 0.14f, HorizontalAlign.Right);
- }
- var CalcEhp = Hud.Game.Players.OrderByDescending(x => x.Defense.EhpMax).First().Defense.EhpMax.ToString();
- var BestEhp = float.Parse(CalcEhp);
- foreach (var player in Hud.Game.Players.OrderBy(p => p.PortraitIndex))
- {
- var portRect = player.PortraitUiElement.Rectangle;
- var EhpMax = player.Defense.EhpMax;
- var EhpHeight = portRect.Height * 0.727f;
- // Player is a Support (zDPS)
- if (EnableSupportHint && IsZDPS(player))
- {
- SupportHintDecorator.Paint(portRect.Left + portRect.Width * 0.12f, portRect.Top + portRect.Height * 0.58f, portRect.Width * 0.48f, portRect.Height * 0.14f, HorizontalAlign.Left);
- }
- // Players Actions & Position Tracker
- if (EnableTrackerHint)
- {
- if (player.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_None, 259848) == 1 && player.SnoArea == Hud.Game.Me.SnoArea && player.CoordinateKnown) {
- var zone = " Identifying a legendary... ";
- var layout = TrackerFont.GetTextLayout(zone);
- TrackerFont.DrawText(layout, portRect.Right + portRect.Width * 0.02f, portRect.Top + portRect.Height * 0.712f);
- }
- if (player.GetAttributeValue(Hud.Sno.Attributes.Power_Buff_0_Visual_Effect_None, 293981) == 1 && player.SnoArea == Hud.Game.Me.SnoArea && player.CoordinateKnown) {
- var zone = " Identifying legendaries... ";
- var layout = TrackerFont.GetTextLayout(zone);
- TrackerFont.DrawText(layout, portRect.Right + portRect.Width * 0.02f, portRect.Top + portRect.Height * 0.712f);
- }
- if (player.AnimationState == AcdAnimationState.CastingPortal && player.SnoArea == Hud.Game.Me.SnoArea && player.CoordinateKnown) {
- var zone = " Teleporting... ";
- var layout = TrackerFont.GetTextLayout(zone);
- TrackerFont.DrawText(layout, portRect.Right + portRect.Width * 0.02f, portRect.Top + portRect.Height * 0.712f);
- }
- if (!player.IsMe && player.SnoArea != Hud.Game.Me.SnoArea) {
- var zone = " [" + player.SnoArea.NameLocalized + "] ";
- var layout = TrackerFont.GetTextLayout(zone);
- TrackerFont.DrawText(layout, portRect.Right + portRect.Width * 0.02f, portRect.Top + portRect.Height * 0.712f);
- }
- }
- // Players EHP Bar
- if (EnableToughnessBar)
- {
- if (Hud.Game.NumberOfPlayersInGame == 1) return;
- if (player.SnoArea == Hud.Game.Me.SnoArea)
- {
- EhpBarDecorator.Paint(portRect.Left - portRect.Width * 0.14f, portRect.Top + portRect.Height * 0.1f, portRect.Width * 0.05f, EhpHeight, HorizontalAlign.Left);
- if (EhpMax == BestEhp)
- {
- var Ehp = EhpMax;
- EhpBarFillDecorator.Paint(portRect.Left - portRect.Width * 0.14f, portRect.Top + portRect.Height * 0.1f, portRect.Width * 0.05f, EhpHeight, HorizontalAlign.Left);
- }
- else
- {
- var Ehp = (EhpMax / BestEhp);
- EhpBarFillDecorator.Paint(portRect.Left - portRect.Width * 0.14f, portRect.Top + portRect.Height * 0.1f + (EhpHeight * (1 - Ehp)), portRect.Width * 0.05f, EhpHeight * Ehp, HorizontalAlign.Left);
- }
- }
- }
- // End Loop Player
- }
- }
- // ZDPS Tracker - Thanks to Resu
- private bool IsZDPS(IPlayer player)
- {
- int Points = 0;
- var IllusoryBoots = player.Powers.GetBuff(318761);
- if (IllusoryBoots == null || !IllusoryBoots.Active) {} else {Points++;}
- var LeoricsCrown = player.Powers.GetBuff(442353);
- if (LeoricsCrown == null || !LeoricsCrown.Active) {} else {Points++;}
- var EfficaciousToxin = player.Powers.GetBuff(403461);
- if (EfficaciousToxin == null || !EfficaciousToxin.Active) {} else {Points++;}
- var OculusRing = player.Powers.GetBuff(402461);
- if (OculusRing == null || !OculusRing.Active) {} else {Points++;}
- var ZodiacRing = player.Powers.GetBuff(402459);
- if (ZodiacRing == null || !ZodiacRing.Active) {} else {Points++;}
- if (player.Offense.SheetDps < 500000f) Points++;
- if (player.Offense.SheetDps > 1500000f) Points--;
- if (player.Defense.EhpMax > 80000000f) Points++;
- var ConventionRing = player.Powers.GetBuff(430674);
- if (ConventionRing == null || !ConventionRing.Active) {} else {Points--;}
- var Stricken = player.Powers.GetBuff(428348);
- if (Stricken == null || !Stricken.Active) {} else {Points--;}
- if (Points >= 4) { return true; } else { return false; }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement