Advertisement
Chill_

RiftGuardianParagonWarning.cs

Jul 29th, 2018
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.98 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4. using System.Collections.Generic;
  5.  
  6. namespace Turbo.Plugins.CLL
  7. {
  8.     public class RiftGuardianParagonWarning : BasePlugin, IInGameTopPainter
  9.     {
  10.         public IFont RGParagonWarningFont { get; set; }
  11.         public int MainStatCap { get; set; }
  12.         private float HudWidth { get { return Hud.Window.Size.Width; } }
  13.         private float HudHeight { get { return Hud.Window.Size.Height; } }
  14.         public float ParaWarningX { get; set; }
  15.         public float ParaWarningY { get; set; }
  16.         public int ParagonInMovementSpeed { get; set; }
  17.         public int baseMainStat { get; set; }
  18.         public string WarningMessage { get; set; }
  19.         public bool AlertBeforeBossSpawns { get; set; }
  20.         public double PercentageWhenToAlert { get; set; }
  21.         public float OffsetX { get; set; }
  22.         public float OffsetY { get; set; }
  23.  
  24.         public RiftGuardianParagonWarning()
  25.         {
  26.             Enabled = true;
  27.         }
  28.  
  29.  
  30.         public override void Load(IController hud)
  31.         {
  32.             base.Load(hud);
  33.  
  34.             RGParagonWarningFont = Hud.Render.CreateFont("tahoma", 20, 255, 255, 0, 0, true, false, true);
  35.             //if someone chooses to use Paragon points in Movement speed
  36.             ParagonInMovementSpeed = 0;
  37.             //Position left/right. Higer number = further right
  38.             OffsetX = 0.4f;
  39.             //Position up/down. Higer number = further down
  40.             OffsetY = 0.25f;
  41.             //270 because every level 70 necro has 217 int without paragon or gear
  42.             baseMainStat = 217;
  43.             //The Message that is displayed
  44.             WarningMessage = "SWITCH PARAGON!!!";
  45.             //true when the alert should be shown before the boss is spawned
  46.             AlertBeforeBossSpawns = false;
  47.             //Percentage when the Alert should be shown
  48.             PercentageWhenToAlert = 95;
  49.         }
  50.  
  51.         public void PaintTopInGame(ClipState clipState)
  52.         {
  53.             if (clipState != ClipState.BeforeClip) return;
  54.             if (Hud.Game.Me.HeroClassDefinition.HeroClass != HeroClass.Necromancer) return;
  55.             ParaWarningY = HudHeight * OffsetY;
  56.             ParaWarningX = HudWidth * OffsetX;
  57.  
  58.             #region CalculatingMainStat
  59.             int GearMainStat = 0;
  60.             int CaldesannMainStat = 0;
  61.             foreach (IItem item in Hud.Game.Items.Where(item => item.Location.IsEquipped()))
  62.             {
  63.                 foreach (IItemStat stat in item.StatList)
  64.                 {
  65.                     IAttribute at = stat.Attribute;
  66.                     if (stat.Id == "main_stat")
  67.                     {
  68.                         //MainStat from gear + gems
  69.                         GearMainStat += Convert.ToInt32(stat.Value);
  70.                     }
  71.                 }
  72.                 //Minimum level caldessan is level 50 and gives 250 mainstat, every other level adds 5 int
  73.                 CaldesannMainStat += 250 + ((item.CaldesannRank - 50) * 5);
  74.             }
  75.             //Int without paragon.
  76.             int MainStatTotalWOParagon = GearMainStat + baseMainStat + CaldesannMainStat;
  77.  
  78.             //600 Points go into Offense,Defense and Utility, 50 points in MaxEssence, up to 50 points in Movementspeed if needed
  79.             int MainStatParagonPoints = Convert.ToInt32(Hud.Game.Me.CurrentLevelParagon) - 600 - 50 - ParagonInMovementSpeed;
  80.  
  81.             //each paragon point in main stat adds 5 int
  82.             int MainStatParagonIntValue = MainStatParagonPoints * 5;
  83.             int MainStatTotal = MainStatTotalWOParagon + MainStatParagonIntValue;
  84.  
  85.             #endregion
  86.  
  87.  
  88.             #region Rift Guardian Paragon Warning
  89.             if (!(Hud.Game.Me.Stats.MainStat < MainStatTotal)) return;
  90.             if (AlertBeforeBossSpawns)
  91.             {
  92.                 if (Hud.Game.RiftPercentage >= PercentageWhenToAlert)
  93.                 {
  94.                     RGParagonWarningFont.DrawText(WarningMessage, ParaWarningX, ParaWarningY);
  95.                 }
  96.             }
  97.             else
  98.             {
  99.                 if (IsGuardianAlive)
  100.                 {
  101.                     RGParagonWarningFont.DrawText(WarningMessage, ParaWarningX, ParaWarningY);
  102.                 }
  103.             }
  104.             #endregion
  105.         }
  106.  
  107.         public bool IsGuardianAlive
  108.         {
  109.             get
  110.             {
  111.                 return riftQuest != null && (riftQuest.QuestStepId == 16);
  112.             }
  113.         }
  114.  
  115.         private IQuest riftQuest
  116.         {
  117.             get
  118.             {
  119.                 return Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == 337492) ?? // rift
  120.                        Hud.Game.Quests.FirstOrDefault(q => q.SnoQuest.Sno == 382695);   // gr          
  121.             }
  122.         }
  123.     }
  124.     public static class EquipExtension
  125.     {
  126.         public static bool IsEquipped(this ItemLocation location)
  127.         {
  128.             return location >= ItemLocation.Head && location <= ItemLocation.Neck;
  129.         }
  130.     }
  131. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement