Jump to content

Recommended Posts

Hello.

For some reason during quests the bot is blacklisting game objects to harvest. I tried to fix that by removing from the blacklist all of objects to harvest for the current quest.  But Quest.QuesterCurrentContext.Profile as Quester.Profile.EasyQuestProfile is always return null. I know that it could be much easier to implement what I wanted, for example, removing the objects to harvest from the blacklist if the bot is in the "harvesting" state near it for some time, but as it has already been done, it's done. The point is that it is not possible to get the necessary information for the log using EasyQuestProfile class. Or maybe I did something wrong?

Log: 

Quote

13:23:32 - [Farming] Farm Burstcap Mushroom > 186.285 ; 8155.31 ; 22.5432 ; "None"
[N] 13:23:32 - [Path-Finding] FindPath from 186.6675 ; 8105.65 ; 22.99214 ; "None" to 186.285 ; 8155.31 ; 22.5432 ; "None" (Expansion01)
[N] 13:23:32 - [Server] [Path-Finding] 186.6675, 8105.65, 22.99214 to 186.285, 8155.31, 22.5432 (Expansion01, ResultPartial=False, ResultSuccess=True, Path count=2, SkipIfPartiel=False, IgnoreServerRoadsWater=False, Time=0
[N] 13:23:32 - [Path-Finding] Path Count: 3 (49.66366y, 154ms, smoothed)
[D] 13:23:35 - [Farming] !MovementManager.InMovement
13:23:35 - [Farming] Farm failed



And this is code I made to fix that: code.cs

private void GetQuestObjectivesInfo()
{
	try
	{
		QuestObjectivesInfo = "";

		string QuestObjectivesLogString = "";

		var EasyQuestProfile = Quest.QuesterCurrentContext.Profile as Quester.Profile.EasyQuestProfile; // doesnt work?
		var OldTypeProfile = Quest.QuesterCurrentContext.Profile as Quester.Profile.QuesterProfile;

		if (EasyQuestProfile != null)
		{
			var CurStep = EasyQuestProfile.QuestsSorted[CurStepNum];

			if (CurStep != null)
			{
				string CurStepNameClass = CurStep.NameClass;

				if (!string.IsNullOrWhiteSpace(CurStepNameClass))
				{
					var EasyQuest = EasyQuestProfile.EasyQuests.FirstOrDefault(q => q.NameClass == EasyQuestProfile.QuestsSorted[CurStepNum].NameClass);

					if (EasyQuest != null)
					{
						string EntriesIdLog = "";
						string QuestTypeString = EasyQuest.QuestType.ToString();
						var BlacklistedObjects = new List<WoWGameObject>();

						if (EasyQuest.QuestType == EasyQuestType.Gatherer)
						{
							Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: " + CurStepClassNameOld + ", QuestType: ["+ QuestTypeString + "]");

							var EasyQuestClass = EasyQuest.QuestClass as Quester.Profile.GathererEasyQuestClass;

							if (EasyQuestClass.EntryIdObjects.Count > 0)
							{
								EasyQuestClass.EntryIdObjects.ForEach(entry =>
								{
									if (string.IsNullOrWhiteSpace(EntriesIdLog))
										EntriesIdLog += "entries id objects to harvest: " + entry + "";
									else
										EntriesIdLog += ", " + entry + "";
								});

								BlacklistedObjects = ObjectManager.GetObjectWoWGameObject().FindAll(o => EasyQuestClass.EntryIdObjects.Contains(o.Entry) && (wManager.wManagerSetting.GetListGuidBlackListed().Contains(o.Guid) || wManager.wManagerSetting.IsBlackListed(o.Guid) || wManager.wManagerSetting.IsBlackListedZone(o.Position)));

								QuestObjectivesLogString += EntriesIdLog;
							}
						}
						else if (EasyQuest.QuestType == EasyQuestType.GrinderGathererQuests)
						{
							Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], QuestType: [" + QuestTypeString + "]");

							var EasyQuestClass = EasyQuest.QuestClass as Quester.Profile.GrinderGathererEasyQuestClass;

							if (EasyQuestClass.EntryGathererTarget.Count > 0)
							{
								var ObjectsEntriesList = new List<int>();

								EasyQuestClass.EntryGathererTarget.ForEach(entry =>
								{
									if (!ObjectsEntriesList.Contains(entry.Entry))
										ObjectsEntriesList.Add(entry.Entry);

									if (string.IsNullOrWhiteSpace(EntriesIdLog))
										EntriesIdLog += "entries id objects to harvest: " + entry.Entry + "";
									else
										EntriesIdLog += ", " + entry.Entry + "";
								});

								QuestObjectivesLogString += EntriesIdLog;

								BlacklistedObjects = ObjectManager.GetObjectWoWGameObject().FindAll(o => ObjectsEntriesList.Contains(o.Entry) && (wManager.wManagerSetting.GetListGuidBlackListed().Contains(o.Guid) || wManager.wManagerSetting.IsBlackListed(o.Guid) || wManager.wManagerSetting.IsBlackListedZone(o.Position)));
							}
						}
						else
						{
							QuestObjectivesInfo = "QuestType: is not gatherer";
							Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], QuestType: is not gatherer");
						}

						// remove objects from blacklist while harvest
						if (BlacklistedObjects.Count > 0)
						{
							string BlacklistedObjectsString = "quest: [" + CurStepClassNameOld + "], remove " + BlacklistedObjects.Count + " objects from blacklist: ";

							BlacklistedObjects.ForEach(o =>
							{
								if (string.IsNullOrWhiteSpace(BlacklistedObjectsString))
									BlacklistedObjectsString += "[" + o.Name + "] " + o.Guid + "";
								else
									BlacklistedObjectsString += ", [" + o.Name + "] " + o.Guid + "";

								if (wManager.wManagerSetting.IsBlackListed(o.Guid))
								{
									Logging.Write("[GetQuestObjectivesInfo] remove guid of object [" + o.Name + "] " + o.Guid + " from blacklisted");
									wManager.wManagerSetting.RemoveBlackList(o.Guid);
								}

								if (wManager.wManagerSetting.GetListGuidBlackListed().Contains(o.Guid))
								{
									Logging.Write("[GetQuestObjectivesInfo] remove guid of object [" + o.Name + "] " + o.Guid + " from GetListGuidBlackListed");
									wManager.wManagerSetting.GetListGuidBlackListed().Remove(o.Guid);
								}

								if (wManager.wManagerSetting.IsBlackListedZone(o.Position))
								{
									var BadBlacklistsForCurrentQuest = wManager.wManagerSetting.GetListZoneBlackListed().FindAll(bl => o.Position.DistanceTo(bl.GetPosition()) < 15);

									Logging.Write("[GetQuestObjectivesInfo] remove " + BadBlacklistsForCurrentQuest.Count + " bad blacklist areas for current quest");

									wManager.wManagerSetting.GetListZoneBlackListed().RemoveAll(bl => o.Position.DistanceTo(bl.GetPosition()) < 15);

									// return back removed blacklists after harvest
									Task.Factory.StartNew(() =>
									{
										while (IsLaunched)
										{
											if (!Conditions.InGameAndConnected || me.Position.DistanceTo(o.Position) > 50)
											{
												Logging.Write("[GetQuestObjectivesInfo] return back " + BadBlacklistsForCurrentQuest.Count + " bad blacklist areas for current quest to blacklist");

												BadBlacklistsForCurrentQuest.ForEach(bl =>
												{
													if (wManager.wManagerSetting.GetListZoneBlackListed().Count(b => b == bl) == 0)
														wManager.wManagerSetting.AddBlackListZone(bl);
												});
                                              
                                              	break;
											}
											Thread.Sleep(10000);
										}
									});
								}
							});

                          	QuestObjectivesInfo = QuestObjectivesLogString;
							SDM("" + info1 + ", " + BlacklistedObjectsString + ", " + info2 + "");
							logs(BlacklistedObjectsString);
							SetCenterText(text: BlacklistedObjectsString, frameflash: true, CenterTextFrameUpdateTimeCD: 15, textcolor: "ff0000", force: true);
							MaximizeWowWindow();
						}
					}
					else
					{
						QuestObjectivesInfo = "EasyQuest = null";
						Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], EasyQuest = null");
					}
				}
				else
				{
					QuestObjectivesInfo = "CurStepNameClass string is null";
					Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], CurStepNameClass string is null");
				}
			}
			else
			{
				QuestObjectivesInfo = "CurStep = null";
				Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], CurStep = null");
			}
		}
		else
		{
			QuestObjectivesInfo = "EasyQuestProfile = null";
			Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], EasyQuestProfile = null");
		}
	}
	catch (Exception e)
	{
      	QuestObjectivesInfo = "? - exception";
		Logging.Write("[GetQuestObjectivesInfo] CurStepClassNameOld: [" + CurStepClassNameOld + "], GetQuestObjectivesInfo exception: " + e.ToString() + "");
	}
}


private string CurStepClassNameOld
{
	get
	{
		string currentstep = "";

		try
		{
			var profile = Quest.QuesterCurrentContext.Profile as Quester.Profile.QuesterProfile;

			if (profile != null)
			{
				if (profile.QuestsSorted[CurStepNum].NameClass != null)
				{
					if (profile.QuestsSorted[CurStepNum].Action == QuestAction.RunCode)
						currentstep = "c# code";
					else if (profile.QuestsSorted[CurStepNum].Action == QuestAction.RunLuaCode)
						currentstep = "lua code";
					else if (profile.QuestsSorted[CurStepNum].NameClass.Length >= 50 || profile.QuestsSorted[CurStepNum].NameClass.Contains(Environment.NewLine))
						currentstep = "? - a lot of symbols";
					else
						currentstep = profile.QuestsSorted[Quest.QuesterCurrentContext.CurrentStep].NameClass;
				}
				else
					currentstep = "? - NameClass is null";
			}
			else
				currentstep = "? - Profile is null";
		}
		catch (Exception e)
		{
			Logging.Write("CurStepClassNameOld exception: " + e.ToString() + "");
			currentstep = "? - exception";
		}

		return currentstep;
	}
}


private int CurStepNum
{
	get { return wManager.Wow.Helpers.Quest.QuesterCurrentContext.CurrentStep; }
}


private string QuestObjectivesInfo;

 

Link to comment
https://wrobot.eu/forums/topic/14230-questerprofileeasyquestprofile/
Share on other sites

wManager.wManagerSetting.CurrentSetting.PathFinderPostionOffset is a very interesting and useful setting but I've detected that highest then default value of it can cause farming fails. Can this be considered as a bug?

https://youtu.be/C-hrfCL_NG8

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...