RNNCode

TimeLeftSkillBar

Jul 31st, 2024 (edited)
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.13 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5. using SharpDX;
  6.  
  7. namespace Turbo.Plugins.RNN
  8. {
  9.     public class TimeLeftSkillBar : BasePlugin, IInGameTopPainter
  10.     {
  11.         public Dictionary<uint,uint> ReplaceSno { get; set; }
  12.         public Dictionary<uint,int> FixedIndex { get; set; }
  13.         public List<uint> ExcludeAll { get; set; }
  14.         public Dictionary<uint,List<int>> ExcludeThis { get; set; }
  15.         public IFont TimeLeftFont { get; set; }
  16.  
  17.         public TimeLeftSkillBar()
  18.         {
  19.             Enabled = true;
  20.         }
  21.  
  22.         public override void Load(IController hud)
  23.         {
  24.             base.Load(hud);
  25.             Order = 31001;
  26.  
  27.             TimeLeftFont  = Hud.Render.CreateFont("arial", 8, 255, 0, 255, 0, true, false, 255, 0, 0, 0, true);
  28.  
  29.             ReplaceSno = new Dictionary<uint,uint>
  30.             {
  31.                 {375049, 375050},   // Mantra Salvación        (Monk)
  32.                 {375082, 375083},   // Mantra Reprensión   (Monk)
  33.                 {373143, 373154},   // Mantra Curación     (Monk)
  34.                 {375088, 375089},   // Mantra Convicción   (Monk)
  35.                 {362102, 362118},   // Aliado Místico      (Monk)
  36.  
  37.                 {342281, 342284},   // Ley Valor        (Crus)
  38.                 {342280, 342286},   // Ley Justicia     (Crus)
  39.                 {342279, 342299},   // Ley Esperanza    (Crus)
  40.  
  41.                 {392883, 134872},   // Archon Override Timeleft (Wiz) Cold
  42.                 {167355, 134872},   // Archon Override Timeleft (Wiz) Arcane
  43.                 {130831, 434964},
  44.             };
  45.  
  46.             FixedIndex = new Dictionary<uint,int>           // Default Skill Index. Por defecto se muestran el primer indice con timeleft > 0 , aquí se puede fijar un indice concreto para la habilidad
  47.             {
  48.                 {130738, 3},    // Marcado Para Morir (DH)
  49.  
  50.                 { 79528, 0},    // Tolerancia Dolor (Barb)
  51.                 { 96296, 9},    // Torbellino       (Barb)
  52.  
  53.                 {462255, 3},    // Parasitar (Necro)
  54.  
  55.                 {317076, 6},    // Santuario Interior   (Monk)
  56.  
  57.                 {375050, 1},    // Mantra Salvación        (Monk)
  58.                 {375083, 1},    // Mantra Reprensión   (Monk)
  59.                 {373154, 1},    // Mantra Curación     (Monk)
  60.                 {375089, 2},    // Mantra Convicción   (Monk)
  61.  
  62.                 {342284, 6},    // Ley Valor        (Crus)
  63.                 {342286, 6},    // Ley Justicia     (Crus)
  64.                 {342299, 6},    // Ley Esperanza    (Crus)
  65.                 {325216, 0},    // Justicia         (Crus) //  o excluir 7
  66.                 {286510, 1},    // Fulminar         (Crus) //  o excluir 14
  67.                 {239042, 4},    // Ataque de barrido(Crus) //  o excluir 0
  68.                 {266951, 2},    // Escudo Bendito   (Crus) //  o excluir 7
  69.                 {291804, 0},    // Piel Férrea     (Crus) //  o excluir 3
  70.  
  71.                 // {134872, 2}, // Arconte      (Wiz)
  72.  
  73.                 {117402, 4},    // Trance Vudú         (WD) // o excluir 1,3,2
  74.                 {108506, 3},    // Rafaga de espiritus  (WD) // o excluir el 1
  75.                 { 67616, 0},    // Cosecha de Almas     (WD) // o excluir el 4
  76.             };
  77.  
  78.             ExcludeAll = new List<uint>  // Ignore Skill index (all)
  79.             {
  80.                  93395, // Rayo de Hielo    (Wiz)  // o excluir 6
  81.                   1765, // Electrocutar     (Wiz)  // o excluir 1
  82.                  91549, // Desintegrar      (Wiz)  // o excluir 10
  83.                 134456, // Rafaga           (Wiz)  // o excluir 2,8,9
  84.  
  85.                 462089,     //Mago esqueletico (Necro)
  86.  
  87.                  77649,     // Multishot        (DH)
  88.                 129216,     // Abrojos          (DH)
  89.                 131325,     // Flecha Elemental (DH)
  90.                 129217,     // Centinela        (DH)
  91.  
  92.                 362102,     // Aliado Místico   (Monk)
  93.                 362118,     // Aliado Místico R (Monk)
  94.                  95940,     // Puños del trueno (Monk)
  95.                 121442,     // Vuelo del Dragón (Monk)
  96.  
  97.                 266766,     // Martillo Bendito (Crus)
  98.                 273941,     // Consagración        (Crus), index 0 y 8  pero no parecen útiles
  99.  
  100.                 105963,     // Murciélagos     (WD) o excluir index 4
  101.             };
  102.  
  103.             ExcludeThis = new Dictionary<uint,List<int>>    // Ignore skill Index (list)
  104.             {
  105.                 {460757, new List<int>{5,1} },      // Devorar          (Necro)
  106.                 {453563, new List<int>{8} },        // Abosorver sangre (Necro)
  107.  
  108.                 {159169, new List<int>{2} },        // Arrollar         (Barb) ( active index = 0 , 1 )
  109.  
  110.                 { 97110, new List<int>{0,2} },      // Senda cien puños    (Monk) ( active index = 1 y 4 )
  111.                 {312736, new List<int>{0} },        // Embestida        (monk) ( active index = 3 ,2 , 4)
  112.                 { 83602, new List<int>{5} },        // Posesión        (WD)
  113.             };
  114.         }
  115.  
  116.         public void TimeLeftDraw( ActionKey key , double TimeLeftSec, uint powersno = 0, uint currentpowersno = 0 )
  117.         {
  118.             var ui = Hud.Render.GetPlayerSkillUiElement(key);
  119.             var rect = new RectangleF((float)Math.Round(ui.Rectangle.X) + 0.5f, (float)Math.Round(ui.Rectangle.Y) + 0.5f, (float)Math.Round(ui.Rectangle.Width), (float)Math.Round(ui.Rectangle.Height));
  120.             string text = string.Empty;
  121.             if (powersno != 0)
  122.             {
  123.                 text = powersno + "\n" + currentpowersno;
  124.             }
  125.             else
  126.             {
  127.                 if (TimeLeftSec < 1.0f)
  128.                 {
  129.                     text = String.Format("{0:N1}",  TimeLeftSec );
  130.                 }
  131.                 else
  132.                 {
  133.                     TimeLeftSec =  (int) (TimeLeftSec + 0.80);  // Redondeará a X si es menor  a X.20
  134.                     text = (TimeLeftSec < 60)? String.Format("{0:0}", TimeLeftSec ) : String.Format("{0:0}:{1:00}", (int) (TimeLeftSec / 60) ,  TimeLeftSec % 60 ) ;
  135.                 }
  136.             }
  137.             var textLayout = TimeLeftFont.GetTextLayout(text) ;
  138.             TimeLeftFont.DrawText(textLayout, rect.X + ((rect.Width - (float)Math.Ceiling(textLayout.Metrics.Width))/2), rect.Y + (((rect.Height / 2.5f) - textLayout.Metrics.Height)/2));
  139.         }
  140.  
  141.         public void PaintTopInGame(ClipState clipState)
  142.         {
  143.             if (Hud.Render.UiHidden)   return;
  144.             if (clipState != ClipState.BeforeClip)   return;
  145.             if ((Hud.Game.MapMode == MapMode.WaypointMap) || (Hud.Game.MapMode == MapMode.ActMap) || (Hud.Game.MapMode == MapMode.Map))  return;
  146.  
  147.             foreach (var skill in Hud.Game.Me.Powers.CurrentSkills)
  148.             {
  149.                 IBuff buff = null ;
  150.                 if (ReplaceSno.TryGetValue(skill.CurrentSnoPower.Sno, out var sno))
  151.                 {
  152.                     buff = Hud.Game.Me.Powers.AllBuffs.FirstOrDefault(b => b.SnoPower.Sno == sno );
  153.                 }
  154.                 else { buff = Hud.Game.Me.Powers.AllBuffs.FirstOrDefault(b => b.SnoPower.Sno == skill.CurrentSnoPower.Sno ); } // else { buff = skill.Buff; }
  155.                 if (buff == null) { /*TimeLeftDraw( skill.Key, 0, skill.SnoPower.Sno, skill.CurrentSnoPower.Sno);*/ continue;    }
  156.                 if (buff.Active)
  157.                 {
  158.                     if (FixedIndex.TryGetValue(buff.SnoPower.Sno, out var index))  // Por si queremos fijar el índice para determinadas habilidades.
  159.                     {
  160.                         var timeleft = buff.TimeLeftSeconds[index];
  161.                         if (skill.CurrentSnoPower.Sno == 130738 && skill.Rune == 2)  // or buff.SnoPower.Sno == 130738
  162.                         {
  163.                             timeleft = timeleft - (Hud.Game.Me.Powers.BuffIsActive(208610, 0)?30:15);
  164.                         }
  165.  
  166.                         if (timeleft > 0)
  167.                         {
  168.                             TimeLeftDraw( skill.Key, timeleft); // TimeLeftDraw( skill.Key, timeleft, skill.CurrentSnoPower.Sno);
  169.                         }
  170.                     }
  171.                     else  if (!ExcludeAll.Contains(buff.SnoPower.Sno))  // Habilidades para las que no se mostrará ningún timeleft , salvo si se prefijó
  172.                     {
  173.                         bool skip = ExcludeThis.ContainsKey(buff.SnoPower.Sno) ? true:false;
  174.                         for (int i = 0; i < buff.TimeLeftSeconds.Length ;i++)
  175.                         {
  176.                             if (buff.TimeLeftSeconds[i] > 0)
  177.                             {
  178.                                 if (skip && ExcludeThis[buff.SnoPower.Sno].Contains(i)) continue;   // Para excluir determinados indices en las comparaciones
  179.                                 TimeLeftDraw( skill.Key, buff.TimeLeftSeconds[i]);  //TimeLeftDraw( skill.Key, buff.TimeLeftSeconds[i], skill.CurrentSnoPower.Sno );
  180.                                 break;
  181.                             }
  182.                         }
  183.                     }
  184.                 }
  185.             }
  186.         }
  187.     }
  188. }
Advertisement
Add Comment
Please, Sign In to add comment