using System.Linq;
using Zeta.Game;
using Zeta.Game.Internals;
using Zeta.TreeSharp;
using Zeta.XmlEngine;
namespace QuestTools.ProfileTags
{
[XmlElement("SplitBounty")]
public class SplitBounty : BaseComplexNodeTag
{
public SplitBounty() { }
protected override Composite CreateBehavior()
{
return
new Decorator(ret => !IsDone,
new PrioritySelector(
GetNodes().Select(b => b.Behavior).ToArray()
)
);
}
public override bool GetConditionExec()
{
foreach (var c in ZetaDia.ActInfo.Bounties.Where(bounty => bounty.Act.ToString().Equals(Act) && bounty.Info.State != QuestState.Completed))
{
if (c.Info.QuestSNO.ToString().Equals(questId)) {
// Bounty is present
if ( c.Info.State.ToString().Equals("NotStarted")) {
// not yet started then go do finish it.
Logger.Log("Starting " + c.Info.Quest.ToString());
return true;
}
else {
// bounty is started..
var b = ZetaDia.ActInfo.Bounties.Where(bounty => bounty.Act.ToString().Equals(Act) && bounty.Info.State == QuestState.NotStarted);
if (b.Count() == 0 ) {
// all bounties started, but this bounty is not yet complete, so help the n00b finish this quest.
Logger.Log("Helping " + c.Info.Quest.ToString());
return true;
}
else {
// There still are not started bounties, so break and go to default false return.
// Lets hope the profile maker has made a profile to finish that quest. Else bot will chill out with the monsters or sit in town.
break;
}
}
}
}
// default, don't play the quest
return false;
}
[XmlAttribute("bountyID", true)]
public string questId { get; set; }
[XmlAttribute("actID", true)]
public string Act { get; set; }
}
}