Advertisement
Guest User

MonsterKrysbinPlugin

a guest
Nov 30th, 2017
1,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.94 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3.  
  4. using Turbo.Plugins.Default;
  5.  
  6. namespace Turbo.Plugins.gjuz
  7. {
  8.     public class MonsterKrysbinPlugin : BasePlugin, IInGameTopPainter
  9.     {
  10.         public bool DrawAtBoss { get; set; }            //Krysbin for Boss
  11.         public bool DrawAtElite { get; set; }           //Krysbin for Elites
  12.         public float SizeMultiplier { get; set; }       //iconSize Multiplier
  13.         public float opacityMultiplier { get; set; }    //opacity Multiplier - single Krysbin (NOT Full Krysbin)
  14.        
  15.         //position offset
  16.         public float OffsetX { get; set; }
  17.         public float OffsetY { get; set; }
  18.        
  19.         private float StandardIconSize { get{ return 55f / 1200.0f * Hud.Window.Size.Height * SizeMultiplier; } }
  20.         private bool inGRift { get{ return Hud.Game.SpecialArea == SpecialArea.GreaterRift; } }
  21.         public List<HeroClass> DrawForHeroClass { get; set; }
  22.  
  23.         public MonsterKrysbinPlugin()
  24.         {
  25.             Enabled = true;
  26.            
  27.             DrawAtBoss = true;
  28.             DrawAtElite = true;
  29.         }
  30.  
  31.         public override void Load(IController hud)
  32.         {
  33.             base.Load(hud);
  34.            
  35.             OffsetX = 0f;
  36.             OffsetY = 0f;
  37.            
  38.             SizeMultiplier = 0.65f;
  39.             opacityMultiplier = 0.35f;
  40.             DrawForHeroClass = new List<HeroClass>();
  41.             DrawForHeroClass.Add(HeroClass.Necromancer);
  42.         }
  43.  
  44.         public void PaintTopInGame(ClipState clipState)
  45.         {
  46.             if (clipState != ClipState.BeforeClip) return;
  47.             if (!inGRift) return;
  48.             if (!isKrybinEquipped()) return;        //no krysbin -> nothing to draw
  49.             if (DrawForHeroClass.Any() && !DrawForHeroClass.Contains(Hud.Game.Me.HeroClassDefinition.HeroClass)) return;
  50.            
  51.             var bosses = Hud.Game.AliveMonsters.Where(m => m.Rarity == ActorRarity.Boss);
  52.             if (DrawAtBoss && bosses.Any())
  53.             {
  54.                 IMonster boss = bosses.FirstOrDefault();
  55.                 DrawKrysbin(boss);
  56.             }
  57.            
  58.             if (DrawAtElite)
  59.             {
  60.                 foreach (var elite in Hud.Game.AliveMonsters.Where(m => m.Rarity == ActorRarity.Rare || m.Rarity == ActorRarity.Champion))
  61.                 {   //no minions
  62.                     //no clones
  63.                     if (elite.SummonerAcdDynamicId != 0)
  64.                         continue;
  65.                    
  66.                     DrawKrysbin(elite);
  67.                 }
  68.             }
  69.         }
  70.        
  71.         private void DrawKrysbin(IMonster elite)
  72.         {
  73.             if (elite == null) return;                          //no elite
  74.             var StateKrysbin = isKrysbin(elite);
  75.             if (StateKrysbin == 0) return;                      //no krysbin_debuff
  76.            
  77.             uint itemSno = 1236308205;                          //1236308205 - KrysbinsSentence_ItemSno
  78.             var snoItem = Hud.Inventory.GetSnoItem(itemSno);
  79.            
  80.             //buff position
  81.             IScreenCoordinate sc = elite.FloorCoordinate.ToScreenCoordinate();
  82.             var itemRect = new System.Drawing.RectangleF(sc.X - StandardIconSize/2 + OffsetX, sc.Y + OffsetY, StandardIconSize, StandardIconSize);
  83.            
  84.             //buff strenght -> opacity
  85.             float opacity = StateKrysbin == 1 ? opacityMultiplier : 1.0f;
  86.            
  87.             var slotTexture = Hud.Texture.InventorySlotTexture;
  88.             slotTexture.Draw(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height, opacity);
  89.            
  90.             var backgroundTexture = Hud.Texture.InventoryLegendaryBackgroundSmall;
  91.             backgroundTexture.Draw(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height, opacity);
  92.            
  93.             var itemTexture = Hud.Texture.GetItemTexture(snoItem);
  94.             if (itemTexture != null)
  95.             {
  96.                 itemTexture.Draw(itemRect.X, itemRect.Y, itemRect.Width, itemRect.Height, opacity);
  97.             }
  98.         }
  99.        
  100.         private bool isKrybinEquipped()
  101.         {   //is a player with krysbin equipped ingame?
  102.             foreach (var p in Hud.Game.Players.Where(p => p.HeroClassDefinition.HeroClass == HeroClass.Necromancer))
  103.             {
  104.                 IBuff _bKrysbin = p.Powers.GetBuff(475241);                 //get buff wegen cube   // Sno: 475241
  105.                 if (_bKrysbin != null && _bKrysbin.Active) return true;     //krysbin in use
  106.             }
  107.            
  108.             return false;
  109.         }
  110.        
  111.         private uint isKrysbin(IMonster elite)
  112.         {
  113.             if (elite.Frozen || elite.Stunned || elite.Blind)
  114.                 return 2;
  115.             if (elite.Slow || elite.Chilled)
  116.                 return 1;
  117.            
  118.             return 0;
  119.         }
  120.  
  121.     }
  122.  
  123. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement