Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace SpyClient
- {
- class PetSpawn : PlayerBotBase
- {
- public override void Init(Playfield pf)
- {
- base.Init(pf);
- // ########################################################################
- // vyber trimmeru (pro vsechny pety) - aoid minus jedno ql
- this.TrimmerAoid = 88383;
- this.TrimmerQl = 97;
- // AddPetDescriptions parametry
- // 223325 ... aoid nana na vycasteni shellu pejsek
- // 45671 ...aoid slayera
- // 217995 .. shell aoid pejsek
- // 96218 .. shell aoid slayer
- // 10 ...... typ peta, nesmi se opakovat!
- // AddBuffs parametry
- // 205237 ... aao buff peta
- this.AddPetDescription(45671, 96218, 10).AddBuffs(205237);
- this.AddPetDescription(223325, 217995, 12).AddBuffs(205237);
- // ########################################################################
- }
- private List<PetDescription> petDescriptions = new List<PetDescription>();
- private int TrimmerAoid = 0;
- private int TrimmerQl = 0;
- private class PetDescription
- {
- public int ShellNanoAoid = 0;
- public int ShellAoid = 0;
- public bool IsTrimmed = false;
- public int PetType = 0;
- public Mob Mob = null;
- public readonly List<PetBuff> Buffs = new List<PetBuff>();
- public PetDescription(int shellNanoAoid, int shellAoid, int petType)
- {
- this.ShellNanoAoid = shellNanoAoid;
- this.ShellAoid = shellAoid;
- this.PetType = petType;
- }
- public void AddBuff(int aoid)
- {
- // kouknem, jestli ten buff uz v seznamu neni,
- // kdyz tak ho nebudem pridavat znovu do seznamu
- foreach (PetBuff pb in this.Buffs)
- if (pb.Aoid == aoid) return;
- PetBuff pbNew = new PetBuff();
- pbNew.Aoid = aoid;
- pbNew.IsRunning = false;
- this.Buffs.Add(pbNew);
- }
- public void AddBuffs(params int[] aoids)
- {
- if (aoids == null) return;
- for (int i = 0; i < aoids.Length; i++)
- {
- bool buffFound = false;
- foreach (PetBuff pb in this.Buffs)
- {
- if (pb.Aoid == aoids[i])
- {
- buffFound = true;
- break;
- }
- }
- if (!buffFound)
- {
- PetBuff pbNew = new PetBuff();
- pbNew.Aoid = aoids[i];
- pbNew.IsRunning = false;
- this.Buffs.Add(pbNew);
- }
- }
- }
- }
- private class PetBuff
- {
- public int Aoid;
- public bool IsRunning = false;
- }
- private PetDescription AddPetDescription(int shellNanoAoid, int shellAoid, int petType)
- {
- bool found = false;
- foreach (PetDescription pd in this.petDescriptions)
- if (pd.PetType == petType)
- {
- found = true;
- break;
- }
- if (!found)
- {
- PetDescription pd = new PetDescription(shellNanoAoid, shellAoid, petType);
- this.petDescriptions.Add(pd);
- return pd;
- }
- else
- {
- BotLogLine(ConsoleColor.Yellow, "Pokus o pridani bota stejneho typu!");
- return null;
- }
- }
- public override void Tick(ref int tickRate)
- {
- // staci tohle poustet kazdych 10 s
- tickRate = 10000;
- Identity[] petIdentities = AoClient.GetClientPetIdentities();
- Mob[] pets = this.playfield.FindOrCreateMob(petIdentities);
- foreach (Mob mPet in pets)
- mPet.IsMyPet = true;
- List<PetDescription> petTypesMissing = new List<PetDescription>();
- List<PetDescription> petTypesShellMissing = new List<PetDescription>();
- this.playfield.RefreshMobStats(1500);
- BotLogLine("Kontroluji, jestli mam vsech {0} petu:", this.petDescriptions.Count);
- for (int i = 0; i < this.petDescriptions.Count; i++)
- {
- PetDescription pd = this.petDescriptions[i];
- Mob mPet = pets.FirstOrDefault(m => m.PetType == pd.PetType);
- // mob v popisu typu je jiny, nez typ peta co vlastnim, zresetuju buffy
- if (pd.Mob != mPet)
- {
- pd.IsTrimmed = false;
- foreach (PetBuff pb in pd.Buffs)
- pb.IsRunning = false;
- }
- pd.Mob = mPet;
- if (mPet == null)
- {
- BotLogLine("Peta typu {0} nemam :(", pd.PetType);
- petTypesMissing.Add(pd);
- }
- else
- {
- BotLogLine("Peta typu {0} mam, jmenuje se {1}, jeho cislo je {2}:{3}.", pd.PetType, mPet.Name == null ? "NULL" : mPet.Name,
- mPet.Type, mPet.Id);
- }
- }
- if (petTypesMissing.Count > 0)
- {
- BotLogLine("Chybi mi celkem {0} petu.", petTypesMissing.Count);
- InventoryItem[] inventory = null;
- foreach (PetDescription pdMissing in petTypesMissing)
- {
- if (pdMissing.ShellAoid == 0)
- {
- BotLogLine("Pet typu {0} nepotrebuje shell.", pdMissing.PetType);
- }
- else
- {
- BotLogLine("Kouknu do invu, jestli tam neni shell {0} k petovi typu {1}.", pdMissing.ShellAoid, pdMissing.PetType);
- if (inventory == null) inventory = AoClient.GetInventory();
- int shellSlotId = -1;
- foreach (InventoryItem i in inventory)
- {
- if (i.LowId == pdMissing.ShellAoid)
- {
- shellSlotId = i.SlotId;
- break;
- }
- }
- if (shellSlotId == -1)
- {
- BotLogLine("Nenasel jsem shell, budu ho muset nacastit.");
- petTypesShellMissing.Add(pdMissing);
- }
- else
- {
- BotLogLine("Nasel jsem v invu shell, pouziju ho.");
- Program.RemoteUseInventoryItem(104, shellSlotId, false);
- }
- tickRate = 2000;
- }
- }
- if (petTypesShellMissing.Count > 0)
- {
- BotLogLine("Je potreba nacastit {0} shellu/petu.", petTypesShellMissing.Count);
- PetDescription pdToCast = petTypesShellMissing[0];
- BotLog("Castnu prvni shell/peta typu {0}, nano program {1}... ", pdToCast.PetType, pdToCast.ShellNanoAoid);
- if (AoClient.IsFormulaReady(53019, (uint)pdToCast.ShellNanoAoid))
- {
- BotLogLine("motam.");
- AoClient.CastNanoSpell(53019, (uint)pdToCast.ShellNanoAoid, 0, 0);
- }
- else
- {
- BotLogLine("ted nemuzu castit.");
- }
- tickRate = 2000;
- }
- }
- else
- {
- BotLogLine("Peti mi nechybi, zkontrolujem jestli jsou buffnuty.");
- for (int i = 0; i < this.petDescriptions.Count; i++)
- {
- PetDescription pd = this.petDescriptions[i];
- if (pd.Mob == null) continue; // to by se stat nikdy nemelo
- foreach (PetBuff pb in pd.Buffs)
- {
- if (!pb.IsRunning)
- {
- BotLog("U peta typu {0} nebezi nano program {1}... ", pd.PetType, pb.Aoid);
- if (AoClient.IsFormulaReady(53019, (uint)pb.Aoid))
- {
- BotLogLine("motam.");
- AoClient.SetTarget(pd.Mob.Type, pd.Mob.Id);
- AoClient.CastNanoSpell(53019, (uint)pb.Aoid, pd.Mob.Type, pd.Mob.Id);
- }
- else
- {
- BotLogLine("ted nemuzu castit.");
- }
- tickRate = 2000;
- return;
- }
- }
- }
- if (this.TrimmerQl > 0 && this.TrimmerAoid > 0)
- {
- // peti jsou bud buffnuti nebo neco castim, je cas na trim. jen prvniho co najdu netrimmnuteho.
- for (int i = 0; i < this.petDescriptions.Count; i++)
- {
- PetDescription pd = this.petDescriptions[i];
- if (pd.Mob == null) continue; // to by se stat nikdy nemelo
- if (pd.IsTrimmed) continue;
- BotLogLine("Trim peta typu {0}.", pd.PetType);
- int trimmerSlot = -1;
- InventoryItem[] inventory = AoClient.GetInventory();
- foreach (InventoryItem invInventoryItem in inventory)
- {
- if (InventoryItem.LowId == this.TrimmerAoid && InventoryItem.QL == this.TrimmerQl)
- trimmerSlot = Inventoryitem.SlotId;
- }
- if (trimmerSlot == -1)
- BotLogLine("Nenasel jsem trimmer v invu.");
- else
- {
- AoClient.SetTarget(pd.Mob.Type, pd.Mob.Id);
- Program.RemoteUseInventoryItem(104, trimmerSlot, false);
- pd.IsTrimmed = true;
- }
- }
- }
- }
- }
- public override void OnPacket(Packet10 p)
- {
- if (p is TimedNanoProgramExecutedMessagePacket)
- {
- TimedNanoProgramExecutedMessagePacket tnpemp = (TimedNanoProgramExecutedMessagePacket)p;
- PetDescription pd;
- PetBuff pb = this.FindPetBuff(tnpemp.MobType, tnpemp.MobId, tnpemp.NanoProgramId, out pd);
- if (pb != null)
- {
- BotLogLine("Na petovi typu {0} spusten buff {1} ze seznamu buffu.", pd.PetType, pb.Aoid);
- pb.IsRunning = true;
- }
- }
- if (p is NanoProgramTerminated)
- {
- NanoProgramTerminated npt = (NanoProgramTerminated)p;
- PetDescription pd;
- PetBuff pb = this.FindPetBuff(npt.TargetType, npt.TargetId, npt.NanoProgramAOID, out pd);
- if (pb != null)
- {
- BotLogLine("Na petovi typu {0} prestal bezet buff {1} ze seznamu buffu.", pd.PetType, pb.Aoid);
- pb.IsRunning = false;
- }
- }
- }
- private PetBuff FindPetBuff(uint mobType, uint mobId, uint nanoProgramAoid, out PetDescription petDescription)
- {
- for (int i = 0; i < this.petDescriptions.Count; i++)
- {
- PetDescription pd = this.petDescriptions[i];
- if (pd.Mob == null) continue;
- if (pd.Mob.Type == mobType && pd.Mob.Id == mobId)
- for (int j = 0; j < pd.Buffs.Count; j++)
- if (pd.Buffs[j].Aoid == nanoProgramAoid)
- {
- petDescription = pd;
- return pd.Buffs[j];
- }
- }
- petDescription = null;
- return null;
- }
- public override void OnSpyKey(KeyEventArgs e)
- {
- if (e.KeyCode == Keys.P)
- {
- Identity[] pets = AoClient.GetClientPetIdentities();
- if (pets != null)
- {
- foreach (Identity i in pets)
- {
- int petType = AoClient.GetDynelSkill(i.Type, i.Id, 512, 0);
- Console.WriteLine("Pet {0}:{1} petType {2}", i.Type, i.Id, petType);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement