Advertisement
RNNCode

DropAlert

Sep 5th, 2019 (edited)
819
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.67 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using Turbo.Plugins.Default;
  4. using System.Windows.Forms;
  5.  
  6. namespace Turbo.Plugins.RNN
  7. {
  8.     public class DropAlert : BasePlugin, INewAreaHandler, IAfterCollectHandler,  ILootGeneratedHandler, ICustomizer
  9.     {
  10.         private List<int> ItemsOlder { get; set; } = new List<int>();
  11.         private List<string> ItemsOlder3 { get; set; } = new List<string>();
  12.         private string Comodin { get; set;}
  13.         private GroundLabelDecorator ItemDecorator { get; set; }
  14.  
  15.         public Dictionary<ISnoItem, string> ItemsAlert { get; } = new Dictionary<ISnoItem, string>();
  16.         public bool SkipNormalLegendary { get; set; }
  17.         public bool SpeakALLPrimal { get; set; }
  18.         public bool SpeakALLAncient { get; set; }
  19.         public string PrimalText { get; set; }
  20.         public string AncientText { get; set; }
  21.         public int LevelAlert { get; set; }
  22.  
  23.         public DropAlert()
  24.         {
  25.             Enabled = true;
  26.         }
  27.  
  28.         public override void Load(IController hud)
  29.         {
  30.             base.Load(hud);
  31.             Order = 30001;
  32.  
  33.             PrimalText = "Primal <name>";       // <name> is replaced with Custom Name (if is added to ItemAlert) or with NameLocalized
  34.             AncientText = "<name> Ancient";     // <name> is replaced with Custom Name (if is added to ItemAlert) or with NameLocalized
  35.             SkipNormalLegendary = false;        // Not speak legendary included in ItemsAlert that is not Primal or Ancient
  36.             SpeakALLPrimal = true;              // Speak All items Primal even if the item is not in ItemsAlert
  37.             SpeakALLAncient = false;            // Speak All items Ancient even if the item is not in ItemsAlert
  38.             LevelAlert = 3;                     // Values: 1 (Notify only loot) , 2 (Notify also identified items) , 3 (Notify all, and each time the coordinates of the items change)
  39.  
  40.             ItemDecorator = new GroundLabelDecorator(Hud)
  41.             {
  42.                 TextFont = Hud.Render.CreateFont("consolas", 10, 255, 255, 255, 255, true, false, false)
  43.             };
  44.         }
  45.  
  46.         public void Customize()
  47.         {
  48.             if ( (LevelAlert != 1) && (LevelAlert != 2) && (LevelAlert != 3) )  LevelAlert = 3 ;
  49.         }
  50.  
  51.         public void OnNewArea(bool newGame, ISnoArea area)
  52.         {
  53.             if (newGame)
  54.             {
  55.                 if (LevelAlert == 3)    ItemsOlder3.Clear();
  56.                 else    ItemsOlder.Clear();
  57.                 Comodin = Hud.Game.Me.FloorCoordinate.ToStringCompact();
  58.             }
  59.         }
  60.  
  61.         private void SpeakCheck(IItem item, bool floor)
  62.         {
  63.             if (item.Seed == 0) return;
  64.             string text = string.Empty;
  65.  
  66.             if (ItemsAlert.ContainsKey(item.SnoItem))
  67.             {
  68.                 if (item.Quality == ItemQuality.Legendary)
  69.                 {
  70.                     if      (item.AncientRank == 1) { text = AncientText.Replace("<name>",ItemsAlert[item.SnoItem]); }
  71.                     else if (item.AncientRank == 2) { text = PrimalText.Replace("<name>",ItemsAlert[item.SnoItem]); }
  72.                     else if (!SkipNormalLegendary || item.SnoItem.MainGroupCode == "consumable" || item.SnoItem.MainGroupCode == "potion" || item.SnoItem.MainGroupCode == "riftkeystone"
  73.                     || item.SnoItem == Hud.Sno.SnoItems.Unique_Ring_004_x1 || item.SnoItem == Hud.Sno.SnoItems.Unique_Polearm_101_x1 || item.SnoItem == Hud.Sno.SnoItems.SwarmRiftKey) 
  74.                     {
  75.                         text = ItemsAlert[item.SnoItem];
  76.                     }
  77.                     else return;
  78.                 }
  79.                 else { text = ItemsAlert[item.SnoItem]; }
  80.  
  81.             }
  82.             else
  83.             {
  84.                 if (item.Quality == ItemQuality.Legendary)
  85.                 {
  86.                     if (item.AncientRank == 1)
  87.                     {
  88.                         if (SpeakALLAncient)    { text = AncientText.Replace("<name>", item.SnoItem.NameLocalized); }
  89.                     }
  90.                     else if (item.AncientRank == 2)
  91.                     {
  92.                         if (SpeakALLPrimal)     { text = PrimalText.Replace("<name>", item.SnoItem.NameLocalized); }
  93.                     }
  94.                     else return;
  95.                 }
  96.                 else return;
  97.             }
  98.  
  99.             if ( (!item.AccountBound || item.BoundToMyAccount) )
  100.             {
  101.                 if (LevelAlert == 3)
  102.                 {
  103.                     string s = item.Seed + "@" + (floor? item.FloorCoordinate.ToStringCompact():Comodin) ;
  104.                     if (!ItemsOlder3.Contains(s))   ItemsOlder3.Add(s);
  105.                     else return;
  106.                 }
  107.                 else
  108.                 {
  109.                     if (!ItemsOlder.Contains(item.Seed))    ItemsOlder.Add(item.Seed);
  110.                     else return;
  111.                 }
  112.                 if (!string.IsNullOrEmpty(text))    Hud.Sound.Speak(text);
  113.             }
  114.         }
  115.  
  116.         public void OnLootGenerated(IItem item, bool gambled)
  117.         {
  118.             if ( (LevelAlert == 3) && (item.Location == ItemLocation.Floor) ) return;  //if ( (LevelAlert == 3) && (!gambled) ) return;
  119.             SpeakCheck(item, (item.Location == ItemLocation.Floor)? true:false);
  120.         }
  121.  
  122.         public void AfterCollect()
  123.         {
  124.             if (LevelAlert == 1) return;
  125.             var items = Hud.Game.Items.Where(item => (item.Location == ItemLocation.Floor) && ( (LevelAlert == 3) || !item.Unidentified )  );
  126.             foreach (var item in items)
  127.             {
  128.                 SpeakCheck(item, true);
  129.             }
  130.         }
  131.     }
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement