Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows.Forms;
  6.  
  7. namespace SpyClient
  8. {
  9.     class PetSpawn : PlayerBotBase
  10.     {
  11.         public override void Init(Playfield pf)
  12.         {
  13.             base.Init(pf);
  14.  
  15.             // ########################################################################
  16.  
  17.             // vyber trimmeru (pro vsechny pety) - aoid minus jedno ql
  18.             this.TrimmerAoid = 88383;
  19.             this.TrimmerQl = 97;
  20.  
  21.             // AddPetDescriptions parametry
  22.             // 223325 ... aoid nana na vycasteni shellu pejsek
  23.             // 45671 ...aoid slayera
  24.             // 217995 .. shell aoid pejsek
  25.             // 96218 .. shell aoid slayer
  26.             // 10 ...... typ peta, nesmi se opakovat!
  27.             // AddBuffs parametry
  28.             // 205237 ... aao buff peta
  29.             this.AddPetDescription(45671, 96218, 10).AddBuffs(205237);
  30.             this.AddPetDescription(223325, 217995, 12).AddBuffs(205237);
  31.             // ########################################################################
  32.         }
  33.  
  34.         private List<PetDescription> petDescriptions = new List<PetDescription>();
  35.  
  36.         private int TrimmerAoid = 0;
  37.         private int TrimmerQl = 0;
  38.  
  39.         private class PetDescription
  40.         {
  41.             public int ShellNanoAoid = 0;
  42.             public int ShellAoid = 0;
  43.             public bool IsTrimmed = false;
  44.             public int PetType = 0;
  45.             public Mob Mob = null;
  46.             public readonly List<PetBuff> Buffs = new List<PetBuff>();
  47.  
  48.             public PetDescription(int shellNanoAoid, int shellAoid, int petType)
  49.             {
  50.                 this.ShellNanoAoid = shellNanoAoid;
  51.                 this.ShellAoid = shellAoid;
  52.                 this.PetType = petType;
  53.             }
  54.  
  55.             public void AddBuff(int aoid)
  56.             {
  57.                 // kouknem, jestli ten buff uz v seznamu neni,
  58.                 // kdyz tak ho nebudem pridavat znovu do seznamu
  59.                 foreach (PetBuff pb in this.Buffs)
  60.                     if (pb.Aoid == aoid) return;
  61.  
  62.                 PetBuff pbNew = new PetBuff();
  63.                 pbNew.Aoid = aoid;
  64.                 pbNew.IsRunning = false;
  65.                 this.Buffs.Add(pbNew);
  66.             }
  67.  
  68.             public void AddBuffs(params int[] aoids)
  69.             {
  70.                 if (aoids == null) return;
  71.  
  72.                 for (int i = 0; i < aoids.Length; i++)
  73.                 {
  74.                     bool buffFound = false;
  75.  
  76.                     foreach (PetBuff pb in this.Buffs)
  77.                     {
  78.                         if (pb.Aoid == aoids[i])
  79.                         {
  80.                             buffFound = true;
  81.                             break;
  82.                         }
  83.                     }
  84.  
  85.                     if (!buffFound)
  86.                     {
  87.                         PetBuff pbNew = new PetBuff();
  88.                         pbNew.Aoid = aoids[i];
  89.                         pbNew.IsRunning = false;
  90.                         this.Buffs.Add(pbNew);
  91.                     }
  92.                 }
  93.             }
  94.         }
  95.  
  96.         private class PetBuff
  97.         {
  98.             public int Aoid;
  99.             public bool IsRunning = false;
  100.         }
  101.  
  102.         private PetDescription AddPetDescription(int shellNanoAoid, int shellAoid, int petType)
  103.         {
  104.             bool found = false;
  105.  
  106.             foreach (PetDescription pd in this.petDescriptions)
  107.                 if (pd.PetType == petType)
  108.                 {
  109.                     found = true;
  110.                     break;
  111.                 }
  112.  
  113.             if (!found)
  114.             {
  115.                 PetDescription pd = new PetDescription(shellNanoAoid, shellAoid, petType);
  116.                 this.petDescriptions.Add(pd);
  117.                 return pd;
  118.             }
  119.             else
  120.             {
  121.                 BotLogLine(ConsoleColor.Yellow, "Pokus o pridani bota stejneho typu!");
  122.                 return null;
  123.             }
  124.            
  125.         }
  126.  
  127.         public override void Tick(ref int tickRate)
  128.         {
  129.             // staci tohle poustet kazdych 10 s
  130.             tickRate = 10000;
  131.  
  132.             Identity[] petIdentities = AoClient.GetClientPetIdentities();
  133.             Mob[] pets = this.playfield.FindOrCreateMob(petIdentities);
  134.  
  135.             foreach (Mob mPet in pets)
  136.                 mPet.IsMyPet = true;
  137.  
  138.             List<PetDescription> petTypesMissing = new List<PetDescription>();
  139.             List<PetDescription> petTypesShellMissing = new List<PetDescription>();
  140.  
  141.             this.playfield.RefreshMobStats(1500);
  142.  
  143.             BotLogLine("Kontroluji, jestli mam vsech {0} petu:", this.petDescriptions.Count);
  144.            
  145.             for (int i = 0; i < this.petDescriptions.Count; i++)
  146.             {
  147.                 PetDescription pd = this.petDescriptions[i];
  148.                
  149.                 Mob mPet = pets.FirstOrDefault(m => m.PetType == pd.PetType);
  150.  
  151.                 // mob v popisu typu je jiny, nez typ peta co vlastnim, zresetuju buffy
  152.                 if (pd.Mob != mPet)
  153.                 {
  154.                     pd.IsTrimmed = false;
  155.                     foreach (PetBuff pb in pd.Buffs)
  156.                         pb.IsRunning = false;
  157.                 }
  158.  
  159.                 pd.Mob = mPet;
  160.  
  161.                 if (mPet == null)
  162.                 {
  163.                     BotLogLine("Peta typu {0} nemam :(", pd.PetType);
  164.                     petTypesMissing.Add(pd);
  165.                 }
  166.                 else
  167.                 {
  168.                     BotLogLine("Peta typu {0} mam, jmenuje se {1}, jeho cislo je {2}:{3}.", pd.PetType, mPet.Name == null ? "NULL" : mPet.Name,
  169.                         mPet.Type, mPet.Id);
  170.                 }
  171.             }
  172.  
  173.             if (petTypesMissing.Count > 0)
  174.             {
  175.                 BotLogLine("Chybi mi celkem {0} petu.", petTypesMissing.Count);
  176.  
  177.                 InventoryItem[] inventory = null;
  178.  
  179.                 foreach (PetDescription pdMissing in petTypesMissing)
  180.                 {
  181.                     if (pdMissing.ShellAoid == 0)
  182.                     {
  183.                         BotLogLine("Pet typu {0} nepotrebuje shell.", pdMissing.PetType);
  184.                     }
  185.                     else
  186.                     {
  187.                         BotLogLine("Kouknu do invu, jestli tam neni shell {0} k petovi typu {1}.", pdMissing.ShellAoid, pdMissing.PetType);
  188.  
  189.                         if (inventory == null) inventory = AoClient.GetInventory();
  190.                         int shellSlotId = -1;
  191.  
  192.                         foreach (InventoryItem i in inventory)
  193.                         {
  194.                             if (i.LowId == pdMissing.ShellAoid)
  195.                             {
  196.                                 shellSlotId = i.SlotId;
  197.                                 break;
  198.                             }
  199.                         }
  200.  
  201.                         if (shellSlotId == -1)
  202.                         {
  203.                             BotLogLine("Nenasel jsem shell, budu ho muset nacastit.");
  204.                             petTypesShellMissing.Add(pdMissing);
  205.                         }
  206.                         else
  207.                         {
  208.                             BotLogLine("Nasel jsem v invu shell, pouziju ho.");
  209.                             Program.RemoteUseInventoryItem(104, shellSlotId, false);
  210.                         }
  211.  
  212.                         tickRate = 2000;
  213.                     }
  214.                 }
  215.  
  216.                 if (petTypesShellMissing.Count > 0)
  217.                 {
  218.                     BotLogLine("Je potreba nacastit {0} shellu/petu.", petTypesShellMissing.Count);
  219.  
  220.                     PetDescription pdToCast = petTypesShellMissing[0];
  221.  
  222.                     BotLog("Castnu prvni shell/peta typu {0}, nano program {1}... ", pdToCast.PetType, pdToCast.ShellNanoAoid);
  223.  
  224.                     if (AoClient.IsFormulaReady(53019, (uint)pdToCast.ShellNanoAoid))
  225.                     {
  226.                         BotLogLine("motam.");
  227.                         AoClient.CastNanoSpell(53019, (uint)pdToCast.ShellNanoAoid, 0, 0);
  228.                     }
  229.                     else
  230.                     {
  231.                         BotLogLine("ted nemuzu castit.");
  232.                     }
  233.  
  234.                     tickRate = 2000;
  235.                 }
  236.             }
  237.             else
  238.             {
  239.                 BotLogLine("Peti mi nechybi, zkontrolujem jestli jsou buffnuty.");
  240.  
  241.                 for (int i = 0; i < this.petDescriptions.Count; i++)
  242.                 {
  243.                     PetDescription pd = this.petDescriptions[i];
  244.                     if (pd.Mob == null) continue; // to by se stat nikdy nemelo
  245.  
  246.                     foreach (PetBuff pb in pd.Buffs)
  247.                     {
  248.                         if (!pb.IsRunning)
  249.                         {
  250.                             BotLog("U peta typu {0} nebezi nano program {1}... ", pd.PetType, pb.Aoid);
  251.  
  252.                             if (AoClient.IsFormulaReady(53019, (uint)pb.Aoid))
  253.                             {
  254.                                 BotLogLine("motam.");
  255.                                 AoClient.SetTarget(pd.Mob.Type, pd.Mob.Id);
  256.                                 AoClient.CastNanoSpell(53019, (uint)pb.Aoid, pd.Mob.Type, pd.Mob.Id);
  257.                             }
  258.                             else
  259.                             {
  260.                                 BotLogLine("ted nemuzu castit.");
  261.                             }
  262.  
  263.                             tickRate = 2000;
  264.  
  265.                             return;
  266.                         }
  267.                     }
  268.                 }
  269.  
  270.                 if (this.TrimmerQl > 0 && this.TrimmerAoid > 0)
  271.                 {
  272.                     // peti jsou bud buffnuti nebo neco castim, je cas na trim. jen prvniho co najdu netrimmnuteho.
  273.                     for (int i = 0; i < this.petDescriptions.Count; i++)
  274.                     {
  275.                         PetDescription pd = this.petDescriptions[i];
  276.                         if (pd.Mob == null) continue; // to by se stat nikdy nemelo
  277.                         if (pd.IsTrimmed) continue;
  278.  
  279.                         BotLogLine("Trim peta typu {0}.", pd.PetType);
  280.  
  281.                         int trimmerSlot = -1;
  282.  
  283.                         InventoryItem[] inventory = AoClient.GetInventory();
  284.                         foreach (InventoryItem invInventoryItem in inventory)
  285.                         {
  286.                             if (InventoryItem.LowId == this.TrimmerAoid && InventoryItem.QL == this.TrimmerQl)
  287.                                 trimmerSlot = Inventoryitem.SlotId;
  288.                         }
  289.  
  290.                         if (trimmerSlot == -1)
  291.                             BotLogLine("Nenasel jsem trimmer v invu.");
  292.                         else
  293.                         {
  294.                             AoClient.SetTarget(pd.Mob.Type, pd.Mob.Id);
  295.                             Program.RemoteUseInventoryItem(104, trimmerSlot, false);
  296.                             pd.IsTrimmed = true;
  297.                         }
  298.  
  299.                     }
  300.                 }
  301.             }
  302.            
  303.         }
  304.  
  305.         public override void OnPacket(Packet10 p)
  306.         {
  307.  
  308.             if (p is TimedNanoProgramExecutedMessagePacket)
  309.             {
  310.                 TimedNanoProgramExecutedMessagePacket tnpemp = (TimedNanoProgramExecutedMessagePacket)p;
  311.                 PetDescription pd;
  312.                 PetBuff pb = this.FindPetBuff(tnpemp.MobType, tnpemp.MobId, tnpemp.NanoProgramId, out pd);
  313.  
  314.                 if (pb != null)
  315.                 {
  316.                     BotLogLine("Na petovi typu {0} spusten buff {1} ze seznamu buffu.", pd.PetType, pb.Aoid);
  317.                     pb.IsRunning = true;
  318.                 }
  319.             }
  320.  
  321.             if (p is NanoProgramTerminated)
  322.             {
  323.                 NanoProgramTerminated npt = (NanoProgramTerminated)p;
  324.  
  325.                 PetDescription pd;
  326.                 PetBuff pb = this.FindPetBuff(npt.TargetType, npt.TargetId, npt.NanoProgramAOID, out pd);
  327.  
  328.                 if (pb != null)
  329.                 {
  330.                     BotLogLine("Na petovi typu {0} prestal bezet buff {1} ze seznamu buffu.", pd.PetType, pb.Aoid);
  331.                     pb.IsRunning = false;
  332.                 }
  333.             }
  334.         }
  335.  
  336.         private PetBuff FindPetBuff(uint mobType, uint mobId, uint nanoProgramAoid, out PetDescription petDescription)
  337.         {
  338.             for (int i = 0; i < this.petDescriptions.Count; i++)
  339.             {
  340.                 PetDescription pd = this.petDescriptions[i];
  341.  
  342.                 if (pd.Mob == null) continue;
  343.  
  344.                 if (pd.Mob.Type == mobType && pd.Mob.Id == mobId)
  345.                     for (int j = 0; j < pd.Buffs.Count; j++)
  346.                         if (pd.Buffs[j].Aoid == nanoProgramAoid)
  347.                         {
  348.                             petDescription = pd;
  349.                             return pd.Buffs[j];
  350.                         }
  351.             }
  352.  
  353.             petDescription = null;
  354.             return null;
  355.         }
  356.  
  357.         public override void OnSpyKey(KeyEventArgs e)
  358.         {
  359.             if (e.KeyCode == Keys.P)
  360.             {
  361.                 Identity[] pets = AoClient.GetClientPetIdentities();
  362.  
  363.                 if (pets != null)
  364.                 {
  365.                     foreach (Identity i in pets)
  366.                     {
  367.                         int petType = AoClient.GetDynelSkill(i.Type, i.Id, 512, 0);
  368.                         Console.WriteLine("Pet {0}:{1} petType {2}", i.Type, i.Id, petType);
  369.                     }
  370.  
  371.                 }
  372.             }
  373.         }
  374.     }
  375. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement