Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Turbo.Plugins.Default;
- using System.Text;
- using System.Linq;
- using System.Collections.Generic;
- namespace Turbo.Plugins.RNN
- {
- public class LevelItemRequired : BasePlugin, IInGameTopPainter
- {
- private IUiElement HoveredItem2;
- private IUiElement HoveredItem2ScrollerBottom;
- public IFont TextFont { get; set; }
- public string textShow { get; set; }
- public bool showAlways { get; set; }
- public bool ApplyLevelReductionStat { get; set; }
- public float xPos { get; set; }
- public float yPos { get; set; }
- private Dictionary<ActorSnoEnum,double> FixItems { get; set; } = new Dictionary<ActorSnoEnum,double>() // fixes for some blacksmith sets (level < 70)
- {
- { ActorSnoEnum._pants_norm_unique_046, 23 }, { ActorSnoEnum._gloves_norm_unique_046, 23 }, { ActorSnoEnum._helm_norm_set_02, 23 }, { ActorSnoEnum._boots_norm_unique_046, 23 }, // Cain
- { ActorSnoEnum._shoulderpads_norm_set_01, 21 }, { ActorSnoEnum._chestarmor_norm_unique_044, 21 }, { ActorSnoEnum._sword_norm_set_01, 21 }, // Born
- { ActorSnoEnum._belt_norm_unique_12, 31 }, { ActorSnoEnum._boots_norm_unique_043, 31 }, { ActorSnoEnum._pants_norm_unique_043, 31 }, // crimson
- { ActorSnoEnum._bracers_norm_unique_09, 42 }, { ActorSnoEnum._chestarmor_norm_unique_043, 42 }, { ActorSnoEnum._shoulderpads_norm_set_02, 42 }, { ActorSnoEnum._helm_norm_set_03, 42 }, // aughild
- };
- public LevelItemRequired()
- {
- Enabled = true;
- }
- public override void Load(IController hud)
- {
- base.Load(hud);
- textShow = "Level: {0} ({1} required)"; // Text to show. {0} Level, {1} = required level.
- showAlways = true; // Always show or only when both values are different.
- ApplyLevelReductionStat = true;
- xPos = 0.05f; // 0f.... 1f
- yPos = 0.02f; // 0f ... 1f
- HoveredItem2 = Hud.Render.RegisterUiElement("Root.TopLayer.item 2.stack.frame body.scrollbox.stack.wrapper.reqs", null, null);
- HoveredItem2ScrollerBottom = Hud.Render.RegisterUiElement("Root.TopLayer.item 2.stack.frame body.scrollbox._scrollerBottom", null, null);
- TextFont = Hud.Render.CreateFont("arial", 8, 255, 255, 255, 255, false, false, true);
- }
- public void PaintTopInGame(ClipState clipState)
- {
- if (!Hud.Game.IsInGame || clipState != ClipState.AfterClip) return;
- if (Hud.Inventory.InventoryMainUiElement.Visible)
- {
- var item = Hud.Inventory.HoveredItem;
- if (item != null)
- {
- if (HoveredItem2.Visible && !HoveredItem2ScrollerBottom.Visible)
- {
- var stat = item.StatList.FirstOrDefault(i => i.Id == "Requirement#57");
- if (stat != null)
- {
- var levelRequired = stat.DoubleValue; double levelItem = item.SnoItem.RequiredLevel;
- stat = item.StatList.FirstOrDefault(i => i.Id == "Item_LegendaryItem_Level_Override#1048575");
- if (stat != null) levelItem = stat.DoubleValue;
- else if (levelItem < 70 && FixItems.TryGetValue(item.SnoActor.Sno, out var data)) levelItem = data;
- if (ApplyLevelReductionStat)
- {
- stat = item.StatList.FirstOrDefault(i => i.Id == "lvlreqred"); // Item_Level_Requirement_Reduction#1048575
- if (stat != null) levelRequired -= stat.DoubleValue;
- }
- if (showAlways || levelItem != levelRequired) // if (showAlways || item.StatList.FirstOrDefault(i => i.Id == "RemoveLevelReq#1048575")?.DobleValue == 1)
- {
- var layout = TextFont.GetTextLayout(string.Format(textShow, levelItem, levelRequired));
- //TextFont.DrawText(layout, HoveredItem2.Rectangle.X + HoveredItem2.Rectangle.Width/2.0f - layout.Metrics.Width, HoveredItem2.Rectangle.Y + (HoveredItem2.Rectangle.Height - layout.Metrics.Height)/2.0f );
- TextFont.DrawText(layout, HoveredItem2.Rectangle.X + HoveredItem2.Rectangle.Width * xPos, HoveredItem2.Rectangle.Y + HoveredItem2.Rectangle.Height * yPos );
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment