Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace Turbo.Plugins.User
- {
- public class RecycleExample : BasePlugin, ICustomizer, IInGameTopPainter
- {
- 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>>
- private int LapseAction = 0;
- public RecycleExample()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- }
- public void Customize()
- {
- // a) Option 1 => Use the original dictionary
- // Hud.RunOnPlugin<Ez.ItemPowerShow>(plugin => ChooseAName = plugin.Sno_IdPercent);
- // b) Option 2 => Duplicate dictionary so as not to modify the original.
- Dictionary<ActorSnoEnum,Tuple<string,bool,string,double>> tmp = null;
- Hud.RunOnPlugin<Ez.ItemPowerShow>(plugin => tmp = plugin.Sno_IdPercent);
- if (tmp != null)
- {
- foreach(var data in tmp)
- {
- ChooseAName.Add(data.Key, data.Value);
- }
- }
- /* ---- 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 */
- 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
- }
- 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
- { // b) ItemIdValue(item2, id = "Item_Power_Passive#475241"); => Find the specified ID and multiply the value by 100 (default behavior)
- 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
- { // 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
- if (ChooseAName.TryGetValue(item.SnoActor.Sno,out var data))
- {
- id = data.Item1; percent = data.Item2; // < item.SnoActor.Sno, Tuple<STAT.Id, multiply x 100, Suffix, MaxValue> >
- }
- else return double.MaxValue; // queries in the Dictionary, but the item does not exist
- }
- var stat = item.StatList.FirstOrDefault(s => s.Id == id);
- if (stat != null)
- {
- return Math.Round(stat.DoubleValue * (percent?10000:100))/100;
- }
- else return 0; // stat (id) not found in item
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (!Hud.Game.IsInGame || !Hud.Game.IsInTown || !Hud.Window.IsForeground) return;
- if (clipState == ClipState.Inventory)
- {
- if (Hud.Inventory.InventoryMainUiElement.Visible && Hud.Game.CurrentGameTick > LapseAction)
- {
- LapseAction = Hud.Game.CurrentGameTick + 180; // 3 sec.
- var item = Hud.Game.Items.FirstOrDefault(x => x.Location == ItemLocation.Inventory && Hud.Inventory.GetItemRect(x).Contains(Hud.Window.CursorX,Hud.Window.CursorY));
- if (item != null)
- {
- if (item.SnoActor.Sno == ActorSnoEnum._p2_ring_norm_unique_03) // Convention of Elements
- {
- var val = ItemIdValue(item);
- if (val < 195)
- Hud.Sound.Speak("Recycle it , the value is" + val + " , below 195 ");
- }
- else if (item.SnoActor.Sno == ActorSnoEnum._belt_norm_unique_07) // The Witching Hour
- {
- var val = ItemIdValue(item);
- if (val < 48)
- Hud.Sound.Speak("Recycle it, the value is" + val + " , below 48 ");
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement