RNNCode

RiftVoice

May 6th, 2020 (edited)
674
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.46 KB | None | 0 0
  1. using Turbo.Plugins.Default;      
  2. using System.Linq;
  3. using System.Collections.Generic;
  4.  
  5. namespace Turbo.Plugins.RNN
  6. {        
  7.     public class RiftVoice : BasePlugin, ICustomizer, INewAreaHandler, IAfterCollectHandler
  8.     {  
  9.         private List<uint> IdGR { get;set; } = new List<uint> {13,16,34,46};
  10.         private List<uint> IdNR { get;set; } = new List<uint> {1,3,10,5};
  11.         private int TBoss { get; set; }
  12.         private int TBossKilled { get; set; }
  13.         private bool InGR { get; set; }
  14.         private bool InNR { get; set; }    
  15.            
  16.         private int MyIndex { get; set; } = -1;
  17.         private string NameBoss { get; set; } = null;
  18.        
  19.         public bool NotifyBoss { get; set; }
  20.         public int WaitingBoss { get; set; }
  21.         public string BossAlive { get; set; }
  22.         public string BossIdAlive { get; set; }
  23.         public string BossDead { get; set; }
  24.         public string BossIdDead { get; set; }
  25.  
  26.         public bool NotifyGR { get; set; }
  27.         public string GROpen { get; set; }
  28.         public string GRClosed { get; set; }
  29.  
  30.         public bool NotifyNR { get; set; }
  31.         public string NROpen { get; set; }
  32.         public string NRClosed { get; set; }
  33.  
  34.         public SortedDictionary<int,string> NextProgressGR { get; set; } = new SortedDictionary<int,string>();
  35.         private int NewTarget { get; set; } = 0;
  36.         public bool NotifyProgressGR { get; set; }
  37.        
  38.         public  RiftVoice()
  39.         {
  40.             Enabled = true;                        
  41.         }
  42.        
  43.         public override void Load(IController hud)
  44.         {
  45.             base.Load(hud);
  46.             Order = 30001;
  47.            
  48.             NotifyBoss = true; 
  49.             WaitingBoss = 90; // Ticks (1 second = 60 ticks) . Attempts will be made to identify the Boss during this time, and if it succeeds, only the text "BossIdAlive" will be read.
  50.             BossAlive = "The boss is here";  
  51.             BossIdAlive = "The Boss is <Boss> "; // Boss was identified. <Boss> will be replaced by the Boss name
  52.             BossDead = "The Boss is Dead";             
  53.             BossIdDead = "<Boss> died";         // Boss was identified. <Boss> will be replaced by the Boss name
  54.            
  55.             NotifyGR = true;                    // Notify when a GR opens or closes
  56.             GROpen = "GR Open";
  57.             GRClosed = "GR Closed";
  58.            
  59.             NotifyNR = true;                    // Notify when a NR opens or closes
  60.             NROpen = "Rift Open";
  61.             NRClosed = "Rift CLosed";
  62.  
  63.             NotifyProgressGR = false;           // Notify when certain progress (NextProgressGR) is achieved in the GR         
  64.         }
  65.  
  66.         public void Customize()  
  67.         {              
  68.             NextProgressGR.Add(int.MaxValue,"∞");
  69.         }
  70.        
  71.         public void OnNewArea(bool newGame, ISnoArea area)
  72.         {  
  73.             if ((newGame) || (MyIndex != Hud.Game.Me.Index))
  74.             {
  75.                 InGR = false; InNR = false; NameBoss = null;
  76.                 MyIndex = Hud.Game.Me.Index;       
  77.             }
  78.         }
  79.         public string FindNameBoss()
  80.         {
  81.             var m = Hud.Game.Markers.FirstOrDefault(k => (k.SnoActor != null) && k.SnoActor.Code.Contains("_Boss_"));
  82.             if  (m != null) {  return m.Name; }
  83.             else
  84.             {
  85.                 var b = Hud.Game.Monsters.FirstOrDefault(s => (s.Rarity == ActorRarity.Boss) && (s.SummonerAcdDynamicId == 0));
  86.                 if (b != null)  { return b.SnoMonster.NameLocalized; }
  87.             }
  88.             return null;                               
  89.         }
  90.  
  91.         public void AfterCollect()  
  92.         {  
  93.             if (!Hud.Game.IsInGame) return;
  94.             var riftQuest = Hud.Game.Quests.FirstOrDefault(q => (q.SnoQuest.Sno == 337492) && (q.State == QuestState.started || q.State == QuestState.completed )) ;
  95.             if (riftQuest != null)
  96.             {          
  97.                 if (IdGR.Contains(riftQuest.QuestStepId))
  98.                 {
  99.                     if (!InGR)  // GR start
  100.                     {                      
  101.                         InGR = true;
  102.                         if (NotifyGR && (Hud.Game.RiftPercentage == 0) && !string.IsNullOrEmpty(GROpen)) { Hud.Sound.Speak(GROpen); }
  103.                         TBoss = 0; TBossKilled = 0; NameBoss = null; NewTarget = 0;
  104.                         foreach(var d in NextProgressGR)
  105.                         {
  106.                             if (d.Key > Hud.Game.RiftPercentage) { NewTarget = d.Key ; break; }
  107.                         }
  108.                     }
  109.  
  110.                     if (riftQuest.QuestStepId == 13)
  111.                     {
  112.                         if ( NotifyProgressGR && (Hud.Game.RiftPercentage >= NewTarget) )
  113.                         {
  114.                             if (NextProgressGR.TryGetValue(NewTarget, out var text))
  115.                             {
  116.                                 text = text.Replace("<Progress>",Hud.Game.RiftPercentage.ToString("F1"));
  117.                                 if (!string.IsNullOrEmpty(text)) { Hud.Sound.Speak(text); }
  118.                             }
  119.                             foreach(var d in NextProgressGR)
  120.                             {
  121.                                 if (d.Key > Hud.Game.RiftPercentage) { NewTarget = d.Key ; break; }
  122.                             }                          
  123.                         }
  124.                        
  125.                     }                      
  126.                     else if (riftQuest.QuestStepId == 16) //GR Boss Alive
  127.                     {  
  128.                         if (TBoss < 2)
  129.                         {
  130.                             if (NameBoss != null)
  131.                             {
  132.                                 TBoss = 2;                                 
  133.                                 if (NotifyBoss)
  134.                                 {
  135.                                     var MsgBoss = BossIdAlive.Replace("<Boss>", NameBoss);
  136.                                     if (!string.IsNullOrEmpty(MsgBoss))  {  Hud.Sound.Speak(MsgBoss); }
  137.                                 }                                  
  138.                             }
  139.                             else
  140.                             {
  141.                                 NameBoss = FindNameBoss();
  142.                                 if (NameBoss == null)  
  143.                                 {
  144.                                     if ( (TBoss == 0) && ((Hud.Game.CurrentGameTick - riftQuest.CreatedOn) > WaitingBoss) )
  145.                                     {
  146.                                         TBoss = 1;
  147.                                         if ( NotifyBoss && !string.IsNullOrEmpty(BossAlive) )  {  Hud.Sound.Speak(BossAlive); }
  148.                                     }
  149.                                 }       // método no estricto                     
  150.                             }
  151.                         }                      
  152.                     }
  153.                     else if ( (riftQuest.QuestStepId == 34) || (riftQuest.QuestStepId == 46) ) // 34 GR Boss Dead, Kadala Appears / 46 GR kadala quit, Orek Appears
  154.                     {
  155.                         if (TBossKilled == 0)
  156.                         {
  157.                             if (NameBoss == null)   { NameBoss = FindNameBoss(); }
  158.                             TBossKilled = 1;                       
  159.                             if (NotifyBoss)
  160.                             {
  161.                                 var MsgBoss = (NameBoss == null)? BossDead : BossIdDead.Replace("<Boss>", NameBoss);
  162.                                 if (!string.IsNullOrEmpty(MsgBoss))  {  Hud.Sound.Speak(MsgBoss); }
  163.                             }
  164.                         }
  165.                     }                                                      
  166.                 }
  167.                 else if (IdNR.Contains(riftQuest.QuestStepId))
  168.                 {
  169.                     if (!InNR) // NR (Nephalem Rift) Start
  170.                     {                              
  171.                         if ((riftQuest.QuestStepId == 5) && InGR) return;
  172.                         InNR = true;
  173.                         if (NotifyNR && (Hud.Game.RiftPercentage == 0) && !string.IsNullOrEmpty(NROpen)) Hud.Sound.Speak(NROpen);
  174.                         TBoss = 0; TBossKilled = 0; NameBoss = null;
  175.                     }
  176.                     if (riftQuest.QuestStepId == 3)
  177.                     {
  178.                         if (TBoss < 2)
  179.                         {
  180.                             if (NameBoss != null)
  181.                             {
  182.                                 TBoss = 2;  
  183.                                 if (NotifyBoss)
  184.                                 {
  185.                                     var MsgBoss = BossIdAlive.Replace("<Boss>", NameBoss);
  186.                                     if (!string.IsNullOrEmpty(MsgBoss))  {  Hud.Sound.Speak(MsgBoss); }
  187.                                 }
  188.                             }
  189.                             else
  190.                             {
  191.                                 NameBoss = FindNameBoss();
  192.                                 if (NameBoss == null)  
  193.                                 {
  194.                                     if ( (TBoss == 0) && ((Hud.Game.CurrentGameTick - riftQuest.CreatedOn) > WaitingBoss) )
  195.                                     {
  196.                                         TBoss = 1;
  197.                                         if ( NotifyBoss && !string.IsNullOrEmpty(BossAlive) )  {  Hud.Sound.Speak(BossAlive); }
  198.                                     }
  199.                                 }                              
  200.                             }
  201.                         }                      
  202.                     }
  203.                     else if ( (riftQuest.QuestStepId == 10) )
  204.                     {
  205.                         if (TBossKilled == 0)
  206.                         {
  207.                             if (NameBoss == null)   { NameBoss = FindNameBoss(); }                         
  208.                             TBossKilled = 1;  //NR Boss Dead , Orek Appears
  209.                             if (NotifyBoss)
  210.                             {
  211.                                 var MsgBoss = (NameBoss == null)? BossDead : BossIdDead.Replace("<Boss>", NameBoss);
  212.                                 if (!string.IsNullOrEmpty(MsgBoss))  {  Hud.Sound.Speak(MsgBoss); }
  213.                             }
  214.                         }
  215.                     }                                  
  216.                 }
  217.                 else return;
  218.             }          
  219.             else
  220.             {
  221.                 if (InGR)
  222.                 {
  223.                     InGR = false; NameBoss = null;
  224.                     if (NotifyGR && !string.IsNullOrEmpty(GRClosed)) Hud.Sound.Speak(GRClosed);                    
  225.                 }
  226.                 if (InNR)
  227.                 {
  228.                     InNR = false; NameBoss = null;
  229.                     if (NotifyNR && !string.IsNullOrEmpty(NRClosed)) Hud.Sound.Speak(NRClosed);                    
  230.                 }
  231.             }              
  232.         }      
  233.     }  
  234. }
Advertisement
Add Comment
Please, Sign In to add comment