Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Text;
- using System.Linq;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Threading;
- namespace Turbo.Plugins.RNN
- {
- public class ENPylonMarker : BasePlugin, ICustomizer, IAfterCollectHandler, IInGameTopPainter, IInGameWorldPainter
- {
- private WorldDecoratorCollection LineBandit { get; set; }
- private WorldDecoratorCollection LineBanditUsed { get; set; }
- protected IUiElement LevelUIE;
- protected IUiElement EnBarUIE;
- private Dictionary<ActorSnoEnum, PylonData> PylonData_Dic { get; set; }
- private bool fixLoad { get; set; } = true;
- private float xPos { get; set; } = 0;
- private float yPos { get; set; } = 0;
- private float heightFont { get; set; } = 0f;
- private float sizeTexture { get; set; } = 0f;
- private SharpDX.DirectWrite.TextLayout layout { get; set; } = null;
- private string TiempoTotalString { get; set; } = string.Empty;
- private string InfoExtra { get; set; } = string.Empty;
- private int OrderBuff { get; set; } = 0;
- private bool BanditAppears { get; set; } = false;
- private bool _InEN { get; set; } = false;
- private bool InEN
- {
- get { return _InEN; }
- set
- {
- if (_InEN ^ value) { foreach(var p in PylonData_Dic) p.Value.Reset(); TiempoTotalString = string.Empty; InfoExtra = string.Empty; OrderBuff = 0; BanditAppears = false; }
- _InEN = value;
- }
- }
- public IFont DefaultFont { get; set; } = null;
- public IFont FontUsed { get; set; }
- public IFont FontLevel { get; set; }
- public IFont FontYellow { get; set; }
- public IFont FontGreen { get; set; }
- public IFont LeftFont { get; set; }
- public IBrush BorderOrangeBrush { get; set; }
- public float xPor { get; set; } = 0;
- public float yPor { get; set; } = 0;
- public float sizeFont { get; set; } = 8;
- public float LineSpacing { get; set; }
- public bool ShowNames { get; set; }
- public bool NotifyBandit { get; set; }
- public string NotifyBanditWav { get; set; }
- public string NotifyBanditSpeak { get; set; }
- public float LineToBanditWidth { get; set;}
- public bool LineToBandit { get; set;}
- public bool LineToBanditHideUsed { get; set;}
- public ENPylonMarker()
- {
- Enabled = true;
- }
- public class PylonData
- {
- public string Name { get; set; }
- public int PreOrder { get; set; }
- public int OrderShow { get; set; } = 0;
- public uint BuffSno { get; set; }
- public ITexture Texture { get; set; }
- public ActorSnoEnum ASE { get; set; }
- public string LeveLStr { get; set; } = "-";
- public string TimeStr { get; set; } = "-";
- public bool Used { get; set; } = false;
- public string Player { get; set; } = string.Empty;
- public void Reset()
- {
- this.LeveLStr = "-";
- this.TimeStr = "-";
- this.Used = false;
- this.Player = string.Empty;
- this.OrderShow = this.PreOrder;
- }
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- Order = 90001;
- xPor = -0.01f; // x = <Nightmare Bar Position> + Hud.Window.Size.Width * xPor
- yPor = 0.033f; // y = <Nightmare Bar Position> + Hud.Window.Size.Height * yPor;
- sizeFont = 8f; // Text font size
- LineSpacing = 1.05f; // Line spacing in text . Allowed values: from 0.8f to 1.2f
- ShowNames = true; // Show the name of the Player who took the Pylon
- NotifyBandit = true; // Notify when bandit appears (sound and/or speak)
- NotifyBanditWav = "notification_5.wav"; // Filename to play, must be in the .\sounds\ folder. Example: "notification_5.wav" (null or "" so that it does not notify)
- NotifyBanditSpeak = ""; // Text to Speak. Example: "Bandit" (null or "" so that it does not notify)
- LineToBandit = true; // Line to Shrine (yellow used, grey not used)
- LineToBanditWidth = 2.0f;
- LineToBanditHideUsed = false; // Hide line to Shrine if used (grey)
- BorderOrangeBrush = Hud.Render.CreateBrush(250, 250, 100, 0, 1);
- LevelUIE = Hud.Render.RegisterUiElement("Root.NormalLayer.eventtext_bkgrnd.eventtext_region.stackpanel.sidequest_wrapper.quest_stack_side 486773.objective_stack.486773 1 1 wrapper.text", null, null);
- EnBarUIE = Hud.Render.RegisterUiElement("Root.NormalLayer.eventtext_bkgrnd.eventtext_region.stackpanel.sidequest_wrapper.quest_stack_side 486773", null, null);
- PylonData_Dic = new Dictionary<ActorSnoEnum, PylonData>() // PreOrder is num 1...5
- {
- { ActorSnoEnum._x1_lr_shrine_infinite_casting, new PylonData(){ Name = "Chann", PreOrder = 1, BuffSno = 486868, Texture = Hud.Texture.GetTexture(3254056115), ASE = ActorSnoEnum._p73_swarmrift_shrine_infinite_casting} },
- { ActorSnoEnum._x1_lr_shrine_run_speed, new PylonData(){ Name = "Speed", PreOrder = 2, BuffSno = 487614, Texture = Hud.Texture.GetTexture(1927801803), ASE = ActorSnoEnum._p73_shrine_run_speed} }, // 487615 KnockBack , 487616 Waller
- { ActorSnoEnum._x1_lr_shrine_damage, new PylonData(){ Name = "Power", PreOrder = 3, BuffSno = 486865, Texture = Hud.Texture.GetTexture(2350065673), ASE = ActorSnoEnum._p73_swarmrift_shrine_damage} },
- { ActorSnoEnum._x1_lr_shrine_electrified, new PylonData(){ Name = "Conduit", PreOrder = 4, BuffSno = 486873, Texture = Hud.Texture.GetTexture(1751750314), ASE = ActorSnoEnum._p73_swarmrift_shrine_electrified} },
- { ActorSnoEnum._shrine_global, new PylonData(){ Name = "Bandit", PreOrder = 5, BuffSno = 0, Texture = Hud.Texture.GetTexture(218235,0), ASE = ActorSnoEnum._p73_shrine_treasuregoblin} },
- };
- }
- public void Customize()
- {
- FontUsed = Hud.Render.CreateFont("Consolas", sizeFont, 255, 170, 170, 170, false, false, 250, 0, 0, 0, true);
- FontLevel = Hud.Render.CreateFont("Consolas", sizeFont, 255, 235, 145, 235, false, false, 160, 0, 0, 0, true);
- FontYellow = Hud.Render.CreateFont("Consolas", sizeFont, 255, 250, 250, 50, false, false, 160, 0, 0, 0, true);
- FontGreen = Hud.Render.CreateFont("Consolas", sizeFont, 255, 50, 250, 50, false, false, 160, 0, 0, 0, true);
- LeftFont = Hud.Render.CreateFont("Consolas", sizeFont - ( (sizeFont > 7)? 1.0f : 0.5f ), 255, 255, 255, 255, false, false, 160, 0, 0, 0, true);
- if (LineSpacing > 1.2f) { LineSpacing = 1.2f; }
- else if (LineSpacing < 0.8f) { LineSpacing = 0.8f; }
- LineBanditUsed = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 200, 200, 200, LineToBanditWidth, SharpDX.Direct2D1.DashStyle.DashDot),
- ShapePainter = new LineFromMeShapePainter(Hud)
- }
- );
- LineBandit = new WorldDecoratorCollection(
- new MapShapeDecorator(Hud)
- {
- Brush = Hud.Render.CreateBrush(255, 255, 200, 50, LineToBanditWidth, SharpDX.Direct2D1.DashStyle.Dash),
- ShapePainter = new LineFromMeShapePainter(Hud)
- }
- );
- }
- public void Play_Sound(string Sonido)
- {
- var playSonido = Hud.Sound.LoadSoundPlayer(Sonido);
- ThreadPool.QueueUserWorkItem(state =>
- {
- try { playSonido.PlaySync(); }
- catch (Exception) { }
- } );
- }
- public void AfterCollect()
- {
- if (!Hud.Game.IsInGame) return;
- var quest = Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == 486773 && q.State == QuestState.started);
- if (quest != null)
- {
- if (!InEN) InEN = true;
- long t = (Hud.Game.CurrentGameTick - quest.CreatedOn)/60; //InfoExtra = string.Format("[{0}/{1}/{2:0}m{3:00}s]", quest.QuestStepId, quest.State , t/60, t%60);
- if (quest.QuestStepId == 13)
- {
- TiempoTotalString = string.Format("{0}s", t - 10);
- }
- else if (quest.QuestStepId == 1)
- {
- TiempoTotalString = (t < 60)?string.Format("{0}s",t):string.Format("{0:0}m{1:00}s", t/60, t%60);
- }
- else if (quest.QuestStepId == 9)
- {
- if (TiempoTotalString == string.Empty) TiempoTotalString = "+" + ((t < 60)?string.Format("{0}s",t):string.Format("{0:0}m{1:00}s", t/60, t%60));
- if (InfoExtra == string.Empty && LevelUIE.Visible)
- {
- if (!string.IsNullOrEmpty(LevelUIE.ReadText(Encoding.UTF8, true)))
- {
- var textLevel = Regex.Replace(LevelUIE.ReadText(Encoding.UTF8, true), @"(.+:\s)?", "");
- if (Int32.TryParse(textLevel,out var levelGem)) InfoExtra = string.Format("[{0}, Gem {1}]", levelGem, levelGem>125?125:levelGem-1);
- }
- }
- }
- }
- else
- {
- if (InEN) InEN = false;
- }
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if ( clipState != ClipState.BeforeClip || !Hud.Game.IsInGame || Hud.Game.IsPaused || Hud.Game.Me.SnoArea.Sno != 486520) return; // || Hud.Game.Me.SnoArea.Sno != 486520
- if (InEN && EnBarUIE.Visible)
- {
- heightFont = FontLevel.GetTextLayout("O").Metrics.Height; sizeTexture = heightFont * LineSpacing - 1;
- xPos = EnBarUIE.Rectangle.Left + Hud.Window.Size.Width * xPor; yPos = EnBarUIE.Rectangle.Bottom + Hud.Window.Size.Height * yPor;
- foreach (var m in Hud.Game.Markers)
- {
- var timeleft = 0d; bool newUsed = false; PylonData data;
- if (m.IsShrine)
- {
- data = PylonData_Dic[ActorSnoEnum._shrine_global];
- if (!BanditAppears)
- {
- BanditAppears = true;
- if (NotifyBandit)
- {
- if (!string.IsNullOrWhiteSpace(NotifyBanditWav) ) { Play_Sound(NotifyBanditWav); }
- if (!string.IsNullOrWhiteSpace(NotifyBanditSpeak) ) { Hud.Sound.Speak(NotifyBanditSpeak); }
- }
- }
- if (data.Used) DefaultFont = FontUsed;
- else
- {
- var bandit = Hud.Game.Actors.FirstOrDefault(a => a.SnoActor.Sno == data.ASE);
- if (bandit != null && bandit.GetAttributeValue(Hud.Sno.Attributes.Gizmo_Has_Been_Operated, 1048575) == 1)
- { // los posibles valores son 2^20 = 1048576 , rango de valores: 0 .. 1048575 (maxvalue, equivalente a -1)
- newUsed = true;
- DefaultFont = FontUsed;
- var pId = bandit.GetAttributeValueAsUInt(Hud.Sno.Attributes.Gizmo_Operator_ACDID, 1048575);
- var pTaker = Hud.Game.Players.FirstOrDefault(p => p.AnnId == pId);
- if (pTaker != null) { data.Player = pTaker.BattleTagAbovePortrait; }
- }
- else DefaultFont = FontLevel;
- }
- }
- else if (m.IsPylon && PylonData_Dic.TryGetValue(m.SnoActor.Sno,out data))
- {
- if (m.IsUsed) // Pylon: Speed, Channeling, Power, Conduit
- {
- if (!data.Used) newUsed = true;
- if (data.Player == string.Empty)
- {
- var actor = Hud.Game.Actors.FirstOrDefault(a => a.SnoActor.Sno == data.ASE);
- if (actor != null)
- {
- var pId = actor.GetAttributeValueAsUInt(Hud.Sno.Attributes.Gizmo_Operator_ACDID, 1048575);
- var pTaker = Hud.Game.Players.FirstOrDefault(p => p.AnnId == pId);
- if (pTaker != null) { data.Player = pTaker.BattleTagAbovePortrait; }
- }
- }
- var players = Hud.Game.Players.Where(p => p.HasValidActor && p.Powers.BuffIsActive(data.BuffSno,0));
- if (players.Any())
- {
- if (Hud.Game.Me.Powers.BuffIsActive(data.BuffSno,0))
- {
- timeleft = Hud.Game.Me.Powers.GetBuff(data.BuffSno).TimeLeftSeconds[0];
- DefaultFont = FontGreen;
- }
- else
- {
- timeleft = players.FirstOrDefault().Powers.GetBuff(data.BuffSno).TimeLeftSeconds[0];
- DefaultFont = FontYellow;
- }
- }
- else DefaultFont = FontUsed;
- }
- else DefaultFont = FontLevel;
- }
- else continue;
- if (newUsed)
- {
- data.Used = true;
- data.LeveLStr = (LevelUIE.Visible && Int32.TryParse(Regex.Replace(LevelUIE.ReadText(Encoding.UTF8, true), @"(.+:\s)?", ""),out var intLevel))?intLevel.ToString():"??";
- data.TimeStr = TiempoTotalString;
- if (++OrderBuff != data.OrderShow)
- {
- foreach(var data2 in PylonData_Dic)
- {
- if (data2.Value.OrderShow == OrderBuff) { data2.Value.OrderShow = data.OrderShow; data.OrderShow = OrderBuff; break; }
- }
- }
- }
- var y = yPos + data.OrderShow * (heightFont * LineSpacing);
- if (timeleft > 0)
- {
- layout = LeftFont.GetTextLayout( timeleft.ToString((timeleft < 1)?"F1":"F0") );
- LeftFont.DrawText(layout,xPos - layout.Metrics.Width - 3, y + (sizeTexture - layout.Metrics.Height)/2.0f);
- }
- data.Texture.Draw(xPos, y + (heightFont - sizeTexture)/2.0f, sizeTexture, sizeTexture);
- BorderOrangeBrush.DrawRectangle(xPos + 1, y + (heightFont - sizeTexture)/2.0f + 1, sizeTexture - 2, sizeTexture - 2);
- if (ShowNames && data.Player != string.Empty) layout = DefaultFont.GetTextLayout(string.Format("{0,-8} Level:{1,-3} Time:{2} [{3}]", data.Name, data.LeveLStr, data.TimeStr, data.Player));
- else layout = DefaultFont.GetTextLayout(string.Format("{0,-8} Level:{1,-3} Time:{2}", data.Name, data.LeveLStr, data.TimeStr));
- DefaultFont.DrawText(layout,xPos + heightFont * 1.5f,y);
- }
- FontLevel.DrawText(FontUsed.GetTextLayout(string.Format("Time Elapsed:{0} {1}", TiempoTotalString, InfoExtra)),xPos + heightFont * 2.0f, yPos);
- }
- }
- public void PaintWorld(WorldLayer layer)
- {
- if (!Hud.Game.IsInGame || layer != WorldLayer.Map || Hud.Game.Me.SnoArea.Sno != 486520) return;
- if (InEN && LineToBandit)
- {
- var bandit = Hud.Game.Markers.FirstOrDefault(m => m.IsShrine); // ActorSnoEnum._shrine_global
- if (bandit != null)
- {
- if (!PylonData_Dic[ActorSnoEnum._shrine_global].Used) LineBandit.Paint(layer, null, bandit.FloorCoordinate, "");
- else if (!LineToBanditHideUsed) LineBanditUsed.Paint(layer, null, bandit.FloorCoordinate, "");
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement