public override void DoProtect() { // Do we have instant debuff set? If not dont bother trying to protect (for now) if (profile.GetString("Necro.DebuffQ") == "" || profile.GetString("Necro.DebuffKey") == "") { return; } try { // Retrieve a list of objects near enough to be attacking our group int myX = _ak.gPlayerXCoord; int myY = _ak.gPlayerYCoord; AKServer.DLL.DAoCServer.Group groupMembers = _ak.GroupMemberInfo; // In a group? If not just return if (groupMembers.GroupMemberTable.Count == 0) { return; } ArrayList pets = new ArrayList(); if (petID > 0) { pets.Add(petID); } int spawnID = _ak.SearchArea((int)profile.GetFloat("SearchDistance"), AKServer.DLL.DAoCServer.DAOCObjectClass.ocMob, pets); while (spawnID != -1) { int mobTarget = _ak.get_MobTarget(spawnID); foreach (AKServer.DLL.DAoCServer.GroupMember grpMember in groupMembers.GroupMemberTable.Values) { //Is this group member being attacked? if (grpMember.ID == mobTarget) { //Yes, use instant debuff to get aggro! if (_ak.isPlayerSitting) { PlayerKeys.SitStand(KeyDirection.KeyUpDown); Thread.Sleep(500); } _ak.SetTarget(spawnID); Thread.Sleep(150); PlayerKeys.Face(KeyDirection.KeyUpDown); UseQbar(profile.GetString("Necro.DebuffQ"), profile.GetString("Necro.DebuffKey")); AddMessage("Protected " + _ak.get_MobName(mobTarget) + " by attacking " + _ak.get_MobName(spawnID)); } } spawnID = _ak.SearchAreaNext((int)profile.GetFloat("SearchDistance"), AKServer.DLL.DAoCServer.DAOCObjectClass.ocMob, pets); } } catch (Exception e) { AddMessage("caught exception " + e.Message); } finally { // Check if we have a next action if (ActionQueue.Count == 0) { throw new Exception("No action in ActionQueue"); } // Next Action Action = ActionQueue.Dequeue(); } }
private void CastPet() { petID = -1; AddMessage("Summoning servant"); if (_ak.isPlayerSitting) { PlayerKeys.SitStand(KeyDirection.KeyUpDown); Thread.Sleep(1000); } //test if we are already a shade by checking local buffs bool bShade = false; AKServer.DLL.DAoCServer.LocalBuffList buffs = _ak.LocalBufs; ICollection MyValues = buffs.BuffTable.Values; foreach (AKServer.DLL.DAoCServer.LocalBuff buff in MyValues) { if (buff.Name.StartsWith("Shade")) { bShade = true; } } //If we are a shade, we need to change pet stance to get a pet packet from server if (bShade) { //it appears if you log out while the pet is summoned AKServer thinks you still have the Shade buff when you log in again //so we try and cast just in case. UseQbar(profile.GetString("Necro.SummonPetQ"), profile.GetString("Necro.SummonPetKey")); AddMessage("We are already a shade! Trying to get pet ID..."); UseQbar(profile.GetString("Necro.PetPassiveQ"), profile.GetString("Necro.PetPassiveKey")); Thread.Sleep(100); UseQbar(profile.GetString("Necro.PetDefensiveQ"), profile.GetString("Necro.PetDefensiveKey")); Thread.Sleep(100); } else { //switch quickbar and cast UseQbar(profile.GetString("Necro.SummonPetQ"), profile.GetString("Necro.SummonPetKey")); } //No idea why, but I get the localBuff "Shade" sometimes even after a reboot and before casting pet //So lets do both and see if we get the packet // UseQbar(profile.GetString("PetPassiveQ"),profile.GetString("PetPassiveKey")); // Thread.Sleep(100); // UseQbar(profile.GetString("PetDefensiveQ"),profile.GetString("PetDefensiveKey")); // Thread.Sleep(100); // UseQbar(profile.GetString("SummonPetQ"), profile.GetString("SummonPetKey")); //Now we can wait for a pet packet to which will fill in petID //check once a second for up to 30 seconds int sanity = 0; //no endless loops please while (petID <= 0 && sanity++ < 30) { Thread.Sleep(1000); } // Did we get the petID? if (petID <= 0) { AddMessage("We didnt find the pet ID! Restart everything"); bPaused = true; } else { AddMessage("Got Pet ID " + petID.ToString() + " for pet " + _ak.get_MobName(petID)); } }
public override void DoCheckBuffs() { // Setup default action Action = BotAction.CheckAgro; // Are we casting, or is pet casting, or are we still casting last buff? if (!cooldowns.IsReady("Buff") || _ak.isPlayerCasting || _ak.get_isMobCasting(petID)) { // Recheck buffs if (ActionQueue.Peek(0) != BotAction.CheckBuffs) { ActionQueue.Insert(0, BotAction.CheckBuffs); } // AddMessage("Check buffs says - Already casting!"); return; } //just in case _ak.StopRunning(); // Are we sitting? if (_ak.isPlayerSitting) { PlayerKeys.SitStand(KeyDirection.KeyUpDown); Thread.Sleep(750); cooldowns.SetTime("Global"); // Recheck buffs if (ActionQueue.Peek(0) != BotAction.CheckBuffs) { ActionQueue.Insert(0, BotAction.CheckBuffs); } return; } //Lets check each buff and cast if needed if (cooldowns.IsReady("BuffDex") && profile.GetString("Necro.BuffDexQ") != "" && profile.GetString("Necro.BuffDexKey") != "") { AddMessage("Casting Dex Buff"); _ak.SetTarget(_ak.PlayerID); System.Threading.Thread.Sleep(500); //switch quickbar and cast UseQbar(profile.GetString("Necro.BuffDexQ"), profile.GetString("Necro.BuffDexKey")); cooldowns.SetTime("BuffDex"); cooldowns.SetTime("Buff"); // Recheck buffs if (ActionQueue.Peek(0) != BotAction.CheckBuffs) { ActionQueue.Insert(0, BotAction.CheckBuffs); } return; } if (cooldowns.IsReady("BuffAbsorb") && profile.GetString("Necro.BuffAbsorbQ") != "" && profile.GetString("Necro.BuffAbsorbKey") != "") { AddMessage("Casting Absorb Buff"); _ak.SetTarget(petID); System.Threading.Thread.Sleep(500); //switch quickbar and cast UseQbar(profile.GetString("Necro.BuffAbsorbQ"), profile.GetString("Necro.BuffAbsorbKey")); cooldowns.SetTime("BuffAbsorb"); cooldowns.SetTime("Buff"); // Recheck buffs if (ActionQueue.Peek(0) != BotAction.CheckBuffs) { ActionQueue.Insert(0, BotAction.CheckBuffs); } return; } if (cooldowns.IsReady("BuffStrength") && profile.GetString("Necro.BuffStrengthQ") != "" && profile.GetString("Necro.BuffStrengthKey") != "") { AddMessage("Casting Strength Buff"); _ak.SetTarget(_ak.PlayerID); System.Threading.Thread.Sleep(500); //switch quickbar and cast UseQbar(profile.GetString("Necro.BuffStrengthQ"), profile.GetString("Necro.BuffStrengthKey")); cooldowns.SetTime("BuffStrength"); cooldowns.SetTime("Buff"); // Recheck buffs if (ActionQueue.Peek(0) != BotAction.CheckBuffs) { ActionQueue.Insert(0, BotAction.CheckBuffs); } return; } }