Advertisement
EzPlugins

RecycleExample

Apr 17th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.83 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace Turbo.Plugins.User
  7. {
  8.     public class RecycleExample : BasePlugin, ICustomizer, IInGameTopPainter
  9.     {
  10.         public Dictionary<ActorSnoEnum,Tuple<string,bool,string,double>> ChooseAName { get; set; } = new Dictionary<ActorSnoEnum, Tuple<string,bool,string,double>>();  // <item.SnoActor.Sno, Tuple<STAT.Id,multiply x 100,Suffix,MaxValue>>
  11.         private int LapseAction = 0;
  12.  
  13.         public RecycleExample()
  14.         {
  15.           Enabled = true;
  16.         }
  17.  
  18.         public override void Load(IController hud)
  19.         {
  20.             base.Load(hud);
  21.         }
  22.  
  23.         public void Customize()
  24.         {
  25.             // a) Option 1 => Use the original dictionary
  26.             //  Hud.RunOnPlugin<Ez.ItemPowerShow>(plugin => ChooseAName = plugin.Sno_IdPercent);
  27.            
  28.             // b) Option 2 => Duplicate dictionary so as not to modify the original.
  29.             Dictionary<ActorSnoEnum,Tuple<string,bool,string,double>> tmp = null;
  30.             Hud.RunOnPlugin<Ez.ItemPowerShow>(plugin => tmp = plugin.Sno_IdPercent);
  31.             if (tmp != null)
  32.             {
  33.                 foreach(var data in tmp)
  34.                 {
  35.                     ChooseAName.Add(data.Key, data.Value);
  36.                 }
  37.             }          
  38.  
  39.             /* ---- From here, you can add other power items to the dictionary. Actually, the dictionary is not limited to items powers, you could add the critical damage of the witching hour  */
  40.              ChooseAName[ActorSnoEnum._belt_norm_unique_07] =  new Tuple<string,bool,string,double>("Crit_Damage_Percent#1048575", true,"%",50);        // Add The Witching Hour to Dictionary , stat crit damage
  41.         }
  42.  
  43.         private double ItemIdValue(IItem item, string id = "", bool percent = true)         // a) ItemIdValue(item1);                                                       => Use default ID and percentage for this item, extracted from the dictionary
  44.         {                                                                                   // b) ItemIdValue(item2, id = "Item_Power_Passive#475241");                     => Find the specified ID and multiply the value by 100 (default behavior)
  45.             if (id == string.Empty)                                                         // c) ItemIdValue(item3, id = "Item_Power_Passive#475241", percent = false);    => Searches for the specified ID and does not multiply by 100
  46.             {                                                                               // Function return 0 if the specified ID/Stat does not exist, or double.MaxValue if the ID was omitted and the item does not exist in the dictionary
  47.                 if (ChooseAName.TryGetValue(item.SnoActor.Sno,out var data))
  48.                 {
  49.                     id = data.Item1;  percent = data.Item2;                                 //  < item.SnoActor.Sno, Tuple<STAT.Id, multiply x 100, Suffix, MaxValue> >
  50.                 }
  51.                 else return double.MaxValue; // queries in the Dictionary, but the item does not exist
  52.             }
  53.             var stat = item.StatList.FirstOrDefault(s => s.Id == id);
  54.             if (stat != null)
  55.             {
  56.                 return Math.Round(stat.DoubleValue * (percent?10000:100))/100;
  57.             }
  58.             else return 0;  // stat (id) not found in item
  59.         }
  60.        
  61.         public void PaintTopInGame(ClipState clipState)
  62.         {
  63.             if (!Hud.Game.IsInGame || !Hud.Game.IsInTown || !Hud.Window.IsForeground) return;
  64.             if (clipState == ClipState.Inventory)
  65.             {
  66.                 if (Hud.Inventory.InventoryMainUiElement.Visible && Hud.Game.CurrentGameTick > LapseAction)
  67.                 {
  68.                     LapseAction = Hud.Game.CurrentGameTick + 180;  // 3 sec.
  69.                     var item = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.Inventory && Hud.Inventory.GetItemRect(x).Contains(Hud.Window.CursorX,Hud.Window.CursorY));
  70.                     if (item != null)
  71.                     {
  72.                         if (item.SnoActor.Sno == ActorSnoEnum._p2_ring_norm_unique_03)      // Convention of Elements
  73.                         {
  74.                             var val = ItemIdValue(item);
  75.                             if (val < 195)
  76.                                 Hud.Sound.Speak("Recycle it , the value is" + val + " , below 195 ");
  77.                         }
  78.                         else if (item.SnoActor.Sno == ActorSnoEnum._belt_norm_unique_07)    // The Witching Hour
  79.                         {
  80.                             var val = ItemIdValue(item);
  81.                             if (val < 48)
  82.                                 Hud.Sound.Speak("Recycle it, the value is" + val + " , below 48 ");
  83.                         }
  84.                     }
  85.                 }
  86.             }
  87.         }
  88.     }
  89. }
  90.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement