Advertisement
RNNCode

TheFellowshipOfThePotion

Jul 20th, 2024 (edited)
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.99 KB | None | 0 0
  1. using Turbo.Plugins.Default;
  2. using System;
  3. using System.Linq;
  4.  
  5. namespace Turbo.Plugins.RNN
  6. {
  7.     public class TheFellowshipOfThePotion : BasePlugin, IInGameTopPainter
  8.     {
  9.         private SharpDX.DirectWrite.TextLayout layout { get; set; } = null;
  10.  
  11.         private ITexture[] PotionTextures { get; set; }
  12.  
  13.         private IFont FontTimeLeft { get; set; }
  14.         private IFont FontCooldown { get; set; }
  15.         private IFont FontStacks { get; set; }
  16.         private IBrush LoveBrush { get; set; }
  17.         private IBrush CreationBrush { get; set; }
  18.         private IBrush DeterminationBrush { get; set; }
  19.  
  20.         private float _SizeMultiplier  { get; set; }
  21.         private uint snoPower { get; set; } = 488071; // Generic_CommunityBuffDarkAlchemy
  22.  
  23.         public float OffsetX { get; set; }
  24.         public float OffsetY { get; set; }
  25.         public float Opacity { get; set; }
  26.         public bool swapTexturePotion { get; set; }
  27.  
  28.         public float SizeMultiplier
  29.         {
  30.             get { return _SizeMultiplier; }
  31.             set
  32.             {
  33.                 if (_SizeMultiplier != value)
  34.                 {
  35.                     _SizeMultiplier = value;
  36.                     FontTimeLeft  = Hud.Render.CreateFont("Tahoma", 9 * _SizeMultiplier, 255, 0, 255, 0, true, false, 255, 0, 0, 0, true);
  37.                     FontCooldown = Hud.Render.CreateFont("Tahoma", 12f * _SizeMultiplier, 255, 255, 255, 255, true, false, 255, 0, 0, 0, true);
  38.                     FontStacks = Hud.Render.CreateFont("Tahoma", 8 * _SizeMultiplier, 255, 255, 255, 0, false, false, 255, 0, 0, 0, true);
  39.                 }
  40.             }
  41.         }
  42.  
  43.         public TheFellowshipOfThePotion()
  44.         {
  45.             Enabled = true;
  46.         }
  47.  
  48.         public override void Load(IController hud)
  49.         {
  50.             base.Load(hud);
  51.             Order = 91000;
  52.  
  53.             OffsetX = 2.90f;            // To set the x coordinate of the icon  (OffsetYX * Portrait Width)
  54.             OffsetY = 0.50f;            // To set the y coordinate of the icon (OffsetYX * Portrait Height)
  55.             Opacity = 0.75f;            // 0f..1f  Opacity for icon texture
  56.             SizeMultiplier = 0.65f;     // Size multiplier for icons
  57.             swapTexturePotion = true;   // Change the texture when you get a buff from the potion.
  58.  
  59.             LoveBrush = Hud.Render.CreateBrush(255, 255, 0, 128, -1);           // Damage
  60.             CreationBrush = Hud.Render.CreateBrush(255, 64, 200, 144, -1);      // CDR
  61.             DeterminationBrush = Hud.Render.CreateBrush(255, 164, 150, 32, -1); // RCR
  62.  
  63.             PotionTextures = new ITexture[]
  64.             {
  65.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_01),      // 2276259498 - Bottomless Potion of the Tower
  66.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_02),      // 2276259499 - Bottomless Potion of the Diamond
  67.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_03),      // 2276259500 - Bottomless Potion of Regeneration
  68.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_04),      // 2276259501 - Bottomless Potion of the Leech
  69.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_05),      // 2276259502 - Bottomless Potion of Mutilation
  70.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_06),      // 2276259503 - Bottomless Potion of Kulle-Aid
  71.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.P2_HealthPotionLegendary_07),   // 510979313 - Bottomless Potion of Rejuvenation
  72.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_08),      // 2276259505 - Bottomless Potion of Fear
  73.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_09),      // 2276259506 - Bottomless Potion of Amplification
  74.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_10),      // 2276259530 - Bottomless Potion of Chaos
  75.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionLegendary_11),      // 2276259531 - Bottomless Potion of the Unfettered
  76.                 Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionBottomless),
  77.             };
  78.         }
  79.  
  80.         int GetIndexTexture(IPlayer p)
  81.         {
  82.             var textureIndex = 11;
  83.             if (Math.Abs(Hud.Game.CurrentGameTick - p.Powers.HealthPotionSkill.CooldownStartTick) < 421)
  84.             {
  85.                 if ( p.Powers.BuffIsActive(342078) )
  86.                 {
  87.                     for(var i = 0; i < 5; i++)
  88.                     {
  89.                         if (p.Powers.BuffIsActive(342078,i)) { textureIndex = i; break; }
  90.                     }
  91.                 }
  92.                 else if (p.Powers.BuffIsActive(344094)) textureIndex = 5;
  93.                 else if (p.Powers.BuffIsActive(433021)) textureIndex = 6;
  94.                 else if (p.Powers.BuffIsActive(428812)) textureIndex = 7;
  95.                 else if (p.Powers.BuffIsActive(434626)) textureIndex = 8;
  96.                 else if (p.Powers.BuffIsActive(451310)) textureIndex = 9;
  97.                 else if (p.Powers.BuffIsActive(483315)) textureIndex = 10;
  98.             }
  99.             return textureIndex;
  100.         }
  101.  
  102.         public void PaintTopInGame(ClipState clipState)
  103.         {
  104.             if (clipState != ClipState.BeforeClip) return;
  105.             if (!Hud.Game.IsInGame) return;
  106.             if (Hud.Game.Me.Powers.BuffIsActive(488071))  // Comunity_Buff_DarkAlchemy , Season
  107.             {
  108.                 var players = Hud.Game.Players.Where( p => p.HasValidActor && p.Powers.BuffIsActive(488004) );  //P75_ItemPassive_DarkAlchemyMayor_001 // Madre
  109.                 foreach(var player in players)
  110.                 {
  111.                     var x = player.PortraitUiElement.Rectangle.X + player.PortraitUiElement.Rectangle.Width * OffsetX;      var y = player.PortraitUiElement.Rectangle.Y + player.PortraitUiElement.Rectangle.Height * OffsetY;
  112.                     var SizeIconWidth = Hud.Texture.BuffFrameTexture.Width   * Hud.Window.Size.Height/1200.0f * _SizeMultiplier;    var SizeIconHeight = Hud.Texture.BuffFrameTexture.Height * Hud.Window.Size.Height/1200.0f * _SizeMultiplier;                   
  113.                    
  114.                     if (swapTexturePotion) PotionTextures[GetIndexTexture(player)].Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
  115.                     else Hud.Texture.GetItemTexture(Hud.Sno.SnoItems.HealthPotionBottomless).Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);                   
  116.                     Hud.Texture.BuffFrameTexture.Draw(x, y, SizeIconWidth, SizeIconHeight, Opacity);
  117.  
  118.                     var skill = player.Powers.HealthPotionSkill;
  119.                     if (skill.CooldownFinishTick > Hud.Game.CurrentGameTick)  // player.Powers.HealthPotionSkill.IsOnCooldown
  120.                     {
  121.                         double remaining = (skill.CooldownFinishTick - Hud.Game.CurrentGameTick)/60.0d;
  122.                         layout = FontCooldown.GetTextLayout( remaining.ToString( (remaining < 1)? "F1":"F0" ) );
  123.                         FontCooldown.DrawText(layout, x + ((SizeIconWidth - (float)Math.Ceiling(layout.Metrics.Width))/2.0f), y + ((SizeIconHeight - (float)Math.Ceiling(layout.Metrics.Height))/1.20f) );
  124.                         if ( (Hud.Game.CurrentGameTick - skill.CooldownStartTick) < 421) // 7s
  125.                         {
  126.                             var circles = Hud.Game.Actors.Where(a => a.SnoActor.Sno == ActorSnoEnum._generic_proxy && a.CreatedAtInGameTick == skill.CooldownStartTick);  
  127.                             if (circles.Any())
  128.                             {
  129.                                 if ( circles.Any(a => a.GetAttributeValueAsInt(Hud.Sno.Attributes.Power_Buff_1_Visual_Effect_None, snoPower) == 1) ) LoveBrush.DrawRectangle(x, y, SizeIconWidth, SizeIconHeight);
  130.                                 else if ( circles.Any(a => a.GetAttributeValueAsInt(Hud.Sno.Attributes.Power_Buff_7_Visual_Effect_None, snoPower) == 1) ) CreationBrush.DrawRectangle(x, y, SizeIconWidth, SizeIconHeight);
  131.                                 else if ( circles.Any(a => a.GetAttributeValueAsInt(Hud.Sno.Attributes.Power_Buff_6_Visual_Effect_None, snoPower) == 1) ) DeterminationBrush.DrawRectangle(x, y, SizeIconWidth, SizeIconHeight);
  132.                             }
  133.                         }
  134.                     }
  135.                 }
  136.             }
  137.         }
  138.     }
  139. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement