public override void Run() { if (!_enRoute) { MovementManager.StopMove(); Logging.Write("Nearby Flight Master " + _flightMaster.Name + " (" + _flightMaster.Entry + ") is not yet discovered."); } _enRoute = true; Npc target = new Npc { Entry = _flightMaster.Entry, Position = _flightMaster.Position, Name = _flightMaster.Name, ContinentIdInt = Usefuls.ContinentId, Faction = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde" ? Npc.FactionType.Horde : Npc.FactionType.Alliance, }; uint baseAddress = MovementManager.FindTarget(ref target, 5.0f); if (MovementManager.InMovement) { return; } if (_flightMaster.GetDistance > 5) { return; } if (baseAddress > 0) { MovementManager.StopMove(); // avoid a red wow error Thread.Sleep(150); Interact.InteractWith(baseAddress); } }
public override void Run() { WoWPlayer TargetPlayer = ObjectManager.GetObjectWoWPlayer(_master.Guid); if (TargetPlayer == null) { if (_positionCheckTimer.IsReady) { _master.Position = MimesisClientCom.GetMasterPosition(); _positionCheckTimer.Reset(); } } else { _master.Position = TargetPlayer.Position; } if (MimesisSettings.CurrentSetting.ActivatePartyMode && _groupInvitCount < 3 && !Party.IsInGroup()) { MimesisClientCom.JoinGroup(); _groupInvitCount++; Thread.Sleep(500 + Usefuls.Latency); } if (!_master.Position.IsValid) { return; } else if (MimesisClientCom.HasTaskToDo()) { MovementManager.Chasing = false; } else { if (_master.Position.DistanceTo(ObjectManager.Me.Position) < 3.0f) { MovementManager.Chasing = false; MovementManager.StopMove(); } else if (_master.Position.Type.ToLower() == "flying" || _master.Position.Type.ToLower() == "swimming") { MovementManager.MoveTo(_master.Position); Logging.Write("Flying or swimming"); } else { MovementManager.Chasing = true; uint baseAddress = MovementManager.FindTarget(ref _master, 3.0f); } } // now we should query for events if (_eventQueryTimer.IsReady) { MimesisClientCom.ProcessEvents(); _eventQueryTimer.Reset(); } MimesisClientCom.DoTasks(); // on event START_LOOT_ROLL lookup if item is an update and roll need/cupidity }
public override void Run() { if (ObjectManager.ObjectManager.Me.IsMounted) { MovementManager.FindTarget(_unit, CombatClass.GetAggroRange); Thread.Sleep(100); if (MovementManager.InMovement) { return; } MountTask.DismountMount(); } Logging.Write("Player Attacked by " + _unit.Name + " (lvl " + _unit.Level + ")"); UInt128 unkillableMob = Fight.StartFight(_unit.Guid); if (!_unit.IsDead && unkillableMob != 0 && _unit.HealthPercent == 100.0f) { if (!nManagerSetting.IsBlackListed(unkillableMob)) { // Don't re-blacklist it if it was temporary blacklisted for Evading. Logging.Write("Blacklisting " + _unit.Name); nManagerSetting.AddBlackList(unkillableMob, 2 * 60 * 1000); // 2 minutes } } else if (_unit.IsDead) { Statistics.Kills++; if (Products.Products.ProductName == "Quester" && !_unit.IsTapped) { Quest.KilledMobsToCount.Add(_unit.Entry); // we may update a quest requiring killing this unit } if (ObjectManager.ObjectManager.GetNumberAttackPlayer() <= 0) { Thread.Sleep(Usefuls.Latency + 500); } while (!ObjectManager.ObjectManager.Me.IsMounted && ObjectManager.ObjectManager.Me.InCombat && ObjectManager.ObjectManager.GetNumberAttackPlayer() <= 0) { Thread.Sleep(150); } Fight.StopFight(); } }
public override void Run() { List <Npc> listNPCs = new List <Npc>(); Npc mailBox = null; // Stop fisher if needed if (Products.Products.ProductName == "Fisherbot" && FishingTask.IsLaunched) { FishingTask.StopLoopFish(); // Then break the cast MovementsAction.MoveBackward(true); Thread.Sleep(50); MovementsAction.MoveBackward(false); } // If we need to send items. if (nManagerSetting.CurrentSetting.ActivateAutoMaillingFeature && !_suspendMailing && nManagerSetting.CurrentSetting.MaillingFeatureRecipient != string.Empty && Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SendMailWhenLessThanXSlotLeft) { if (_useMollE) { MountTask.DismountMount(); ItemsManager.UseItem(ItemsManager.GetItemNameById(40768)); Thread.Sleep(2000); WoWGameObject portableMailbox = ObjectManager.ObjectManager.GetNearestWoWGameObject( ObjectManager.ObjectManager.GetWoWGameObjectById(191605)); if (portableMailbox.IsValid && portableMailbox.CreatedBy == ObjectManager.ObjectManager.Me.Guid) { mailBox = new Npc { Entry = portableMailbox.Entry, Position = portableMailbox.Position, Name = portableMailbox.Name, ContinentIdInt = Usefuls.ContinentId, Faction = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde" ? Npc.FactionType.Horde : Npc.FactionType.Alliance, SelectGossipOption = 0, Type = Npc.NpcType.Mailbox }; } } if (mailBox == null && NpcDB.GetNpcNearby(Npc.NpcType.Mailbox).Entry > 0) { mailBox = NpcDB.GetNpcNearby(Npc.NpcType.Mailbox); } listNPCs.Add(mailBox); } // If we need to repair. if (ObjectManager.ObjectManager.Me.GetDurability <= nManagerSetting.CurrentSetting.RepairWhenDurabilityIsUnderPercent && nManagerSetting.CurrentSetting.ActivateAutoRepairFeature) { if (_magicMountMammoth && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0) { if (_travelersTundraMammoth.HaveBuff || _travelersTundraMammoth.IsSpellUsable) { if (!_travelersTundraMammoth.HaveBuff) { MountTask.DismountMount(); _travelersTundraMammoth.Launch(true, true, true); Thread.Sleep(2000); } if (ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde") { WoWUnit drixBlackwrench = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(32641)); if (drixBlackwrench.IsValid && drixBlackwrench.IsAlive) { Npc drixBlackwrenchNpc = new Npc { Entry = drixBlackwrench.Entry, Position = drixBlackwrench.Position, Name = drixBlackwrench.Name, ContinentIdInt = Usefuls.ContinentId, Faction = Npc.FactionType.Horde, SelectGossipOption = 0, Type = Npc.NpcType.Repair }; listNPCs.Add(drixBlackwrenchNpc); } } else { WoWUnit gnimo = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(32639)); if (gnimo.IsValid && gnimo.IsAlive) { Npc gnimoNpc = new Npc { Entry = gnimo.Entry, Position = gnimo.Position, Name = gnimo.Name, ContinentIdInt = Usefuls.ContinentId, Faction = Npc.FactionType.Alliance, SelectGossipOption = 0, Type = Npc.NpcType.Repair }; listNPCs.Add(gnimoNpc); } } } } else if (_magicMountYak && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0) { if (_grandExpeditionYak.HaveBuff || _grandExpeditionYak.IsSpellUsable) { if (!_grandExpeditionYak.HaveBuff) { MountTask.DismountMount(); _grandExpeditionYak.Launch(true, true, true); Thread.Sleep(2000); } WoWUnit cousinSlowhands = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(62822)); if (cousinSlowhands.IsValid && cousinSlowhands.IsAlive) { Npc cousinSlowhandsNpc = new Npc { Entry = cousinSlowhands.Entry, Position = cousinSlowhands.Position, Name = cousinSlowhands.Name, ContinentIdInt = Usefuls.ContinentId, Faction = ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde" ? Npc.FactionType.Horde : Npc.FactionType.Alliance, SelectGossipOption = 0, Type = Npc.NpcType.Repair }; listNPCs.Add(cousinSlowhandsNpc); } } } else if (_use74A) { Npc npcA = DoSpawnRobot("74A", Npc.NpcType.Repair); if (npcA != null) { listNPCs.Add(npcA); } } else if (_use110G) { Npc npcG = DoSpawnRobot("110G", Npc.NpcType.Repair); if (npcG != null) { listNPCs.Add(npcG); } } else if (_useJeeves) { Npc npcJeeves = DoSpawnRobot("Jeeves", Npc.NpcType.Repair); if (npcJeeves != null) { listNPCs.Add(npcJeeves); } } else { if (NpcDB.GetNpcNearby(Npc.NpcType.Repair).Entry > 0) { listNPCs.Add(NpcDB.GetNpcNearby(Npc.NpcType.Repair)); } } } // If we need to sell. if (NeedFoodSupplies() || NeedDrinkSupplies() || Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SellItemsWhenLessThanXSlotLeft && nManagerSetting.CurrentSetting.ActivateAutoSellingFeature && !_suspendSelling) { if (_magicMountMammoth && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0) { if (_travelersTundraMammoth.HaveBuff || _travelersTundraMammoth.IsSpellUsable) { if (!_travelersTundraMammoth.HaveBuff) { MountTask.DismountMount(); _travelersTundraMammoth.Launch(true, true, true); Thread.Sleep(2000); } if (ObjectManager.ObjectManager.Me.PlayerFaction.ToLower() == "horde") { WoWUnit mojodishu = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(32642)); if (mojodishu.IsValid && mojodishu.IsAlive) { Npc mojodishuNpc = new Npc { Entry = mojodishu.Entry, Position = mojodishu.Position, Name = mojodishu.Name, ContinentIdInt = Usefuls.ContinentId, Faction = Npc.FactionType.Horde, SelectGossipOption = 0, Type = Npc.NpcType.Vendor }; listNPCs.Add(mojodishuNpc); } } else { WoWUnit hakmuddArgus = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(32638)); if (hakmuddArgus.IsValid && hakmuddArgus.IsAlive) { Npc hakmuddArgusNpc = new Npc { Entry = hakmuddArgus.Entry, Position = hakmuddArgus.Position, Name = hakmuddArgus.Name, ContinentIdInt = Usefuls.ContinentId, Faction = Npc.FactionType.Alliance, SelectGossipOption = 0, Type = Npc.NpcType.Vendor }; listNPCs.Add(hakmuddArgusNpc); } } } } else if (_magicMountYak && MountTask.GetMountCapacity() >= MountCapacity.Ground && Skill.GetValue(SkillLine.Riding) > 0) { if (_grandExpeditionYak.HaveBuff || _grandExpeditionYak.IsSpellUsable) { if (!_grandExpeditionYak.HaveBuff) { MountTask.DismountMount(); _grandExpeditionYak.Launch(true, true, true); Thread.Sleep(2000); } WoWUnit cousinSlowhands = ObjectManager.ObjectManager.GetNearestWoWUnit( ObjectManager.ObjectManager.GetWoWUnitByEntry(62822)); if (cousinSlowhands.IsValid && cousinSlowhands.IsAlive) { Npc cousinSlowhandsNpc = new Npc { Entry = cousinSlowhands.Entry, Position = cousinSlowhands.Position, Name = cousinSlowhands.Name, ContinentIdInt = Usefuls.ContinentId, Faction = Npc.FactionType.Neutral, SelectGossipOption = 0, Type = Npc.NpcType.Vendor }; listNPCs.Add(cousinSlowhandsNpc); } } } else if (_use74A) { Npc npcA = DoSpawnRobot("74A", Npc.NpcType.Vendor); if (npcA != null) { listNPCs.Add(npcA); } } else if (_use110G) { Npc npcG = DoSpawnRobot("110G", Npc.NpcType.Vendor); if (npcG != null) { listNPCs.Add(npcG); } } else if (_useJeeves) { Npc npcJeeves = DoSpawnRobot("Jeeves", Npc.NpcType.Vendor); if (npcJeeves != null) { listNPCs.Add(npcJeeves); } } else { if (NpcDB.GetNpcNearby(Npc.NpcType.Vendor).Entry > 0) { listNPCs.Add(NpcDB.GetNpcNearby(Npc.NpcType.Vendor)); } } } #region Repairer, Seller/Buyer, MailBox if (listNPCs.Count > 0) { listNPCs.Sort(OnComparison); foreach (Npc npc in listNPCs) { Npc target = npc; bool doTravel = target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 400 || target.ContinentIdInt != Usefuls.ContinentId; if (!doTravel && target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 400) { // Close NPC but no path ? bool success; PathFinder.FindPath(ObjectManager.ObjectManager.Me.Position, target.Position, Usefuls.ContinentNameMpq, out success); if (!success) { doTravel = true; } } //Start travel if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f) { if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid) { _travelLocation = Products.Products.TravelFrom; Products.Products.TravelRegenerated = false; } } if (doTravel && (_travelLocation == null || _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 0.1f) && !_travelDisabled && !Usefuls.IsFlying) { MovementManager.StopMove(); switch (npc.Type) { case Npc.NpcType.Repair: Logging.Write("Calling travel system to NpcRepair " + npc.Name + " (" + npc.Entry + ")..."); break; case Npc.NpcType.Vendor: Logging.Write("Calling travel system to NpcVendor " + npc.Name + " (" + npc.Entry + ")..."); break; case Npc.NpcType.Mailbox: Logging.Write("Calling travel system to Mailbox " + npc.Name + " (" + npc.Entry + ")..."); break; default: Logging.Write("Calling travel system for ToTown to " + npc.Name + " (" + npc.Entry + ")..."); break; } Products.Products.TravelToContinentId = target.ContinentIdInt; Products.Products.TravelTo = target.Position; Products.Products.TravelFromContinentId = Usefuls.ContinentId; Products.Products.TravelFrom = ObjectManager.ObjectManager.Me.Position; // Pass the check for valid destination as a lambda Products.Products.TargetValidationFct = Quest.IsNearQuestGiver; // compare me.Pos to dest.Pos _travelLocation = Products.Products.TravelFrom; return; } if (_travelLocation != null && _travelLocation.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 0.1f) { _travelDisabled = true; // don't forget to release travel once arrived. } //Start target finding based on Seller. uint baseAddress = MovementManager.FindTarget(ref target, 0, !ObjectManager.ObjectManager.Me.IsMounted); if (!target.ValidPath) { Logging.WriteDebug("No valid path/travel to Npc " + target.Name + ", removing him from NpcDB."); NpcDB.DelNpc(target); } if (MovementManager.InMovement) { return; } if (target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) >= 5f) { return; } _travelDisabled = false; if (baseAddress == 0 && target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 5f) { NpcDB.DelNpc(target); } else if (baseAddress > 0) { if (!_travelersTundraMammoth.HaveBuff) { DoProspectingInTown(target); DoMillingInTown(target); } Interact.InteractWith(baseAddress); Thread.Sleep(500); MovementManager.StopMove(); if (target.SelectGossipOption != 0) { Lua.LuaDoString("SelectGossipOption(" + target.SelectGossipOption + ")"); Thread.Sleep(500); } else if (target.Type == Npc.NpcType.Repair || target.Type == Npc.NpcType.Vendor) { if (!Gossip.SelectGossip(Gossip.GossipOption.Vendor)) { Logging.WriteError("Problem with NPC " + npc.Name + " Removing it for NpcDB"); NpcDB.DelNpc(npc); return; } } // NPC Repairer if (target.Type == Npc.NpcType.Repair) { Logging.Write("Repair items from " + target.Name + " (" + target.Entry + ")."); Vendor.RepairAllItems(); Thread.Sleep(1000); } // End NPC Repairer if (target.Type == Npc.NpcType.Vendor) { // NPC Buyer Logging.Write("Selling items to " + target.Name + " (" + target.Entry + ")."); List <WoWItemQuality> vQuality = new List <WoWItemQuality>(); if (nManagerSetting.CurrentSetting.SellGray) { vQuality.Add(WoWItemQuality.Poor); } if (nManagerSetting.CurrentSetting.SellWhite) { vQuality.Add(WoWItemQuality.Common); } if (nManagerSetting.CurrentSetting.SellGreen) { vQuality.Add(WoWItemQuality.Uncommon); } if (nManagerSetting.CurrentSetting.SellBlue) { vQuality.Add(WoWItemQuality.Rare); } if (nManagerSetting.CurrentSetting.SellPurple) { vQuality.Add(WoWItemQuality.Epic); } Vendor.SellItems(nManagerSetting.CurrentSetting.ForceToSellTheseItems, nManagerSetting.CurrentSetting.DontSellTheseItems, vQuality); Thread.Sleep(3000); if (Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SellItemsWhenLessThanXSlotLeft) { _suspendSelling = true; } // End NPC Buyer // NPC Seller if (NeedFoodSupplies() || NeedDrinkSupplies()) { Logging.Write("Buying beverages and food from " + target.Name + " (" + target.Entry + ")."); } for (int i = 0; i < 10 && NeedFoodSupplies(); i++) { Vendor.BuyItem(nManagerSetting.CurrentSetting.FoodName, 1); } for (int i = 0; i < 10 && NeedDrinkSupplies(); i++) { Vendor.BuyItem(nManagerSetting.CurrentSetting.BeverageName, 1); } // End NPC Seller } if (target.Type == Npc.NpcType.Repair || target.Type == Npc.NpcType.Vendor) { Gossip.CloseGossip(); } // MailBox if (target.Type == Npc.NpcType.Mailbox) { List <WoWItemQuality> mQuality = new List <WoWItemQuality>(); if (nManagerSetting.CurrentSetting.MailGray) { mQuality.Add(WoWItemQuality.Poor); } if (nManagerSetting.CurrentSetting.MailWhite) { mQuality.Add(WoWItemQuality.Common); } if (nManagerSetting.CurrentSetting.MailGreen) { mQuality.Add(WoWItemQuality.Uncommon); } if (nManagerSetting.CurrentSetting.MailBlue) { mQuality.Add(WoWItemQuality.Rare); } if (nManagerSetting.CurrentSetting.MailPurple) { mQuality.Add(WoWItemQuality.Epic); } bool mailSendingCompleted = false; for (int i = 7; i > 0 && !mailSendingCompleted; i--) { Interact.InteractWith(baseAddress); Thread.Sleep(1000); Mail.SendMessage(nManagerSetting.CurrentSetting.MaillingFeatureRecipient, nManagerSetting.CurrentSetting.MaillingFeatureSubject, "", nManagerSetting.CurrentSetting.ForceToMailTheseItems, nManagerSetting.CurrentSetting.DontMailTheseItems, mQuality, out mailSendingCompleted); Thread.Sleep(500); } if (mailSendingCompleted) { Logging.Write("Sending items to the player " + nManagerSetting.CurrentSetting.MaillingFeatureRecipient + " using " + target.Name + " (" + target.Entry + ")."); } if (Usefuls.GetContainerNumFreeSlots <= nManagerSetting.CurrentSetting.SendMailWhenLessThanXSlotLeft) { _suspendMailing = true; } Lua.LuaDoString("CloseMail()"); } // End MailBox } // still on the road, but not in movement for some reasons } } #endregion Repairer, Seller/Buyer, MailBox }
public static void LaunchTaxi() { try { if (_availableTaxis == null) { _availableTaxis = XmlSerializer.Deserialize <List <Taxi> >(Application.StartupPath + @"\Data\TaxiList.xml"); } if (_availableTaxiLinks == null) { _availableTaxiLinks = XmlSerializer.Deserialize <List <TaxiLink> >(Application.StartupPath + @"\Data\TaxiLinks.xml"); } uint firstTaxiId = 0; while (true) { _availableTaxis = XmlSerializer.Deserialize <List <Taxi> >(Application.StartupPath + @"\Data\TaxiList.xml"); _availableTaxiLinks = XmlSerializer.Deserialize <List <TaxiLink> >(Application.StartupPath + @"\Data\TaxiLinks.xml"); if (IsTaxiOpen()) { if (firstTaxiId != 0 && firstTaxiId == ObjectManager.Me.Target.GetWoWId) { Logging.Write("The continent have been parsed !"); break; } if (firstTaxiId == 0) { firstTaxiId = ObjectManager.Me.Target.GetWoWId; } if (TaxiListContainsTaxiId(ObjectManager.Me.Target.GetWoWId)) { Logging.WriteDebug("The taxi from NPC " + ObjectManager.Target.Name + " is already in our database."); Taxi myTaxi = GetTaxiFromTaxiId(ObjectManager.Me.Target.GetWoWId); if (myTaxi.Faction != Npc.FactionType.Neutral && ObjectManager.Me.PlayerFaction != myTaxi.Faction.ToString()) { for (int i = 0; i < _availableTaxis.Count; i++) { if (myTaxi.Id == _availableTaxis[i].Id) { _availableTaxis[i].Faction = Npc.FactionType.Neutral; } } } } else { var localTaxi = new Taxi(); localTaxi.Id = ObjectManager.Me.Target.GetWoWId; localTaxi.Position = ObjectManager.Target.Position; string taxiInfo = ExtractCurrentTaxiInfo(); localTaxi.Name = taxiInfo.Split('#')[0]; localTaxi.ContinentId = Usefuls.ContinentId; localTaxi.Xcoord = taxiInfo.Split('#')[1].Split('^')[0]; localTaxi.Ycoord = taxiInfo.Split('^')[1].Split('@')[0]; localTaxi.Faction = ObjectManager.Me.PlayerFaction == "Alliance" ? Npc.FactionType.Alliance : Npc.FactionType.Horde; _availableTaxis.Add(localTaxi); foreach (TaxiLink taxiLink in _availableTaxiLinks) { if (taxiLink.PointB == 0 && taxiLink.PointB_XY == localTaxi.Xcoord + localTaxi.Ycoord) { taxiLink.PointB = localTaxi.Id; taxiLink.PointB_XY = ""; } } } foreach (string ctaxi in ExtractDirectPathTaxiInfoList()) { string taxiInfo = ctaxi; var localTaxi = new Taxi(); localTaxi.Name = taxiInfo.Split('#')[0]; localTaxi.ContinentId = Usefuls.ContinentId; localTaxi.Xcoord = taxiInfo.Split('#')[1].Split('^')[0]; localTaxi.Ycoord = taxiInfo.Split('^')[1].Split('@')[0]; bool taxiExist = false; var taxiFound = new Taxi(); foreach (Taxi taxi in _availableTaxis) { if (taxi.Xcoord == localTaxi.Xcoord && taxi.Ycoord == localTaxi.Ycoord) { // this taxi exist in the list so we have its ID taxiExist = true; taxiFound = taxi; } } bool found = false; foreach (TaxiLink taxiLink in _availableTaxiLinks) { if (taxiExist && taxiLink.PointA == ObjectManager.Me.Target.GetWoWId && taxiLink.PointB == taxiFound.Id) { found = true; break; } if (taxiExist && taxiLink.PointB == ObjectManager.Me.Target.GetWoWId && taxiLink.PointA == taxiFound.Id) { found = true; break; } if (taxiLink.PointA == ObjectManager.Me.Target.GetWoWId && taxiLink.PointB_XY == localTaxi.Xcoord + localTaxi.Ycoord) { found = true; break; } } if (!found) { _availableTaxiLinks.Add(taxiExist ? new TaxiLink { PointA = ObjectManager.Me.Target.GetWoWId, PointB = taxiFound.Id } : new TaxiLink { PointA = ObjectManager.Me.Target.GetWoWId, PointB_XY = localTaxi.Xcoord + localTaxi.Ycoord }); } } XmlSerializer.Serialize(Application.StartupPath + @"\Data\TaxiList.xml", _availableTaxis); XmlSerializer.Serialize(Application.StartupPath + @"\Data\TaxiLinks.xml", _availableTaxiLinks); string nextHop = ExtractNextTaxiInfo(); Logging.Write("Taking taxi from " + ExtractCurrentTaxiInfo().Split('#')[0] + " to " + nextHop.Split('#')[0]); Gossip.TakeTaxi(nextHop.Split('#')[1].Split('^')[0], nextHop.Split('^')[1].Split('@')[0]); Thread.Sleep(1000); } if (ObjectManager.Me.OnTaxi) { Travel.TravelPatientlybyTaxiOrPortal(true); Thread.Sleep(2000); continue; } WoWUnit taxiUnit = ObjectManager.GetNearestWoWUnit(ObjectManager.GetWoWUnitFlightMaster()); uint baseAddress = MovementManager.FindTarget(taxiUnit); if (MovementManager.InMovement) { continue; } if (baseAddress > 0) { Interact.InteractWith(baseAddress); Thread.Sleep(500); if (!Gossip.IsTaxiWindowOpen()) { Gossip.SelectGossip(Gossip.GossipOption.Taxi); Thread.Sleep(250 + Usefuls.Latency); } } Thread.Sleep(200); } } catch (Exception e) { Logging.WriteDebug(e.ToString()); } }
private static void Ground(IEnumerable <WoWGameObject> nodes, bool ignoreCanOpen = false) { try { nodes = nodes.OrderBy(x => x.GetDistance); foreach (WoWGameObject node in nodes) { WoWGameObject inode = node; if (_curNode != null && _curNode.IsValid && !nManagerSetting.IsBlackListed(_curNode.Guid)) { inode = _curNode; } if (!inode.IsValid) { MovementManager.StopMove(); nManagerSetting.AddBlackList(inode.Guid, 2 * 60 * 1000); Logging.Write("Current inode not valid, blacklist."); continue; } _curNode = inode; // we save a inode we potentially bypassed to make sure we run the list. if (!inode.CanOpen && !ignoreCanOpen) { nManagerSetting.AddBlackList(inode.Guid, 5000); return; } if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) > 5.0f) { if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) >= nManagerSetting.CurrentSetting.MinimumDistanceToUseMount || !nManagerSetting.CurrentSetting.UseGroundMount) { if (MountTask.GetMountCapacity() == MountCapacity.Fly || Usefuls.IsFlying) { if (!Usefuls.IsFlying) { if (!MountTask.OnFlyMount()) { MountTask.Mount(true, true); } else { MountTask.Takeoff(); } } Fly(nodes); return; } if (Usefuls.IsSwimming) { if (MountTask.GetMountCapacity() == MountCapacity.Swimm && !MountTask.OnAquaticMount()) { MountTask.Mount(); } Fly(nodes); return; } } // fallback to ground mount or feet if (ObjectManager.ObjectManager.Me.Position.DistanceTo(inode.Position) >= nManagerSetting.CurrentSetting.MinimumDistanceToUseMount && nManagerSetting.CurrentSetting.UseGroundMount) { if (MountTask.GetMountCapacity() == MountCapacity.Ground && !MountTask.OnGroundMount()) { MountTask.Mount(); } } if (MovementManager.FindTarget(inode, 5.5f, true, nManagerSetting.CurrentSetting.GatheringSearchRadius * 4.0f) == 0) { nManagerSetting.AddBlackList(inode.Guid, 1000 * 20); _curNode = null; return; } if (_lastnode != inode.Guid) { _lastnode = inode.Guid; Logging.Write("Ground Farm " + inode.Name + " (" + inode.Entry + ") > " + inode.Position); } if (inode.GetDistance < 5.5f) // max range is usually 5.8-9 yards { MovementManager.StopMove(); } if (MovementManager.InMovement) { return; } } MovementManager.StopMove(); while (ObjectManager.ObjectManager.Me.GetMove) { Thread.Sleep(250); } Thread.Sleep(250 + Usefuls.Latency); if (ObjectManager.ObjectManager.Me.InCombat) { if (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId()))) { MountTask.DismountMount(); // If we don't have druid mount or Sky Golem, dismount and fight. return; } // We are druid or using sky golem, let's try to loot } _wasLooted = false; CountThisLoot = true; NodeOrUnit = true; Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 300); if (!ObjectManager.ObjectManager.Me.IsCast) { Interact.InteractWith(inode.GetBaseAddress); Thread.Sleep(Usefuls.Latency + 250); } while (ObjectManager.ObjectManager.Me.IsCast) { Thread.Sleep(150); } if (ObjectManager.ObjectManager.Me.InCombat && (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId())))) { CountThisLoot = false; return; } Thread.Sleep(100 + Usefuls.Latency); if (ObjectManager.ObjectManager.Me.InCombat && (!ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()) && (!inode.IsHerb || inode.IsHerb && !ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId())))) { CountThisLoot = false; return; } if (CountThisLoot && !ObjectManager.ObjectManager.Me.InCombat) { nManagerSetting.AddBlackList(inode.Guid, 1000 * 20); } Thread.Sleep(1000); if (!_wasLooted) { Logging.Write("Farm failed #2"); if (ObjectManager.ObjectManager.Me.InCombat && (ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.HerbsInteractMountId()) || ObjectManager.ObjectManager.Me.HaveBuff(SpellManager.AllInteractMountId()))) { MountTask.DismountMount(); // we got cancelled during farm, let's fight this out for good.. } } return; } } catch (Exception ex) { Logging.WriteError("FarmingTask > Ground(IEnumerable<WoWGameObject> nodes): " + ex); } }
public override void Run() { if (MovementManager.InMovement) { return; } // Now configure if not already done if (tList == null) { // Fill the task list tList = new Stack <Task>(); tList.Push(Task.CheckGarrisonRessourceCache); if (Garrison.GetGarrisonLevel() > 1) { tList.Push(Task.MineWorkOrder); tList.Push(Task.GatherMinerals); tList.Push(Task.GardenWorkOrder); tList.Push(Task.GatherHerbs); } tList.Push(Task.GoToGarrison); // And fill the variables _cacheGarrison = new List <int> { 237722, 236916, 237191, 237724, 237720, 237723 }; if (ObjMgr.Me.PlayerFaction == "Alliance") { _npcGarden = 85514; _cacheGarden = 235885; _npcMine = 77730; _cacheMine = 235886; _garden = new Point { X = 1833.85f, Y = 154.7408f, Z = 76.66339f }; _mineEntrance = new Point { X = 1886.021f, Y = 83.23455f, Z = 84.31888f }; _cacheGarrisonPoint = new Point { X = 1914.361f, Y = 290.3863f, Z = 88.96407f }; } else { _npcGarden = 85783; _cacheGarden = 239238; _npcMine = 81688; _cacheMine = 239237; _garden = new Point { X = 5413.795f, Y = 4548.928f, Z = 139.1232f }; _mineEntrance = new Point { X = 5465.796f, Y = 4430.045f, Z = 145.4595f }; _cacheGarrisonPoint = new Point { X = 5592.229f, Y = 4569.476f, Z = 136.1069f }; } _cacheGardenGathered = false; _cacheMineGathered = false; } bool success, display = false; Point me = ObjMgr.Me.Position; Task currentTask = tList.Peek(); if (currentTask != previousTask) { previousTask = currentTask; display = true; } switch (currentTask) { case Task.GoToGarrison: if (display) { Logging.Write("Task: go to garrison"); } /*var pathToGarrison2 = PathFinder.FindPath(new Point() { X = 2727.872f, Y = 6451.539f, Z = 191.9229f }, out success); * if (success) * { * //this code allow me to test a path easily. * MovementManager.Go(pathToGarrison2); * return; * }*/ if (!Garrison.GarrisonMapIdList.Contains(Usefuls.RealContinentId)) { // We are in Draenor if (Usefuls.ContinentId == Usefuls.ContinentIdByContinentName("Draenor")) { // We can fly, then fly if (MountTask.GetMountCapacity() == MountCapacity.Fly) { LongMove.LongMoveGo(_cacheGarrisonPoint); return; } // else if not too far go by foot else if (_cacheGarrisonPoint.DistanceTo(me) < 100) { List <Point> pathToGarrison = PathFinder.FindPath(_cacheGarrisonPoint, out success); if (success) { MovementManager.Go(pathToGarrison); return; } } } // We have to use the garrison hearthstone if (ItemsManager.GetItemCount(GarrisonHearthstone) > 0 && !ItemsManager.IsItemOnCooldown(GarrisonHearthstone)) { Logging.Write("Using garrison Hearthstone"); ItemsManager.UseItem(GarrisonHearthstone); } else { Logging.Write("Run aborted, you are not in Draenor or too far away and don't known how to fly and don't have a Garrison Hearthstone or it's on Cooldown."); tList.Clear(); break; // prevent poping an empty stack, break to the end } } tList.Pop(); break; case Task.CheckGarrisonRessourceCache: if (display) { Logging.Write("Task: gather garrison cache"); } if (_cacheGarrisonPoint.DistanceTo(me) > 75.0f) { List <Point> pathToGCache = PathFinder.FindPath(_cacheGarrisonPoint); MovementManager.Go(pathToGCache); return; } WoWGameObject cache = ObjMgr.GetNearestWoWGameObject(ObjMgr.GetWoWGameObjectById(_cacheGarrison)); if (cache.GetBaseAddress != 0) { if (cache.Position.DistanceTo(me) > 5.0f) { _targetNpc = new Npc { Entry = cache.Entry, Position = cache.Position }; MovementManager.FindTarget(ref _targetNpc, 5f); return; } Interact.InteractWith(cache.GetBaseAddress, true); } tList.Pop(); break; case Task.GatherHerbs: if (display) { Logging.Write("Task: gather plants in garrison garden"); } if (_garden.DistanceTo(me) > 15.0f) { List <Point> pathToGarden = PathFinder.FindPath(_garden, out success); // assume success MovementManager.Go(pathToGarden); return; } nManagerSetting.CurrentSetting.ActivateHerbsHarvesting = true; nManagerSetting.CurrentSetting.GatheringSearchRadius = 30f; if (!FarmingState.NeedToRun) // Nothing anymore to farm, then next task { Logging.Write("Finished to farm garrison garden"); nManagerSetting.CurrentSetting.ActivateHerbsHarvesting = false; tList.Pop(); } break; case Task.GatherMinerals: if (display) { Logging.Write("Task: gather ores and carts in garrison mine"); } if (_mineEntrance.DistanceTo(me) > 15.0f) { List <Point> pathToMine = PathFinder.FindPath(_mineEntrance, out success); // assume success MovementManager.Go(pathToMine); return; } nManagerSetting.CurrentSetting.GatheringSearchRadius = 120f; nManagerSetting.CurrentSetting.ActivateVeinsHarvesting = true; if (FarmingState.NeedToRun) { Logging.Write("Take coffee and Mining Pick buffs"); if (ItemsManager.GetItemCount(PreservedMiningPick) > 0 && !ItemsManager.IsItemOnCooldown(PreservedMiningPick) && ItemsManager.IsItemUsable(PreservedMiningPick) && !ObjMgr.Me.HaveBuff(PreservedMiningPickBuff)) { ItemsManager.UseItem(PreservedMiningPick); Thread.Sleep(150 + Usefuls.Latency); while (ObjMgr.Me.IsCast) { Thread.Sleep(150); } Thread.Sleep(1000); } if (ItemsManager.GetItemCount(MinerCoffee) > 0 && !ItemsManager.IsItemOnCooldown(MinerCoffee) && ItemsManager.IsItemUsable(MinerCoffee) && ObjMgr.Me.BuffStack(MinerCoffeeBuff) < 2) { ItemsManager.UseItem(MinerCoffee); Thread.Sleep(150 + Usefuls.Latency); while (ObjMgr.Me.IsCast) { Thread.Sleep(150); } } } else // Nothing anymore to farm, then next task { Logging.Write("Finished to farm garrison mine"); nManagerSetting.CurrentSetting.ActivateVeinsHarvesting = false; tList.Pop(); } break; case Task.GardenWorkOrder: if (display) { Logging.Write("Task: collect garden cache and send work order"); } if (!_cacheGardenGathered) { WoWGameObject gardenCache = ObjMgr.GetNearestWoWGameObject(ObjMgr.GetWoWGameObjectById(_cacheGarden)); if (gardenCache.GetBaseAddress != 0) { if (gardenCache.Position.DistanceTo(me) > 5.0f) { _targetNpc = new Npc { Entry = gardenCache.Entry, Position = gardenCache.Position }; MovementManager.FindTarget(ref _targetNpc, 5f); return; } else { Thread.Sleep(Usefuls.Latency + 250); Interact.InteractWith(gardenCache.GetBaseAddress, true); _cacheGardenGathered = true; Thread.Sleep(Usefuls.Latency + 1750); } } } WoWUnit gardenNpc = ObjMgr.GetNearestWoWUnit(ObjMgr.GetWoWUnitByEntry(_npcGarden)); if (gardenNpc.GetBaseAddress != 0) { if (gardenNpc.Position.DistanceTo(me) > 5.0f) { _targetNpc = new Npc { Entry = gardenNpc.Entry, Position = gardenNpc.Position }; MovementManager.FindTarget(ref _targetNpc, 5f); return; } else { Interact.InteractWith(gardenNpc.GetBaseAddress, true); Thread.Sleep(Usefuls.Latency + 1000); Interact.InteractWith(gardenNpc.GetBaseAddress, true); Thread.Sleep(Usefuls.Latency + 500); Lua.LuaDoString("GarrisonCapacitiveDisplayFrame.CreateAllWorkOrdersButton:Click()"); Thread.Sleep(Usefuls.Latency + 1000); } } tList.Pop(); break; case Task.MineWorkOrder: if (display) { Logging.Write("Task: collect mine cache and send work order"); } if (!_cacheMineGathered) { WoWGameObject mineCache = ObjMgr.GetNearestWoWGameObject(ObjMgr.GetWoWGameObjectById(_cacheMine)); if (mineCache.GetBaseAddress != 0) { if (mineCache.Position.DistanceTo(me) > 5.0f) { _targetNpc = new Npc { Entry = mineCache.Entry, Position = mineCache.Position }; MovementManager.FindTarget(ref _targetNpc, 5f); return; } else { Thread.Sleep(Usefuls.Latency + 250); Interact.InteractWith(mineCache.GetBaseAddress, true); _cacheMineGathered = true; Thread.Sleep(Usefuls.Latency + 1750); } } } WoWUnit mineNpc = ObjMgr.GetNearestWoWUnit(ObjMgr.GetWoWUnitByEntry(_npcMine)); if (mineNpc.GetBaseAddress != 0) { if (mineNpc.Position.DistanceTo(me) > 5.0f) { _targetNpc = new Npc { Entry = mineNpc.Entry, Position = mineNpc.Position }; MovementManager.FindTarget(ref _targetNpc, 5f); return; } else { Interact.InteractWith(mineNpc.GetBaseAddress, true); Thread.Sleep(Usefuls.Latency + 1000); Interact.InteractWith(mineNpc.GetBaseAddress, true); Thread.Sleep(Usefuls.Latency + 500); Lua.LuaDoString("GarrisonCapacitiveDisplayFrame.CreateAllWorkOrdersButton:Click()"); Thread.Sleep(Usefuls.Latency + 1000); } } tList.Pop(); break; } if (tList.Count == 0) { Logging.Write("Garrison Farming completed"); CloseProduct(); } }
public override void Run() { Logging.Write("Pause started"); if (!_onBreak) { // That's the normal pausing system. Helpers.MovementManager.StopMove(); while (Products.Products.IsStarted && Products.Products.InAutoPause) { Thread.Sleep(300); } } else { // We are on break, will we just pause their in the middle of nowhere ? No we wont ! Point position = ObjectManager.ObjectManager.Me.Position; switch (Others.Random(1, 4)) { case 1: position.X += Others.Random(100, 300); break; case 2: position.X += Others.Random(-300, -100); break; case 3: position.Y += Others.Random(100, 300); break; case 4: position.Y += Others.Random(-300, -100); break; } if (MountTask.GetMountCapacity() == MountCapacity.Fly) { if (!ObjectManager.ObjectManager.Me.IsMounted) { MountTask.Mount(false, true); } // should be mounted here.. if (ObjectManager.ObjectManager.Me.IsMounted) { if (Usefuls.IsFlying) { position.Z += Others.Random(20, 50); } else { MountTask.Takeoff(); position.Z += Others.Random(50, 100); } MovementManager.MoveTo(position); } } else { // we are a f*****g non flyer dude, so let's suppose we are under level 60 (ofc), so, that mean our NPC DB actually cover our zone, so let's just stuck our ass to the closest NPC ever Npc target = new Npc(); target = NpcDB.GetNpcNearby(Npc.NpcType.Mailbox); if (target.Entry <= 0) { target = NpcDB.GetNpcNearby(Npc.NpcType.Repair); if (target.Entry <= 0) { target = NpcDB.GetNpcNearby(Npc.NpcType.Vendor); if (target.Entry <= 0) { target = NpcDB.GetNpcNearby(Npc.NpcType.FlightMaster); } } } if (target.Entry > 0) { //Start target finding based on Seller. uint baseAddress = MovementManager.FindTarget(ref target); if (MovementManager.InMovement) { return; } // I need to handle this f*****g possibility... if (baseAddress == 0 && target.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 10) { NpcDB.DelNpc(target); // The NPC is not found, let's remove it from the DB, but still we must be in a safe place right now. } else if (baseAddress > 0) { // We arrived at our target (either mailbox or repair/vendor or flight master), let's wait here, we're safe. } } // We have no place to go... so just wait there. } while (!_breakTime.IsReady) { Thread.Sleep(300); } _forceResetTimer = true; // force recalculate the "time between pause" timer when our break is done } Logging.Write("Pause stoped"); }
public static void QuestTurnIn(ref Npc npc, string questName, int questId, bool ignoreBlacklist = false, bool forceTravel = false) { if (npc.ForceTravel) { forceTravel = true; } Point me = ObjectManager.ObjectManager.Me.Position; WoWUnit mNpc = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(npc.Entry, true), false, ignoreBlacklist, true); if (mNpc.IsValid && mNpc.CanTurnIn) { npc.Position = mNpc.Position; } WoWGameObject mObj = ObjectManager.ObjectManager.GetNearestWoWGameObject(ObjectManager.ObjectManager.GetWoWGameObjectByEntry(npc.Entry), ignoreBlacklist); if (mObj.IsValid && mObj.CanTurnIn) { npc.Position = mObj.Position; } bool bypassTravel = false; if (me.DistanceTo(npc.Position) <= 800f) { PathFinder.FindPath(npc.Position, out bypassTravel); } if (Usefuls.IsFlying && npc.ContinentIdInt == Usefuls.ContinentId) { bypassTravel = true; } else if (Usefuls.IsFlying) { MountTask.DismountMount(); } if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f) { if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid) { _travelLocation = Products.Products.TravelFrom; Products.Products.TravelRegenerated = false; } } if (!bypassTravel && (_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled) { MovementManager.StopMove(); Logging.Write("Calling travel system for TurnInQuest " + questName + "(" + questId + ") from " + npc.Name + " (" + npc.Entry + ")..."); Products.Products.TravelToContinentId = npc.ContinentIdInt; Products.Products.TravelTo = npc.Position; Products.Products.TravelFromContinentId = Usefuls.ContinentId; Products.Products.TravelFrom = me; Products.Products.ForceTravel = forceTravel; // Pass the check for valid destination as a lambda Products.Products.TargetValidationFct = IsNearQuestGiver; _travelLocation = Products.Products.TravelFrom; return; } if (_travelLocation != null && _travelLocation.DistanceTo(me) <= 0.1f) { _travelDisabled = true; } //Start target finding based on QuestGiver. uint baseAddress = MovementManager.FindTarget(ref npc, 4.5f, true, true, 0f, ignoreBlacklist); if (MovementManager.InMovement) { return; } if (baseAddress > 0) { var tmpNpc = ObjectManager.ObjectManager.GetObjectByGuid(npc.Guid); if (tmpNpc is WoWUnit) { var unitTest = tmpNpc as WoWUnit; if (unitTest.IsValid && unitTest.GetDistance < 20f && !unitTest.CanTurnIn) { _travelDisabled = false; // reset travel nManagerSetting.AddBlackList(unitTest.Guid, 30000); Logging.Write("Npc QuestGiver " + unitTest.Name + " (" + unitTest.Entry + ", distance: " + unitTest.GetDistance + ") cannot TurnIn any quest right now. Blacklisting it for 30 seconds."); return; } } } _travelDisabled = false; // reset travel ItemInfo equip = null; //End target finding based on QuestGiver. if (mObj.IsValid && mObj.GetDistance <= 4.5f || npc.Position.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) < 4.5f && npc.Position.DistanceZ(ObjectManager.ObjectManager.Me.Position) < 6f || npc.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 4.5f) { if (baseAddress <= 0) { npc.Ignore(120000); return; } if (Usefuls.IsFlying) { MountTask.Land(); } InteractTarget(ref npc, baseAddress); Logging.Write("QuestTurnIn " + questName + " (" + questId + ") to " + npc.Name + " (" + npc.Entry + ")"); int id = GetQuestID(); if (GetNumGossipActiveQuests() == 0 && id == questId) { if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton")) { Lua.RunMacroText("/click QuestFrameCompleteButton"); Thread.Sleep(300); } equip = CompleteQuest(); Thread.Sleep(Usefuls.Latency + 500); } if (!GetLogQuestId().Contains(questId)) // It's no more in the quest log, then we did turn in it sucessfuly { id = GetQuestID(); FinishedQuestSet.Add(questId); CloseWindow(); AbandonnedId = id; } else { bool systemWorks = GetGossipActiveQuestsWorks(); if (systemWorks) // 2 quest gossip systems = 2 different codes :( { for (int i = 1; i <= GetNumGossipActiveQuests(); i++) { SelectGossipActiveQuest(i); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); if (id == 0) { systemWorks = false; break; } if (id == questId) { if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton")) { Lua.RunMacroText("/click QuestFrameCompleteButton"); Thread.Sleep(300); } equip = CompleteQuest(); Thread.Sleep(Usefuls.Latency + 500); // here it can be the next quest id presented automatically when the current one is turned in id = GetQuestID(); CloseWindow(); if (GetLogQuestId().Contains(questId)) { equip = null; Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\""); break; } FinishedQuestSet.Add(questId); AbandonnedId = id; break; } CloseWindow(); Thread.Sleep(Usefuls.Latency + 500); Interact.InteractWith(baseAddress); Thread.Sleep(Usefuls.Latency + 500); } } if (!systemWorks) { int gossipid = 1; while (GetActiveTitle(gossipid) != "") { SelectActiveQuest(gossipid); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); if (id == questId) { if (Others.IsFrameVisible("QuestFrameCompleteButton") && !Others.IsFrameVisible("QuestFrameCompleteQuestButton")) { Lua.RunMacroText("/click QuestFrameCompleteButton"); Thread.Sleep(300); } equip = CompleteQuest(); Thread.Sleep(Usefuls.Latency + 500); CloseWindow(); if (GetLogQuestId().Contains(questId)) { equip = null; Logging.WriteError("Could not turn-in quest " + questId + ": \"" + questName + "\""); break; } FinishedQuestSet.Add(questId); break; } CloseWindow(); Thread.Sleep(Usefuls.Latency + 500); Interact.InteractWith(baseAddress); Thread.Sleep(Usefuls.Latency + 500); gossipid++; } } } } Thread.Sleep(Usefuls.Latency); if (equip != null) { ItemSelection.EquipItem(equip); Thread.Sleep(Usefuls.Latency + 500); } CloseWindow(); if (!GetLogQuestId().Contains(questId)) { FinishedQuestSet.Add(questId); } }
public static void QuestPickUp(ref Npc npc, string questName, int questId, out bool cancelPickUp, bool ignoreBlacklist = false, bool forceTravel = false) { if (npc.ForceTravel) { forceTravel = true; } cancelPickUp = false; if (AbandonnedId == questId) // should happen only when we do a different quest requirement for optimization { AbandonnedId = 0; return; } if (AbandonnedId != 0) { AbandonQuest(AbandonnedId); } AbandonnedId = 0; Point me = ObjectManager.ObjectManager.Me.Position; WoWUnit mNpc = ObjectManager.ObjectManager.GetNearestWoWUnit(ObjectManager.ObjectManager.GetWoWUnitByEntry(npc.Entry, true), false, ignoreBlacklist, true); // We have the NPC in memory and he is closer than the QuesterDB entry. (some Npc moves) if (mNpc.IsValid && mNpc.HasQuests) { npc.Position = mNpc.Position; } WoWGameObject mObj = ObjectManager.ObjectManager.GetNearestWoWGameObject(ObjectManager.ObjectManager.GetWoWGameObjectByEntry(npc.Entry), ignoreBlacklist); if (mObj.IsValid && mObj.HasQuests) { npc.Position = mObj.Position; } bool bypassTravel = false; if (me.DistanceTo(npc.Position) <= 800f) { PathFinder.FindPath(npc.Position, out bypassTravel); } if (Usefuls.IsFlying && npc.ContinentIdInt == Usefuls.ContinentId) { bypassTravel = true; } else if (Usefuls.IsFlying) { MountTask.DismountMount(); } if (_travelLocation != null && _travelLocation.DistanceTo(me) > 0.1f) { if (Products.Products.TravelRegenerated && Products.Products.TravelFrom.IsValid) { _travelLocation = Products.Products.TravelFrom; Products.Products.TravelRegenerated = false; } } if (!bypassTravel && (_travelLocation == null || _travelLocation.DistanceTo(me) > 0.1f) && !_travelDisabled) { MovementManager.StopMove(); Logging.Write("Calling travel system for PickUpQuest " + questName + "(" + questId + ") from " + npc.Name + " (" + npc.Entry + ")..."); Products.Products.TravelToContinentId = npc.ContinentIdInt; Products.Products.TravelTo = npc.Position; Products.Products.TravelFromContinentId = Usefuls.ContinentId; Products.Products.TravelFrom = me; Products.Products.ForceTravel = forceTravel; // Pass the check for valid destination as a lambda Products.Products.TargetValidationFct = IsNearQuestGiver; _travelLocation = Products.Products.TravelFrom; return; } if (_travelLocation != null && _travelLocation.DistanceTo(me) <= 0.1f) { _travelDisabled = true; } //Start target finding based on QuestGiver. uint baseAddress = MovementManager.FindTarget(ref npc, 4.5f, true, true, 0f, ignoreBlacklist); // can pick up quest on dead NPC. if (MovementManager.InMovement) { return; } _travelDisabled = false; // reset travel if (baseAddress > 0) { var tmpNpc = ObjectManager.ObjectManager.GetObjectByGuid(npc.Guid); if (tmpNpc is WoWUnit) { var unitTest = tmpNpc as WoWUnit; if (unitTest.IsValid && unitTest.GetDistance < 20f && !unitTest.HasQuests) { _travelDisabled = false; // reset travel nManagerSetting.AddBlackList(unitTest.Guid, 30000); Logging.Write("Npc QuestGiver " + unitTest.Name + " (" + unitTest.Entry + ", distance: " + unitTest.GetDistance + ") does not have any available quest for the moment. Blacklisting it for 30 seconds."); cancelPickUp = true; return; } } } //End target finding based on QuestGiver. if (mObj.IsValid && mObj.GetDistance <= 4.5f || npc.Position.DistanceTo2D(ObjectManager.ObjectManager.Me.Position) <= 4.5f && npc.Position.DistanceZ(ObjectManager.ObjectManager.Me.Position) < 6f || npc.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) <= 4.5f) { if (baseAddress <= 0) { cancelPickUp = true; // We are there but no NPC waiting for us. // This code is there for Mimesis and I'm not currently working on Quester, so I'm not going to "return;" there as quester will be even more lost. npc.Ignore(120000); return; } if (Usefuls.IsFlying) { MountTask.Land(); } InteractTarget(ref npc, baseAddress); Logging.Write("PickUpQuest " + questName + " (" + questId + ") from " + npc.Name + " (" + npc.Entry + ")"); int id = GetQuestID(); if (GetNumGossipAvailableQuests() == 0 && id == questId) { AcceptQuest(); Thread.Sleep(Usefuls.Latency + 500); } if (GetLogQuestId().Contains(questId)) { CloseWindow(); } else { bool systemWorks = GetGossipAvailableQuestsWorks(); if (systemWorks) // 2 quest gossip systems = 2 different codes :( { for (int i = 1; i <= GetNumGossipAvailableQuests(); i++) { SelectGossipAvailableQuest(i); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); if (id == 0) { systemWorks = false; break; } if (id == questId) { AcceptQuest(); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); CloseWindow(); if (id != questId) { AbandonQuest(id); } break; } CloseWindow(); Thread.Sleep(Usefuls.Latency + 500); AbandonQuest(id); Interact.InteractWith(baseAddress); Thread.Sleep(Usefuls.Latency + 500); } } if (!systemWorks) { int gossipid = 1; while (GetAvailableTitle(gossipid) != "") { SelectAvailableQuest(gossipid); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); if (id == questId) { AcceptQuest(); Thread.Sleep(Usefuls.Latency + 500); id = GetQuestID(); CloseWindow(); if (id != questId) { AbandonQuest(id); } break; } CloseWindow(); Thread.Sleep(Usefuls.Latency + 500); AbandonQuest(id); Interact.InteractWith(baseAddress); Thread.Sleep(Usefuls.Latency + 500); gossipid++; } } } KilledMobsToCount.Clear(); Thread.Sleep(Usefuls.Latency); } CloseWindow(); }
public override void Run() { if (_listOfTeachers.Count <= 0) { return; } Npc bestTeacher = new Npc(); for (int i = 0; i < _listOfTeachers.Count; i++) { Npc teacher = _listOfTeachers[i]; if (bestTeacher.Entry > 0) { // priority checks first switch (Products.Products.ProductName) { case "Gatherer": if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.HerbalismTrainer) { continue; } if (teacher.Type == Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.HerbalismTrainer) { bestTeacher = teacher; } break; case "Quester": case "Grinder": if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.MiningTrainer) { continue; } if (teacher.Type == Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer) { bestTeacher = teacher; } break; } if (bestTeacher == teacher) { continue; // We just set a best from priority checks, so distance check is not important anymore } if (ObjectManager.ObjectManager.Me.Position.DistanceTo(teacher.Position) < ObjectManager.ObjectManager.Me.Position.DistanceTo(bestTeacher.Position)) { bestTeacher = teacher; // We do not have priority between teacher and the actual bestTeacher, so we use distance instead } } else { bestTeacher = teacher; } } if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 800) { if (Quest.TravelToQuestZone(bestTeacher.Position, ref _doTravel, bestTeacher.ContinentIdInt, false, bestTeacher.Type.ToString())) { return; } } uint baseAddress = MovementManager.FindTarget(ref bestTeacher); if (MovementManager.InMovement) { return; } if (baseAddress == 0 && bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 10) { NpcDB.DelNpc(bestTeacher); } else if (baseAddress > 0) { if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 5f) { return; } string[] skillInfo = bestTeacher.InternalData.Split(','); if (skillInfo.Length == 2) { SkillLine skillLine = (SkillLine)Others.ToInt32(skillInfo[0]); SkillRank skillRank = (SkillRank)Others.ToInt32(skillInfo[1]); SkillRank nextRank; if (skillRank == SkillRank.ZenMaster) { nextRank = skillRank + 100; } else { nextRank = skillRank + 75; } string oldRank = ""; if (skillRank != SkillRank.None) { oldRank = " We were only " + skillRank.ToString() + " of " + skillLine.ToString() + "."; } Logging.Write("We have just reached the Teacher of " + skillLine.ToString() + ", " + bestTeacher.Name + ". We are now going to learn " + nextRank.ToString() + " of " + skillLine.ToString() + "." + oldRank); } Interact.InteractWith(baseAddress); Thread.Sleep(500 + Usefuls.Latency); Quest.CompleteQuest(); Gossip.TrainAllAvailableSpells(); TeacherFoundNoSpam.Remove(bestTeacher); SpellManager.UpdateSpellBook(); _doTravel = true; } // still on the road, but not in movement for some reasons }