Advertisement
Jembo33

DiadrasFirstGemPlugin.cs

Nov 14th, 2020 (edited)
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 8.17 KB | None | 0 0
  1. // https://github.com/User5981/Resu
  2. // Diadra's First Gem Plugin for TurboHUD Version 14/01/2018 19:51
  3. using System;
  4. using System.Collections.Generic;
  5. using Turbo.Plugins.Default;
  6. using System.Linq;
  7.  
  8. namespace Turbo.Plugins.Resu
  9. {
  10.  
  11.     public class DiadrasFirstGemPlugin : BasePlugin, IInGameWorldPainter
  12.     {
  13.         public int StrickenRank { get; set; }
  14.         public bool ElitesnBossOnly { get; set; }
  15.         public bool BossOnly { get; set; }
  16.         public int propSquare { get; set; }
  17.         public bool cooldown { get; set; }
  18.         public int monsterCount { get; set; }
  19.         public int offsetX { get; set; }
  20.         public int offsetY { get; set; }
  21.         public TopLabelDecorator StrickenStackDecorator { get; set; }
  22.         public TopLabelDecorator StrickenPercentDecorator { get; set; }
  23.         public Dictionary<uint,Tuple<double,int>> MonsterStatus { get; set; }  // AcdId, Health, Stacks
  24.        
  25.        
  26.         public DiadrasFirstGemPlugin()
  27.         {
  28.             Enabled = true;
  29.             ElitesnBossOnly = false;
  30.             BossOnly = false;
  31.             offsetX = 0;
  32.             offsetY = 0;
  33.             MonsterStatus = new Dictionary<uint,Tuple<double,int>>();
  34.         }
  35.  
  36.         public override void Load(IController hud)
  37.         {
  38.             base.Load(hud);
  39.             StrickenRank = 0;
  40.             propSquare = (int)(Hud.Window.Size.Width/53.333);
  41.             cooldown = false;
  42.             monsterCount = 0;
  43.            
  44.             StrickenStackDecorator = new TopLabelDecorator(Hud)
  45.             {
  46.               TextFont = Hud.Render.CreateFont("tahoma", 7, 255, 0, 0, 0, true, false, 250, 255, 255, 255, true),
  47.             };
  48.            
  49.             StrickenPercentDecorator = new TopLabelDecorator(Hud)
  50.             {
  51.               TextFont = Hud.Render.CreateFont("tahoma", 6, 255, 255, 255, 255, false, false, 250, 0, 0, 0, true),
  52.             };
  53.        
  54.         }
  55.        
  56.        
  57.        
  58.          public void OnNewArea(bool newGame, ISnoArea area)
  59.         {
  60.             if (newGame)
  61.             {
  62.                 MonsterStatus.Clear();
  63.             }
  64.         }
  65.        
  66.  
  67.  
  68.        
  69.         public void PaintWorld(WorldLayer layer)
  70.         {
  71.             var hedPlugin = Hud.GetPlugin<HotEnablerDisablerPlugin>();
  72.             bool GoOn = hedPlugin.CanIRun(Hud.Game.Me,this.GetType().Name);
  73.             if (!GoOn) return;
  74.            
  75.             bool StrickenActive = false;
  76.             var jewelsLocations = Hud.Game.Items.Where(x => x.Location == ItemLocation.LeftRing || x.Location == ItemLocation.RightRing || x.Location == ItemLocation.Neck);
  77.            
  78.             foreach (var StrickenLocation in jewelsLocations)
  79.                     {
  80.                       if (StrickenLocation.SocketCount != 1 || StrickenLocation.ItemsInSocket == null) continue;
  81.                       var Stricken = StrickenLocation.ItemsInSocket.FirstOrDefault();
  82.                       if (Stricken == null) continue;
  83.                       if (Stricken.SnoItem.Sno == 3249948847) {StrickenActive = true; StrickenRank = Stricken.JewelRank; break;} else {continue;}
  84.                     }
  85.          
  86.          
  87.            if (StrickenActive == false) return;
  88.                
  89.          
  90.            float gemMaths = 0.8f + (0.01f*(float)StrickenRank);
  91.            var Texture = Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.Unique_Gem_018_x1);
  92.            var monsters = Hud.Game.Monsters.OrderBy(i => i.NormalizedXyDistanceToMe);
  93.            foreach (var monster in monsters)
  94.                    {
  95.                      if (ElitesnBossOnly && !monster.IsElite) continue;
  96.                      if (BossOnly && monster.Rarity.ToString() != "Boss") continue;
  97.                      var monsterScreenCoordinate = monster.FloorCoordinate.ToScreenCoordinate();
  98.                    
  99.                      if (monster.IsAlive)
  100.                         {
  101.                            
  102.                           Tuple<double,int> valuesOut;
  103.                           if  (MonsterStatus.TryGetValue(monster.AcdId, out valuesOut))
  104.                               {
  105.                                 double Health = monster.CurHealth;
  106.                                 double prevHealth = valuesOut.Item1;
  107.                                 int prevStacks = valuesOut.Item2;
  108.                                
  109.                                 if (prevHealth > Health && Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.BaneOfTheStrickenPrimary.Sno, 2) && monsterCount == 0 && !cooldown)
  110.                                    {
  111.                                      int Stacks = (int)(prevStacks + 1);
  112.                                      Tuple<double,int> updateValues = new Tuple<double,int>(monster.CurHealth, Stacks);
  113.                                      MonsterStatus[monster.AcdId] = updateValues;
  114.                                      monsterCount++;
  115.                                      cooldown = true;
  116.                                    }
  117.                                    
  118.                                 else if (!Hud.Game.Me.Powers.BuffIsActive(Hud.Sno.SnoPowers.BaneOfTheStrickenPrimary.Sno, 2) && cooldown)
  119.                                         {
  120.                                           cooldown = false;
  121.                                           monsterCount = 0;
  122.                                           if (prevHealth > Health)
  123.                                              {
  124.                                                int Stacks = (int)(prevStacks);
  125.                                                Tuple<double,int> updateValues = new Tuple<double,int>(monster.CurHealth, Stacks);
  126.                                                MonsterStatus[monster.AcdId] = updateValues;
  127.                                              }
  128.                                         }  
  129.                                    
  130.  
  131.                                 if (prevStacks > 0)
  132.                                    {
  133.                                      int bossPerc = 0;
  134.                                      if (monster.SnoMonster.Priority == MonsterPriority.boss) {bossPerc = 25;}
  135.                                      else {bossPerc = 0;}
  136.                                      float StrickenDamagePercent = (float)(bossPerc + (prevStacks * gemMaths));
  137.                                      string percentDamageBonus = "+" + StrickenDamagePercent.ToString("0.00") + "%";
  138.                                      Texture.Draw(monsterScreenCoordinate.X + offsetX, monsterScreenCoordinate.Y + offsetY, propSquare, propSquare);
  139.                                      StrickenStackDecorator.TextFunc = () => prevStacks.ToString();
  140.                                      StrickenPercentDecorator.TextFunc = () => percentDamageBonus;
  141.                                      StrickenStackDecorator.Paint(monsterScreenCoordinate.X + offsetX, monsterScreenCoordinate.Y + offsetY, propSquare, propSquare, HorizontalAlign.Center);
  142.                                      StrickenPercentDecorator.Paint(monsterScreenCoordinate.X + offsetX, (float)(monsterScreenCoordinate.Y + offsetY +(propSquare/2.5)), propSquare, propSquare, HorizontalAlign.Right);
  143.                                      if (cooldown)
  144.                                         {
  145.                                           StrickenPercentDecorator.TextFunc = () => System.Char.ConvertFromUtf32(0x0000231B);
  146.                                           StrickenPercentDecorator.Paint((float)(monsterScreenCoordinate.X + offsetX +(propSquare/2)),monsterScreenCoordinate.Y + offsetY, propSquare, propSquare, HorizontalAlign.Center);
  147.                                         }
  148.                
  149.                                    }
  150.                               }
  151.                           else
  152.                               {
  153.                                 Tuple<double,int> valuesIn = new Tuple<double,int>(monster.CurHealth, (int)(0));
  154.                                 MonsterStatus.Add(monster.AcdId, valuesIn);
  155.                               }
  156.                            
  157.                         }
  158.                     else
  159.                         {
  160.                           MonsterStatus.Remove(monster.AcdId);
  161.                         }
  162.                    }
  163.         }
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement