Here's some examples of stuff that can be used to help understand the process of working with the Masters' quests. Due to the variety of the quests, you pretty much need to control CR logic at times, or change the way BasicGrindBot works to avoid issues.
For the long run, I would like to find a better way to implement bot logic in a way that doesn't require pure coding, but generic profiles have issues by design for dynamic content in a game like PoE as opposed to real MMOs that have a lot of static positions. So for now, what we have is what you see.
Looking for a named master. In your Tick logic, you'd be looking for a master until you found one, so you know where you need to travel to talk to them once you're able to. This is so you can finish combat, and looting, then go to where the master was.
Code:
var haku = LokiPoe.ObjectManager.GetObjectByName("Haku, Armourmaster");
if(haku != null)
{
Log.InfoFormat("[{0}] was detected.", haku.Name);
}
Getting the current mission quest state. This is to know if you have a mission quest active or not. It's a generic quest for all missions. You can figure out the general state of the mission quest, but keep note of performance issues if you call GetQuestState often.
Code:
var missionQuest = Dat.Quests.FirstOrDefault(q => q.Id == "mission");
// Note: this is an expensive call. Try to reduce how often you call it to avoid performance issues.
var state = Dat.GetQuestState(missionQuest, Difficulty.Normal);
if (state == null)
{
Log.InfoFormat("We have not done a quest in this area yet.");
}
else
{
Log.InfoFormat("Mission Quest: {0}", state.QuestProgressText);
/*
From dumped QuestStates:
[Index] [StateId] [QuestProgressText] [QuestStateText]
[328] [0] [Mission Failed] []
[329] [1] [Mission Complete] []
[330] [2] [Return to the Master] []
[331] [3] [Complete the Mission] []
*/
}
To actually figure out which quest you are doing and what you're objects are, you need to do some text parsing. Your quest log must be visible.
Code:
foreach(var e in LokiPoe.InGameState.QuestTrackerEntries)
{
Log.InfoFormat("{0}", e);
/*
<fg:argb(255,255,102,0)>{Haku, Armourmaster}<fg:argb(255,255,255,255)>{
Enter the haunted area.
Find the Karui spirit.}
<fg:argb(255,255,102,0)>{Haku, Armourmaster}<fg:argb(255,255,255,255)>{
Find the Karui spirit.}
<fg:argb(255,255,102,0)>{Haku, Armourmaster}<fg:argb(255,255,255,255)>{
Return the Karui spirit.}
<fg:argb(255,255,102,0)>{Haku, Armourmaster}<fg:argb(255,255,255,255)>{
Mission complete. Talk to Haku.}
*/
}
To find the area transition for the mission area, you can do some simple distance checks, or you can do it more properly like this.
Code:
AreaTransition missionTransition = null;
foreach (var at in LokiPoe.ObjectManager.GetObjectsByType<AreaTransition>())
{
var name = at.Name;
var area = Dat.WorldAreas.FirstOrDefault(wa => wa.Name == name);
if (area != null)
{
if (area.IsMissionArea)
{
missionTransition = at;
break;
}
}
}
if (missionTransition != null)
{
Log.InfoFormat("The mission area transition is: {0}.", missionTransition.Name);
}
To find the Karui Spirit object, it's just a matter of checking by name: In some cases, you need to kill the boss first, so you need to make sure you have additional logic to seek and destroy unique mobs. Otherwise, there's a good chance it'll be missed.
Code:
var obj = LokiPoe.ObjectManager.GetObjectByName("Karui Spirit");
To know if you have the Karui Spirit or not, you can check Actor.HasKaruiSpirit.
Code:
if(LokiPoe.Me.HasKaruiSpirit)
{
// we should look for an exit.
}
For the other masters, you use a similar process of checking Object Explorer to find useful objects, checks buffs/auras to determine if you have something, etc...
There's not API support for all the mission types, so some things you'll have to code around. You won't be able to get the time left for time based missions, missions that add minimap markers cannot be accessed unless they are actual objects (dump metadata and you'll see the mission marker object). I'm not sure about all the mission varieties and stuff, but that's basically the challenge of trying to handle everything.
Various API support for more stuff in missions can be placed on the todo list if needed, but due to the nature of missions in general, and how long it can take to try and get the data needed and re-test, expect it to be a lengthy process.