Inheritance: GroupComposite
Exemple #1
0
        public static Composite GetBase()
        {
            Orders = Crafty.OrderForm.GetOrders(); // Get what we want to craft

            if (Orders.Count == 0)
            {
                Orders.Add(new Crafty.Order(0, "Orders Empty", 0, ClassJobType.Adventurer));
                //Adding an item if it's blank.
            }

            //Pace the selector
            var sleep = new Sleep(400);

            //Animation Locked
            var animationLocked = new Decorator(condition => CraftingManager.AnimationLocked, new Sleep(1000));

            //Currently Synthing
            var continueSynth = new Decorator(condition => CraftingManager.IsCrafting, Strategy.GetComposite());

            //Orders Empty Check
            var ordersEmpty = new Decorator(condition => CheckOrdersEmpty(), StopBot("Looks like we've completed all the orders!"));

            //Incorrect Job
            var correctJob = new Decorator(condition => Character.ChangeRequired(GetJob()), Character.ChangeJob());

            //Recipe not Selected
            var selectRecipe = new Decorator(condition => IsRecipeSet(GetID()), new ActionRunCoroutine(action => SetRecipeTask(GetID())));

            //Can't Craft the item
            //var cantCraft = new Decorator(condition => CanICraftIt(), StopBot("Can't craft the item " + GetName() + ". Stopping!"));

            //Begin crafting
            var beginCrafting = BeginSynthAction();

            //Base Composite that we'll return
            return new PrioritySelector(sleep, animationLocked, continueSynth, ordersEmpty, correctJob, selectRecipe, beginCrafting);


            /*
            var setRecipeCoroutine = new ActionRunCoroutine(r=> SetRecipeTask(Orders[0].ItemId));
            var setRecipe = new Decorator(s=>IsRecipeSet(Orders[0].ItemId), setRecipeCoroutine);
                var canCast = new Decorator(s => CraftingManager.AnimationLocked, new Sleep(1000));
                var canCraft = new Decorator(s => CanICraftIt(), StopBot("Can't Craft the item. Stopping!"));
                var beginSynth = new Action(a =>
                {
                    Character.CurrentRecipeLvl = CraftingManager.CurrentRecipe.RecipeLevel;
                    Mend.Available = true;
                    CraftingLog.Synthesize();
                    Orders[0].Qty--;
                    Logging.Write("Crafting " + Orders[0].ItemName + ". Remaining: " + Orders[0].Qty);
                    while(Orders[0].Qty == 0)Orders.RemoveAt(0);
                });
                var continueSynth = new Decorator(s => CraftingManager.IsCrafting, Strategy.GetComposite());
                var correctJob = new Decorator(s => Character.ChangeRequired(Orders[0].Job),
                    Character.ChangeJob(Orders[0].Job));
                return new PrioritySelector(new Sleep(350), canCast, setRecipe, continueSynth,
                    correctJob, canCraft, beginSynth);
            */
        }
Exemple #2
0
 public static Composite ChangeJob()
 {
     var closewindow = new Action(a => CraftingLog.Close());
     var wait = new Sleep(4000);
     var windowcheck = new Decorator(condition => CraftingLog.IsOpen, closewindow);
     var changegearset = new Action(a =>
     {
         Logging.Write("Changing to gearset number: " + Crafty.OrderForm.GetJobGearSet(CraftyComposite.GetJob()));
         ChatManager.SendChat("/gs change " + Crafty.OrderForm.GetJobGearSet(CraftyComposite.GetJob()));
     });
     return new Sequence(windowcheck, wait, changegearset);
 }
Exemple #3
0
 public static Composite GetComposite()
 {
     var mend = new Decorator(a => (Mend.Available && CraftingManager.Durability == 10), Mend.UseBestMend());
     var increasequal =
         new Decorator(
             a =>
                 (Core.Me.CurrentCP > 18 &&
                  Synth.ExpectFinish() & (CraftingManager.Durability > 20 || (Mend.Available && (Core.Me.CurrentCP - Touch.GetBestTouch().Cost) > 91)) &
                  (CraftingManager.HQPercent < 100) && Core.Me.ClassLevel >= 5), Touch.UseBestTouch());
     var progress = Synth.UseSynth();
     var steady = new Decorator(a => Buff.SteadyRequired(), Buff.GetSteadyAction());
     var inner = new Decorator(a => Buff.InnerQuietAvail(), Buff.GetInnerQuietAction());
     return new PrioritySelector(inner, mend, steady, increasequal, progress);
 }
        /// <summary>
        /// Attempts to get complex behavior from the tag. Will return null if tags are not
        /// <see cref="IfTag"/> or <see cref="WhileTag"/> implementations of the <see cref="ProfileBehavior"/> class
        /// </summary>
        /// <param name="behavior"></param>
        /// <returns></returns>
        private Composite GetProfileBehaviorTree(ProfileBehavior behavior)
        {
            var ifBehavior = behavior as IfTag;
            var whileBehavior = behavior as WhileTag;
            Composite bodyBehavior;

            if (ifBehavior != null)
            {
                bodyBehavior = new Decorator(
                    (r) => ScriptManager.GetCondition(ifBehavior.Condition).Invoke(),
                    new Sequence(
                        this.GetProfileBehaviorCollectionBehavior(ifBehavior.Body).ToArray()
                        )
                    );
            }
            else if (whileBehavior != null)
            {
                bodyBehavior = new WhileLoop(
                    (r) => ScriptManager.GetCondition(whileBehavior.Condition).Invoke(),
                    this.GetProfileBehaviorCollectionBehavior(whileBehavior.Body).ToArray()
                );
            }
            else
            {
                bodyBehavior = (Composite) behavior.InvokePrivateMethod<Composite>("CreateBehavior", null);
            }

            return new PrioritySelector(
                new ActionRunOnce(
                    (r) =>
                    {
                        try
                        {
                            behavior.InvokePrivateMethod("UpdateBehavior");
                            behavior.Start();
                        }
                        catch
                        {
                            // TODO: Get a better understanding of how RB starts the profile behaviors during behavior execution
                        }

                        return RunStatus.Failure;
                    }
                ),
                bodyBehavior,
                new ActionAlwaysSucceed()
            );
        }